BENDERS DECOMPOSITION WITH GAMS
ERWIN KALVELAGEN
Abstract. This document describes an implementation of Benders Decom-
position using GAMS.
1. Introduction
Benders’ Decomposition[1] is a popular technique in solving certain classes of dif-
ficult problems such as stochastic programming problems[4, 7] and mixed-integer
nonlinear programming problems[3, 2]. In this document we describe how a Ben-
ders’ Decomposition algorithm can be implemented in a GAMS environment.
2. Benders’ Decomposition for MIP Problems
Using the notation in [6] , we can state the MIP problem as:
MIP minimize cT x + f T y
x,y
Ax + By ≥ b
y∈Y
x≥0
If y is fixed to a feasible integer configuration, the resulting model to solve is:
min cT x
x
(1) Ax ≥ b − By
x≥0
The complete minimization problem can therefore be written as:
(2) min f T y + min{cT x|Ax ≥ b − By}
y∈Y x≥0
The dual of the inner LP problem is:
max (b − By)T u
u
(3) AT u ≤ c
u≥0
The Benders’ Decomposition algorithm can be stated as:
{initialization}
y := initial feasible integer solution
LB := −∞
U B := ∞
Date: 20 december 2002.
1
2 ERWIN KALVELAGEN
while U B − LB > do
{solve subproblem}
minu {f T y + (b − By)T u|AT u ≤ c, u ≥ 0}
if Unbounded then
Get unbounded ray u
Add cut (b − By)T u ≤ 0 to master problem
else
Get extreme point u
Add cut z ≥ f T y + (b − By)T u to master problem
U B := min{U B, f T y + (b − By)T u}
end if
{solve master problem}
miny {z|cuts, y ∈ Y }
LB := z
end while
The subproblem is a dual LP problem, and the master problem is a pure IP
problem (no continuous variables are involved). Benders’ Decomposition for MIP
is of special interest when the Benders’ subproblem and the relaxed master problem
are easy to solve, while the original problem is not.
3. The Fixed Charge Transportation Problem
The problem we consider is the Fixed Charge Transportation Problem (FCTP).
The standard transportation problem can be described as:
X
TP minimize ci,j xi,j
x
i,j
X
xi,j = si
j
X
xi,j = dj
i
xi,j ≥ 0
The fixed charge transportation problem adds a fixed cost fi,j to a link i → j.
This can be modeled using extra binary variables yi,j indicating whether a link is
open or closed:
X
FCTP minimize (fi,j yi,j + ci,j xi,j )
x,y
i,j
X
xi,j = si
j
X
xi,j = dj
i
xi,j ≤ Mi,j yi,j
xi,j ≥ 0, yi,j ∈ {0, 1}
where Mi,j are large enough numbers. When solving this as a straight MIP problem,
it is important to assign reasonable values to Mi,j . As Mi,j can be considered as
3
an upper bound on xi,j , we can find good values:
(4) Mi,j = min{si , dj }
When we rewrite the problem as
X X
min ci,j xi,j + fi,j yi,j
x,y
i,j i,j
X
− xi,j ≥ −si
j
X
(5) xi,j ≥ dj
i
− xi,j + Mi,j yi,j ≥ 0
xi,j ≥ 0
yi,j ∈ {0, 1}
we see that the Benders’ subproblem can be stated as:
X X X
max (−si )ui + dj vj + (−Mi,j y i,j )wi,j
u,v,w
i j i,j
(6)
− ui + vj − wi,j ≤ ci,j
ui ≥ 0, vj ≥ 0, wi,j ≥ 0
The Benders’ Relaxed Master Problem can be written as:
min z
y
(k) (k) (k)
X X X X
z≥ fi,j yi,j + (−si )ui + dj v j + (−Mi,j wi,j )yi,j
i,j i j i,j
(7)
(`) (`) (`)
X X X
(−si )ui + dj v j + (−Mi,j wi,j )yi,j ≤0
i j i,j
yi,j ∈ {0, 1}
Using this result the GAMS model can now be formulated as:
1
Model benders.gms.
$ontext
An example of Benders Decomposition on fixed charge transportation
problem bk4x3.
Optimal objective in reference : 350.
Erwin Kalvelagen, December 2002
See:
http://www.in.tu-clausthal.de/~gottlieb/benchmarks/fctp/
$offtext
set i ’sources’ /i1*i4/;
set j ’demands’ /j1*j3/;
parameter supply(i) /
i1 10
i2 30
1http://www.gams.com/~erwin/benders/benders.gms
4 ERWIN KALVELAGEN
i3 40
i4 20
/;
parameter demand(j) /
j1 20
j2 50
j3 30
/;
table c(i,j) ’variable cost’
j1 j2 j3
i1 2.0 3.0 4.0
i2 3.0 2.0 1.0
i3 1.0 4.0 3.0
i4 4.0 5.0 2.0
;
table f(i,j) ’fixed cost’
j1 j2 j3
i1 10.0 30.0 20.0
i2 10.0 30.0 20.0
i3 10.0 30.0 20.0
i4 10.0 30.0 20.0
;
*
* check supply-demand balance
*
scalar totdemand, totsupply;
totdemand = sum(j, demand(j));
totsupply = sum(i, supply(i));
abort$(abs(totdemand-totsupply)>0.001) "Supply does not equal demand.";
*
* for big-M formulation we need tightest possible upperbounds on x
*
parameter xup(i,j) ’tight upperbounds for x(i,j)’;
xup(i,j) = min(supply(i),demand(j));
*--------------------------------------------------------------------
* standard MIP problem formulation
*--------------------------------------------------------------------
variables
cost ’objective variable’
x(i,j) ’shipments’
y(i,j) ’on-off indicator for link’
;
positive variable x;
binary variable y;
equations
obj ’objective’
cap(i) ’capacity constraint’
dem(j) ’demand equation’
xy(i,j) ’y=0 => x=0’
;
obj.. cost =e= sum((i,j), f(i,j)*y(i,j) + c(i,j)*x(i,j));
cap(i).. sum(j, x(i,j)) =l= supply(i);
dem(j).. sum(i, x(i,j)) =g= demand(j);
xy(i,j).. x(i,j) =l= xup(i,j)*y(i,j);
option optcr=0;
model fscp /obj,cap,dem,xy/;
solve fscp minimizing cost using mip;
5
*---------------------------------------------------------------------
* Benders Decomposition Initialization
*---------------------------------------------------------------------
scalar UB ’upperbound’ /INF/;
scalar LB ’lowerbound’ /-INF/;
y.l(i,j) = 1;
*---------------------------------------------------------------------
* Benders Subproblem
*---------------------------------------------------------------------
variable z ’objective variable’;
positive variables
u(i) ’duals for capacity constraint’
v(j) ’duals for demand constraint’
w(i,j) ’duals for xy constraint’
;
equations
subobj ’objective’
subconstr(i,j) ’dual constraint’
;
* to detect unbounded subproblem
scalar unbounded /1.0e6/;
z.up = unbounded;
subobj.. z =e= sum(i, -supply(i)*u(i)) + sum(j, demand(j)*v(j))
+ sum((i,j), -xup(i,j)*y.l(i,j)*w(i,j))
;
subconstr(i,j).. -u(i) + v(j) - w(i,j) =l= c(i,j);
model subproblem /subobj, subconstr/;
*---------------------------------------------------------------------
* Benders Modified Subproblem to find unbounded ray
*---------------------------------------------------------------------
variable dummy ’dummy objective variable’;
equations
modifiedsubobj ’objective’
modifiedsubconstr(i,j) ’dual constraint’
edummy;
;
modifiedsubobj..
sum(i, -supply(i)*u(i)) + sum(j, demand(j)*v(j))
+ sum((i,j), -xup(i,j)*y.l(i,j)*w(i,j)) =e= 1;
modifiedsubconstr(i,j)..
-u(i) + v(j) - w(i,j) =l= 0;
edummy.. dummy =e= 0;
model modifiedsubproblem /modifiedsubobj, modifiedsubconstr, edummy/;
*---------------------------------------------------------------------
* Benders Relaxed Master Problem
*---------------------------------------------------------------------
set iter /iter1*iter50/;
set cutset(iter) ’dynamic set’;
cutset(iter)=no;
6 ERWIN KALVELAGEN
set unbcutset(iter) ’dynamic set’;
unbcutset(iter)=no;
variable z0 ’relaxed master objective variable’;
equations
cut(iter) ’Benders cut for optimal subproblem’
unboundedcut(iter) ’Benders cut for unbounded subproblem’
;
parameters
cutconst(iter) ’constant term in cuts’
cutcoeff(iter,i,j)
;
cut(cutset).. z0 =g= sum((i,j), f(i,j)*y(i,j))
+ cutconst(cutset)
+ sum((i,j), cutcoeff(cutset,i,j)*y(i,j));
unboundedcut(unbcutset)..
cutconst(unbcutset)
+ sum((i,j), cutcoeff(unbcutset,i,j)*y(i,j)) =l= 0;
model master /cut,unboundedcut/;
*---------------------------------------------------------------------
* Benders Algorithm
*---------------------------------------------------------------------
loop(iter,
*
* solve Benders subproblem
*
solve subproblem maximizing z using lp;
*
* check results.
*
abort$(subproblem.modelstat>=2) "Subproblem not solved to optimality";
*
* was subproblem unbounded?
*
if (z.l+1 < unbounded,
*
* no, so update upperbound
*
UB = min(UB, sum((i,j), f(i,j)*y.l(i,j)) + z.l);
*
* and add Benders’ cut to Relaxed Master
*
cutset(iter) = yes;
else
*
* solve modified subproblem
*
solve modifiedsubproblem maximizing dummy using lp;
*
* check results.
7
abort$(modifiedsubproblem.modelstat>=2)
"Modified subproblem not solved to optimality";
*
* and add Benders’ cut to Relaxed Master
*
unbcutset(iter) = yes;
);
*
* cut data
*
cutconst(iter) = sum(i, -supply(i)*u.l(i)) + sum(j, demand(j)*v.l(j));
cutcoeff(iter,i,j) = -xup(i,j)*w.l(i,j);
*
* solve Relaxed Master Problem
*
option optcr=0;
solve master minimizing z0 using mip;
*
* check results.
*
abort$(master.modelstat=4) "Relaxed Master is infeasible";
abort$(master.modelstat>=2) "Masterproblem not solved to optimality";
*
* update lowerbound
*
LB = z0.l;
display UB,LB;
abort$( (UB-LB) < 0.1 ) "Converged";
);
The Benders’ algorithm will converge to the optimal solution in 11 cycles. The
values of the bounds are as follows:
cycle LB U B
1 250 460
2 260 460
3 280 460
4 310 460
5 320 460
6 330 460
7 330 460
8 340 410
9 340 410
10 340 410
11 350 350
4. Conclusion
We have shown how a standard Benders’ Decomposition algorithm can be imple-
mented in GAMS. Algorithmic development using a high level modeling language
8 ERWIN KALVELAGEN
like GAMS is particular useful if complex subproblems need to be solved that can
take advantage of the direct availability of the state-of-the-art LP, MIP or NLP
capabilities of GAMS. Another example of such an exercise is found in [5] where a
special form of a Generalized Benders’ Decomposition is used to solve a MINLP
problem. A related use of GAMS is as a prototyping language. In this case a GAMS
implementation of an algorithm is used to test the feasibility and usefulness of a
certain computational approach. In a later stage the algorithm can be formalized
and implemented in a more traditional language. Indeed, this is the way solvers
like SBB and DICOPT have been developed.
References
1. J. F. Benders, Partitioning procedures for solving mixed-variables programming problems, Nu-
merische Mathematik 4 (1962), 238–252.
2. C. A. Floudas, A. Aggarwal, and A. R. Ciric, Global optimum search for nonconvex NLP and
MINLP problems, Computers and Chemical Engineering 13 (1989), no. 10, 1117–1132.
3. A. M. Geoffrion, Generalized Benders decomposition, Journal of Optimization Theory and
Applications 10 (1972), no. 4, 237–260.
4. Gerd Infanger, Planning under uncertainty – solving large-scale stochastic linear programs,
Boyd & Fraser, 1994.
5. G. E. Paules IV and C. A. Floudas, APROS: Algorithmic development methodology for discrete-
continuous optimization problems, Operations Research 37 (1989), no. 6, 902–915.
6. Richard Kipp Martin, Large scale linear and integer optimization; a unified approach, Kluwer,
1999.
7. S. S. Nielsen and S.A. Zenios, Scalable parallel benders decomposition for stochastic linear
programming, Parallel Computing 23 (1997), 1069–1088.
GAMS Development Corp., Washington D.C.
E-mail address:
[email protected]