[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unexpected result with FD solver
From: |
Xiao-Hua Kong |
Subject: |
Re: Unexpected result with FD solver |
Date: |
Mon, 17 Feb 2003 15:53:37 -0500 (EST) |
Thank you very much.
As I understand, the result of a variable, say
X: _#integer(a,b)
in which (a,b) means (I do not understand _#integer :-)):
If the evaluation of X be an integer between a and b, there exists at
least one assignement for the rest of variables.
This is true for variables in list LD1 and LD2 of my example, however it
is not true for variable Va.
For Va=0 or Va=1, there is NO assignement! This superised me alot.
Actually, my original goal is:
What is the domain of Va, so that there exsits assignment for the
constraints?
Therefore an answer with the "possible region" of the assignment is
acceptable for me.
Is it the right way to represent it in Prolog?
On Mon, 17 Feb 2003, Jean Michel LECONTE wrote:
> try :
>
> ieq(LD1,LD2,Va):-
> LD1 = [X1,X2,X3,X4],
> LD2 = [D1,D2],
> fd_domain(LD1,0,20),
> fd_domain(LD2,1,12),
> Va #=<5,
> Va #>=0,
> X1 #=0,
> X2 #=< X1+4,
> X2 #>= X1+2,
> X3 #= X1+D1,
> X4 #= X2+D2,
> D1 #=< D2+Va,
> D1 #>= D2-Va,
> X4 #=< X3,
> fd_labeling(LD1),
> fd_labeling(LD2),
> fd_labeling(Va).
>
> read the note in the doc about fd_labeling, you have to do this operation if
> you want some answers cause when gprolog says
> >
> > LD1 = [0,_#25(2..4),_#47(3..12),_#69(3..12)]
> > LD2 = [_#91(3..12),_#113(1..10)]
> > Va = _#134(0..5)
>
> it just means that Va could be between 0 and 5 but thts not meaning that
> there's a solution...
> gprolog tries to reduce the domain of possible values for each FD (i.e.
> constrained) variable but if you want a solution you have to 'label' each FD
> variable
>
> and the _#integer(a..b) means FD variable which has integer for internal
> system number (as an internal ID) is between a and b
>
>
> Jean Michel LECONTE
> -----------------------------------------
> address@hidden
> address@hidden
> -----------------------------------------
>
>
>
>
>
>
> Xiao-Hua Kong writes:
>
> > Hello,
> >
> > I'm a beginer in Prolog, I want to use GNU Prolog for constraint sovling
> > in FD. I have tried the solver with a set of in-equations. But for some of
> > them, I did not get the result expected.
> >
> > Here is an example:
> >
> > I wrote a rule:
> >
> > ieq(LD1,LD2,Va):-
> > LD1 = [X1,X2,X3,X4],
> > LD2 = [D1,D2],
> > fd_domain(LD1,0,20),
> > fd_domain(LD2,1,12),
> > Va #=<5,
> > Va #>=0,
> > X1 #= 0,
> > X2 #=< X1+4,
> > X2 #>= X1+2,
> > X3 #= X1+D1,
> > X4 #= X2+D2,
> > D1 #=< D2+Va,
> > D1 #>= D2-Va,
> > X4 #=< X3.
> >
> > And asked for the possible assignment for these in-equations
> > (constraints).
> > However I got the follwing result:
> >
> > | ?- ieq(LD1,LD2,Va).
> >
> > LD1 = [0,_#25(2..4),_#47(3..12),_#69(3..12)]
> > LD2 = [_#91(3..12),_#113(1..10)]
> > Va = _#134(0..5)
> >
> > In which the resulting domain of Va is larger than it should be. For
> > example, ask
> > | ?- ieq(LD1,LD2,0).
> > or | ?- ieq(LD1,LD2,1).
> >
> > will have an answer "no".
> >
> > Is there any problem with the code? Or I should not use more than three
> > variables in a constraint? How can I solve this problem.
> >
> > BTW, what does _#integer mean in the result?
> >
> > Thanks in advance.
> > Xiaohua Kong
> >
> >
> >
> > _______________________________________________
> > Users-prolog mailing list
> > address@hidden
> > http://mail.gnu.org/mailman/listinfo/users-prolog
>
>