How to use disjoint constraints with intlinprog? Two variables can't have the same solution (x1-x2 != 0)

3 次查看(过去 30 天)
Hi,
I have a a number of people which have to go into rooms in pairs. If two people know each other they cannot go into the same room (and some cost function to maximize). I was trying to use intlinprog and having the solution vector be the people, where the value of the vector at each position is the room each person goes to.
Eg:
x1 (Joe)
x2 (Mary)
There are 3 rooms. So the bounds are:
1 <= x1,x2 <= 3
Joe knows Mary so my constraint would be:
x1-x2 != 0
Since they have to go to different rooms. How do I add this constraint to intlinprog? Any light shed on this ways to solve this problem would be greatly appreciated.

采纳的回答

Torsten
Torsten 2016-1-11
编辑:Torsten 2016-1-11
x_ij decision variable ; x_ij = 1 if person i enters room j, x_ij=0 else.
For Mary and Joe and three rooms this means that the three inequalities
x_Mary,1 + x_Joe,1 <= 1
x_Mary,2 + x_Joe,2 <= 1
x_Mary,3 + x_Joe,3 <= 1
must hold.
Best wishes
Torsten.

更多回答(1 个)

Walter Roberson
Walter Roberson 2016-1-11
It turns out you cannot solve those kinds of problems using linear programming. There is a good argument shown at http://math.stackexchange.com/questions/37075/how-can-not-equals-be-expressed-as-an-inequality-for-a-linear-programming-model
  3 个评论
Walter Roberson
Walter Roberson 2016-1-11
fmincon does not handle integer programming.
ga supports integer programming, but is not certain to find the global minima.
One thing you can do is divide up into regions each of which is convex, and find the solution on each region, and then pick the best solution.
Also if the problem is symmetric in change of variables, if cost(A,B) = cost(B,A), then instead of imposing an inequality constraint A<>B, impose A<B which is valid for linear programming. It is [1 -1]*[A;B] <= -eps(realmin) . Or since A and B are integer, [1 -1]*[A;B] <= -1

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by