manipulate best bound value from the CPLEX output

445 views
Skip to first unread message

Fei Xie

unread,
May 30, 2014, 9:57:26 AM5/30/14
to am...@googlegroups.com
Dear all,

When we use the CPLEX to solve a mixed integer program, the solver will give us the best integer and best bound. My purpose is to automatically assign the value of the best bound to a parameter after solving the program. I was wondering if anyone knows how to do so. Note that I am not supposed to read the best bound from screen and assign the value by hand.

I am thinking of a "stupid" way to do that. If the MIP relative gap between best integer and best bound is e%. I can easily output the best integer which is just the optimal objective value. Then, best bound = best integer/(1+e%). However, with some stopping criteria such as "timelimit=XXX", I don't know the final MIP gap until I solve it. So, the question becomes how to output the gap e%.

I am not sure if I express my question clearly. Thanks so much for your time and efforts in addressing my question!

Best wishes,
Fei Xie

Robert Fourer

unread,
Jun 2, 2014, 12:46:59 AM6/2/14
to am...@googlegroups.com
If you set

option cplex_options 'bestbound';

(or add 'bestbound' to your cplex_options string) then the value of the best bound is given by an expression of the form

<obj>.bestbound

where <obj> is replaced by the name of your objective function.

Bob Fourer
am...@googlegroups.com

=======

Fei Xie

unread,
Jun 2, 2014, 11:03:10 AM6/2/14
to am...@googlegroups.com, 4...@ampl.com
Hi Bob,

Thanks for your reply. However, I still have problems in getting the bestbound. In cplex_options, I set something like this:

option cplex_options 'bestbound mipdisplay=2 mipinterval=2000 timelimit=600';

After I solve the model, I try to assign the bestbound to a parameter like this (Master_cost is the objective name):

let previousbound[nCUT] := Master_cost.bestbound;

However, the screen outputs errors as follows:

nested.run, line 68 (offset 2839):
    Bad suffix .bestbound for Master_cost
context:  let previousbound[nCUT] :=  >>> Master_cost.bestbound; <<<
Possible suffix values for Master_cost.suffix:
    astatus   exitcode   message   no
    relax     result     sense     sno
    sstatus   stage      val 

It seems that "bestbound" is not part of ".suffix". Would you like to help me to identify if I missed anything? Thanks.

By the way, I used the cplex 12.6 with AMPL (64bit, windows 7).

Fei

Robert Fourer

unread,
Jun 3, 2014, 1:05:49 PM6/3/14
to am...@googlegroups.com
The listing from your CPLEX run should include the following (though of course your details will be different):

ampl: model multmip3.mod;
ampl: data multmip3.dat;
ampl: option solver cplex;
ampl: option cplex_options 'bestbound';
ampl: solve;

CPLEX 12.6.0.0: bestbound
CPLEX 12.6.0.0: optimal integer solution; objective 235625
109 MIP simplex iterations
0 branch-and-bound nodes

suffix bestbound OUT;
ampl:

If you don't see "CPLEX 12.6 ... bestbound" and (the first solve only) "suffix bestbound OUT;" then the CPLEX bestbound option hasn't seen set. (If you are solving a Master and a Sub problem in a loop, be sure that you set cplex_options when the Master problem is current; otherwise the setting won't be remembered when you return to the Master problem.)

Fei Xie

unread,
Jun 5, 2014, 10:17:01 AM6/5/14
to am...@googlegroups.com, 4...@ampl.com
Hi Bob,

Thanks for your reply. Yes, I am solving a master problem and a set of sub problems. I followed your instruction. In the run file, after the declaration of each problem, I have something like the following:

problem Master:  variable and constraint......;                                     #master problem
    option solver cplex, cplex_options 'bestbound timelimit=600';

problem Sub{(k,t) in event_nodes:t>1}: variable and constraint......;      #subproblem
    option solver cplex;

 Note that, I have include the bestbound in the cplex_options just after the "problem Master". I think that means I have set the cplex_options when the Master problem is current. Please correct me if I am wrong.

However, when I solve the problem in an iterative process, I didn't see "suffix bestbound OUT" from the screen output. Should I type it in somewhere in my code?

My purpose is actually to assign the "Master_cost.bestbound" (Master_cost is the objective name) to a parameter such as "previous_bound". I tried two ways. The first one cannot be processed, and the second one is OK. Could you help me to identify my problems? Thanks.


Case 1:
In my run file, if I try to make the assignment in my code as follows:
   
    solve Master;
    #let previous_bound := Master_cost.bestbound;

The problem cannot be solved with error output as follows:


nested.run, line 68 (offset 2839):
    Bad suffix .bestbound for Master_cost
context:  let previous_bound :=  >>> Master_cost.bestbound; <<<
Possible suffix values for Master_cost.suffix:
    astatus   exitcode   message   no
    relax     result     sense     sno
    sstatus   stage      val  

Case 2:
If I delete the line "let previous_bound := Master_cost.bestbound" from the code and try to break the process after solve the master problem, there is no error message and the screen output has similar results (I copied your results from your previous email) as follows:


   CPLEX 12.6.0.0: bestbound
   CPLEX 12.6.0.0: optimal integer solution; objective 235625
   109 MIP simplex iterations
   0 branch-and-bound nodes

Then, if I try to assign the value by hand in the command line as follows:

ampl: let previous_bound := Master_cost.bestbound;

The command is correctly processed.



My concern is how to make the command in my code without having errors. I am not sure if I express my problem clearly. Thanks for your time.

Best wishes,
Fei Xie

Robert Fourer

unread,
Jun 6, 2014, 12:00:54 PM6/6/14
to am...@googlegroups.com
Your option statements look correct. But to reference a suffix within a loop, you may need to define it before the loop starts. So in your case you would put the command

suffix bestbound OUT;

toward the beginning of your script, before the start of your master-subproblem loop.

(To be precise, CPLEX tells AMPL to define suffix .bestbound if it's not already defined; when this happens you see "suffix bestbound OUT;" after the solve. However, AMPL scans the entire contents of the loop before starting to execute it. So if you solve problem Master only after the loop has started, then when AMPL scans the loop it will encounter .bestbound before the solve has had a chance to define that suffix. In that case your script must explicitly define .bestbound before the loop starts.)

Fei Xie

unread,
Jun 6, 2014, 2:22:08 PM6/6/14
to am...@googlegroups.com, 4...@ampl.com
Hi Bob,

It works right now! Thanks for your instructions!

Best wishes,
Fei Xie
Reply all
Reply to author
Forward
0 new messages