convert2.gms : CONVERT test suite - Basic test of convert output for linear model

Description

This tests the basic convert file formats using the
good old trnsport model and the 'all' (most) files option.


Small Model of Type : LP


Category : GAMS Test library


Main file : convert2.gms

$title 'CONVERT test suite - Basic test of convert output' (CONVERT2,SEQ=212)

* This tests the basic convert file formats using the
* good old trnsport model and the 'all' (most) files option.

$onDollar
$set ide ide=%gams.ide% lo=%gams.lo%

$call gamslib -q trnsport
$onEcho > convert.opt
all
filelist
$offEcho

$call gams trnsport.gms optfile=1 lp=convert %ide%

$onEcho > ampl_mod
#  LP written by GAMS Convert
#
# Equation counts
#     Total        E        G        L        N        X        C        B
#         5        0        3        2        0        0        0        0
#
# Variable counts
#                  x        b        i      s1s      s2s       sc       si
#     Total     cont   binary  integer     sos1     sos2    scont     sint
#         6        6        0        0        0        0        0        0
# FX      0
#
# Nonzero counts
#     Total    const       NL
#        12       12        0
#
# Reformulation has removed 1 variable and 1 equation

var x1 >= 0;
var x2 >= 0;
var x3 >= 0;
var x4 >= 0;
var x5 >= 0;
var x6 >= 0;

minimize obj: 0.225 * x1 + 0.153 * x2 + 0.162 * x3 + 0.225 * x4 + 0.162 * x5 +
    0.126 * x6;

subject to

e1:  x1 + x2 + x3 <= 350;
e2:  x4 + x5 + x6 <= 600;
e3:  x1 + x4 >= 325;
e4:  x2 + x5 >= 300;
e5:  x3 + x6 >= 275;
$offEcho
* $call =diff -b -I "LP written by GAMS" ampl_mod ampl.mod
$call grep -v "LP written by GAMS" ampl_mod > ampl.mod.want
$call grep -v "LP written by GAMS" ampl.mod > ampl.mod.got
$call =diff -b ampl.mod.want ampl.mod.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > cplex_lp
\  LP written by GAMS Convert
\
\ Equation counts
\     Total        E        G        L        N        X        C        B
\         6        1        3        2        0        0        0        0
\
\ Variable counts
\                  x        b        i      s1s      s2s       sc       si
\     Total     cont   binary  integer     sos1     sos2    scont     sint
\         7        7        0        0        0        0        0        0
\ FX      0
\
\ Nonzero counts
\     Total    const       NL
\        19       19        0

Minimize
 obj: x7

Subject To
 e1: -0.225 x1 - 0.153 x2 - 0.162 x3 - 0.225 x4 - 0.162 x5 - 0.126 x6 + x7 = 0
 e2: x1 + x2 + x3 <= 350
 e3: x4 + x5 + x6 <= 600
 e4: x1 + x4 >= 325
 e5: x2 + x5 >= 300
 e6: x3 + x6 >= 275

Bounds
 x7 Free

End
$offEcho
$call grep -v "LP written by GAMS" cplex_lp > cplex.lp.want
$call grep -v "LP written by GAMS" cplex.lp > cplex.lp.got
$call =diff -b cplex.lp.want cplex.lp.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > cplex_mps
*  LP written by GAMS Convert
*
* Equation counts
*     Total        E        G        L        N        X        C        B
*         6        1        3        2        0        0        0        0
*
* Variable counts
*                  x        b        i      s1s      s2s       sc       si
*     Total     cont   binary  integer     sos1     sos2    scont     sint
*         7        7        0        0        0        0        0        0
* FX      0
*
* Nonzero counts
*     Total    const       NL
*        19       19        0

NAME Convert
OBJSENSE
 MIN
OBJNAME
 obj
ROWS
 N obj
 E e1
 L e2
 L e3
 G e4
 G e5
 G e6
COLUMNS
 x1 e1 -0.225
 x1 e2 1
 x1 e4 1
 x2 e1 -0.153
 x2 e2 1
 x2 e5 1
 x3 e1 -0.162
 x3 e2 1
 x3 e6 1
 x4 e1 -0.225
 x4 e3 1
 x4 e4 1
 x5 e1 -0.162
 x5 e3 1
 x5 e5 1
 x6 e1 -0.126
 x6 e3 1
 x6 e6 1
 x7 obj 1
 x7 e1 1
RHS
 rhs e2 350
 rhs e3 600
 rhs e4 325
 rhs e5 300
 rhs e6 275
BOUNDS
 FR bnd x7
