copy a model

80 views
Skip to first unread message

Eric

unread,
Feb 17, 2015, 2:56:25 PM2/17/15
to gur...@googlegroups.com
Hi,

I have a couple of questions in regards to "copy a model" and reuse it. I am working with Java interface.
1. what is the difference between the following scenarios if I want to reuse a built model. I haven't benchmarked these two scenarios thoroughly but according to some tests, they seem the same.
I am wondering if they are the same and if so, which one is better in terms of performance?

*******************************************************************************
GRBModel solver = new GRBModel(env);
...
create model using the solver API.
...
solver.optimize();

// reuse the created model
// scenario 1
solver.reset();
...
change the model and other parameters
...
solver.optimize();

// scenario 2
GRBModel newSolver = new GRBModel(solver);
...
change the model and other parameters
...
newSolver.optimize();

******************************************************************************

2. if I remove some constraints from a model but without calling solver.update(), i.e. just mark the constraints as "removed", what would be happened if I use the newSolver = new GRBModel(solver).
I mean the constraints which marked as "removed" will be copied or not, or I have to call the solver.update() before creating the second solver (newSolver).
In my preliminary tests, it seems the marked constraints will be copied. I am wondering whether it is true. What is the best practice about copying a model and reuse it several times?

3. And my third question which is not related to the first two questions: Is there any parameters or practices to improve the performance of the solver in order to get the relaxed objective function in an IP setting? In other words,
I have a very big Integer Programming model. I want to just get the relaxed objective function. But it takes a long time to solve. How can I improve it and get the relaxed objective value sooner?


Many thanks,
Eric

Greg Glockner

unread,
Feb 23, 2015, 6:47:00 PM2/23/15
to gur...@googlegroups.com
> 1. what is the difference between the following scenarios if I want to reuse a built model. I haven't benchmarked these two scenarios thoroughly but according to some tests, they seem the same.

Reusing a model is generally faster than duplicating a model.


> 2. if I remove some constraints from a model but without calling solver.update(), i.e. just mark the constraints as "removed", what would be happened if I use the newSolver = new GRBModel(solver).

newSolver will contain the original model, including the constraints that were removed. You need to call GRBModel.update() to remove the constraints from the original model.


> 3. And my third question which is not related to the first two questions: Is there any parameters or practices to improve the performance of the solver in order to get the relaxed objective function in an IP setting?

There are too many possibilities here. Please post a log for more information.


Eric

unread,
Feb 27, 2015, 8:53:13 AM2/27/15
to gur...@googlegroups.com
Thank you so much Greg.

Eric
Reply all
Reply to author
Forward
0 new messages