2016-04-10 35 views
1

Dies ist das erste Mal, dass ich AMPL benutze und ich bin nicht wirklich damit vertraut. Ich muss mein Modell optimieren, aber ich denke, dass meine Codes falsch sind und ich immer als die optimale Lösung und "NOS 5.51: Ignorieren Integralität von 20 Variablen". Mein Modell ist Min (Abfall) unterliegen I attached a picture of constraintsAMPL findet optimale Lösung Null, alle Variablen sind auf 0 gesetzt

und hier sind meine Codes:

`set DAY;  #the day we buy ingredient 
set INGRED; #fresh ingredients 
set TIME;  #day that keeps track of the inventory 
param M default 0; 
param cost{INGRED} > 0; #cost for each ingredient (per pound) 
param demand{TIME, INGRED} >= 0; #the expected demand for each ingredient fo each day t 
param min_pur_req > 0; #minimum total cost of order required to get a delivery 
param expiry{INGRED} ; #shelf life of each ingredient 
var amount{t in TIME, i in DAY, j in INGRED} >=0; #is defined only for t = i 
var is_bought {t in TIME,i in DAY,j in INGRED : i <= t }binary; #only for t =i 
var inventory {t in TIME,i in DAY, j in INGRED : i<=t <= i+expiry[j] } >= 0; # t >= i 
var used{t in TIME,i in DAY, j in INGRED : i <= t <= i+expiry[j]} >= 0; 
var waste{t in TIME,i in DAY, j in INGRED : t <= i+expiry[j] } >= 0;` 
minimize Total_waste: 
     sum{t in TIME,i in DAY, j in INGRED : i <= t <= i+expiry[j]} waste[t,i,j]; 
subject to invalid_amount{t in TIME, i in DAY, j in INGRED: i <= t <= i+expiry[j]}: 
     if t != i then amount[t,i,j] = 0; 
subject to invalid_binary{t in TIME, i in DAY, j in INGRED: i <= t <= i+expiry[j]}: 
    if t != i then is_bought[t,i,j] = 0; 
subject to usage{t in TIME, j in INGRED}: 
    sum {i in DAY: i <= t <= i + expiry[j]} used[t,i,j] = demand[t, j]; 
subject to inventory_formula {t in TIME, i in DAY, j in INGRED: i+1 <= t <= i+expiry[j]}: 
    waste[t,i,j] = amount[t,i,j] + inventory[t-1,i,j] - used[t,i,j] - inventory[t,i,j] ; 
subject to cost_check {t in TIME, i in DAY: t = i}: 
    sum {j in INGRED} cost[j]*amount[t,i,j] >= sum{j in INGRED: t <= i+expiry[j]} min_pur_req*is_bought[t,i,j]; 
subject to blah{t in TIME,i in DAY, j in INGRED: i <= t <= i+expiry[j]}: 
     amount[t,i,j] <= M*is_bought[t,i,j]; 
subject to invalid_inventory{t in TIME, i in DAY, j in INGRED: i+1 <= t <= i+expiry[j]}: 
#i+1 because for i = 1 i get error in invetory[0,1,j] 
     if t=i then inventory[t-1,i,j] = 0; 

Dies ist, was ich bekomme:

ampl: model waste.mod; 
ampl: data waste.dat; 
ampl: solve; 
MINOS 5.51: ignoring integrality of 20 variables 
MINOS 5.51: optimal solution found. 
23 iterations, objective 0 

Antwort

0

MINOS Löser doesn 't binäre Variablen werden nur kontinuierlich unterstützt. Also ignoriert (entspannt) die Ganzheitlichkeit und warnt davor mit der Nachricht "Ignorieren der Vollständigkeit von 20 Variablen". Sie sollten eine gemischt-ganzzahlige Programmierung AMPL Löser wie CPLEX oder Gurobi verwenden, um eine ganzzahlige Lösung zu erhalten.