Elements of the blending model
Presents the data file, decision variables and constraints.
Problem data
The model is described in terms of a number of constants specifying
the various types of metals, raw materials, scrap, and ingots. In
the instance data shown in Instance
data for the blending problem (blending.dat),
there are three metals, two raw materials, two kinds of scrap, and
one kind of ingot. The model also defines ranges for each of the components.
It then defines the cost of the various components in costMetal, costRaw, costScrap, costIngo.
In the instance data, for example, the second raw material has a cost
of 5. The data items Low and Up specify
the production constraints and give lower and upper bounds on the
quantity of each sort of metal in the alloy. For example, in the instance
data, between 30% and 40% of the alloy must be the second metal. The
next data items, percRaw, percScrap,
and percIngo, specify the percentage of each metal
in the sources. In Instance
data for the blending problem (blending.dat),
the second type of scrap contains 1% of the first metal, none of the
second metal, and 70% of the third metal. Finally, the data alloy
specifies the amount of alloy to be produced.
Instance data for the blending problem
(blending.dat)
NbMetals = 3;
NbRaw = 2;
NbScrap = 2;
NbIngo = 1;
CostMetal = [22, 10, 13];
CostRaw = [6, 5];
CostScrap = [ 7, 8];
CostIngo = [ 9 ];
Low = [0.05, 0.30, 0.60];
Up = [0.10, 0.40, 0.80];
PercRaw = [ [ 0.20, 0.01 ], [ 0.05, 0 ], [ 0.05, 0.30 ] ];
PercScrap = [ [ 0 , 0.01 ], [ 0.60, 0 ], [ 0.40, 0.70 ] ];
PercIngo = [ [ 0.10 ], [ 0.45 ], [ 0.45 ] ];
Alloy = 71;
Decision variables
The decision variables specify how much of each source is used
in the alloy: the array p specifies the quantities
of pure metals, array r specifies the quantities
of raw materials, array s specifies the quantities
of scrap, array i specifies the number of ingots.
All variables are of type float except number of
ingots, which are integers. The problem is thus a mixed integer-linear
program. The instruction
dvar float m[j in Metals] in low[j] * alloy .. up[j] * alloy;
is particularly interesting, since it shows how to specify the
range of decision variables in a generic fashion. More precisely,
the range of variables m[j] is given by the expression:
low[j] * alloy .. up[j] * alloy
Note also that the model uses the variables in array m as
intermediary variables to represent the quantity of each metal produced.
Constraints
There are two types of constraints in this problem.
The
forallconstraintsubject to { forall( j in Metals ) ct1: m[j] == p[j] + sum( k in Raws ) PercRaw[j][k] * r[k] + sum( k in Scraps ) PercScrap[j][k] * s[k] + sum( k in Ingos ) PercIngo[j][k] * i[k]; ct2: sum( j in Metals ) m[j] == Alloy; }makes sure that the right amounts of metal are produced. The amount
m[j]of metaljmust be equal to the amount of pure metalp[j]added to the quantity of metaljcontained in the raw materials, the scrap, and the ingots. The correct amount of metals are computed using the percentage of metals contained in the sources.The
sumconstraintsum(j in Metals) m[j] == alloy;makes sure that the various metals produced give the correct amount of alloy. The objective function in this model is rather simple. It consists of computing the price of each source from its unit price (e.g.,
costMetal) and the amount produced (e.g.,p[j]).
A solution to blending.mod
For
the instance data given in Instance
data for the blending problem (blending.dat),
OPL returns the solution
Final Solution with objective 653.6100:
p = [0.0467 0.0000 0.0000];
r = [0.0000 0.0000];
s = [17.4167 30.3333];
i = [32];
m = [3.5500 24.8500 42.6000];