1

What is the difference between active and passive constraints in the ECLiPSe CLP language? And how/when can I use one or the other?

SND
  • 1,552
  • 2
  • 16
  • 29
The Oddler
  • 6,314
  • 7
  • 51
  • 94

1 Answers1

1

The distinction refers to the way the constraints are used during execution. Active constraints (may) directly affect the variables present in them, whereas passive constraints will not. Consider a small, trivial example of both structures:

% Active
f(a,X) = f(Y,b)

% Passive
2*X < 3*Y+2

In the first example, when either X or Y becomes instantiated, the 'constraint' can trigger and immediately evaluate (and if valid, unify) both sides = active behaviour.

In the second example on the other hand, both sides are dependent on each other and thus it doesn't matter whether X or Y becomes instantiated first, the evaluation will have to be delayed until both sides' variables are instantiated = passive behaviour.

(Note that I tried to answer without using any constraint/language-specific syntax, since the concept of active/passive constraints can generically be applied to all constraint logic based systems. Also note that some languages like ECLiPSe provide global constraints reasoning over finite integer domains and may actually make some behaviour active/passive to our needs. However, being outside the scope of this question, no further behaviour is considered to keep things simple.)

Hope this helps!

SND
  • 1,552
  • 2
  • 16
  • 29
  • Is it also correct that when using the `ic` library in ECLiPSe this constraint will be active: `2*X #< 3*Y+2`? (Note the added #). Then when either side's domain is updated, the other's domain can be updated as well. – The Oddler Jun 05 '16 at 07:56
  • 1
    Yes that is correct. In ECLiPSe, when X or Y would possess finite domains and either one of them would become instantiated, the constraint #< would trigger and be checked for correctness. Also, if necessary, it would reduce the domain of the still uninstantiated variable to make the constraint express valid information. Of course, this is classified as active behaviour. – SND Jun 05 '16 at 08:05
  • 1
    Thanks, it makes sense now :D – The Oddler Jun 05 '16 at 08:09