线性规划LP建模实例——机器生产
Bill Of Materials Required Files: billmaterial.mod, data1.dat,
configExe
Maximum number of files: 10
Type of work: Individual workYou are responsible for the design of the MPS (Master production
schedule). Two products P and Q are assembled in the workshop of your company and are sold respectively for 90 euros and 100 euros. P requires three intermediate products: MP1, MP2, MP3 (one unit of each) whereas Q requires one unit of MP2 and MP3. The intermediate products MP1, MP2, MP3 are bought for 5, 20, 20 euros respectively.
Four machines, denoted A, B, C, D are available in the workshop and each product requires some processing time on some of the machines. For instance, product Q needs 15 minutes on machine B and 5 minutes on machine D. Finally a machine can only work 40h per week.The bill of materials is shown on the picture below with resource
consumption and a synthesis of all the data of the problem.
The problem is to give the production plan for a week in other words how many P and Q should be produced to maximize profit ?
In general, the consumption of product i on machine j is denoted sij and can vary among instances.
Question 1: Can you compute by hand the optimal solution for the
instance given as example ? Explain your reasonings.Question 2: Suppose Product P requires 20 minutes on machine C (rather than 15), can you compute by hand the new optimal solution ?
Question 3: Give a linear program.
Note French/English: MPS = PDP (Programme Directeur de Production);
Bill of materials = Nomenclature
billmaterial.mod,
/*********************************************
* OPL 12.6.0.0 Model
* Dyeing plant program
*********************************************/
/***
Q1:
non,En raison de la matrice et du fait que les chiffres sont un peu élevés,
cela a pris plus de temps et n'était pas pratique.
Q2:
15:
OBJECTIVE: 6514.286
Produit = [114.29 22.857 114.29 137.14 137.14];
20:
OBJECTIVE: 6133.333
Produit = [88.889 35.556 88.889 124.44 124.44];
***/
range products = 1..5; //Products: P, Q, MP1, MP2, MP3
range machines = 1..4; //Machines A, B, C, D
float s[products][machines] = ...; //resource consumption of each product on each machine in minutes
float c[products] = ...; //selling price of each product (if positive) or buying price (if negative)
dvar float+ Produit[products];
maximize sum(p in products) Produit[p]*c[p];
subject to {
forall (i in machines)
Machines:
sum(p in products) Produit[p]*s[p][i]<=40*60;
Produit[1] <=Produit[3];//nombre de MP1
Produit[1]+Produit[2]<=Produit[4];//nombre de MP2->P+Q
Produit[1]+Produit[2]<=Produit[5];//nombre de MP3->P+Q
Produit[1]<=100;//P
Produit[2]<=50;//Q
}
/* Display */
execute {
writeln("Post-processing: ");
writeln("The value of the objective is "+cplex.getObjValue());
for(var i in machines){
write("varDual ,Machines[i]");
writeln(" = ",Machines[i].dual);
}
}
data1.dat,
c = [90, 100, -5, -20, -20];
s = [[0, 0, 20, 15],
[0, 15, 0, 5],
[15, 0, 0, 0],
[0, 15, 0, 0],
[0, 0, 5, 0]];
configExe
billmaterial.mod
data1.dat
运行结果
Default LOCALE: en_US.UTF-8
IBM ILOG CPLEX Optimization Studio Community Edition. The CPLEX Optimizers will solve problems up to 1000 variables and 1000 constr
aints.
CP Optimizer (Community Edition) solves problems with a search space of up to 2^1000
<<< setup, at 0s, took 1.64581e+09s
<<< generate, at 0s, took 0.00530696s
Tried aggregator 1 time.
LP Presolve eliminated 5 rows and 1 columns.
Aggregator did 2 substitutions.
Reduced LP has 2 rows, 2 columns, and 4 nonzeros.
Presolve time = 0.00 sec. (0.00 ticks)
Iteration log . . .
Iteration: 1 Dual objective = 6300.000000
<<< solve, at 0s, took 0.000607014s
OBJECTIVE: 6133.333
Post-processing:
The value of the objective is 6133.33
varDual ,Machines[i] = 0
varDual ,Machines[i] = 1.88889
varDual ,Machines[i] = 0.666667
varDual ,Machines[i] = 0
<<< post process, at 0s, took 0.000388145s
// solution (optimal) with objective 6133.33333333333
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Max. unscaled (scaled) Ax-b resid. = 7.10543e-14 (4.44089e-15)
// Max. unscaled (scaled) c-B'pi resid. = 7.10543e-15 (7.10543e-15)
// Max. unscaled (scaled) |x| = 124.444 (124.444)
// Max. unscaled (scaled) |slack| = 1066.67 (66.6667)
// Max. unscaled (scaled) |pi| = 48.3333 (48.3333)
// Max. unscaled (scaled) |red-cost| = 0 (0)
// Condition number of scaled basis = 6.8e+00
//
Produit = [88.889
35.556 88.889 124.44 124.44];
<<< done, at 0s, took 0.000298977s