lp12.gms : Test solution quality with solvelink=3/6

Description

This test is a modified version of lp01.  In this model, we use
m.solvelink = %solveLink.asyncGrid% so we can test the solution returned in this case.

N.B.: An alternate way to test this is to use m.solvelink = %solveLink.asyncSimulate% which
uses handles and their associated calls (e.g. handlestatus,
execute_loadhandle) internally without requiring any changes to the
model.  There should be at least one explicit test of m.solvelink = %solveLink.asyncGrid%
though.

Tests include:
  a) correct model attributes
  b) correct levels and marginals on rows and cols

Update for GAMS 24.6: Do not test %solveLink.asyncGrid% only but also %solveLink.aSyncThreads%.

Contributor: Steve Dirkse


Small Model of Type : LP


Category : GAMS Test library


Main file : lp12.gms

$title 'Test solution quality with solvelink=%solveLink.asyncGrid%/%solveLink.aSyncThreads%' (LP12,SEQ=252)

$onText
This test is a modified version of lp01.  In this model, we use
m.solvelink = %solveLink.asyncGrid% so we can test the solution returned in this case.

N.B.: An alternate way to test this is to use m.solvelink = %solveLink.asyncSimulate% which
uses handles and their associated calls (e.g. handlestatus,
execute_loadhandle) internally without requiring any changes to the
model.  There should be at least one explicit test of m.solvelink = %solveLink.asyncGrid%
though.

Tests include:
  a) correct model attributes
  b) correct levels and marginals on rows and cols

Update for GAMS 24.6: Do not test %solveLink.asyncGrid% only but also %solveLink.aSyncThreads%.

Contributor: Steve Dirkse
$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% /;


variable obj;

equations defobje
          defobjl
          defobjg;

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

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

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

scalar tol / 1e-6 /;

set sl SolveLink settings to be tested
       / %solveLink.asyncGrid%
         %solveLink.aSyncThreads% /;

loop(sl,
  lp01e.solvelink = sl.val;
  lp01l.solvelink = sl.val;
  lp01g.solvelink = sl.val;

  solve lp01e max obj us %MTYPE%;
  abort$readyCollect(lp01e.handle,100)    'lp01e not ready';
  abort$(not handleCollect(lp01e.handle)) 'Trouble collecting lp01e';
  display$handleDelete(lp01e.handle)      'Trouble deleting handle for lp01e';
  
  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$readyCollect(lp01l.handle,100)    'lp01l not ready';
  abort$(not handleCollect(lp01l.handle)) 'Trouble collecting lp01l';
  display$handleDelete(lp01l.handle)      'Trouble deleting handle for lp01l';

  abort$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01g.handle,100)    'lp01g not ready';
    abort$(not handleCollect(lp01g.handle)) 'Trouble collecting lp01g';
    display$handleDelete(lp01g.handle)      'Trouble deleting handle for lp01g';

    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';
  }

  solve lp01e min obj us %MTYPE%;
  abort$readyCollect(lp01e.handle,100)    'lp01e not ready';
  abort$(not handleCollect(lp01e.handle)) 'Trouble collecting lp01e';
  display$handleDelete(lp01e.handle)      'Trouble deleting handle for lp01e';

  abort$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01l.handle,100)    'lp01l not ready';
    abort$(not handleCollect(lp01l.handle)) 'Trouble collecting lp01l';
    display$handleDelete(lp01l.handle)      'Trouble deleting handle for lp01l';

    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';
  }

  solve lp01g min obj us %MTYPE%;
  abort$readyCollect(lp01g.handle,100)    'lp01g not ready';
  abort$(not handleCollect(lp01g.handle)) 'Trouble collecting lp01g';
  display$handleDelete(lp01g.handle)      'Trouble deleting handle for lp01g';

  abort$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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;

loop(sl,
  lp01e.solvelink = sl.val;
  lp01l.solvelink = sl.val;
  lp01g.solvelink = sl.val;

  solve lp01e max obj us %MTYPE%;
  abort$readyCollect(lp01e.handle,100)    'lp01e not ready';
  abort$(not handleCollect(lp01e.handle)) 'Trouble collecting lp01e';
  display$handleDelete(lp01e.handle)      'Trouble deleting handle for lp01e';

  abort$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01l.handle,100)    'lp01l not ready';
  abort$(not handleCollect(lp01l.handle)) 'Trouble collecting lp01l';
  display$handleDelete(lp01l.handle)      'Trouble deleting handle for lp01l';

  abort$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01g.handle,100)    'lp01g not ready';
  abort$(not handleCollect(lp01g.handle)) 'Trouble collecting lp01g';
  display$handleDelete(lp01g.handle)      'Trouble deleting handle for lp01g';

  abort$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01e.handle,100)    'lp01e not ready';
  abort$(not handleCollect(lp01e.handle)) 'Trouble collecting lp01e';
  display$handleDelete(lp01e.handle)      'Trouble deleting handle for lp01e';

  abort$(lp01e.solvestat <> %solveStat.normalCompletion% or lp01e.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01l.handle,100)    'lp01l not ready';
  abort$(not handleCollect(lp01l.handle)) 'Trouble collecting lp01l';
  display$handleDelete(lp01l.handle)      'Trouble deleting handle for lp01l';

  abort$(lp01l.solvestat <> %solveStat.normalCompletion% or lp01l.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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$readyCollect(lp01g.handle,100)    'lp01g not ready';
  abort$(not handleCollect(lp01g.handle)) 'Trouble collecting lp01g';
  display$handleDelete(lp01g.handle)      'Trouble deleting handle for lp01g';

  abort$(lp01g.solvestat <> %solveStat.normalCompletion% or lp01g.modelstat <> %modelStat.optimal%) 'wrong status codes';
  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';
);