trnspwl.gms : A Transportation Problem with discretized economies of scale
This problem finds a least cost shipping schedule that meets
requirements at markets and supplies at factories. This instance
applies economies of scale which results in a non-convex
objective. This is an extension of the trnsport model in the GAMS
Model Library.
The original nonlinear term is "sum((i,j), c(i,j)*sqrt(x(i,j)))". We
use the following discretization f(x) of sqrt(x)
For x<=50: f(x) = 1/sqrt(50)*x,
for x>=400: f(x) = (sqrt(600)-sqrt(400))/200*(x-400) + sqrt(400)
in between we discretize with linear interpolation between points
This discretization has some good properties:
0) f(x) is a continuous function
1) f(0)=0, otherwise we would pick up a fixed cost even for unused connections
2) a fine representation in the reasonable range of shipments (between 50 and 400)
3) f(x) underestimates sqrt in the area of x=0 to 600. Past that is overestimates sqrt.
The model is organized as follows:
1) We set a starting point for the NLP solver so it will get stuck
in local optimum that is not the global optimum.
2) We use three formulations for representing piecewise linear
functions all based on the same discretization.
a) a formulation with SOS2 variables. This formulation mainly is
based on the convex combination of neighboring
points. Moreover, the domain of the discretization can be
unbounded: we can assign a slope in the (potentially
unbounded) first and last segment.
b) a formulation with SOS2 variables based on convex combinations
of neighboring points. This formulation requires a bounded
region for the discretization. Here we discretize between 0 and
600.
c) a formuation with binary variables. This also requires the
domain to be bounded, but it does not rely on the convex
combination of neighboring points. There are examples, where
this formulation solves much faster than the formulation b).
In this example x is clearly bounded by 0 from below and
min(smax(i,a(i),smax(j,b(j)) from above, so formulation b and c
are sufficient and perform better on this particular model and
instance. We added the formulation a to demonstrate how to model
an unbounded discretization, in case there are no derived
bounds. The formulation a can be easily adjusted to accommodate
problems where only one end of the discretization is unbounded.
3) We restart the non-convex NLP from the solution of the discretized
model and hope that the NLP solver finds the global solution.
Reference:
- Dantzig, G B, Chapter 3.3. In Linear Programming and Extensions. Princeton University Press, Princeton, New Jersey, 1963.
Small Model of Type: MIP
$Title A Transportation Problem with discretized economies of scale (TRNSPWL,SEQ=351)
$Ontext
This problem finds a least cost shipping schedule that meets
requirements at markets and supplies at factories. This instance
applies economies of scale which results in a non-convex
objective. This is an extension of the trnsport model in the GAMS
Model Library.
The original nonlinear term is "sum((i,j), c(i,j)*sqrt(x(i,j)))". We
use the following discretization f(x) of sqrt(x)
For x<=50: f(x) = 1/sqrt(50)*x,
for x>=400: f(x) = (sqrt(600)-sqrt(400))/200*(x-400) + sqrt(400)
in between we discretize with linear interpolation between points
This discretization has some good properties:
0) f(x) is a continuous function
1) f(0)=0, otherwise we would pick up a fixed cost even for unused connections
2) a fine representation in the reasonable range of shipments (between 50 and 400)
3) f(x) underestimates sqrt in the area of x=0 to 600. Past that is overestimates sqrt.
The model is organized as follows:
1) We set a starting point for the NLP solver so it will get stuck
in local optimum that is not the global optimum.
2) We use three formulations for representing piecewise linear
functions all based on the same discretization.
a) a formulation with SOS2 variables. This formulation mainly is
based on the convex combination of neighboring
points. Moreover, the domain of the discretization can be
unbounded: we can assign a slope in the (potentially
unbounded) first and last segment.
b) a formulation with SOS2 variables based on convex combinations
of neighboring points. This formulation requires a bounded
region for the discretization. Here we discretize between 0 and
600.
c) a formuation with binary variables. This also requires the
domain to be bounded, but it does not rely on the convex
combination of neighboring points. There are examples, where
this formulation solves much faster than the formulation b).
In this example x is clearly bounded by 0 from below and
min(smax(i,a(i),smax(j,b(j)) from above, so formulation b and c
are sufficient and perform better on this particular model and
instance. We added the formulation a to demonstrate how to model
an unbounded discretization, in case there are no derived
bounds. The formulation a can be easily adjusted to accommodate
problems where only one end of the discretization is unbounded.
3) We restart the non-convex NLP from the solution of the discretized
model and hope that the NLP solver finds the global solution.
Dantzig, G B, Chapter 3.3. In Linear Programming and Extensions.
Princeton University Press, Princeton, New Jersey, 1963.
$Offtext
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 ;
Variables
x(i,j) shipment quantities in cases
z total transportation costs in thousands of dollars ;
Positive Variable x ;
Equations
cost define objective function with economies of scale
supply(i) observe supply limit at plant i
demand(j) satisfy demand at market j ;
cost .. z =e= sum((i,j), c(i,j)*sqrt(x(i,j))) ;
supply(i) .. sum(j, x(i,j)) =l= a(i) ;
demand(j) .. sum(i, x(i,j)) =g= b(j) ;
Model transport /all/ ;
* Start the local NLP solver in a local solution that is not globally optimal
x.l('seattle ','chicago ') = 25;
x.l('seattle ','topeka ') = 275;
x.l('san-diego','new-york') = 325;
x.l('san-diego','chicago ') = 275;
Scalar localopt objective of local optimum that is not globally optimal;
option nlp=conopt;
Solve transport using nlp minimizing z ;
localopt = z.l;
* The first model (formulation a) implements a piecewise linear
* approximation based on the convex combination of neighboring points
* using SOS2 variables with unbounded segments at the beginning and
* end of the discretization
Set s SOS2 elements / slope0,s1*s6,slopeN /
ss(s) sample points / s1*s6 /
Parameter
p(s) x coordinate of sample point
sqrtp(s) y coordinate of sample point
xlow / 50 /, xhigh / 400 /, xmax;
xmax = smax(i, a(i));
abort$(xmax 1e-6) 'we should get an improved solution'