线性规划LP建模实例——德国葡萄酒
German Wines
Required Files: GermanWines.mod, configExe
Maximum number of files: 4 Type of work: Individual work An American distillery produces 3 kinds of genuine German wines:Heidelberg sweet,Heidelberg regular and Deutschland extra dry. The basic products, the workforce and the profit per gallon are given in the following table.
The distillery owns 150 bushel of grapes of type A, 150 bushel of
grapes of type B, 80 kg of sugar and can provide 225 hours of work. What quantity of each wine should be produced to maximize profit?Question: model this problem as a linear program.
configExe
GermanWines.mod
GermanWines.mod
/*********************************************
* OPL 12.6.0.0 Model
* German Wines
*********************************************/
//Make sure you use c[i] to access the i-th cost
//and do not remove/change the following line
float c[1..3] = [10, 12, 20];
dvar float+ sweet;
dvar float+ regular;
dvar float+ extraDry;
maximize c[1]*sweet+c[2]*regular+c[3]*extraDry;
subject to {
sweet*1+regular*2 <=150;
sweet +extraDry*2<=150;
sweet*2+regular*1 <=80;
sweet*2+regular*3+extraDry*1<=225;
}
/* Display */
execute {
writeln("Post-traitement: ");
writeln("La valeur de l'objectif est de "+cplex.getObjValue());
}
运行结果:
CP Optimizer (Community Edition) solves problems with a search space of up to 2^1000
<<< setup, at 0s, took 1.64574e+09s
<<< generate, at 0.01s, took 0.0046761s
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec. (0.00 ticks)
Iteration log . . .
Iteration: 1 Dual infeasibility = 0.000000
Iteration: 2 Dual objective = 2100.000000
<<< solve, at 0.01s, took 0.000485897s
OBJECTIVE: 2100
Post-traitement:
La valeur de l'objectif est de 2100
<<< post process, at 0.01s, took 0.000190973s
// solution (optimal) with objective 2100
// Quality There are no bound infeasibilities.
// There are no reduced-cost infeasibilities.
// Maximum Ax-b residual = 0
// Maximum c-B'pi residual = 0
// Maximum |x| = 75
// Maximum |slack| = 50
// Maximum |pi| = 8
// Maximum |red-cost| = 6
// Condition number of unscaled basis = 6.8e+00
//
sweet = 0;
regular = 50;
extraDry = 75;
<<< done, at 0.01s, took 0.000183105s