我正在努力学习AMPL语法(这是我的第一个项目)。在我的模型里:
set GRID; # a grid represented by a sequence of integer
param W; # width of the grid
param d{i in GRID, j in GRID}; # distance between point of the grid在我的数据中:
set GRID = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
param W = 4;
param d{i in GRID, j in GRID} = sqrt( (abs(i-j) mod W)**2 + (abs(i-j) div W)**2 ); # I want to calculate the distance between each pair of points但在最后一行,我得到了一个错误:
(offset 7)
expected ; ( [ : or symbol发布于 2015-01-19 15:02:10
AMPL数据格式不允许表达式,因此需要在模型本身中指定d参数的初始化:
set GRID; # a grid represented by a sequence of integer
param W; # width of the grid
param d{i in GRID, j in GRID} = sqrt((abs(i-j) mod W)**2 + (abs(i-j) div W)**2);https://stackoverflow.com/questions/28008910
复制相似问题