【线性规划LP建模实例——广告】
Required Files: advertizing.mod, configExe
A company has an advertising budget of 4800 monetary units (mu) for launching a new product. Its advertising campaign will consist of television commercials and newspaper advertisements. Each minute of television will reach 100 000 new viewers and each page in the newspaper will be read by 80 000 new readers. One minute of television costs 800mu and a page in the newspaper costs 600mu. The direction wants to broadcast at least 3 minutes of commercials and print at least one page in a newspaper. Its objective is to maximize the target audience (viewers and readers).Question : Model this problem as a linear program.
configExe
advertizing.mod
advertizing.mod
/*********************************************
* OPL 12.6.0.0 Model
* Advertizing
*********************************************/
//Data declarations.
//Make sure you use c[i] to access the i-th cost
//and do not remove/change the following line
float c[1..2] = [100000, 80000];
//Decision variables.
dvar float+ television;
dvar float+ journal;
//Objective function.
maximize c[1]*television+c[2]*journal;
//Constraints
subject to {
television*800+journal*600<=4800;
television>=3;
journal>=1;
}
// Display
execute {
writeln("Post treatment: ");
writeln("The objectif's value is "+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 0.01s, took 0.0037539s
Tried aggregator 1 time.
LP Presolve eliminated 3 rows and 2 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec. (0.00 ticks)
<<< solve, at 0.01s, took 0.000427008s
OBJECTIVE: 620000
Post treatment:
The objectif's value is 620000
<<< post process, at 0.01s, took 0.000201941s
// solution (optimal) with objective 620000
// 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| = 4 (4)
// Max. unscaled (scaled) |slack| = 3 (3)
// Max. unscaled (scaled) |pi| = 6666.67 (136533)
// Max. unscaled (scaled) |red-cost| = 0 (0)
// Condition number of scaled basis = 6.4e+00
//
television = 3;
journal = 4;
<<< done, at 0.01s, took 0.000190973s