【线性规划LP建模实例——茶壶生产】

线性规划LP建模实例——茶壶生产

等级:难
The teapot - Le pot de terre et la théière
Required Files: theiere.mod, configExe, instance.dat
Maximum number of files: 10
Type of work: Individual work
The company The TeaPot uses part of its production capacity to produce hand-painted teapots. A teapot requires half an hour of a painter’s time and 30 painters from the region declare their permanent availability. The problem of employing painters who are not constantly hired has to be solved, but only if the demand becomes important, which happens next week. They can work only on Thursday, Friday and Saturday. Any painter needed in production will be hired for 2 days of 8 hours each (not necessarily consecutive) and will be paid for these 16 hours, even if he works less. Without counting the price of labor, the profit from the sale of a teapot is 20€. The demand not satisfied on the day it is presented is lost and, in addition, the company will be charged a penalty of 6€ per piece not supplied on Thursday, 18€ on Friday and 30€ on Saturday. One day’s production can satisfy the demand of that day and possibly future days and it costs 3€ to store a teapot from one day to the next. However, nothing can be stored from Saturday to Sunday and any overproduction will be lost. The painters are paid 20€ per hour. Requests for teapots are 100 on Thursday, 300 on Friday and 600 on Saturday.

Model as a linear program the production that would maximize the net profit. At this point in the course, we assume that the number of painters can be non-integer.

theiere.mod,

/*********************************************
 * OPL 12.6.0.0 Model
 * Theiere
 *********************************************/

//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..7] = ...;
//c = [20,-6, -18, -30, -3,-3,-20];
// Prix d'une théiere, pénalités, cout de stockage de jeudi à vendredi puis de vendredi à samedi, cout des peintres

//Decision variables.
dvar float+ produit_teapot;
dvar float+ amende_jeudi;
dvar float+ amende_vendredi;
dvar float+ amende_samedi;
dvar float+ depot_jv;
dvar float+ depot_vs;
dvar float+ cout_peintre;

dvar float+ produit_jeudi;
dvar float+ produit_vendredi;
dvar float+ produit_samedi;

dvar float+ produit_jeudiPlus;
dvar float+ produit_vendrediPlus;

dvar float+ produit_jeudiReste;
dvar float+ produit_jeudiUtilise;

dvar float+ tempsReste;
//Objective function.
maximize c[1]*produit_teapot
            +c[2]*amende_jeudi+c[3]*amende_vendredi+c[4]*amende_samedi
            +c[5]*depot_jv+c[6]*depot_vs+c[7]*cout_peintre*16;

//Constraints
subject to {
    //jeudi
    produit_jeudi+amende_jeudi==100;
    produit_jeudi+amende_jeudi+produit_jeudiPlus>=100;
    
    depot_jv==produit_jeudiPlus;
    produit_jeudi+produit_jeudiPlus<=cout_peintre*16;
    //vendredi
    depot_jv==produit_jeudiUtilise+produit_jeudiReste;
    produit_jeudiUtilise+produit_vendredi+amende_vendredi==300;
    produit_jeudiUtilise+produit_vendredi+amende_vendredi+produit_vendrediPlus>=300;
    
    depot_vs==produit_vendrediPlus+produit_jeudiReste;
    produit_vendredi+produit_vendrediPlus<=cout_peintre*16;
    //samedi
    depot_vs+produit_samedi+amende_samedi==600;
    produit_samedi<=cout_peintre*16;
    //
    produit_teapot==produit_jeudi+produit_jeudiPlus
                  +produit_vendredi+produit_vendrediPlus
                  +produit_samedi;
    cout_peintre<=30;
    16*cout_peintre==produit_teapot/2+tempsReste;
    
}

// Display
execute {
  writeln("Post treatment: ");
  writeln("The objectif's value is  "+cplex.getObjValue());
} 

configExe,

theiere.mod
instance.dat

instance.dat

c = [20,-6, -18, -30, -3,-3,-20];

运行结果

efault LOCALE: en_US.UTF-8                                                                                                         
                                                                                                                                    
<<< setup, at 0s, took 1.64574e+09s                                                                                                 
                                                                                                                                    
                                                                                                                                    
<<< generate, at 0.01s, took 0.00505996s                                                                                            
                                                                                                                                    
Tried aggregator 1 time.                                                                                                            
LP Presolve eliminated 2 rows and 2 columns.                                                                                        
Aggregator did 5 substitutions.                                                                                                     
Reduced LP has 7 rows, 9 columns, and 27 nonzeros.                                                                                  
Presolve time = 0.00 sec. (0.01 ticks)                                                                                              
Initializing dual steep norms . . .                                                                                                 
                                                                                                                                    
Iteration log . . .                                                                                                                 
Iteration:     1   Dual objective     =         18200.000000                                                                        
                                                                                                                                    
<<< solve, at 0.01s, took 0.000656128s                                                                                              
                                                                                                                                    
                                                                                                                                    
OBJECTIVE: 9000                                                                                                                     
Post treatment:                                                                                                                     
The objectif's value is  9000                                                                                                       
                                                                                                                                    
<<< post process, at 0.01s, took 0.00018692s                                                                                        
                                                                                                                                    
// solution (optimal) with objective 9000                                                                                           
// 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|                  = 960 (960)                                                                          
// Max. unscaled (scaled) |slack|              = 420 (120)                                                                          
// Max. unscaled (scaled) |pi|                 = 560 (832)                                                                          
// Max. unscaled (scaled) |red-cost|           = 52 (832)                                                                           
// Condition number of scaled basis            = 3.0e+02                                                                            
//                                                                                                                                  
                                                                                                                                    
produit_teapot = 960;                                                                                                               
amende_jeudi = 40;                                                                                                                  
amende_vendredi = 0;                                                                                                                
amende_samedi = 0;                                                                                                                  
depot_jv = 0;
depot_vs = 120;                                                                                                                     
cout_peintre = 30;                                                                                                                  
produit_jeudi = 60;                                                                                                                 
produit_jeudiPlus = 0;                                                                                                              
produit_jeudiUtilise = 0;                                                                                                           
produit_jeudiReste = 0;                                                                                                             
produit_vendredi = 300;                                                                                                             
produit_vendrediPlus = 120;                                                                                                         
produit_samedi = 480;                                                                                                               
tempsReste = 0;                                                                                                                     
                                                                                                                                    
<<< done, at 0.01s, took 0.000316143s        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值