这是我第一次使用AMPL并且我并不熟悉它。 我必须优化我的模型,但我认为我的代码是错误的,我一直在寻找最佳解决方案和“NOS 5.51:忽略20个变量的完整性”。 我的模特是 敏(废物) 受制于 I attached a picture of constraints
这是我的代码:
^(?=.*\\p{Ll})(?=.*\\p{Lu})(?=.*\\p{N})(?:(?=.*\\p{P})|((?=.*\\p{S})))[\\p{L}\\p{N}\\p{P}\\p{S}]{8,64}$
这就是我得到的:
`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;