Fixed model when running in batch mode on the compute server
AnsweredThanks for a great product!
In our team we are developing a large MIP optimization model that we send to our compute server solution as a batch job. We obtain the solution in the json format after the run. Since the solution of the MIP does not contain sensitivity results, we want to create a fixed model (`model.fixed()`) and run this, making use of the solution of all integervalued variables from the MIP.
My question is if there is a convenient way (already implemented) to obtain the fixed model from the MIP solution in the jsonformat, or if we will have to implement this on our part. Or if there is a setting that will make the compute server also run the fixed model after having finished solving the MIP, and return the results in the json.

Hi,
You can fix the values of all integer variables by iterating through the result and adding constraints to these variables. Example: variable X takes value 0, therefore you add a constraint that X = 0. If you optimize the model after adding these constraints, you should have your result.
Another way to do this, is to manually iterate through all the constraints and objective function and replace the variables for the fixed value. This should take longer for you to do, and this is what Gurobi will do in the presolve of the fixed model I described above.
Nonetheless, I wonder what is the objective of running this fixed MIP model. It is very likely that you will get the same solution, or at least one equivalent in objective function. I might have missed your point here.
0 
Thanks a lot for your comment, Michel Soares!
The purpose of running the fixed model is to obtain shadow prices for the binding constraints. The json returned from solving the MIP model in batch mode does not contain information on the constraints. I am fairly new to gurobi, and it could be that I am missing to set some parameter when sending the batch job.
0 
Unfortunately there is no functionality for turning the JSON output into a fixed model as you described. The approach by Michel is the way to go. As a slight variation, you might consider setting the LB and UB of each integer variable to its solution value to avoid adding new constraints to your model.
0 
Thanks, Ronald van der Velden! I will proceed as suggested.
0
Please sign in to leave a comment.
Comments
4 comments