Re: Eclipse and C++

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 11 Feb 2005 04:57:13 PM GMT
Message-ID: <420CE3E9.2060700@icparc.ic.ac.uk>
Cristina Marconcini wrote:
> We understand that we have to use some search method. For example 
> indomain for a variable, labeling for list.
> This methods returns the firt solution (that is allways the minimun of 
> the interval solution),

There is in general no such thing as an "interval solution".

Constraint propagation is _not_complete_, which means you cannnot
(in general) assume that every remaining value in the domain actually
occurs in a solution.  And even if they do, it still doesn't mean that
you can just pick arbitrary values from the domains and expect to
automatically get a solution.

[ Such an assumption can only be made in very specific circumstances,
like when you have no delayed goals at all, or when your remaining
constraints/delayed goals are of a particularly simple form and you
have certain guarantees about the strength of the constraint propagation.
These conditions certainly don't hold in your example where you have
disequality constraints like neg(X1 #= 5) ]

In your example, e.g (X1=1,X2=1) is not a solution even though these
values are in the domains.


 > but if we want to
> get a random solution we have to call more times for it.
> We need to get, at a single run,  a solution randomly taken  in the list 
> of possible goals solutions.

The list of all solutions does not come for free, you have to explore
the whole search space and collect them!  In your example you could use

    ..., findall(X1-X2, labeling([X1,X2]), Solutions).

to do that.

Clearly, collecting all solutions is too much work if you are only
interested in a random one. A better way is to use randomised search
by either calling

    ..., indomain(X1,random), indomain(X2,random).

or by using the configurable search/6 predicate:

    ..., search([X1,X2],0,input_order,indomain_random,complete,[]).


> 
> So, we define our equations as goals and we get a list of possible 
> solutions.

You should now see that this statement is not true.


> How can we choose randomly a solution between them?
> 
> 


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Feb 11 17:03:11 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:33 PM GMT GMT