How to test the performance of an optimal solution on different scenarios?
I want to change the value of my basic setting after I have got a optimal solution, to test the performance of the optimal solution in different scenarios.
I mean:
I use Gurobi to solve a model, when the demand is set to be 10 passengers per minute. After I get an optimal solution, I want to fix this solution, and change the demand to be 20 passengers per minute, and calculate the objective value without changing solution but only demand is changed to be 20.
Can I achieve this idea?
-
I'm not sure I fully understand what you want to do.
If you simply want to evaluate a different objective function at the current solution, you can define a new expression and then use the getValue method to compute the value of this expression in the current solution. (The link goes to the method for linear expressions, but there are similar methods for quadratic or matrix expressions.)
If that is not what you want, please give us some more details about exactly what you want to change and what you want to fix.
1 -
Hi Silke,
Sorry for my unclear description. I don't need to change the objective function. I just want to calculate the objective value when only the demand in my model is changed.
Let me try to describe my problem again:
My original model has:
basic setting: a fixed traffic demand (passengers/minute), the cost to buy a car for tranpsort department
objective function: minimize (passengers' delay + the total cost to buy cars)
decision variables: dispatch pattern and fleet size
constrains: maximum fleet size......
Step 1: I will get an optimal solution through Gurobi's optimization, including how the cars are dispatched and how many cars will be bought under this scenario.
Step 2: After I solve this model, I want to change the traffic demand to be stochastic, and apply the optimal solution in step 1 (dispatch pattern and fleet size), to calculate the new objective value when demand is changed. Only the traffic demand is changed in this step, the objective value and all other parts of the model are the same.
I have finished the step 1 and I don't know how to achieve step 2.
Thank you very much! Please let me know if my description is still unclear.
0 -
Thanks for adding more details.
You can modify your model, then simply call optimize again. Gurobi will then use the known solution the warm-start the second optimization.
With the scenario feature that came with Gurobi 9, you can also define both model versions in one model and then have Gurobi solve them in one go.
1
Please sign in to leave a comment.
Comments
3 comments