Domanda

There is the predicate indomain/1 in manual that assigns values to a variable (let's call it X) in increasing order via backtracking.

I would like to change the order of values that are assigned to the variable X as I try writing a custom labeling predicate. I've come up with this code:

fd_set(X, X_as_set),
fdset_to_list(X_as_set, X_as_list), % now I have domain of the variable X in form of a list
% sort X_as_list in some way and return the changed list as X_as_list2
member(Val, X_as_list2), 
X = Val   % assign value to CLPFD variable

But I don't really know if it is correct or not. Moreover, I'm not sure if it is a proper way how to do it.

È stato utile?

Soluzione

That's a perfectly fine way of doing it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top