 |
|
| Computers Forum Index » Computer - Constraints » CLPFD newbie question... |
|
Page 1 of 1 |
|
| Author |
Message |
| zslevi at (no spam) gmail.com... |
Posted: Wed Apr 29, 2009 12:09 pm |
|
|
|
Guest
|
:- use_module(library(clpfd)).
clpsum(Sum,L,AddStr):-
clpsum2(L,AddStr),AddStr#=Sum.
clpsum2([H],H).
clpsum2([H|T],AddStr):-
clpsum2(T,AddStr2),
AddStr = H+AddStr2.
| ?- X in 1..100,Y in 1..100,clpsum(10,[X,Y],A).
! Type error in argument 1 of user: #= /2
! integer expected, but _76+_77 found
! goal: _76+_77#=10
| ?-
I don't really understand, what is the problem.
_76+_77#=10 seems ok for me.
By the way, I'm using sicstus prolog. |
|
|
| Back to top |
|
|
|
| Arnaud Gotlieb... |
Posted: Sat May 02, 2009 11:58 am |
|
|
|
Guest
|
When you post constraint AddStr#=Sum, AddStr is dynamically
typed to 'FD variable or integer constant'
and you are calling the predicate with a Prolog term instead
+(_76, _77).
Solution may be to replace AddStr = H+AddStr2
by AddStr #= H+AddStr2.
Cheers,
zslevi at (no spam) gmail.com a écrit :
Quote: :- use_module(library(clpfd)).
clpsum(Sum,L,AddStr):-
clpsum2(L,AddStr),AddStr#=Sum.
clpsum2([H],H).
clpsum2([H|T],AddStr):-
clpsum2(T,AddStr2),
AddStr = H+AddStr2.
| ?- X in 1..100,Y in 1..100,clpsum(10,[X,Y],A).
! Type error in argument 1 of user: #= /2
! integer expected, but _76+_77 found
! goal: _76+_77#=10
| ?-
I don't really understand, what is the problem.
_76+_77#=10 seems ok for me.
By the way, I'm using sicstus prolog. |
|
|
| Back to top |
|
|
|
| zslevi... |
Posted: Fri Jun 12, 2009 12:47 am |
|
|
|
Guest
|
On máj. 2, 09:58, Arnaud Gotlieb <Arnaud.Gotl... at (no spam) irisa.fr> wrote:
Quote: When you post constraint AddStr#=Sum, AddStr is dynamically
typed to 'FD variable or integer constant'
and you are calling the predicate with a Prolog term instead
+(_76, _77).
Solution may be to replace AddStr = H+AddStr2
by AddStr #= H+AddStr2.
Cheers,
zsl... at (no spam) gmail.com a écrit :
:- use_module(library(clpfd)).
clpsum(Sum,L,AddStr):-
clpsum2(L,AddStr),AddStr#=Sum.
clpsum2([H],H).
clpsum2([H|T],AddStr):-
clpsum2(T,AddStr2),
AddStr = H+AddStr2.
| ?- X in 1..100,Y in 1..100,clpsum(10,[X,Y],A).
! Type error in argument 1 of user: #= /2
! integer expected, but _76+_77 found
! goal: _76+_77#=10
| ?-
I don't really understand, what is the problem.
_76+_77#=10 seems ok for me.
By the way, I'm using sicstus prolog.
I figured out that the goal expansion was missing i.e.:
instead of
Quote: clpsum(Sum,L,AddStr):-
clpsum2(L,AddStr),AddStr#=Sum.
clpsum(Sum,L,AddStr):-
clpsum2(L,AddStr),call(AddStr#=Sum). |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Mon Nov 30, 2009 11:40 pm
|
|