0

I am currently running a MIQP optimization problem in Drake using Gurobi. I keep on getting an infeasible solution to my optimization problem and I wanted to know if Drake can return any more useful information such as which specific constraint is causing the infeasibility.

I already have returned the type of error (ex: GRB_INFEASIBLE, GRB_UNBOUNDED, GRB_INF_OR_UNBD) from the gurobi.cc file.

Otherwise if such helpful function does not exist, could you offer some tips on debugging a large optimization problem? (Other than creating small test cases)

Thank you

Yuki
  • 139
  • 6

1 Answers1

1

It's tricky to debug the mixed-integer optimization problem. For gurobi, you could try the function computeIIS(). Do you use the pydrake or the C++ version? If you have the C++ source code, then the easiest way is to to add the following code before this line https://github.com/RobotLocomotion/drake/blob/3f1482d4808d238ee63095ba05c18434b47d1fbf/solvers/gurobi_solver.cc#L1058

GRBcompueIIS(model);
GRBwrite(model, `infeasible.ilp`)

Gurobi will write the infeasible constraint to a text file name infeasible.ilp. If you have set the name of the variables, by calling NewContinuousVariable(size, var_name), then the infeasible report infeasible.ilp will use the variable name var_name.

Unfortunately we cannot associate the infeasible constraint in Gurobi computeIIS function to the constraint you added through Drake, namely it doesn't report which Drake constraint causes the infeasibility yet.

BTW, we have a tutorial on debugging MathematicalProgram in Drake. It is mostly for nonlinear optimization with gradient based solvers.

Hongkai Dai
  • 2,546
  • 11
  • 12
  • BTW, I filed a github issue https://github.com/RobotLocomotion/drake/issues/14944, I will add the first two features in that issue soon. – Hongkai Dai Apr 23 '21 at 18:55
  • I tried to add the 2 lines of code. Both of the status return is 0. However, there is no file being created. Would you know why it does not create the infeasible.ilp file? Minor fixes to your lines: int iis_status = GRBcomputeIIS(model); int ilp_status = GRBwrite(model, "infeasible.ilp"); – Yuki Apr 23 '21 at 19:26
  • When you call `GRBcomputeIIS`, is the program infeasible? You could turn on the verbose report of Gurobi, by doing ``` prog.SetSolverOption(GurobiSolver::id(), "OutputFlag", True); ``` it will print out some progress on the screen. You could check the feasibility from that progress report. – Hongkai Dai Apr 23 '21 at 19:42
  • Yes, the "Model is infeasible" is what it output. Also just to make sure, should it output that file in the "solvers" folder? (same place as where gurobi_solver.cc is) – Yuki Apr 23 '21 at 20:15
  • It would output to where you run your binary target, not necessarily the solvers folder. – Hongkai Dai Apr 23 '21 at 21:42