mps2gms2.gms : Test mps2gms more

Description

This tests that the various MPS sections are converted correctly into
GDX files.

Contributor: Stefan Vigerske, March 2022


Small Model of Type : GAMS


Category : GAMS Test library


Main file : mps2gms2.gms

$title 'MPS2GMS test suite - Test MPS sections'

* This tests that the various MPS sections are converted correctly into
* GDX files.
*
* Contributor: Stefan Vigerske, March 2022

$onCheckErrorLevel

* ============================================================ qp_matrix

$onEcho > %gams.scrdir%qp_qmatrix.mps
NAME Convert
OBJSENSE
 MAX
ROWS
 N obj
COLUMNS
 x1 obj 1
 x2 obj 1
RHS
BOUNDS
 LO bnd x1 0
 UP bnd x1 2
 LO bnd x2 0
 UP bnd x2 4
QMATRIX
 x1 x1 2
 x1 x2 2
 x2 x1 2
 x2 x2 2
ENDATA
$offEcho

$onEcho > %gams.scrdir%qp_qmatrix.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order / /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x1' 1, 
'x2' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns / /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective /
' xc'.'x1'.' xc'.'x1' 2, 
' xc'.'x2'.' xc'.'x1' 4, 
' xc'.'x2'.' xc'.'x2' 2 /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2, 
'x2'.UP 4 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_j' 2, 
'set_jc' 2, 
'par_c' 2 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%qp_qmatrix.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%qp_qmatrix.gdx" > "%gams.scrdir%qp_qmatrix.gdx.got"
$call =diff -b "%gams.scrdir%qp_qmatrix.gdx.want" "%gams.scrdir%qp_qmatrix.gdx.got"
$call =rm "%gams.scrdir%qp_qmatrix.mps" "%gams.scrdir%qp_qmatrix.gms" "%gams.scrdir%qp_qmatrix.gdx"
$call =rm "%gams.scrdir%qp_qmatrix.gdx.got" "%gams.scrdir%qp_qmatrix.gdx.want"

* =========================================================== qp_quadobj

$onEcho > %gams.scrdir%qp_quadobj.mps
NAME Convert
OBJSENSE
 MAX
ROWS
 N obj
COLUMNS
 x1 obj 1
 x2 obj 1
RHS
BOUNDS
 LO bnd x1 0
 UP bnd x1 2
 LO bnd x2 0
 UP bnd x2 4
QUADOBJ
 x1 x1 2
 x1 x2 2
 x2 x2 2
ENDATA
$offEcho

$onEcho > %gams.scrdir%qp_quadobj.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order / /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x1' 1, 
'x2' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns / /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective /
' xc'.'x1'.' xc'.'x1' 2, 
' xc'.'x2'.' xc'.'x1' 4, 
' xc'.'x2'.' xc'.'x2' 2 /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2, 
'x2'.UP 4 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_j' 2, 
'set_jc' 2, 
'par_c' 2 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%qp_quadobj.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%qp_quadobj.gdx" > "%gams.scrdir%qp_quadobj.gdx.got"
$call =diff -b "%gams.scrdir%qp_quadobj.gdx.want" "%gams.scrdir%qp_quadobj.gdx.got"
$call =rm "%gams.scrdir%qp_quadobj.mps" "%gams.scrdir%qp_quadobj.gms" "%gams.scrdir%qp_quadobj.gdx"
$call =rm "%gams.scrdir%qp_quadobj.gdx.got" "%gams.scrdir%qp_quadobj.gdx.want"

* ========================================================= qcp_qcmatrix

$onEcho > %gams.scrdir%qcp_qcmatrix.mps
NAME          Convert
ROWS
 N  obj
 E  e1
COLUMNS
    x1        e1                  -1
    x2        e1                  -1
    x3        obj                 -1
    x3        e1                   1
RHS
BOUNDS
 UP bnd       x1                   2
 UP bnd       x2                   4
 FR bnd       x3
