I can specify variable's domain in this way:

MyVar in 1..10

or

MyVar in {1,10,15}

but I have a variable which I would like to specify like this:

Activity_1__room in {room_1, room_2}  % i.e. as atoms not as integers

Is it possible to do it? Of course, it is possible to encode the names to integers but is it really necessary?

有帮助吗?

解决方案

You can't use atoms. The domains in CLPFD range over integers.

But suppose that you want to say "MyVar should take one of the values of the list L", i.e. the set is not known a priori. This can be coded as:

?- list_to_fdset(L, Set),
   MyVar in_set Set.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top