prolog - 在 eplex 库中是否对模运算有任何明确的支持
问题描述
我正在使用eplex
和ic
图书馆并试图解决一个问题。我看到and 为eplex
andic
提供了明确的支持addition,multiplication
,subtraction
但不支持modulo
or division
。
更准确地说,我有这个代码:
FirstResult #= (Result[I] mod Val), % Here it gives error because Result[I] is not instantiated.
NewVal is Val+1,
SecondResult #= (Result[I] mod NewVal)
并且mod
要求它的两个参数是接地的,但Result[I]
没有实例化,而是具有值范围。所以我的问题是如何延迟这种涉及mod
操作的约束。
解决方案
您通常可以重新制定
R #= X mod Y
作为
0 #=< R, R #=< Y-1, % R is between 0 and Y-1
X #= _*Y + R, % X is some multiple of Y, plus a remainder R
这假设您正在使用library(ic)
并且您对带有否定参数的行为没有任何特殊要求。
对于library(eplex)
使用 MILP 求解器的 ,您几乎可以执行相同的操作(只要 Y 是整数参数),但您必须更加明确地了解完整性:
0 $=< R, R $=< Y-1,
integers([K,R]),
X $= K*Y + R,
推荐阅读
- python - python中列的并行处理
- java - Android:如何将列表视图保存在根目录中
- python - 如何使用 tf.data 的可初始化迭代器和可重新初始化的迭代器并将数据提供给 estimator api?
- azure - 在哪里下载 WindowsAzureSDK 1.8
- lwjgl - LWJGL 3D 纹理被拉伸
- angular - 如何在角度 5 处为拦截器添加错误缓存?
- mysql - SQL:如何从第一张表上的第二张表中获取总计数?
- swift - 使用 JTAppleCalender 和 CoreData 的习惯跟踪器
- python - TemplateDoesNotExist Django 错误仅在 VPS 上 - 在本地工作正常
- azure-data-factory-2 - Azure 数据工厂 V2 上的错误处理