QCMATRIX   e1
    x1        x1                  -2
    x1        x2                  -2
    x2        x1                  -2
    x2        x2                  -2
ENDATA
$offEcho

$onEcho > %gams.scrdir%qcp_qcmatrix.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'e1' /;

Set ei(*,*) equ type mapping /
' ee'.'e1' /;

Set ie(*) equality rows /
'e1' /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2', 
'x3' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2', 
'x3' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x3' -1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'e1'.'x1' -1, 
'e1'.'x2' -1, 
'e1'.'x3' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks /
' ee'.'e1'.' xc'.'x1'.' xc'.'x1' -2, 
' ee'.'e1'.' xc'.'x2'.' xc'.'x1' -4, 
' ee'.'e1'.' xc'.'x2'.' xc'.'x2' -2 /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2, 
'x2'.UP 4, 
'x3'.LO -Inf /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 1, 
'set_ie' 1, 
'set_j' 3, 
'set_jc' 3, 
'par_c' 1, 
'par_ac' 3 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%qcp_qcmatrix.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%qcp_qcmatrix.gdx" > "%gams.scrdir%qcp_qcmatrix.gdx.got"
$call =diff -b "%gams.scrdir%qcp_qcmatrix.gdx.want" "%gams.scrdir%qcp_qcmatrix.gdx.got"
$call =rm "%gams.scrdir%qcp_qcmatrix.mps" "%gams.scrdir%qcp_qcmatrix.gms" "%gams.scrdir%qcp_qcmatrix.gdx"
$call =rm "%gams.scrdir%qcp_qcmatrix.gdx.got" "%gams.scrdir%qcp_qcmatrix.gdx.want"

* ========================================================= qcp_qsection

$onEcho > %gams.scrdir%qcp_qsection.mps
NAME          Convert
ROWS
 N  obj
 E  e1
COLUMNS
    x1        e1                  -1
    x2        e1                  -1
    x3        obj                 -1
    x3        e1                   1
RHS
BOUNDS
 UP bnd       x1                   2
 UP bnd       x2                   4
 FR bnd       x3
QSECTION   e1
    x1        x1                  -2
    x1        x2                  -2
    x2        x2                  -2
ENDATA
$offEcho

$onEcho > %gams.scrdir%qcp_qsection.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'e1' /;

Set ei(*,*) equ type mapping /
' ee'.'e1' /;

Set ie(*) equality rows /
'e1' /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2', 
'x3' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2', 
'x3' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x3' -1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'e1'.'x1' -1, 
'e1'.'x2' -1, 
'e1'.'x3' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks /
' ee'.'e1'.' xc'.'x1'.' xc'.'x1' -2, 
' ee'.'e1'.' xc'.'x2'.' xc'.'x1' -4, 
' ee'.'e1'.' xc'.'x2'.' xc'.'x2' -2 /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2, 
'x2'.UP 4, 
'x3'.LO -Inf /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 1, 
'set_ie' 1, 
'set_j' 3, 
'set_jc' 3, 
'par_c' 1, 
'par_ac' 3 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%qcp_qsection.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%qcp_qsection.gdx" > "%gams.scrdir%qcp_qsection.gdx.got"
$call =diff -b "%gams.scrdir%qcp_qsection.gdx.want" "%gams.scrdir%qcp_qsection.gdx.got"
$call =rm "%gams.scrdir%qcp_qsection.mps" "%gams.scrdir%qcp_qsection.gms" "%gams.scrdir%qcp_qsection.gdx"
$call =rm "%gams.scrdir%qcp_qsection.gdx.got" "%gams.scrdir%qcp_qsection.gdx.want"

* ================================================================ sos1a

$onEcho > %gams.scrdir%sos1a.mps
NAME          gamsmodel
ROWS
 N  _obj    
 L  xsum    
