Gurobi Constraints value print

908 views
Skip to first unread message

sandy

unread,
Feb 24, 2017, 12:26:23 AM2/24/17
to Gurobi Optimization
Hello Everyone ,

I have written an optimization model using JAVA with gurobi. it has several thousand constraints in the model. Is it possible  to print below.

1) All Constraints value after optimization in some file.
2) All constraints with value which did not satisfy in case of infeasible solution.

Appreciate if anyone could help.

Thanks in advance.

Renan Garcia

unread,
Feb 24, 2017, 9:45:25 AM2/24/17
to gur...@googlegroups.com
1) All Constraints value after optimization in some file.

You can infer this by querying for the Slack constraint attribute (see http://www.gurobi.com/documentation/7.0/refman/slack.html#attr:Slack). For general guidance on querying for attributes in Java, refer to http://www.gurobi.com/documentation/7.0/refman/java_attribute_examples.html#JavaAttributeExamples.

Another approach would be to use the GRBExpr.getValue() method (see http://www.gurobi.com/documentation/7.0/refman/java_grbexpr_getvalue.html) if you've saved off the expressions for the constraints.

2) All constraints with value which did not satisfy in case of infeasible solution.

Try the GRBModel.computeIIS() method (see http://www.gurobi.com/documentation/7.0/refman/java_grbmodel_computeiis.html) to find an irreducible inconsistent subsystem.

sandy

unread,
Feb 26, 2017, 3:10:08 PM2/26/17
to Gurobi Optimization


Thanks Renan for answering . for GRBExpr.getValue() , do i need to put constraint name or whole expression inside brackets , I tried constraint but it is giving error. and also i read documentation and could not find any syntax example. 

Kostja Siefen

unread,
Feb 27, 2017, 2:32:35 AM2/27/17
to Gurobi Optimization
Hi Sandy,

The getValue() function does not have any parameter. It computes the value of the expression from the latest optimal solution available. Thus, it will throw an error if no solution is available.

Kostja
Reply all
Reply to author
Forward
0 new messages