gurobi07.gms : GUROBI test suite - nonlinear constraints to general constraints

Description

Tests a model with some nonlinear constraints that can be handled by GUROBI's
general constraint concept.

Contributor: Renke Kuhlmann, June 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : gurobi07.gms

$TITLE 'GUROBI test suite - nonlinear constraints to general constraints' (GUROBI07,SEQ=905)
$ontext
Tests a model with some nonlinear constraints that can be handled by GUROBI's
general constraint concept.

Contributor: Renke Kuhlmann, June 2022
$offtext

$onecho > gurobi.opt
writeprob prob.lp
$offecho

Set
    i / 1*4 /;
Variable
    r, x(i), x1, x2, x3, x4;
Equation
    e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17,
    e18, e19, e20, e21, e22, e23, e24, e25, e26;

e1.. r =e= max(x1, x2, x3, x4, 42);
e2.. r =e= min(x1, x2, x3, x4, 42);
e3.. r =e= x1 and x2 and x3 and x4;
e4.. r =e= x1 or x2 or x3 or x4;
e5.. r =e= abs(x1);
e6.. r =e= sin(x1);
e7.. r =e= cos(x1);
e8.. r =e= tan(x1);
e9.. r =e= exp(x1);
e10.. r =e= log(x1);
e11.. r =e= log2(x1);
e12.. r =e= log10(x1);
e13.. r =e= x1**42;
e14.. r =e= 42**x1;
e15.. r =e= poly(x1, 1, 2, 3, 4, 5);
e16.. r =e= edist(x1, x2, x3, x4);
e17.. r =e= smax(i, x(i));
e18.. r =e= smin(i, x(i));
e19.. r =e= sand(i, x(i));
e20.. r =e= sor(i, x(i));
e21.. r =e= sum(i, abs(x(i)));
e22.. r =e= sqrt(sum(i, sqr(x(i))));
e23.. r =e= smax(i, abs(x(i)));
e24.. r =e= abs(x1) + abs(x2) + abs(x3) + abs(x4);
e25.. r =e= sqrt(sqr(x1) + sqr(x2) + sqr(x3) + sqr(x4));
e26.. r =e= max(abs(x1), abs(x2), abs(x3), abs(x4));

x1.lo = 0;
x1.l = 1;

Model m / all /;

m.optfile = 1;
option dnlp = gurobi;

Solve m using DNLP minimizing r;

execute.checkErrorlevel 'grep -qF "e1: r = MAX ( x1 , x2 , x3 , x4 , 42 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e2: r = MIN ( x1 , x2 , x3 , x4 , 42 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e3: r = AND ( x1 , x2 , x3 , x4 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e4: r = OR ( x1 , x2 , x3 , x4 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e5: r = ABS ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e6: r = SIN ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e7: r = COS ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e8: r = TAN ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e9: r = EXP ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e10: r = LOG ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e11: r = LOG_2 ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e12: r = LOG_10 ( x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e13: r = POW ( x1 ^ 42 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e14: r = EXPA ( 42 ^ x1 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e15: r = POLY ( 5 x1 ^ 4 + 4 x1 ^ 3 + 3 x1 ^ 2 + 2 x1 ^ 1 + 1 x1 ^ 0 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e16: r = NORM ( 2 ) ( x1 , x2 , x3 , x4 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e17: r = MAX ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e18: r = MIN ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e19: r = AND ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e20: r = OR ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e21: r = NORM ( 1 ) ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e22: r = NORM ( 2 ) ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e23: r = NORM ( Inf ) ( x(1) , x(2) , x(3) , x(4) )" prob.lp';
execute.checkErrorlevel 'grep -qF "e24: r = NORM ( 1 ) ( x1 , x2 , x3 , x4 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e25: r = NORM ( 2 ) ( x1 , x2 , x3 , x4 )" prob.lp';
execute.checkErrorlevel 'grep -qF "e26: r = NORM ( Inf ) ( x1 , x2 , x3 , x4 )" prob.lp';