1

My question may be related to this one, however I did not get its solution. So I'll try to ask for my specific problem.

I want to find out whether a set of halfplanes in 2D has an empty intersection or not. Thus, I have two unbounded variables x and y. In C# i have

x = gModel.AddVar(-GRB.INFINITY, GRB.INFINITY, 0.0, GRB.CONTINUOUS, "x");
y = gModel.AddVar(-GRB.INFINITY, GRB.INFINITY, 0.0, GRB.CONTINUOUS, "y");

Then I add constraints, one for each halfplane:

gModel.AddConstr((-1.0 * x) + (0 * y) <= 100, "h10");
gModel.AddConstr((1.0 * x) + (0 * y) <= 100, "h09");
gModel.AddConstr((0 * x) + (-1.0 * y) <= 100, "h08");
gModel.AddConstr((0 * x) + (1.0 * y) <= 100, "h07");
gModel.AddConstr((1.0 * x) + (0 * y) <= -33.3333334, "h06");
gModel.AddConstr((-1.0 * x) + (0 * y) <= 77.7777778, "h05");
gModel.AddConstr((-1.0 * x) + (0 * y) <= 55.55555533333333, "h04");
gModel.AddConstr((-1.0 * x) + (0 * y) <= 48.148148155555553, "h03");
gModel.AddConstr((-1.0 * x) + (0 * y) <= 40.740740733333332, "h02");
gModel.AddConstr((-1.0 * x) + (0 * y) <= 70.370370377777789, "h01");
gModel.AddConstr((1.0 * x) + (0 * y) <= -62.962962955555561, "h00");

I optimize with (0 * x + 0 * y, GRB.MINIMIZE) to get the result state which says whether there is a feasible solution (i.e. not an empty intersection), or not (an empty intersection).

The problem is that with the previous setup, I get an UNBOUNDED state while it is clear that h00 and h02 contradict! How that?

I'm using Gurobi 5.5. With the initial setting

 GurobiEnv.Set(GRB.IntParam.DualReductions, 0);

Any suggestions please?

SUPPLEMENTAL: Rich created a gist to reproduce the issue.

Community
  • 1
  • 1
Isolin
  • 845
  • 7
  • 20

1 Answers1

0

I guess that this is again a numerical problem because Gurobi tries to eliminate variables with zero coefficient from the problem description. An objective function which is completely zero might lead to unwanted consequences.

Actually, I would say that using Gurobi for this problem is overkill. A simple way to determine if these half-planes have a common point would be to calculate all intersection points of the boundary lines (about n² for n lines) and then check for each of them if it lies in all half-planes. If it does, it is your feasible point. Otherwise, there is no such point.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Dear JF, thank you for your answer. I will certainly test your proposal and report about the performance for 2 variables. Unfortunately I have to cope with the same problem in 3D causing n^3 complexity. According to [this thread](http://cs.stackexchange.com/questions/28889/feasible-solution-existence) there is no better solution in general. – Isolin Sep 19 '15 at 12:04
  • It's true: It very much depends on the problem size if the overhead of Gurobi is justified. If your problem get more complicated (like in 3d), I would suggest to set an objective function where the coefficients are of the same magnitude as the coefficients of your equations. – J Fabian Meier Sep 19 '15 at 12:07
  • The reason why I optimize with 0 coefficients is the suggestion for the UNBOUNDED state in the [Gurobi documentation](http://www.gurobi.com/documentation/6.0/refman/optimization_status_codes.html). In this particular case even different objective functions do not provide the correct result. – Isolin Sep 19 '15 at 14:26
  • So far I have fixed the Gurobi problem the following way: In my algorithm the constraints are added incrementally. Because of the nature of the application, I have to do a feasibility check after each constraint added. Therefore, when adding the h00 I know that the set of inequalities h10, h09, ... , h01 produced a feasible solution. So my approach is to set up a second model where I add the half-spaces in reverse order: h00, h01, ... . This works in some cases, but not always (in particular when the _problematic one_ is the first one. – Isolin Sep 19 '15 at 14:32
  • I noticed that some half spaces do not contribute to the convex intersection at all. Therefore, I track them and avoid adding the corresponding constraint to the second (reverse constraints order) model. This solves the problem for all my synthetic test cases. The key idea is to get the closest feasible point to the border of the halfspace-to-be-added (using an appropriate objective) and then repeating the search after the constraint was added. In case the points are identical the half-space can be omitted. – Isolin Sep 19 '15 at 14:36
  • Dear JF, I have finally implemented and tested out your proposal. Let me first note that my application scenario involves building a stack of halfplanes/halfspaces where the emptiness test is performed after each push of a new element. The implementation was not straight forward, there were some special cases to be handled. I tried to keep it as efficient as possible. Unfortunately, in all of the various test cases it performs much worse than Gurobi that surprisingly approaches O(n) (tested for up to 500 constraints). – Isolin Oct 15 '15 at 11:52