gpt4 book ai didi

prolog - 是否可以将变量的域设置为 clpfd 中的名称枚举?

转载 作者:行者123 更新时间:2023-12-01 10:00:51 27 4
gpt4 key购买 nike

我可以用这种方式指定变量的域:

MyVar in 1..10

MyVar in {1,10,15}

但我有一个变量,我想这样指定:

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

可以吗?当然,可以将名称编码为整数,但真的有必要吗?

最佳答案

你不能使用原子。 CLPFD 中的域范围超过整数。

但是假设您想说“MyVar 应该采用列表 L 的值之一”,即集合不是先验的。这可以编码为:

?- list_to_fdset(L, Set),
MyVar in_set Set.

关于prolog - 是否可以将变量的域设置为 clpfd 中的名称枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16471012/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com