2012-03-10 2 views
0

Как вы выполняете переменное суммирование в языке программирования ограничений ECLiPSe (http://www.eclipseclp.org/examples/)?Переменная суммирование

Я пытаюсь получить эту функцию:

:- lib(ic).   % include the standard interval constraint library 
:- lib(branch_and_bound). % include the branch and bound library for minimization 
:- lib(ic_edge_finder).  % include the cumulative constraint library needed for resource constraints 

    triangle(sums) :- 
     places = [a,b,c,d,e,f,g,h,i], 
     places :: 1..9, 
     sums = [sum1], 
     sums :: 10..30, 
     alldifferent(places), 
     sum1 #= a + b + c + d, 
     sum1 #= b + e + f + g, 
     sum1 #= d + g + h + i, 
     flatten([places,sums],allVars), 
     labeling(allVars). 

И ошибка я получаю это:

[eclipse 13]: compile('2a.ecl').   
undefined arithmetic expression in _1187 is sum1 in module eclipse 
syntax error : in source transformation in triangle(sums) :- places = [a, b, c, d, e, f, g, h, i], places :: 1 .. 9, sums = [sum1], sums :: 10 .. 30, alldifferent(places), sum1 #= a + b + c + d, flatten([places, sums], allVars), labeling(allVars) 

ответ

1

В ECLIPSE, как в Прологе имена переменных должны начинаться с заглавная буква или подчеркивание:

Places = [A,B,C,D,E,F,G,H,I], 

и т.д.

+0

* Facepalm * Спасибо – NickHalden

 Смежные вопросы

  • Нет связанных вопросов^_^