Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Binary AMPL找到最优解零,所有变量都设置为零_Binary_Continuous_Ampl - Fatal编程技术网

Binary AMPL找到最优解零,所有变量都设置为零

Binary AMPL找到最优解零,所有变量都设置为零,binary,continuous,ampl,Binary,Continuous,Ampl,这是我第一次使用AMPL,我对它不是很熟悉。 我必须优化我的模型,但我认为我的代码是错误的,我一直把它作为最优解和“第5.51条:忽略20个变量的完整性”。 我的模式是 最低(废物) 从属于 这是我的密码: `set DAY; #the day we buy ingredient set INGRED; #fresh ingredients set TIME; #day that keeps track of the inventory param M default

这是我第一次使用AMPL,我对它不是很熟悉。 我必须优化我的模型,但我认为我的代码是错误的,我一直把它作为最优解和“第5.51条:忽略20个变量的完整性”。 我的模式是 最低(废物) 从属于

这是我的密码:

`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;

MINOS解算器不支持二进制变量,只支持连续变量。因此,它忽略(放松)完整性,并以“忽略20个变量的完整性”的消息发出警告。您应该使用混合整数规划解算器(如或)来获得整数解。

MINOS解算器不支持二进制变量,只支持连续变量。因此,它忽略(放松)完整性,并以“忽略20个变量的完整性”的消息发出警告。您应该使用混合整数规划解算器(如或)来获得整数解

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