lp01.gms : Simple test on one equation

Description

```In this test we check how a solver behaves when there is only
one objective variable in one equation. Different tests
are performed applying different directions of optimization
as well as different types of signs of the constraints.

Jun 2006: break out the test on an =n= equation into a separate test
(lp11) so that for some solvers we can skip just =n= but still test
the other equation types.
```

Small Model of Type : LP

Category : GAMS Test library

Main file : lp01.gms

``````\$title Simple test on one equation (LP01,SEQ=66)

\$onText

In this test we check how a solver behaves when there is only
one objective variable in one equation. Different tests
are performed applying different directions of optimization
as well as different types of signs of the constraints.

Jun 2006: break out the test on an =n= equation into a separate test
(lp11) so that for some solvers we can skip just =n= but still test
the other equation types.

\$offText

\$if not set MTYPE       \$set MTYPE lp
\$if not set solvedasmcp \$set solvedasmcp 0
\$if not set SKIPUNBND \$set SKIPUNBND 0
scalar skipUnBnd / %SKIPUNBND% /;
\$if not set SLOWOK \$set SLOWOK 0
scalar slowOK 'slow solves are OK: just abort.noError in this case' / %SLOWOK% /;

variable obj;

equations defobje
defobjl
defobjg;

model lp01e /defobje/
lp01l /defobjl/
lp01g /defobjg/;

defobje.. obj =e= 1;
defobjl.. obj =l= 1;
defobjg.. obj =g= 1;

option limcol=0,limrow=0,bratio=1;

scalar tol / 1e-6 /;

solve lp01e max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01e.solvestat] 'Solve too slow';
abort\$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01e.solvestat, lp01e.modelstat;
abort\$(lp01e.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01e.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01e.objval - 1) > tol) 'bad m.objval';
abort\$(abs(defobje.l - 1) > tol)    'bad equation level';
abort\$(abs(defobje.m - 1) > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)     > tol)    'bad variable level';
abort\$(abs(obj.m - 0)     > tol)    'bad variable marginal';

solve lp01l max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01l.solvestat] 'Solve too slow';
abort\$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01l.solvestat, lp01l.modelstat;
abort\$(lp01l.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01l.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01l.objval - 1) > tol) 'bad m.objval';
abort\$(abs(defobjl.l - 1) > tol)    'bad equation level';
abort\$(abs(defobjl.m - 1) > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)     > tol)    'bad variable level';
abort\$(abs(obj.m - 0)     > tol)    'bad variable marginal';

if {not skipUnBnd,
solve lp01g max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01g.solvestat] 'Solve too slow';
abort\$(lp01g.solvestat <> %solveStat.normalCompletion%
or ( (lp01g.modelstat <> %modelStat.unbounded%) and (lp01g.modelstat <> %modelStat.unboundedNoSolution%)
and ((lp01g.modelstat <> %modelStat.infeasible%) or (%solvedasmcp% = 0))))
'wrong status codes', lp01g.solvestat, lp01g.modelstat;
};

solve lp01e min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01e.solvestat] 'Solve too slow';
abort\$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01e.solvestat, lp01e.modelstat;
abort\$(lp01e.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01e.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01e.objval - 1) > tol) 'bad m.objval';
abort\$(abs(defobje.l - 1) > tol)    'bad equation level';
abort\$(abs(defobje.m - 1) > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)     > tol)    'bad variable level';
abort\$(abs(obj.m - 0)     > tol)    'bad variable marginal';

if {not skipUnBnd,
solve lp01l min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01l.solvestat] 'Solve too slow';
abort\$(lp01l.solvestat <> %solveStat.normalCompletion%
or ( (lp01l.modelstat <> %modelStat.unbounded%) and (lp01l.modelstat <> %modelStat.unboundedNoSolution%)
and ((lp01l.modelstat <> %modelStat.infeasible%) or (%solvedasmcp% = 0))))
'wrong status codes', lp01l.solvestat, lp01l.modelstat;
};

