different objective value CPLEX and COUENNE

139 views
Skip to first unread message

Gazi Md Daud Iqbal

unread,
Oct 5, 2015, 12:59:16 AM10/5/15
to am...@googlegroups.com
Hi AMPL experts,

I ran some experiments using COUENNE solver for my NLP minimization problem. After that I linearized all non-linear parts, and solved the same problem with same objective function using CPLEX solver to improve CPU time.


 Unfortunately, I am getting different objective value (almost double than COUENNE). Seems like my linearization is correct. What could be the possible reasons for different objective value?



Thanks in advance 

Robert Fourer

unread,
Oct 5, 2015, 4:16:40 PM10/5/15
to am...@googlegroups.com
If both Couenne and CPLEX report "optimal solution" but they show different objective values, then it is very likely that your linearization is not correct. However, if one of these solvers was unable to find an optimal solution, then the solutions cannot be compared.

Bob Fourer
am...@googlegroups.com

=======

Gazi Md Daud Iqbal

unread,
Oct 5, 2015, 11:47:08 PM10/5/15
to AMPL Modeling Language, 4...@ampl.com

Hi Bob,


Thanks for your reply. I am doing some scenario analysis and set 15 minutes as time limit for optimization.


 For Couenne - I am getting optimal solutions for 27 customers out of 165.


 For CPLEX - I am getting optimal solutions for all 165 customers with very low time (average solve time is less than 1 second for each customer), but objective values are increasing.


 Since Couenne is not giving optimal solutions for all customers, Can I compare with CPLEX in this case?  I am attaching the screenshots so that you can take a look. If you have any suggestions to overcome this problem, please let me know. I checked my linearization. I think it is correct. However, I will recheck it again.


I really appreciate your helps and suggestions. 

Couenne_not optimal.png
Couenne_optimal solution.png
cplex_optimal result.png

Robert Fourer

unread,
Oct 6, 2015, 12:47:46 PM10/6/15
to am...@googlegroups.com
If Couenne is reaching the time limit before it can verify optimality, then it may not be finding as good a solution as CPLEX. Then if (as it appears) you are minimizing, the Couenne solution will higher than the CPLEX solution. If the Couenne solution is lower than the CPLEX solution then you should conclude that your linearization is incorrect.

Gazi Md Daud Iqbal

unread,
Oct 6, 2015, 11:41:05 PM10/6/15
to AMPL Modeling Language, 4...@ampl.com

Hi Bob,

 

Thanks for your reply. I think I figured out my error. My Y1bar is a variable in stage 1 and that is parameter in stage 2. I treated Y1bar in stage 2 as a variable again and then linearized. That’s why I got high objective values in CPLEX.

 

var Y1bar{1..nsample} >=0, <=50;

….

subject to LQ_11{j in 1..nsample}: Y1bar[j] >= -50*IY1[j];

subject to LQ_12{j in 1..nsample}: Y1bar[j] <= 50*IY1[j];

subject to LQ_13{j in 1..nsample}: Y1bar[j] >= Y1[j] -((1-IY1[j])*50);

subject to LQ_14{j in 1..nsample}: Y1bar[j] <= Y1[j] - (-50*(1- IY1[j]));


where Y1[j] is results from stage 1 and IY1[j] is binary variable.

 

subject to secondstage {i in 1..nsample, j in 1..nsample}:

-Y2[i,j] + 3.613077 * Y1bar[j] - 0.07653371* x2[8,j]* Y1bar[j] - 1.22007* x2[7,j]* Y1bar[j] - 0.3248128* x2[10,j]* Y1bar[j] - 0.6995695* x2[2,j] * Y1bar[j]   + err2[i] = -16.12741;

 

Here-  x2[8,j] , x2[7,j], x2[10,j], and x2[2,j] are decision variables in stage 2 and already defined before.  


Could you please tell me how to use Y1bar[j] (that I got from LQ_11 to LQ_14 constraints) in secondstage constraint as parameter?

 

Again thank you so much for all of your helps. 

Robert Fourer

unread,
Oct 7, 2015, 5:38:02 PM10/7/15
to am...@googlegroups.com
If you are doing a solve for the first stage and then another solve for the second stage, you can the AMPL command "fix Y1bar;" after the first solve to fix all of the Y1bar variables, so that they will be like parameters in the second solve. There is more about this command in the AMPL book here:

http://ampl.com/BOOK/CHAPTERS/14-command.pdf#page=13

pujate...@gmail.com

unread,
Oct 8, 2015, 8:46:30 AM10/8/15
to AMPL Modeling Language, 4...@ampl.com

Hi  Bob,


I got a problem which is very similar (transferring r1 value from constraint 1 to other constraint (where decision variable is r2) as fixed value). Both r1 and r2 are in my objective function.  

 

You said to solve two times and also used fix command.  I created my .run file like following--

 

model mymodel.mod;

data mymodel.dat;

let nthpath :=1;

for {1..15} {

solve;

fix r1;

solve;

let nthpath  := nthpath + 1;

}

 

The code is not running. I think my .run is not right.  Please help me how to use two solve in .run file.

 

Thanks in advance.

 

Puja

victor.z...@gmail.com

unread,
Oct 8, 2015, 4:25:49 PM10/8/15
to am...@googlegroups.com
What do you mean by "not running"? If you get an error, please post the full error message and the context it refers to.

- Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

pujate...@gmail.com

unread,
Oct 8, 2015, 9:21:23 PM10/8/15
to AMPL Modeling Language

Hi Victor,

 

Error is attached. “Constraint _scon[1] is not convex quadratic since it is an equality constraint.” - I know this error is happening because of non-linear term. That means, my fix command is not right. All I want is to transfer my r1 variable value as parameter into my other constraint (where r2 is variable).  My objective function contains both r1 and r2. In my myresult.out file I should get 15 paths objective value. But I am getting only first objective value. Please help me to figure this. I am stuck with my .run file.



.run file:


reset;

model mymodel.mod;

data mymodel.dat;

option solver cplexamp;

option cplex_options 'timelimit=480';

option nl_comments 1;

let nthpath := 1;

for {1..15}{

        solve;

       let nthpath := nthpath + 1;

}

fix{j in 1..sample} r1[j];

let nthpath := 1;

for {1..15} {

       solve;

       display nthpath > myresult.out;

      display obj > myresult.out;

        let nthpath := nthpath + 1;

}



Thanks in advance. 

error1.png

Robert Fourer

unread,
Oct 9, 2015, 1:17:58 PM10/9/15
to am...@googlegroups.com
You are going to need to fix the error with the nonlinear term. Use the command "print _sconname[1];" to see what constraint is nonlinear, and then try posting the AMPL declaration for that constraint -- and be sure to tell us which are the variables and which are the parameters in the constraint!

Other error messages show that there is a separate problem with the upper bounds computed by AMPL's presolve phase for the r2[7,j] variables being very slightly less than the lower bounds. This leads AMPL to declare your problem to be infeasible. You might be able to fix this by just loosening the tolerances a bit; as the messages suggest, you could try setting, say, "option presolve_eps 1e-14;".

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages