indic04.gms : Test of indicator constraints with explicit labels

Description

```Test indicator constraints where indicators are specified indexed
equations and variables using explicit labels.

This is the second model from the Fixed Charge Transportation Problem from
https://www.gams.com/latest/docs/UG_LanguageFeatures.html#UG_LanguageFeatures_IndicatorConstraintsExample

Contributed by Stefan Vigerske, August 2014
```

Large Model of Type : MIP

Category : GAMS Test library

Main file : indic04.gms

``````\$title Test of indicator constraints with explicit labels (INDIC04,SEQ=663)

\$ontext
Test indicator constraints where indicators are specified indexed
equations and variables using explicit labels.

This is the second model from the Fixed Charge Transportation Problem from
https://www.gams.com/latest/docs/UG_LanguageFeatures.html#UG_LanguageFeatures_IndicatorConstraintsExample

Contributed by Stefan Vigerske, August 2014
\$offtext

\$Title  Fixed Charge Transportation Problem with Indicator Constraints

Sets
i   canning plants   / seattle, san-diego /
j   markets          / new-york, chicago, topeka / ;

Parameters

a(i)  capacity of plant i in cases
/    seattle     350
san-diego   600  /

b(j)  demand at market j in cases
/    new-york    325
chicago     300
topeka      275  / ;

Table d(i,j)  distance in thousands of miles
new-york       chicago      topeka
seattle          2.5           1.7          1.8
san-diego        2.5           1.8          1.4  ;

Scalar f  freight in dollars per case per thousand miles  /90/ ;

Parameter c(i,j)  transport cost in thousands of dollars per case ;

c(i,j) = f * d(i,j) / 1000 ;

Parameter fixcost(i,j)  fixed cost in thousands of dollars ;

fixcost(i,j) = 10*d(i,j) / 1000 ;

Scalar minshipping minimum shipping of cases /100/;

Variables
x(i,j)   shipment quantities in cases
use(i,j) is 1 if arc is used in solution
z        total transportation costs in thousands of dollars ;

Positive Variable x;
Binary   Variable use;

Equations
cost          define objective function
supply(i)     observe supply limit at plant i
demand(j)     satisfy demand at market j
iminship(i,j) ensure minimum shipping
imaxship(i,j) ensure zero shipping if use variable is 0;

cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j) + fixcost(i,j)*use(i,j)) ;

supply(i) ..   sum(j, x(i,j))  =l=  a(i) ;

demand(j) ..   sum(i, x(i,j))  =g=  b(j) ;

iminship(i,j).. x(i,j) =g= minshipping;

imaxship(i,j).. x(i,j) =e= 0;

Model indicatorModel /all/ ;

* write indicator options file for CPLEX
file fcpx Cplex Option file / cplex.opt /;
loop((i,j),
put fcpx 'indic ' iminship.tn(i,j) '\$' use.tn(i,j) yes
/ 'indic ' imaxship.tn(i,j) '\$' use.tn(i,j) no / );
putclose fcpx;

* write indicator options file for GUROBI
file fgrb Gurobi Option file / gurobi.opt /;
loop((i,j),
put fgrb 'indic ' iminship.tn(i,j) '\$' use.tn(i,j) yes
/ 'indic ' imaxship.tn(i,j) '\$' use.tn(i,j) no / );
putclose fgrb;

* write indicator options file for XPRESS
file fxpr Xpress Option file / xpress.opt /;
loop((i,j),
put fxpr 'indic ' iminship.tn(i,j) '\$' use.tn(i,j) yes
/ 'indic ' imaxship.tn(i,j) '\$' use.tn(i,j) no / );
putclose fxpr;

* write indicator options file for SCIP
file fscip SCIP Option file / scip.opt /;
put fscip 'gams/indicatorfile = "cplex.opt"' /;
putclose fscip;

indicatorModel.optfile = 1;
Option limrow=0, limcol=0, optcr=0;
Solve indicatorModel using mip minimizing z ;

abort\$(indicatorModel.modelstat <> %modelstat.optimal%) 'not solved to optimality'
abort\$(abs(z.l - 153.7310) > 1e-6)  'wrong optimal value'
``````