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 =gzip "%gams.scrdir%qp_qmatrix.mps"
$call mps2gms "%gams.scrdir%qp_qmatrix.mps.gz" > 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.gz" "%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_noc
$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 /
' eg'.'k1', 
' eg'.'k2' /;

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

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

Set ig(*) greater-than-or equal rows /
'k1', 
'k2' /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

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 /;

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 /
' eg'.'k1'.' xc'.'x1'.' xc'.'x1' -2, 
' eg'.'k1'.' xc'.'x2'.' xc'.'x2' -2, 
' eg'.'k1'.' xc'.'x4'.' xc'.'x4' 2, 
' eg'.'k2'.' xc'.'x3'.' xc'.'x3' -2, 
' eg'.'k2'.' xc'.'x5'.' xc'.'x6' 4 /;

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

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 / /;

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

$offEmpty
$offEcho

$onEcho > %gams.scrdir%cqo1.gdx.want_withc
$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_noc"
$call mps2gms "%gams.scrdir%cqo1.mps" cequations=Y > mps2gms.log
$call gdxdump "%gams.scrdir%cqo1.gdx" > "%gams.scrdir%cqo1.gdx.got_withc"
$call =diff -b "%gams.scrdir%cqo1.gdx.want_noc" "%gams.scrdir%cqo1.gdx.got_noc"
$call =diff -b "%gams.scrdir%cqo1.gdx.want_withc" "%gams.scrdir%cqo1.gdx.got_withc"
$call =rm "%gams.scrdir%cqo1.mps" "%gams.scrdir%cqo1.gms" "%gams.scrdir%cqo1.gdx"
$call =rm "%gams.scrdir%cqo1.gdx.got_noc" "%gams.scrdir%cqo1.gdx.want_noc"
$call =rm "%gams.scrdir%cqo1.gdx.got_withc" "%gams.scrdir%cqo1.gdx.want_withc"

* =============================================================== 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"


* ================================================================ qp.lp

$onEcho > %gams.scrdir%qp.lp
Maximize
 obj: x2 + x3 + [2 x2^2 + 4 x2 * x3 + 2 x3^2]/2

Bounds
 0 <= x2 <= 2
 0 <= x3 <= 4

End
$offEcho

$onEcho > %gams.scrdir%qp.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 /
'x2', 
'x3' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'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 /
'x2' 1, 
'x3' 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'.'x2'.' xc'.'x2' 2, 
' xc'.'x2'.' xc'.'x3' 4, 
' xc'.'x3'.' xc'.'x3' 2 /;

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

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x2'.UP 2, 
'x3'.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

$onEcho > %gams.scrdir%qcp.lp
Maximize
 obj: x1
 
Subject To
 e1: -x1 + x2 + x3 + [x2^2 + 2 x2 * x3 + x3^2] = 0

Bounds
 x1 Free
 0 <= x2 <= 2
 0 <= x3 <= 4

End
$offEcho

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

* =============================================================== qcp.lp

$onEcho > %gams.scrdir%qcp.lp
Maximize
 obj: x1
 
Subject To
 e1: -x1 + x2 + x3 + [x2^2 + 2 x2 * x3 + x3^2] = 0

Bounds
 x1 Free
 0 <= x2 <= 2
 0 <= x3 <= 4

End
$offEcho

$onEcho > %gams.scrdir%qcp.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 /
'x1' 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'.'x2'.' xc'.'x2' 2, 
' ee'.'e1'.' xc'.'x2'.' xc'.'x3' 4, 
' ee'.'e1'.' xc'.'x3'.' xc'.'x3' 2 /;

Parameter b(*) mps file RHS / /;

positive Variable xc(*) continuous variables /
'x1'.LO -Inf, 
'x2'.UP 2, 
'x3'.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_i' 1, 
'set_ie' 1, 
'set_j' 3, 
'set_jc' 3, 
'par_c' 1, 
'par_ac' 3 /;

$offEmpty
$offEcho

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

* ============================================================= sos1a.lp

$onEcho > %gams.scrdir%sos1a.lp
\ Problem name     : sos1a
Maximize
 Obj: +0.9 s1 +1 s2 +1.1 s3
Subject to
 e2: +1 s1 +1 s2 +1 s3 <= +1
Bounds
 0 <= s1 <= 0.8
 0 <= s2 <= 0.6
 0 <= s3 <= 0.6
SOS
 sos1_1: S1:: s1:1 s2:2 s3:3
End
$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 /
'e2' /;

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

Set ie(*) equality rows / /;

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

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

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
's1', 
's2', 
's3' /;

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

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 /
'sos1_1'.'s1', 
'sos1_1'.'s2', 
'sos1_1'.'s3' /;

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

Set js(*,*) SOS mapping /
's1'.'sos1_1', 
's2'.'sos1_1', 
's3'.'sos1_1' /;

Scalar cobj objective constant / 0 /;

Parameter c(*) objective row /
's1' 0.9, 
's2' 1, 
's3' 1.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 /
'e2'.'sos1_1'.'s1' 1, 
'e2'.'sos1_1'.'s2' 1, 
'e2'.'sos1_1'.'s3' 1 /;

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

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

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

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

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 /
'sos1_1'.'s1'.UP 0.8, 
'sos1_1'.'s2'.UP 0.6, 
'sos1_1'.'s3'.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' 3, 
'set_s' 1, 
'set_js1' 3, 
'par_c' 3, 
'par_b' 1, 
'par_as1' 3 /;

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%sos1a.lp" > 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.lp" "%gams.scrdir%sos1a.gms" "%gams.scrdir%sos1a.gdx"
$call =rm "%gams.scrdir%sos1a.gdx.got" "%gams.scrdir%sos1a.gdx.want"

* ============================================================= sos2a.lp

$onEcho > %gams.scrdir%sos2a.lp
Minimize
 Obj: +1 x4 +1 x5
Subject to
 e1: +1 s1 +1 s2 +1 s3 = +1
 e2: +1 s1 +2 s2 +3 s3 -1 x7 = +0
 e3: +1 s1 +2 s2 +3 s3 -1 x8 = +0
 e6: +1 x4 -1 x8 >= -1.3
 e7: +1 x5 +1 x8 >= +1.3
Bounds
 0.8 <= s1
 x7 free
 x8 free
SOS
 sos2_1: S2:: s1:1 s2:2 s3:3
End
$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 /
'e1', 
'e2', 
'e3', 
'e6', 
'e7' /;

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

Set ie(*) equality rows /
'e1', 
'e2', 
'e3' /;

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

Set ig(*) greater-than-or equal rows /
'e6', 
'e7' /;

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x4', 
'x5', 
's1', 
's2', 
's3', 
'x7', 
'x8' /;

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

Set jc(*) continuous columns /
'x4', 
'x5', 
'x7', 
'x8' /;

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 /
'sos2_1'.'s1', 
'sos2_1'.'s2', 
'sos2_1'.'s3' /;

Set js(*,*) SOS mapping /
's1'.'sos2_1', 
's2'.'sos2_1', 
's3'.'sos2_1' /;

Scalar cobj objective constant / 0 /;

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

Parameter ac(*,*) constraint matrix: continuous columns /
'e2'.'x7' -1, 
'e3'.'x8' -1, 
'e6'.'x4' 1, 
'e6'.'x8' -1, 
'e7'.'x5' 1, 
'e7'.'x8' 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 /
'e1'.'sos2_1'.'s1' 1, 
'e1'.'sos2_1'.'s2' 1, 
'e1'.'sos2_1'.'s3' 1, 
'e2'.'sos2_1'.'s1' 1, 
'e2'.'sos2_1'.'s2' 2, 
'e2'.'sos2_1'.'s3' 3, 
'e3'.'sos2_1'.'s1' 1, 
'e3'.'sos2_1'.'s2' 2, 
'e3'.'sos2_1'.'s3' 3 /;

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

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

Parameter b(*) mps file RHS /
'e1' 1, 
'e6' -1.3, 
'e7' 1.3 /;

positive Variable xc(*) continuous variables /
'x7'.LO -Inf, 
'x8'.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 /
'sos2_1'.'s1'.LO 0.8 /;

Variable r(*) range variable / /;

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

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%sos2a.lp" > 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.lp" "%gams.scrdir%sos2a.gms" "%gams.scrdir%sos2a.gdx"
$call =rm "%gams.scrdir%sos2a.gdx.got" "%gams.scrdir%sos2a.gdx.want"

* ========================================================== vartypes.lp

$onEcho > %gams.scrdir%vartypes.lp
Min Obj: x1 + 2 x2 + 3 x3 + 4 x4
Subject to x1 + x2 <= 1
Bounds
  x3 >= 3
  x4 >= 4
Bin
  x1
Gen
  x2
  x4
Semis
  x3
  x4
End
$offEcho

$onEcho > %gams.scrdir%vartypes.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', 
'x3', 
'x4' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns / /;

Set jb(*) binary columns /
'x1' /;

Set ji(*) integer columns /
'x2' /;

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

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

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' 2, 
'x3' 3, 
'x4' 4 /;

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

Parameter ab(*,*) constraint matrix: binary columns /
''.'x1' 1 /;

Parameter ai(*,*) constraint matrix: integer columns /
''.'x2' 1 /;

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 /
'' 1 /;

positive Variable xc(*) continuous variables / /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables / /;

semicont Variable xsc(*) semi-continuous variables /
'x3'.LO 3 /;

semiint  Variable xsi(*) semi-integer variables /
'x4'.LO 4 /;

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

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

Variable r(*) range variable / /;

Parameter mps2gmsstats(*) MPS2GMS statistics /
'set_i' 1, 
'set_il' 1, 
'set_j' 4, 
'set_jb' 1, 
'set_ji' 1, 
'set_jsc' 1, 
'set_jsi' 1, 
'par_c' 4, 
'par_b' 1, 
'par_ab' 1, 
'par_ai' 1 /;

$offEmpty
$offEcho

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

* ======================================================== duplicates.lp

$onEcho > %gams.scrdir%duplicates.lp
Minimize
  obj: x1 + x2 + x1 + [ x1*x2 + x2^2 + x2^2 ]/2

Subject To
  e1: x1 + x2 - x1 = 0
  e2: [ x2*x3 - x2*x3 ] = 0

End
$offEcho

$onEcho > %gams.scrdir%duplicates.gdx.want_add
$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', 
'e2' /;

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

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

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 /
'x1' 2, 
'x2' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'e1'.'x2' 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 /
' xc'.'x1'.' xc'.'x2' 1, 
' xc'.'x2'.' xc'.'x2' 2 /;

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 / /;

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

$offEmpty
$offEcho

$onEcho > %gams.scrdir%duplicates.gdx.want_ignore
$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', 
'e2' /;

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

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

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 /
'x1' 1, 
'x2' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'e1'.'x1' 1, 
'e1'.'x2' 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 /
' xc'.'x1'.' xc'.'x2' 1, 
' xc'.'x2'.' xc'.'x2' 1 /;

Parameter q(*,*,*,*,*,*) Q matrix for blocks /
' ee'.'e2'.' xc'.'x2'.' xc'.'x3' 2 /;

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 / /;

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

$offEmpty
$offEcho

$call mps2gms "%gams.scrdir%duplicates.lp" DUPLICATES=ADD > mps2gms.log
$call gdxdump "%gams.scrdir%duplicates.gdx" > "%gams.scrdir%duplicates.gdx.got"
$call =diff -b "%gams.scrdir%duplicates.gdx.want_add" "%gams.scrdir%duplicates.gdx.got"

$call mps2gms "%gams.scrdir%duplicates.lp" Duplicates=Ignore > mps2gms.log
$call gdxdump "%gams.scrdir%duplicates.gdx" > "%gams.scrdir%duplicates.gdx.got"
$call =diff -b "%gams.scrdir%duplicates.gdx.want_ignore" "%gams.scrdir%duplicates.gdx.got"

$offCheckErrorLevel

$call mps2gms "%gams.scrdir%duplicates.lp" > mps2gms.log 2>&1
$if not errorlevel 1 $abort mps2gms did not abort as expected

$call mps2gms "%gams.scrdir%duplicates.lp" duplicates=error > mps2gms.log 2>&1
$if not errorlevel 1 $abort mps2gms did not abort as expected
$call grep -q Multiple mps2gms.log
$if errorlevel 1 $abort mps2gms did not print expected error messages

$call =rm "%gams.scrdir%duplicates.lp" "%gams.scrdir%duplicates.gms" "%gams.scrdir%duplicates.gdx"
$call =rm "%gams.scrdir%duplicates.gdx.got" "%gams.scrdir%duplicates.gdx.want_add" "%gams.scrdir%duplicates.gdx.want_ignore"

$onCheckErrorLevel


* ======================================================== longnameclash.lp

$onEcho > %gams.scrdir%longnameclash.lp
Maximize
 obj: x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_A + 2 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_B + 3 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_C + x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_D
Subject To
 c1: - x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_A + x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_B + x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_C + 10 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_D <= 20
 c2: x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_A - 3 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_B + x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_C <= 30
 c3: x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_B - 3.5 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_D = 0
Bounds
 0 <= x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_A <= 40
 2 <= x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_D <= 3
General
 x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_variable_names_D
End
$offEcho

$onEcho > %gams.scrdir%longnameclash.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', 
'c2', 
'c3' /;

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

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

Set il(*) less-than-or equal rows /
'c1', 
'c2' /;

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

Set ir(*) ranged rows / /;

Set ik(*) cone rows / /;

Set j(*) all columns in MPS order /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v', 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1', 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~2', 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3' /;

Set s(*) SOS sets / /;

Set jc(*) continuous columns /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v', 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1', 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~2' /;

Set jb(*) binary columns / /;

Set ji(*) integer columns /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3' /;

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 /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v' 1, 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1' 2, 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~2' 3, 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3' 1 /;

Parameter ac(*,*) constraint matrix: continuous columns /
'c1'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v' -1, 
'c1'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1' 1, 
'c1'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~2' 1, 
'c2'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v' 1, 
'c2'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1' -3, 
'c2'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~2' 1, 
'c3'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~1' 1 /;

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

Parameter ai(*,*) constraint matrix: integer columns /
'c1'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3' 10, 
'c3'.'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3' -3.5 /;

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' 20, 
'c2' 30 /;

positive Variable xc(*) continuous variables /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for_v'.UP 40 /;

binary   Variable xb(*) binary variables / /;

integer  Variable xi(*) integer variables /
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3'.LO 2, 
'x_very_long_variable_name_which_exeeds_the_maximum_lenght_for~3'.UP 3 /;

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_il' 2, 
'set_ie' 1, 
'set_j' 4, 
'set_jc' 3, 
'set_ji' 1, 
'par_c' 4, 
'par_b' 2, 
'par_ac' 7, 
'par_ai' 2 /;

$offEmpty
$offEcho

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