Description
This uses the model mathopt3 from the GAMS Model library and the discretization techniques offered by Gurobi 9 to solve a nonlinear nonconvex optimization problem. Contributor: Michael Bussieck, December 2019
Small Model of Type : GAMS
Category : GAMS Test library
Main file : gurobi05.gms
$title 'GUROBI test suite - general constraints sin/cos' (GUROBI05,SEQ=808)
$onText
This uses the model mathopt3 from the GAMS Model library and the
discretization techniques offered by Gurobi 9 to solve a nonlinear
nonconvex optimization problem.
Contributor: Michael Bussieck, December 2019
$offText
Variable x1, x2, x3, x4, x5, x6, x7, obj;
Equation defobj, eq1, eq2, eq3, eq4, eq5, ineq1, ineq2, ineq3;
* Auxilliary constraints and variables
Equation defa1,defa2,defa3,defa4,defa5,defa6,defa7,defa8,defa9;
Equation defa1nl,defa3nl,defa4nl,defa6nl,defa9nl;
Variables aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9;
defobj.. obj =e= sqr(x1 + x2) + sqr(x3 - x5) + sqr(x6 - x4)
+ 2*sqr(x1 + x3 - x4) + sqr(x2 - x1 + x3 - x4)
+ 10*sqr(aux1);
defa1nl.. aux1 =e= sin[aux2];
defa1.. aux1 =e= aux2;
defa2.. aux2 =e= x5 - x6 + x1;
eq1.. sqr(x1) - aux3 - x4 + x5 + x6 =e= 0;
defa3nl.. aux3 =e= sin[x2];
defa3.. aux3 =e= x2;
eq5.. x7 =e= x4*x1;
eq2.. x1*x3 - x2*x7 - x5 - aux4 =e= 0;
defa4nl.. aux4 =e= sin[aux5];
defa4.. aux4 =e= aux5;
defa5.. aux5 =e= x6 - x1 - x3;
eq3.. x2*aux7 - aux9 + x2 - x5 =e= 0;
defa6nl.. aux6 =e= cos[x5];
defa6.. aux6 =e= x5;
defa7.. aux7 =e= x6*aux6;
defa8.. aux8 =e= x3*x4;
defa9nl.. aux9 =e= sin(aux8);
defa9.. aux9 =e= aux8;
eq4.. x1*x2 - sqr(x3) - x4*x5 - sqr(x6) =e= 0;
ineq1.. 2*x1 + 5*x2 + x3 + x4 - 1 =l= 0;
ineq2.. 3*x1 - 2*x2 + x3 - 4*x4 =l= 0;
ineq3.. x1 + x2 + x3 + x4 + x5 + x6 - 2 =l= 0;
Model m / defobj, eq1, eq2, eq3, eq4, eq5, ineq1, ineq2, ineq3, defa1,defa2,defa3,defa4,defa5,defa6,defa7,defa8,defa9 /;
Model mnl / m - defa1 - defa3 - defa4 - defa6 - defa9 + defa1nl + defa3nl + defa4nl + defa6nl + defa9nl /;
* most local solvers will find the global solution from this starting point
* x1.l = 1; x2.l = -2; x3.l = 1; x4.l = 2; x5.l = 1; x6.l = -1;
* solve m using nlp min obj;
x1.l = 10; x2.l = -10; x3.l = 10; x4.l = 10; x5.l = 10; x6.l = -10;
$onEcho > gurobi.opt
defa1.genconstrtype 11
defa3.genconstrtype 11
defa4.genconstrtype 11
defa6.genconstrtype 12
defa9.genconstrtype 11
nonconvex 2
heuristics 1
$offEcho
option qcp=gurobi;
m.optfile=1; m.optcr=0;
solve m using qcp min obj;
abort$(m.modelstat<>1) 'expect to be solved to global optimality'
* Now solve with local solver Conopt4
option nlp=conopt4;
solve mnl using nlp min obj;
abort$(mnl.modelstat<>2) 'expect to be solved to local optimality'
Parameter report 'diff from global solution';
report('x1') = round(0 - x1.l,6);
report('x2') = round(0 - x2.l,6);
report('x3') = round(0 - x3.l,6);
report('x4') = round(0 - x4.l,6);
report('x5') = round(0 - x5.l,6);
report('x6') = round(0 - x6.l,6);
display report;