1

Let's say I pass the following list of domain variables to the labeling predicate:

Z=[X1,Y1,X2,X3,Y2,X4,Y3.......Xn,Ym],
labeling(...., Z).

For variable(Sel): Further more I want the labeling to maybe choose all the Y's first before continuing on the X's. Or even more complicated: Start on a X or on a Y and the continue to label a X if there are more unlabeled compared to Y and vise versa.

For value(Enum): To even complicate it I maybe want to have different strategy to use depending on if it is a X of if it is a Y.

My first attempt has been to use attributed variable and add further information to each variable:

put_atts( X1,  type_var(is_xvar)),
put_atts( X2,  type_var(is_xvar)),
put_atts( Y1,  type_var(is_yvar)),
.
.

And the inside variable(Sel) and value(Enum) I can search and select by use of this attribute.

But since a fd_var is already an attributed variable, this attempt does not work very well.

So my question is: Is use of attributed variables the right strategy to solve such a task? Is there an alternative way to do this?

This is only a simplified example. I would need about 10 different variable types, not just two as shown here.

suspectus
  • 16,548
  • 8
  • 49
  • 57
MortenM
  • 522
  • 2
  • 12

1 Answers1

2

There is absolutely no problem with additional attributes on domain variables. As long as you are relying on labeling/2 for variable selection, that is the most natural solution.

An alternative way is to write your own search procedure that does not rely on labeling/2.

Mats Carlsson
  • 1,426
  • 7
  • 3
  • Yes, I'm relying on labeling/2 in variable selection. By adding additional attributes to domain variable, do I have to do any extra then using put_atts/2? Does verify_attributes/3 have to be implemented in the module? Is there any examples anywhere on how to use attributes on a domain variable and then use this information in the labeling phase? – MortenM Jul 07 '13 at 08:55