COLUMNS
    x(1)      _obj                         -0.9
    x(1)      xsum                            1
    x(2)      _obj                           -1
    x(2)      xsum                            1
    x(3)      _obj                         -1.1
    x(3)      xsum                            1
    constobj  _obj                           -1
RHS
    rhs       xsum                            1
BOUNDS
 UP bnd       x(1)                          0.8
 UP bnd       x(2)                          0.6
 UP bnd       x(3)                          0.6
 FX bnd       constobj                        0
SOS
 S1 s1
    x(1)                            1
    x(2)                            2
    x(3)                            3
ENDATA
$offEcho

$onEcho > %gams.scrdir%sos1a.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'xsum' /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows /
'xsum' /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x(1)', 
'x(2)', 
'x(3)', 
'constobj' /;

Set s(*) SOS sets /
's1' /;

Set jc(*) continuous columns /
'constobj' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns /
's1'.'x(1)', 
's1'.'x(2)', 
's1'.'x(3)' /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping /
'x(1)'.'s1', 
'x(2)'.'s1', 
'x(3)'.'s1' /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x(1)' -0.9, 
'x(2)' -1, 
'x(3)' -1.1, 
'constobj' -1 /;

Parameter ac(*,*) constraint matrix: continuous columns / /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 /
'xsum'.'s1'.'x(1)' 1, 
'xsum'.'s1'.'x(2)' 1, 
'xsum'.'s1'.'x(3)' 1 /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS /
'xsum' 1 /;

positive Variable xc(*) continuous variables /
'constobj'.UP 0 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables /
's1'.'x(1)'.UP 0.8, 
's1'.'x(2)'.UP 0.6, 
's1'.'x(3)'.UP 0.6 /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 1, 
'set_il' 1, 
'set_j' 4, 
'set_s' 1, 
'set_jc' 1, 
'set_js1' 3, 
'par_c' 4, 
'par_b' 1, 
'par_as1' 3 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%sos1a.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%sos1a.gdx" > "%gams.scrdir%sos1a.gdx.got"
$call =diff -b "%gams.scrdir%sos1a.gdx.want" "%gams.scrdir%sos1a.gdx.got"
$call =rm "%gams.scrdir%sos1a.mps" "%gams.scrdir%sos1a.gms" "%gams.scrdir%sos1a.gdx"
$call =rm "%gams.scrdir%sos1a.gdx.got" "%gams.scrdir%sos1a.gdx.want"

* ================================================================ sos2a

$onEcho > %gams.scrdir%sos2a.mps
NAME          gamsmodel
ROWS
 N  _obj    
 E  wsum    
 E  xdef    
 E  fxdef   
 G  defwLo  
 G  gapplus 
 G  gapminus
COLUMNS
    w(1)      wsum                           -1
    w(1)      xdef                           -1
    w(1)      fxdef                          -1
    w(1)      defwLo                          1
    w(2)      wsum                           -1
    w(2)      xdef                           -2
    w(2)      fxdef                          -2
    w(3)      wsum                           -1
    w(3)      xdef                           -3
    w(3)      fxdef                          -3
    fplus     _obj                            1
    fplus     gapplus                         1
    fminus    _obj                            1
    fminus    gapminus                        1
    x         xdef                            1
    fx        fxdef                           1
    fx        gapplus                        -1
    fx        gapminus                        1
    constobj  _obj                            1
RHS
    rhs       wsum                           -1
    rhs       defwLo                        0.8
    rhs       gapplus                      -1.3
    rhs       gapminus                      1.3
BOUNDS
 FR bnd       x       
 FR bnd       fx      
 FX bnd       constobj                        0
SOS
 S2 s1
    w(1)                            1
    w(2)                            2
    w(3)                            3
ENDATA
$offEcho

$onEcho > %gams.scrdir%sos2a.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'wsum', 
'xdef', 
'fxdef', 
'defwLo', 
'gapplus', 
'gapminus' /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows /
'wsum', 
'xdef', 
'fxdef' /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows /
'defwLo', 
'gapplus', 
'gapminus' /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'w(1)', 
'w(2)', 
'w(3)', 
'fplus', 
'fminus', 
'x', 
'fx', 
'constobj' /;

