Re: [eclipse-clp-users] Variables and domains

From: Kish Shen <kisshen_at_cisco.com>
Date: Wed, 11 Nov 2009 18:05:25 +0000
Hi Alfonso,

Afonso Henrique Sampaio wrote:
> Hello!
> I've a problem in wich the number of variables depends on the size of the
> input. Also, the domain of those variables are unknown at the time of their
> declaration. So I used the "_" to declare this variables in a list. My
bl
I am not quite sure I understand how "_" should occur in your source 
code in the situation you outlined. You should create the variable list 
at run-time, when you obtain the `size of the input', for example, using 
length/2:

        length(Vars, N),

where N is the number of variables you want to create.

> problem is that I need to impose a constraint in various subsets of this
> variables, so I get the subset and impose its domain and the constraint over
> the subset. But could happen that I impose the domain of a variable more
> than once, for example:
>

If you impose different on (ic) variables, the resulting domain will be 
the intersection of the two domains.

> original set of variables
> [_263, _274, _285, _308, _319, _338]
> 
> a subset of (no domain) variables
> [_319, _308, _263]
> 
> after impose the domain
> [_717{1 .. 4}, _735{1 .. 4}, _753{1 .. 4}]
> constraint
> 
> another subset
> [_338, _735{1 .. 4}, _274]
> 
> after impose the domain
> [_1112{1 .. 4}, _735{1 .. 4}, _1130{1 .. 4}]
> constraint
> 
> I've concluded that the variable with no domain and the associated variable
> with domain is still the same although they have different ## in the "_##"
> name. Is it realy the case?

You should not rely on the internal numbering for variables (the ## you 
are referring to) to stay the same throughout the lifetime of the 
variable. Various things can change this (such as adding an attribute, 
as in your example).

If you want unique and stable names for variables, you can use 
lib(var_name) for this.


> As the model is working, I supose that the constraint propagator is
> triggered after all the variables in the subset have their domains declared.
> Again, is it the case?
> Does Eclipse provide a better way to do this?

Constraint propagation in ic is triggered by changes in the domains of 
variables involved in a constraint. With ic, this is determined by the 
solver itself (what conditions triggers the execution of a "propagator", 
and the order in which different triggered propagators are executed), 
and not the programmer.

I am not quite sure what you mean by a "better" way. As far as ease of 
programming is concerned, propagation happens "automatically", and this 
is simplest from the point of view of the programmer. Basically, you can 
assume that the propagation will happen as soon as you post a 
constraint, and this is done by executing the propagator code at a 
higher priority than the default user code, so it will be executed in 
preference to the user code. You can execute your user code at a higher 
priority so that it will execute first, but normally, unless you are 
writing your own constraints, there is little reason to do this.

Cheers,

Kish
-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Wed Nov 11 2009 - 18:05:41 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET