ampl - 我如何更改我的 AMPL mod/data 文件的容量,以免出现语法错误
问题描述
我来自 NEOS 服务器的问题是:
amplin,第 16 行(偏移量 239):语法错误上下文:param Capacity{i in >>> 1...m <<< }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
数据为:
param m := 4;
param n := 30;
param Facilitycost:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 :=
1 2 7 7 6
2 8 3 1 5
3 2 5 6 6
4 7 5 2 3
5 5 3 6 8
6 9 8 5 1
7 4 4 6 7
8 8 4 8 11
9 10 5 2 5
10 1 8 9 9
11 7 1 5 8
12 1 7 8 8
13 1 7 8 8
14 7 1 3 6
15 3 5 8 8
16 8 1 4 8
17 7 1 3 6
18 7 3 2 4
19 10 3 3 7
20 4 4 7 9
21 4 5 5 4
22 6 6 4 2
23 9 6 2 3
24 6 4 8 10
25 6 6 4 2
26 4 7 6 4
27 8 1 3 7
28 1 8 9 8
29 6 2 6 9
30 9 6 2 3;
param Capacity:= 1 5000 2 5000 3 5000 4 5000;
param Demand:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 :=
1 220
2 374
3 351
4 432
5 161
6 300
7 300
8 219
9 339
10 312
11 653
12 440
13 207
14 492
15 91
16 190
17 351
18 323
19 23
20 157
21 281
22 233
23 409
24 215
25 7
26 680
27 215
28 395
29 165
30 333;
我的模型是:
param m; #number of facilites
param n; #number of customers needed to be served
param Facilitycost{j in 1..n, i in 1..m};
param Capacity{i in 1...m};
param Demand{j in 1..n};
#THE DECISION VARIABLES
var AllocatedFacility{j in 1..n, i in 1..m} binary;
#OBJECTIVE FUNCTION
minimize Total_AllocationCost: sum {j in 1..n, i in 1..m}:
Facilitycost[j,i] * AllocatedFacility[j,i];
#THE CONSTRAINTS
s.t. CapacityConstraints {i in 1..m}:
Demand[j] * AllocatedFacility[j,i] <= Capacity[i];
s.t. AllocatedFacilityContraints {j in 1..n}:
sum {i in 1..m} AllocatedFacility[j,i] = 1;
我怎样才能改变容量,以便满足第 i 列所需的条件?模型中的数据有问题吗?
解决方案
这一行的语法错误是因为你有1...m
你应该有的地方1..m
。
推荐阅读
- python - vs code,尝试安装包时出错
- php - 我添加 1 个月后的 strtotime 值错误
- r - 用所需数据填充 NA'S
- angular - 对 ngContent 的内容应用 CdkVirtualScroll
- angular - Angular 11 Universal 和 Bootstrap 5 Toast 不起作用 - 新的引导程序 TS2304:找不到名称“引导程序”,被粉碎
- python - 如何限制 FastAPI 请求标头中的内容类型
- tensorflow - 使用 ImageDataGenerator 时,模型拟合永远不会完成第一个 epoch
- jquery - 获取 gallery.scrollGallery 不是函数
- r - 计算 1-1-1(人内、多层次)中介分析的间接影响
- java - 错误解组返回;嵌套异常是:java.io.StreamCorruptedException: Inconsistent vector internals