Set s(*) SOS sets /
's1' /;

Set jc(*) continuous columns /
'fplus', 
'fminus', 
'x', 
'fx', 
'constobj' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns /
's1'.'w(1)', 
's1'.'w(2)', 
's1'.'w(3)' /;

Set js(*,*) SOS mapping /
'w(1)'.'s1', 
'w(2)'.'s1', 
'w(3)'.'s1' /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'fplus' 1, 
'fminus' 1, 
'constobj' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'xdef'.'x' 1, 
'fxdef'.'fx' 1, 
'gapplus'.'fplus' 1, 
'gapplus'.'fx' -1, 
'gapminus'.'fminus' 1, 
'gapminus'.'fx' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 /
'wsum'.'s1'.'w(1)' -1, 
'wsum'.'s1'.'w(2)' -1, 
'wsum'.'s1'.'w(3)' -1, 
'xdef'.'s1'.'w(1)' -1, 
'xdef'.'s1'.'w(2)' -2, 
'xdef'.'s1'.'w(3)' -3, 
'fxdef'.'s1'.'w(1)' -1, 
'fxdef'.'s1'.'w(2)' -2, 
'fxdef'.'s1'.'w(3)' -3, 
'defwLo'.'s1'.'w(1)' 1 /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS /
'wsum' -1, 
'defwLo' 0.8, 
'gapplus' -1.3, 
'gapminus' 1.3 /;

positive Variable xc(*) continuous variables /
'x'.LO -Inf, 
'fx'.LO -Inf, 
'constobj'.UP 0 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 6, 
'set_ig' 3, 
'set_ie' 3, 
'set_j' 8, 
'set_s' 1, 
'set_jc' 5, 
'set_js2' 3, 
'par_c' 3, 
'par_b' 4, 
'par_ac' 6, 
'par_as2' 10 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%sos2a.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%sos2a.gdx" > "%gams.scrdir%sos2a.gdx.got"
$call =diff -b "%gams.scrdir%sos2a.gdx.want" "%gams.scrdir%sos2a.gdx.got"
$call =rm "%gams.scrdir%sos2a.mps" "%gams.scrdir%sos2a.gms" "%gams.scrdir%sos2a.gdx"
$call =rm "%gams.scrdir%sos2a.gdx.got" "%gams.scrdir%sos2a.gdx.want"

* ============================================================ sos2a_xpr

$onEcho > %gams.scrdir%sos2a_xpr.mps
* Names escaped using: @
NAME          m
ROWS
 N  __OBJ___
 E  R1      
 E  R2      
 E  R3      
 G  R4      
 G  R5      
 G  R6      
COLUMNS
    C1        R1        -1
    C1        R2        -1
    C1        R3        -1
    C1        R4        1
    C2        R1        -1
    C2        R2        -2
    C2        R3        -2
    C3        R1        -1
    C3        R2        -3
    C3        R3        -3
    C4        __OBJ___  1
    C4        R5        1
    C5        __OBJ___  1
    C5        R6        1
    C6        R2        1
    C7        R3        1
    C7        R5        -1
    C7        R6        1
SETS
 S2 @_01    
    @_01      C1        1
    @_01      C2        2
    @_01      C3        3
RHS
    RHS00001  R1        -1
    RHS00001  R4        0.8
    RHS00001  R5        -1.3
    RHS00001  R6        1.3
BOUNDS
 FR BND00001  C6      
 FR BND00001  C7      
ENDATA
$offEcho

$onEcho > %gams.scrdir%sos2a_xpr.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'R1', 
'R2', 
'R3', 
'R4', 
'R5', 
'R6' /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows /
'R1', 
'R2', 
'R3' /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows /
'R4', 
'R5', 
'R6' /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'C1', 
'C2', 
'C3', 
'C4', 
'C5', 
'C6', 
'C7' /;

Set s(*) SOS sets /
'@_01' /;

Set jc(*) continuous columns /
'C4', 
'C5', 
'C6', 
'C7' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns /
'@_01'.'C1', 
'@_01'.'C2', 
'@_01'.'C3' /;

Set js(*,*) SOS mapping /
'C1'.'@_01', 
'C2'.'@_01', 
'C3'.'@_01' /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'C4' 1, 
'C5' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'R2'.'C6' 1, 
'R3'.'C7' 1, 
'R5'.'C4' 1, 
'R5'.'C7' -1, 
'R6'.'C5' 1, 
'R6'.'C7' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 /
'R1'.'@_01'.'C1' -1, 
'R1'.'@_01'.'C2' -1, 
'R1'.'@_01'.'C3' -1, 
'R2'.'@_01'.'C1' -1, 
'R2'.'@_01'.'C2' -2, 
'R2'.'@_01'.'C3' -3, 
'R3'.'@_01'.'C1' -1, 
'R3'.'@_01'.'C2' -2, 
'R3'.'@_01'.'C3' -3, 
'R4'.'@_01'.'C1' 1 /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS /
'R1' -1, 
'R4' 0.8, 
'R5' -1.3, 
'R6' 1.3 /;

positive Variable xc(*) continuous variables /
'C6'.LO -Inf, 
'C7'.LO -Inf /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 6, 
'set_ig' 3, 
'set_ie' 3, 
'set_j' 7, 
'set_s' 1, 
'set_jc' 4, 
'set_js2' 3, 
'par_c' 2, 
'par_b' 4, 
'par_ac' 6, 
'par_as2' 10 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%sos2a_xpr.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%sos2a_xpr.gdx" > "%gams.scrdir%sos2a_xpr.gdx.got"
$call =diff -b "%gams.scrdir%sos2a_xpr.gdx.want" "%gams.scrdir%sos2a_xpr.gdx.got"
$call =rm "%gams.scrdir%sos2a_xpr.mps" "%gams.scrdir%sos2a_xpr.gms" "%gams.scrdir%sos2a_xpr.gdx"
$call =rm "%gams.scrdir%sos2a_xpr.gdx.got" "%gams.scrdir%sos2a_xpr.gdx.want"

* ================================================================= cqo1

$onEcho > %gams.scrdir%cqo1.mps
NAME          CQO1 EXAMPLE
OBJSENSE
    MIN
ROWS
 N  obj
 E  c1      
COLUMNS
    x1        obj       0.0
    x1        c1        1.0
    x2        obj       0.0
    x2        c1        1.0
    x3        obj       0.0
    x3        c1        2.0
    x4        obj       1.0
    x5        obj       1.0
    x6        obj       1.0
RHS
    rhs       c1        1.0
BOUNDS
 FR bound     x4      
 FR bound     x5      
 FR bound     x6      
CSECTION      k1        0.0            QUAD
    x4      
    x1      
    x2      
CSECTION      k2        0.0            RQUAD
    x5      
    x6      
    x3      
ENDATA
$offEcho

$onEcho > %gams.scrdir%cqo1.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'c1', 
'k1', 
'k2' /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows /
'c1' /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows /
'k1', 
'k2' /;

Set j(*) all columns in MPS order /
'x1', 
'x2', 
'x3', 
'x4', 
'x5', 
'x6' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2', 
'x3', 
'x4', 
'x5', 
'x6' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
'x4' 1, 
'x5' 1, 
'x6' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'c1'.'x1' 1, 
'c1'.'x2' 1, 
'c1'.'x3' 2, 
'k1'.'x1' -1, 
'k1'.'x2' -1, 
'k1'.'x4' 1, 
'k2'.'x3' -1, 
'k2'.'x5' 1, 
'k2'.'x6' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS /
'c1' 1 /;

