cplex04.gms : CPLEX test suite - free gams model test

Description

Tests the CPLEX link option 'freegamsmodel'.

Contributor: Renke Kuhlmann, October 2020


Small Model of Type : GAMS


Category : GAMS Test library


Main file : cplex04.gms

$title 'CPLEX test suite - free gams model test' (CPLEX04,SEQ=829)
$if not '%GAMS.lp%' == '' $set solver %GAMS.lp%
$if not set solver        $set solver cplex
$onText
Tests the CPLEX link option 'freegamsmodel'.

Contributor: Renke Kuhlmann, October 2020
$offText


* testing LP

$call gamslib -q 1

$echo "x.l(i,j) = 0;" >> trnsport.gms
$echo "x.m(i,j) = 0;" >> trnsport.gms

$echo "solve transport using lp minimizing z;" >> trnsport.gms

$echo "Parameter x_l1(i,j), x_m1(i,j);" >> trnsport.gms
$echo "x_l1(i,j) = x.l(i,j);" >> trnsport.gms
$echo "x_m1(i,j) = x.m(i,j);" >> trnsport.gms

$echo "x.l(i,j) = 0;" >> trnsport.gms
$echo "x.m(i,j) = 0;" >> trnsport.gms

$echo "transport.optfile=1;" >> trnsport.gms
$echo "solve transport using lp minimizing z;" >> trnsport.gms

$echo "Parameter x_l2(i,j), x_m2(i,j);" >> trnsport.gms
$echo "x_l2(i,j) = x.l(i,j);" >> trnsport.gms
$echo "x_m2(i,j) = x.m(i,j);" >> trnsport.gms

$echo "abort$(transport.modelstat <> %modelStat.optimal% or transport.solvestat <> %solveStat.normalCompletion%) 'problems with freegamsmodel';" >> trnsport.gms
$echo "abort$(smax((i,j), abs(x_l1(i,j) - x_l2(i,j))) > 1e-8) 'problems with freegamsmodel';" >> trnsport.gms
$echo "abort$(smax((i,j), abs(x_m1(i,j) - x_m2(i,j))) > 1e-8) 'problems with freegamsmodel';" >> trnsport.gms

$echo freegamsmodel 1 > %solver%.opt
$call =gams trnsport lo=%GAMS.lo% solver=%solver%
$if errorlevel 1 $abort 'problems with %solver% freegamsmodel option'


* testing QCP

$call gamslib -q 293

$echo "x.l(n,k) = 0;" >> qabel.gms
$echo "x.m(n,k) = 0;" >> qabel.gms
$echo "u.l(m,k) = 0;" >> qabel.gms
$echo "u.m(m,k) = 0;" >> qabel.gms

$echo "solve abel minimizing j using qcp;" >> qabel.gms

$echo "Parameter x_l1(n,k), x_m1(n,k);" >> qabel.gms
$echo "Parameter u_l1(m,k), u_m1(m,k);" >> qabel.gms
$echo "x_l1(n,k) = x.l(n,k);" >> qabel.gms
$echo "x_m1(n,k) = x.m(n,k);" >> qabel.gms
$echo "u_l1(m,k) = u.l(m,k);" >> qabel.gms
$echo "u_m1(m,k) = u.m(m,k);" >> qabel.gms

$echo "x.l(n,k) = 0;" >> qabel.gms
$echo "x.m(n,k) = 0;" >> qabel.gms
$echo "u.l(m,k) = 0;" >> qabel.gms
$echo "u.m(m,k) = 0;" >> qabel.gms

$echo "abel.optfile=1;" >> qabel.gms
$echo "solve abel minimizing j using qcp;" >> qabel.gms

$echo "Parameter x_l2(n,k), x_m2(n,k);" >> qabel.gms
$echo "Parameter u_l2(m,k), u_m2(m,k);" >> qabel.gms
$echo "x_l2(n,k) = x.l(n,k);" >> qabel.gms
$echo "x_m2(n,k) = x.m(n,k);" >> qabel.gms
$echo "u_l2(m,k) = u.l(m,k);" >> qabel.gms
$echo "u_m2(m,k) = u.m(m,k);" >> qabel.gms