ENDATA
$offEcho
$call grep -v "LP written by GAMS" cplex_mps > cplex.mps.want
$call grep -v "LP written by GAMS" cplex.mps > cplex.mps.got
$call =diff -b cplex.mps.want cplex.mps.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > fixed_mps
*  LP written by GAMS Convert
*
* Equation counts
*     Total        E        G        L        N        X        C        B
*         6        1        3        2        0        0        0        0
*
* Variable counts
*                  x        b        i      s1s      s2s       sc       si
*     Total     cont   binary  integer     sos1     sos2    scont     sint
*         7        7        0        0        0        0        0        0
* FX      0
*
* Nonzero counts
*     Total    const       NL
*        19       19        0

NAME          Convert
*
* original model was minimizing
*
ROWS
 N  obj
 E  e1
 L  e2
 L  e3
 G  e4
 G  e5
 G  e6
COLUMNS
    x1        e1              -0.225
    x1        e2                   1
    x1        e4                   1
    x2        e1              -0.153
    x2        e2                   1
    x2        e5                   1
    x3        e1              -0.162
    x3        e2                   1
    x3        e6                   1
    x4        e1              -0.225
    x4        e3                   1
    x4        e4                   1
    x5        e1              -0.162
    x5        e3                   1
    x5        e5                   1
    x6        e1              -0.126
    x6        e3                   1
    x6        e6                   1
    x7        obj                  1
    x7        e1                   1
RHS
    rhs       e2                 350
    rhs       e3                 600
    rhs       e4                 325
    rhs       e5                 300
    rhs       e6                 275
BOUNDS
 FR bnd       x7
ENDATA
$offEcho
$call grep -v "LP written by GAMS" fixed_mps > fixed.mps.want
$call grep -v "LP written by GAMS" fixed.mps > fixed.mps.got
$call =diff -b fixed.mps.want fixed.mps.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > gams_gms
*  LP written by GAMS Convert
*
* Equation counts
*     Total        E        G        L        N        X        C        B
*         6        1        3        2        0        0        0        0
*
* Variable counts
*                  x        b        i      s1s      s2s       sc       si
*     Total     cont   binary  integer     sos1     sos2    scont     sint
*         7        7        0        0        0        0        0        0
* FX      0
*
* Nonzero counts
*     Total    const       NL
*        19       19        0

* Solve m using LP minimizing x7;

Variables
    x1,x2,x3,x4,x5,x6,x7;

Positive Variables
    x1,x2,x3,x4,x5,x6;

Equations
    e1,e2,e3,e4,e5,e6;

e1..  -0.225 * x1 - 0.153 * x2 - 0.162 * x3 - 0.225 * x4 - 0.162 * x5 - 0.126 *
      x6 + x7 =E= 0;
e2..  x1 + x2 + x3 =L= 350;
e3..  x4 + x5 + x6 =L= 600;
e4..  x1 + x4 =G= 325;
e5..  x2 + x5 =G= 300;
e6..  x3 + x6 =G= 275;

Model m / all /;

m.limrow = 0;
m.limcol = 0;

Solve m using LP minimizing x7;
$offEcho
$call grep -v "LP written by GAMS" gams_gms > gams.gms.want
$call grep -v "LP written by GAMS" gams.gms > gams.gms.got
$call =diff -b gams.gms.want gams.gms.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > lingo_lng
!  LP written by GAMS Convert
!
! Equation counts
!     Total        E        G        L        N        X        C        B
!         5        0        3        2        0        0        0        0
!
! Variable counts
!                  x        b        i      s1s      s2s       sc       si
!     Total     cont   binary  integer     sos1     sos2    scont     sint
!         6        6        0        0        0        0        0        0
! FX      0
!
! Nonzero counts
!     Total    const       NL
!        12       12        0
!
! Reformulation has removed 1 variable and 1 equation

! ;

MODEL:

[Obj] MIN = 0.225 * x1 + 0.153 * x2 + 0.162 * x3 + 0.225 * x4 + 0.162 * x5 +
      0.126 * x6;

[e1] x1 + x2 + x3 <= 350;
[e2] x4 + x5 + x6 <= 600;
[e3] x1 + x4 >= 325;
[e4] x2 + x5 >= 300;
[e5] x3 + x6 >= 275;

END
$offEcho
$call grep -v "LP written by GAMS" lingo_lng > lingo.lng.want
$call grep -v "LP written by GAMS" lingo.lng > lingo.lng.got
$call =diff -b lingo.lng.want lingo.lng.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > dict_txt
LP written by GAMS Convert

Equation counts
    Total        E        G        L        N        X        C        B
        6        1        3        2        0        0        0        0

Variable counts
                 x        b        i      s1s      s2s       sc       si
    Total     cont   binary  integer     sos1     sos2    scont     sint
        7        7        0        0        0        0        0        0
FX      0

Nonzero counts
    Total    const       NL
       19       19        0

Equations 1 to 6
  e1  cost
  e2  supply(seattle)
  e3  supply(san-diego)
  e4  demand(new-york)
  e5  demand(chicago)
  e6  demand(topeka)