positive Variable xc(*) continuous variables /
'x4'.LO -Inf, 
'x5'.LO -Inf, 
'x6'.LO -Inf /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 3, 
'set_ie' 1, 
'set_ik' 2, 
'set_j' 6, 
'set_jc' 6, 
'par_c' 3, 
'par_b' 1, 
'par_ac' 9 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%cqo1.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%cqo1.gdx" > "%gams.scrdir%cqo1.gdx.got"
$call =diff -b "%gams.scrdir%cqo1.gdx.want" "%gams.scrdir%cqo1.gdx.got"
$call =rm "%gams.scrdir%cqo1.mps" "%gams.scrdir%cqo1.gms" "%gams.scrdir%cqo1.gdx"
$call =rm "%gams.scrdir%cqo1.gdx.got" "%gams.scrdir%cqo1.gdx.want"

* =============================================================== ranges

$onEcho > %gams.scrdir%ranges.mps
NAME
OBJSENSE
 MAX
ROWS
 N  R0      
 G  con1    
COLUMNS
    x         R0         1.000000000   con1      1.0000000000
    y         R0         1.000000000   con1      1.0000000000
RHS
    RHS       R0        -42.00000000   con1      1.0000000000
RANGES
    RGS       con1      1.0000000000
ENDATA
$offEcho

$onEcho > %gams.scrdir%ranges.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order /
'con1' /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows /
'con1' /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x', 
'y' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x', 
'y' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 42 /;

Parameter c(*) objective row /
'x' 1, 
'y' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'con1'.'x' 1, 
'con1'.'y' 1 /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective / /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables / /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable /
'con1'.LO 1, 
'con1'.UP 2 /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 1, 
'set_ir' 1, 
'set_j' 2, 
'set_jc' 2, 
'par_c' 2, 
'par_ac' 2 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%ranges.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%ranges.gdx" > "%gams.scrdir%ranges.gdx.got"
$call =diff -b "%gams.scrdir%ranges.gdx.want" "%gams.scrdir%ranges.gdx.got"
$call =rm "%gams.scrdir%ranges.mps" "%gams.scrdir%ranges.gms" "%gams.scrdir%ranges.gdx"
$call =rm "%gams.scrdir%ranges.gdx.got" "%gams.scrdir%ranges.gdx.want"

* ============================================================== latecol

* column that appears in BOUNDS but not in COLUMNS section
$onEcho > %gams.scrdir%latecol.mps
NAME Convert
OBJSENSE
 MAX
ROWS
 N obj
COLUMNS
RHS
BOUNDS
 LO bnd x1 0
 UP bnd x1 2
 LO bnd x2 0
 UP bnd x2 4
QMATRIX
 x1 x1 2
 x1 x2 2
 x2 x1 2
 x2 x2 2
ENDATA
$offEcho

* column that does not appear in COLUMN section
$onEcho > %gams.scrdir%latecol.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order / /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row / /;

Parameter ac(*,*) constraint matrix: continuous columns / /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective /
' xc'.'x1'.' xc'.'x1' 2, 
' xc'.'x2'.' xc'.'x1' 4, 
' xc'.'x2'.' xc'.'x2' 2 /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2, 
'x2'.UP 4 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_j' 2, 
'set_jc' 2 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%latecol.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%latecol.gdx" > "%gams.scrdir%latecol.gdx.got"
$call =diff -b "%gams.scrdir%latecol.gdx.want" "%gams.scrdir%latecol.gdx.got"
$call =rm "%gams.scrdir%latecol.mps" "%gams.scrdir%latecol.gms" "%gams.scrdir%latecol.gdx"
$call =rm "%gams.scrdir%latecol.gdx.got" "%gams.scrdir%latecol.gdx.want"

* ============================================================= latecol2

* column that appears in QMATRIX but not in COLUMNS section
$onEcho > %gams.scrdir%latecol2.mps
NAME Convert
OBJSENSE
 MAX
ROWS
 N obj
COLUMNS
RHS
BOUNDS
 LO bnd x1 0
 UP bnd x1 2