$echo "abort$(abel.modelstat <> %modelStat.optimal% or abel.solvestat <> %solveStat.normalCompletion%) 'problems with freegamsmodel';" >> qabel.gms
$echo "abort$(smax((n,k), abs(x_l1(n,k) - x_l2(n,k))) > 1e-8) 'problems with freegamsmodel';" >> qabel.gms
$echo "abort$(smax((n,k), abs(x_m1(n,k) - x_m2(n,k))) > 1e-8) 'problems with freegamsmodel';" >> qabel.gms
$echo "abort$(smax((m,k), abs(u_l1(m,k) - u_l2(m,k))) > 1e-8) 'problems with freegamsmodel';" >> qabel.gms
$echo "abort$(smax((m,k), abs(u_m1(m,k) - u_m2(m,k))) > 1e-8) 'problems with freegamsmodel';" >> qabel.gms

$echo freegamsmodel 1 > %solver%.opt
$call =gams qabel lo=%GAMS.lo% solver=%solver%
$if errorlevel 1 $abort 'problems with %solver% freegamsmodel option'


* testing MIP

$call gamslib -q 19

$echo "pl.l(v,s) = 0;" >> bid.gms
$echo "pl.m(v,s) = 0;" >> bid.gms
$echo "plb.l(v,s) = 0;" >> bid.gms
$echo "plb.m(v,s) = 0;" >> bid.gms

$echo "solve bideval minimizing c using mip;" >> bid.gms

$echo "Parameter pl_l1(v,s), pl_m1(v,s);" >> bid.gms
$echo "Parameter plb_l1(v,s), plb_m1(v,s);" >> bid.gms
$echo "pl_l1(v,s) = pl.l(v,s);" >> bid.gms
$echo "pl_m1(v,s) = pl.m(v,s);" >> bid.gms
$echo "plb_l1(v,s) = plb.l(v,s);" >> bid.gms
$echo "plb_m1(v,s) = plb.m(v,s);" >> bid.gms

$echo "pl.l(v,s) = 0;" >> bid.gms
$echo "pl.m(v,s) = 0;" >> bid.gms
$echo "plb.l(v,s) = 0;" >> bid.gms
$echo "plb.m(v,s) = 0;" >> bid.gms

$echo "bideval.optfile=1;" >> bid.gms
$echo "solve bideval minimizing c using mip;" >> bid.gms

$echo "Parameter pl_l1(v,s), pl_l2(v,s), pl_m1(v,s), pl_m2(v,s);" >> bid.gms
$echo "Parameter plb_l1(v,s), plb_l2(v,s), plb_m1(v,s), plb_m2(v,s);" >> bid.gms
$echo "pl_l2(v,s) = pl.l(v,s);" >> bid.gms
$echo "pl_m2(v,s) = pl.m(v,s);" >> bid.gms
$echo "plb_l2(v,s) = plb.l(v,s);" >> bid.gms
$echo "plb_m2(v,s) = plb.m(v,s);" >> bid.gms

$echo "abort$(bideval.modelstat <> %modelStat.optimal% or bideval.solvestat <> %solveStat.normalCompletion%) 'problems with freegamsmodel';" >> bid.gms
$echo "abort$(smax((v,s), abs(pl_l1(v,s) - pl_l2(v,s))) > 1e-8) 'problems with freegamsmodel';" >> bid.gms
$echo "abort$(smax((v,s), abs(pl_m1(v,s) - pl_m2(v,s))) > 1e-8) 'problems with freegamsmodel';" >> bid.gms
$echo "abort$(smax((v,s), abs(plb_l1(v,s) - plb_l2(v,s))) > 1e-8) 'problems with freegamsmodel';" >> bid.gms
$echo "abort$(smax((v,s), abs(plb_m1(v,s) - plb_m2(v,s))) > 1e-8) 'problems with freegamsmodel';" >> bid.gms

$echo freegamsmodel 1 > %solver%.opt
$call =gams bid lo=%GAMS.lo% solver=%solver%
$if errorlevel 1 $abort 'problems with %solver% freegamsmodel option'