线性规划LP建模实例——乳制品
Dairy Products
Required Files: dairy.mod, configExe
Maximum number of files: 10
Type of work: Individual work
A dairy cooperative is producing 3 types of cheese: Beaufort, Abondance and Reblochon. The milk needed for each cheese differs depending on the species of the cow (abondances (a), monbéliardes (m) and tarines (t)). The following table gives the quantity of each milk needed to produce one kilogram of a given cheese as well as the labor time needed.
3000 liters of milk a, 1000 liters of milk m and 4000 liters of milk t are usually collected during a week. The available labor time in a week is 250 hours. The cooperative is wondering what kind of cheese should be made to maximize its profit. The unused milk is sold for 0.25 € per liter.
Question: Formulate the problem as a linear program and compute the optimal profit.
configExe
dairy.mod
dairy.mod
/*********************************************
* OPL 12.6.0.0 Model
* Dairy Products
*********************************************/
//Make sure you use c[i] to access the i-th cost
//and do not remove/change the following line
float c[1..4] = [20, 25, 15, 0.25];
dvar float+ Beaufort;
dvar float+ Abondance ;
dvar float+ Reblochon;
maximize c[1]*Abondance+c[2]*Beaufort+c[3]*Reblochon
+c[4]*(
3000-(Abondance*5 +Beaufort*5 +Reblochon*2)
+1000-(Abondance*3)
+4000-(Abondance*2 +Beaufort*5 +Reblochon*4)
);
subject to {
abondances_a: Abondance*5 +Beaufort*5 +Reblochon*2 <=3000;
monbeliardes_m:Abondance*3 <=1000;
tarines_t: Abondance*2 +Beaufort*5 +Reblochon*4 <=4000;
LaborTime: Abondance*15+Beaufort*30+Reblochon*10<=250*60;
}
/* Display */
execute {
writeln("Post-traitement: ");
writeln("La valeur de l'objectif est de "+cplex.getObjValue());
}
运行结果
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.64574e+09s
<<< generate, at 0s, took 0.0055511s
Tried aggregator 1 time.
LP Presolve eliminated 1 rows and 0 columns.
Reduced LP has 3 rows, 3 columns, and 9 nonzeros.
Presolve time = 0.00 sec. (0.00 ticks)
Iteration log . . .
Iteration: 1 Scaled dual infeas = 0.000000
Iteration: 2 Dual objective = 18333.333333
<<< solve, at 0s, took 0.000577927s
OBJECTIVE: 18187.5
Post-traitement:
La valeur de l'objectif est de 18187.5
<<< post process, at 0s, took 0.000193119s
// solution (optimal) with objective 18187.5
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Max. unscaled (scaled) Ax-b resid. = 0 (0)
// Max. unscaled (scaled) c-B'pi resid. = 0 (0)
// Max. unscaled (scaled) |x| = 875 (875)
// Max. unscaled (scaled) |slack| = 2500 (125)
// Max. unscaled (scaled) |pi| = 2.6875 (10.75)
// Max. unscaled (scaled) |red-cost| = 1.09375 (1.09375)
// Condition number of scaled basis = 5.8e+00
//
Abondance = 250;
Beaufort = 0;
Reblochon = 875;
<<< done, at 0s, took 0.00019598s