Skip to content

Propagator constraints connected to variables specified with variable_define/3 #263

@daveraja

Description

@daveraja

It looks like the propagator can behave strangely when the input and/or outputs of an execution_declare/5 constraint are connected to variables that are "defined" rather than "declared".

Consider the example below of constraint that takes external inputs from variables xin1 and xin2 and outputs their sum to external variable xout. Variables xin1 and xin2 can both take values 0 or 1, but xout is fixed to 0; so there is only a single solution where all external variables are set to 0.

When the external variables are specified with variable_declare/3 and variable_domain/2 everything works fine, but when I use variable_define/3 I get different behaviour:

  • If xout is specified with variable_define/3 then I get UNSAT.
  • Strangely if one of xin1 or xin2 are specified with variable_define/3 then it works, but if both are specified with variable_define/3 then I get UNSAT.
variable_declare(x,xin1,fromFacts).
variable_domain(xin1,val(int,0)).
variable_domain(xin1,val(int,1)).

variable_declare(x,xin2,fromFacts).
variable_domain(xin2,val(int,0)).
variable_domain(xin2,val(int,1)).

%variable_define(x,execution_input(constraint,in1),variable(xin1)).   % alternative
variable_declare(x,execution_input(constraint,in1),fromFacts).
variable_domain(execution_input(constraint,in1),variable(xin1)).

%variable_define(x,execution_input(constraint,in2),variable(xin2)).  % alternative
variable_declare(x,execution_input(constraint,in2),fromFacts).
variable_domain(execution_input(constraint,in2),variable(xin2)).

ensure(x,operation(eq,(variable(execution_output(constraint,out)),(variable(xout),())))).

%variable_define(x,xout,val(int,0)).   % alternative
variable_declare(x,xout,fromFacts).
variable_domain(xout,val(int,0)).

execution_run(x,constraint).
execution_declare(x,constraint,assign(out,operation(add,(variable(in1),(variable(in2),())))),(in1,(in2,())),(out,())).

defaultEngine(propagator).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions