[Ipopt] Couenne and Ipopt with OS producing very different results on same simplistic NLP
Florent Teichteil
florent.teichteil at gmail.com
Fri Jul 17 05:49:09 EDT 2015
Hi all,
I'm trying to solve this very simple NLP problem:
min x+y
s.t. x*y=1
s.t. x>0
s.t. y>0
The obvious solution is x=y=1 with an objective function of 2.
However, for some reason, Ipopt does not produce the correct solution,
as if it did not unscale the problem after finalization of solving.
Thus, I compared with Couenne on the same problem with the exact same
OS instance and this time I got the correct result.
Am I doing something wrong? Should I manually unscale Ipopt results?
You'll find below the main() program I am using, followed by its
output on my machine.
Thank you very much for your kind help!
Best,
Florent
/// BEGIN MAIN() ///
#include <coin/OSInstance.h>
#include <coin/OSOption.h>
#include <coin/OSCouenneSolver.h>
int main() {
OSInstance* instance = new OSInstance();
OSOption* option = new OSOption();
IpoptSolver* ipoptsolver = new IpoptSolver();
CouenneSolver* couennesolver = new CouenneSolver();
instance->setInstanceName("test");
instance->setVariableNumber(2);
instance->addVariable(0, "x", 0, OSDBL_MAX, 'C');
instance->addVariable(1, "y", 0, OSDBL_MAX, 'C');
instance->setObjectiveNumber(1);
instance->setConstraintNumber(1);
SparseVector* objvec = new SparseVector(2);
objvec->indexes[0] = 0;
objvec->indexes[1] = 1;
objvec->values[0] = 1.0;
objvec->values[1] = 1.0;
instance->addObjective(-1, "obj", "min", 0.0, 1.0, objvec);
delete objvec;
instance->addConstraint(0, "xy=1", 1, 1, 1);
if (instance->instanceData->nonlinearExpressions == NULL)
instance->instanceData->nonlinearExpressions = new
NonlinearExpressions();
instance->instanceData->nonlinearExpressions->numberOfNonlinearExpressions
= 1;
instance->instanceData->nonlinearExpressions->nl = new Nl*[1];
instance->instanceData->nonlinearExpressions->nl[0] = new Nl();
instance->instanceData->nonlinearExpressions->nl[0]->idx = 0;
std::vector<ExprNode*> nlNodeVec;
instance->instanceData->nonlinearExpressions->nl[0]->osExpressionTree
= new ScalarExpressionTree();
OSnLNodeTimes* times = new OSnLNodeTimes();
nlNodeVec.push_back(times);
OSnLNodeVariable* px = new OSnLNodeVariable();
px->idx = 0;
nlNodeVec.push_back(px);
OSnLNodeVariable* py = new OSnLNodeVariable();
py->idx = 1;
nlNodeVec.push_back(py);
instance->instanceData->nonlinearExpressions->nl[0]->osExpressionTree->m_treeRoot
= ((OSnLNode*) nlNodeVec[0])->createExpressionTreeFromPrefix(nlNodeVec);
std::cout << "/// MODEL ///" << std::endl <<
instance->printModel() << std::endl;
std::cout << std::endl << "/// IPOPT ///" << std::endl;
ipoptsolver->osinstance = instance;
ipoptsolver->osoption = option;
ipoptsolver->buildSolverInstance();
ipoptsolver->setSolverOptions();
ipoptsolver->solve();
std::cout << "--------------------" << std::endl;
std::cout << "x*=" << ipoptsolver->osresult->getVarValue(0, 0) << std::endl;
std::cout << "y*=" << ipoptsolver->osresult->getVarValue(0, 1) << std::endl;
std::cout << "obj*=" <<
ipoptsolver->osresult->getOptimalObjValue(-1, 0) << std::endl;
std::cout << "--------------------" << std::endl;
std::cout << std::endl << "/// COUENNE ///" << std::endl;
couennesolver->osinstance = instance;
couennesolver->osoption = option;
couennesolver->buildSolverInstance();
couennesolver->setSolverOptions();
couennesolver->solve();
std::cout << "--------------------" << std::endl;
std::cout << "x*=" << couennesolver->osresult->getVarValue(0, 0)
<< std::endl;
std::cout << "y*=" << couennesolver->osresult->getVarValue(0, 1)
<< std::endl;
std::cout << "obj*=" <<
couennesolver->osresult->getOptimalObjValue(-1, 0) << std::endl;
std::cout << "--------------------" << std::endl;
delete option;
delete instance;
delete ipoptsolver;
delete couennesolver;
return 0;
}
/// END MAIN() ...
/// BEGIN OUTPUT ///
/// MODEL ///
Objectives:
min 1*x_0 + 1*x_1
Constraints:
xy=1 (x_0*x_1) = 1
Variables:
x: x_0 Type = C Lower Bound = 0 Upper Bound = INF
y: x_1 Type = C Lower Bound = 0 Upper Bound = INF
/// IPOPT ///
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
--------------------
x*=9.97206e-12
y*=9.97206e-12
obj*=1.99441e-11
--------------------
/// COUENNE ///
NLP0012I
Num Status Obj It time
Location
NLP0014I 1 OPT -1.998068e-08 29 0.008614
Coin0506I Presolve 0 (-1) rows, 0 (-5) columns and 0 (-3) elements
Clp0000I Optimal - objective value 1.1125369e-308
Clp0032I Optimal objective 1.112536929e-308 - 0 iterations time 0.002,
Presolve 0.00
Clp0000I Optimal - objective value 0
NLP Heuristic: NLP0014I 2 OPT 1.2744706e-08
21 0.005022
no solution.
Clp0000I Optimal - objective value 0
Optimality Based BT: 0 improved bounds
Probing: 0 improved bounds
NLP Heuristic: no solution.
Optimality Based BT: Couenne: new cutoff value 2.5000000000e+00
(0.051001 seconds)
0 improved bounds
Optimality Based BT: 0 improved bounds
Couenne: new cutoff value 2.0403367290e+00 (0.064839 seconds)
Couenne: new cutoff value 2.0002267160e+00 (0.070665 seconds)
Couenne: new cutoff value 2.0000362496e+00 (0.07153 seconds)
Couenne: new cutoff value 2.0000207244e+00 (0.071871 seconds)
Couenne: new cutoff value 1.9999966244e+00 (0.071968 seconds)
--------------------
x*=0.998093
y*=1.0019
obj*=2
--------------------
///
-------------- next part --------------
/// MODEL ///
Objectives:
min 1*x_0 + 1*x_1
Constraints:
xy=1 (x_0*x_1) = 1
Variables:
x: x_0 Type = C Lower Bound = 0 Upper Bound = INF
y: x_1 Type = C Lower Bound = 0 Upper Bound = INF
/// IPOPT ///
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
--------------------
x*=9.97206e-12
y*=9.97206e-12
obj*=1.99441e-11
--------------------
/// COUENNE ///
NLP0012I
Num Status Obj It time Location
NLP0014I 1 OPT -1.998068e-08 29 0.008614
Coin0506I Presolve 0 (-1) rows, 0 (-5) columns and 0 (-3) elements
Clp0000I Optimal - objective value 1.1125369e-308
Clp0032I Optimal objective 1.112536929e-308 - 0 iterations time 0.002, Presolve 0.00
Clp0000I Optimal - objective value 0
NLP Heuristic: NLP0014I 2 OPT 1.2744706e-08 21 0.005022
no solution.
Clp0000I Optimal - objective value 0
Optimality Based BT: 0 improved bounds
Probing: 0 improved bounds
NLP Heuristic: no solution.
Optimality Based BT: Couenne: new cutoff value 2.5000000000e+00 (0.051001 seconds)
0 improved bounds
Optimality Based BT: 0 improved bounds
Couenne: new cutoff value 2.0403367290e+00 (0.064839 seconds)
Couenne: new cutoff value 2.0002267160e+00 (0.070665 seconds)
Couenne: new cutoff value 2.0000362496e+00 (0.07153 seconds)
Couenne: new cutoff value 2.0000207244e+00 (0.071871 seconds)
Couenne: new cutoff value 1.9999966244e+00 (0.071968 seconds)
--------------------
x*=0.998093
y*=1.0019
obj*=2
--------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-c++src
Size: 3077 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20150717/84906764/attachment.bin>
More information about the Ipopt
mailing list