Optimization GAMS错误:线性模型中不允许内生函数参数

Optimization GAMS错误:线性模型中不允许内生函数参数,optimization,integer-programming,gams-math,Optimization,Integer Programming,Gams Math,我试图用MIP在GAMS中求解二进制变量,但我经常会遇到一个错误。我无法理解原因。有人有办法吗 Set i cities /1*7/; Binary variables z1,z2,z3,z4,z5,z6,z7 1 if selected and 0 otherwise ; variable y ; Equations con1,con2,con3,con4,con5,con6,con7,obj ; obj.. y =E= z1*10+z2*6+z3*7+z4*8+z5*13+z6*9

我试图用MIP在GAMS中求解二进制变量,但我经常会遇到一个错误。我无法理解原因。有人有办法吗

Set i cities /1*7/;
Binary variables z1,z2,z3,z4,z5,z6,z7     1 if selected and 0 otherwise ;
variable y ;
Equations con1,con2,con3,con4,con5,con6,con7,obj ;
obj..  y =E= z1*10+z2*6+z3*7+z4*8+z5*13+z6*9+z7*8;
con1.. min(z2*6.1,z3*15.2,z4*17,z5*16.8,z6*8.4,z7*16.6) =L= 10 ;
con2.. min(z1*6.1,z3*7.6,z4*16.0,z5*11.3,z6*2.2,z7*11.9) =L= 10 ;
con3.. min(z1*15.2,z2*7.6,z4*22.0,z5*17.3,z6*10.2,z7*16.7) =L= 10 ;
con4.. min(z1*17.0,z2*16.0,z3*22.0,z5*12.1,z6*14.8,z7*7.2) =L= 10 ;
con5.. min(z1*16.8,z2*11.3,z3*17.3,z4*12.1,z6*9.4,z7*2.9) =L= 10 ;
con6.. min(z1*8.4,z2*2.2,z3*10.2,z4*14.8,z5*9.4,z7*9.2) =L= 10 ;
con7.. min(z1*16.6,z2*11.9,z3*16.7,z4*7.2,z5*2.9,z6*9.2) =L= 10 ;

Model planmall /all/ ;

Solve planmall using MIP minimizing y;

display z1.L,z2.L,z3.L,z4.L,z5.L,z6.L,z7.L,y.L;

如果我运行您的模型,我会在lst文件中看到:

****  51  Endogenous function argument(s) not allowed in linear models
**** 256  Error(s) in analyzing solve statement. More detail appears
****      Below the solve statement above
**** The following MIP errors were detected in model planmall:
****  51 equation con1.. the function MIN is called with non-constant arguments
...
所以问题是,你试图解决一个(线性)MIP,但是你用变量来计算函数MIN,这对于这个模型类型是不允许的。因此,解决此问题的一种方法是将模型类型更改为MINLP,如下所示:

Solve planmall using MINLP minimizing y;

或者,你重新构造你的模型,这样你就不再使用最小函数了。

错误是什么?它确实适用于最小线性规划,但我的公式是错误的吗?-我需要在这里使用MIP公式没有错误,但最小函数不是线性的。但通常你可以用不同的方式来表述这些方程,这样它们就成了线性的。看看这篇文章的例子: