optimization - GAMS 错误:线性模型中不允许使用内生函数参数
问题描述
我正在尝试在 GAMS 中使用 MIP 解决二进制变量,但不断出现错误。我无法理解原因。有人有解决方案吗?
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;
或者,您重新制定模型,以便不再使用 MIN 函数。
推荐阅读
- arduino - Arduino esp32:存储结构 EEPROM 的数组
- python - VSCode 中的终端在 Ubuntu 18 中显示空白屏幕
- php - 在 laravel 上的数组上调用成员函数失败()
- python - 将 4d 数组存储为一个文件
- node.js - Swagger 3.0.1 服务器生成器
- json - AWS Batch Job container_properties 无效:解码 JSON 时出错:无效字符“v”正在寻找值的开头
- database - 使用逻辑复制避免数据重复 (PostgreSQL 10)
- c - 如何将字符附加到C中的字符串数组
- javascript - React + mobx 在初始页面加载时不呈现
- python - 在 Python 中对词频进行排序