Variables 1 to 7
  x1  x(seattle,new-york)
  x2  x(seattle,chicago)
  x3  x(seattle,topeka)
  x4  x(san-diego,new-york)
  x5  x(san-diego,chicago)
  x6  x(san-diego,topeka)
  x7  z
$offEcho
$call grep -v "LP written by GAMS" dict_txt > dict.txt.want
$call grep -v "LP written by GAMS" dict.txt > dict.txt.got
$call =diff -b dict.txt.want dict.txt.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%

$onEcho > files_txt
gamsdual.gms
gamsmcp.gms
ampl.mod
ampl.nl
cplex.lp
cplex.mps
dict.txt
dictmap.gdx
dump.gdx
fixed.mps
gams.gms
jump.jl
lingo.lng
osil.xml
pyomo.py
files.txt
$offEcho

$call grep -v "LP written by GAMS" files_txt > files.txt.want
$call grep -v "LP written by GAMS" files.txt > files.txt.got
$call =diff -b files.txt.want files.txt.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%


$onEcho > jump_jl
# LP written by GAMS Convert
#
# Equation counts
#     Total        E        G        L        N        X        C        B
#         5        0        3        2        0        0        0        0
#
# Variable counts
#                  x        b        i      s1s      s2s       sc       si
#     Total     cont   binary  integer     sos1     sos2    scont     sint
#         6        6        0        0        0        0        0        0
# FX      0
#
# Nonzero counts
#     Total    const       NL
#        12       12        0
#
# Reformulation has removed 1 variable and 1 equation

using JuMP
using MathOptInterface
const MOI = MathOptInterface

model = m = Model()

@variable(m, 0 <= x1, start=0)
@variable(m, 0 <= x2, start=0)
@variable(m, 0 <= x3, start=0)
@variable(m, 0 <= x4, start=0)
@variable(m, 0 <= x5, start=0)
@variable(m, 0 <= x6, start=0)

@objective(m, Min, 0.225 * x1 + 0.153 * x2 + 0.162 * x3 + 0.225 * x4 + 0.162 *
    x5 + 0.126 * x6)

@constraint(m, e1, x1 + x2 + x3 <= 350)
@constraint(m, e2, x4 + x5 + x6 <= 600)
@constraint(m, e3, x1 + x4 >= 325)
@constraint(m, e4, x2 + x5 >= 300)
@constraint(m, e5, x3 + x6 >= 275)
$offEcho
$call grep -v "LP written by GAMS" jump_jl > jump.jl.want
$call grep -v "LP written by GAMS" jump.jl > jump.jl.got
$call =diff -b jump.jl.want jump.jl.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%


$onEcho > pyomo_py
# LP written by GAMS Convert
#
# Equation counts
#     Total        E        G        L        N        X        C        B
#         5        0        3        2        0        0        0        0
#
# Variable counts
#                  x        b        i      s1s      s2s       sc       si
#     Total     cont   binary  integer     sos1     sos2    scont     sint
#         6        6        0        0        0        0        0        0
# FX      0
#
# Nonzero counts
#     Total    const       NL
#        12       12        0
#
# Reformulation has removed 1 variable and 1 equation

from pyomo.environ import *

model = m = ConcreteModel()

m.x1 = Var(within=Reals, bounds=(0,None), initialize=0)
m.x2 = Var(within=Reals, bounds=(0,None), initialize=0)
m.x3 = Var(within=Reals, bounds=(0,None), initialize=0)
m.x4 = Var(within=Reals, bounds=(0,None), initialize=0)
m.x5 = Var(within=Reals, bounds=(0,None), initialize=0)
m.x6 = Var(within=Reals, bounds=(0,None), initialize=0)

m.obj = Objective(sense=minimize, expr= 0.225 * m.x1 + 0.153 * m.x2 + 0.162 *
    m.x3 + 0.225 * m.x4 + 0.162 * m.x5 + 0.126 * m.x6)

m.e1 = Constraint(expr= m.x1 + m.x2 + m.x3 <= 350)
m.e2 = Constraint(expr= m.x4 + m.x5 + m.x6 <= 600)
m.e3 = Constraint(expr= m.x1 + m.x4 >= 325)
m.e4 = Constraint(expr= m.x2 + m.x5 >= 300)
m.e5 = Constraint(expr= m.x3 + m.x6 >= 275)
$offEcho
$call grep -v "LP written by GAMS" pyomo_py > pyomo.py.want
$call grep -v "LP written by GAMS" pyomo.py > pyomo.py.got
$call =diff -b pyomo.py.want pyomo.py.got
$if NOT errorlevel 0 $error errorlevel not 0 but is %system.errorlevel%
$if     errorlevel 1 $error errorlevel not 0 but is %system.errorlevel%