solve lp01g min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01g.solvestat] 'Solve too slow';
abort\$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01g.solvestat, lp01g.modelstat;
abort\$(lp01g.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01g.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01g.objval - 1) > tol) 'bad m.objval';
abort\$(abs(defobjg.l - 1) > tol)    'bad equation level';
abort\$(abs(defobjg.m - 1) > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)     > tol)    'bad variable level';
abort\$(abs(obj.m - 0)     > tol)    'bad variable marginal';

obj.lo = -1000; obj.up = 1000;

solve lp01e max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01e.solvestat] 'Solve too slow';
abort\$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01e.solvestat, lp01e.modelstat;
abort\$(lp01e.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01e.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01e.objval - 1) > tol) 'bad m.objval';
abort\$(abs(defobje.l - 1)    > tol)    'bad equation level';
abort\$(abs(defobje.m - 1)    > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)        > tol)    'bad variable level';
abort\$(abs(obj.m - 0)        > tol)    'bad variable marginal';

solve lp01l max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01l.solvestat] 'Solve too slow';
abort\$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01l.solvestat, lp01l.modelstat;
abort\$(lp01l.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01l.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01l.objval - 1) > tol)    'bad m.objval';
abort\$(abs(defobjl.l - 1)    > tol)    'bad equation level';
abort\$(abs(defobjl.m - 1)    > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)        > tol)    'bad variable level';
abort\$(abs(obj.m - 0)        > tol)    'bad variable marginal';

solve lp01g max obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01g.solvestat] 'Solve too slow';
abort\$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01g.solvestat, lp01g.modelstat;
abort\$(lp01g.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01g.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01g.objval - 1000) > tol) 'bad m.objval';
abort\$(abs(defobjg.l - 1000) > tol)    'bad equation level';
abort\$(abs(defobjg.m - 0)    > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1000)     > tol)    'bad variable level';
abort\$(abs(obj.m - 1)        > tol)    'bad variable marginal';

solve lp01e min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01e.solvestat] 'Solve too slow';
abort\$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01e.solvestat, lp01e.modelstat;
abort\$(lp01e.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01e.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01e.objval - 1) > tol)    'bad m.objval';
abort\$(abs(defobje.l - 1)    > tol)    'bad equation level';
abort\$(abs(defobje.m - 1)    > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)        > tol)    'bad variable level';
abort\$(abs(obj.m - 0)        > tol)    'bad variable marginal';

solve lp01l min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01l.solvestat] 'Solve too slow';
abort\$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01l.solvestat, lp01l.modelstat;
abort\$(lp01l.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01l.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01l.objval + 1000) > tol) 'bad m.objval';
abort\$(abs(defobjl.l + 1000) > tol)    'bad equation level';
abort\$(abs(defobjl.m - 0)    > tol)    'bad equation marginal';
abort\$(abs(obj.l + 1000)     > tol)    'bad variable level';
abort\$(abs(obj.m - 1)        > tol)    'bad variable marginal';

solve lp01g min obj us %MTYPE%;
abort.noError\$[slowOK and %solveStat.resourceInterrupt% = lp01g.solvestat] 'Solve too slow';
abort\$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%)
'wrong status codes', lp01g.solvestat, lp01g.modelstat;
abort\$(lp01g.numnopt  <> 0) '    NONOPT flags set';
abort\$(lp01g.numinfes <> 0) 'INFEASIBLE flags set';
abort\$(abs(lp01g.objval - 1) > tol)    'bad m.objval';
abort\$(abs(defobjg.l - 1)    > tol)    'bad equation level';
abort\$(abs(defobjg.m - 1)    > tol)    'bad equation marginal';
abort\$(abs(obj.l - 1)        > tol)    'bad variable level';
abort\$(abs(obj.m - 0)        > tol)    'bad variable marginal';
``````
GAMS Development Corp.
GAMS Software GmbH

General Information and Sales
U.S. (+1) 202 342-0180
Europe: (+49) 221 949-9170
GAMS is a registered trademark of GAMS Software GmbH in the European Union