2015-01-18 8 views
1

AMPL 구문에 어려움을 겪고 있습니다. 내 모델에서 내가 가진 :AMPL param syntax

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 

을하지만 마지막 줄에 내가 오류 얻을 :

내 데이터
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 

내가 가진

이 에게
(offset 7) 
expected ; ([ : or symbol 

답변

1
에게

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