QMATRIX
 x1 x1 2
 x1 x2 2
 x2 x1 -2
 x2 x2 -2
ENDATA
$offEcho

$onEcho > %gams.scrdir%latecol2.gdx.want
$onEmpty

Set mps2gms(*) important cardinal values /
'set_i' 'all rows in MPS order', 
'set_ig' 'greater-than-or equal rows', 
'set_il' 'less-than-or equal rows', 
'set_ie' 'equality rows', 
'set_ir' 'ranged rows', 
'set_ik' 'cone rows', 
'set_j' 'all columns in MPS order', 
'set_s' 'sos sets', 
'set_jc' 'continuous columns', 
'set_jb' 'binary columns', 
'set_ji' 'integer columns', 
'set_jsc' 'semi-continuous columns', 
'set_jsi' 'semi-integer columns', 
'set_js1' 'sos 1 columns', 
'set_js2' 'sos 2 columns', 
'par_c' 'objective coefs', 
'par_b' 'right hand sides', 
'par_ac' 'matrix coefs: continuous columns', 
'par_ab' 'matrix coefs: binary columns', 
'par_ai' 'matrix coefs: integer columns', 
'par_asc' 'matrix coefs: semi-continuous columns', 
'par_asi' 'matrix coefs: semi-integer columns', 
'par_as1' 'matrix coefs: sos 1 columns', 
'par_as2' 'matrix coefs: sos 2 columns' /;

Set e(*) gams equ labels /
' eg' eg, 
' el' el, 
' ee' ee, 
' er' er /;

Set v(*) gams var labels /
' xc' xc, 
' xb' xb, 
' xi' xi, 
' xsc' xsc, 
' xsi' xsi, 
' xs1' xs1, 
' xs2' xs2 /;

Set i(*) all rows in MPS order / /;

Set ei(*,*) equ type mapping / /;

Set ie(*) equality rows / /;

Set il(*) less-than-or equal rows / /;

Set ig(*) greater-than-or equal rows / /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x1', 
'x2' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x1', 
'x2' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns / /;

Set jsc(*) semi-continuous columns / /;

Set jsi(*) semi-integer columns / /;

Set js1(*,*) sos 1 columns / /;

Set js2(*,*) sos 2 columns / /;

Set js(*,*) SOS mapping / /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row / /;

Parameter ac(*,*) constraint matrix: continuous columns / /;

Parameter ab(*,*) constraint matrix: binary columns / /;

Parameter ai(*,*) constraint matrix: integer columns / /;

Parameter asc(*,*) constraint matrix: semi-continuous columns / /;

Parameter asi(*,*) constraint matrix: semi-integer columns / /;

Parameter as1(*,*,*) constraint matrix: Sos 1 / /;

Parameter as2(*,*,*) constraint matrix: Sos 2 / /;

Parameter qobj(*,*,*,*) Q matrix for objective /
' xc'.'x1'.' xc'.'x1' 2, 
' xc'.'x2'.' xc'.'x1' 4, 
' xc'.'x2'.' xc'.'x2' -2 /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks / /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.UP 2 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables / /;

semiint  Variable xsi(*) semi-integer variables / /;

sos1     Variable xs1(*,*) sos 1 variables / /;

sos2     Variable xs2(*,*) sos 2 variables / /;

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_j' 2, 
'set_jc' 2 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%latecol2.mps" > mps2gms.log
$call gdxdump "%gams.scrdir%latecol2.gdx" > "%gams.scrdir%latecol2.gdx.got"
$call =diff -b "%gams.scrdir%latecol2.gdx.want" "%gams.scrdir%latecol2.gdx.got"
$call =rm "%gams.scrdir%latecol2.mps" "%gams.scrdir%latecol2.gms" "%gams.scrdir%latecol2.gdx"
$call =rm "%gams.scrdir%latecol2.gdx.got" "%gams.scrdir%latecol2.gdx.want"