我想对多变量使用AddMultiplicationEquality()
,并**使用**乘法的结果.在看了很少的其他讨论帖子后,我想我们不能执行多个决策变量的乘法.但或许我错了.
我用的是CP-SAT solver v9.5.2237
作为下面的函数,我没有给出我想要的:
product_var = model.NewIntVar(1, 1000, 'product_var')
decision_var = [model.NewIntvar(1, 10, 'name_{i}') for _ in range(4)]
###
#some processing on 'decision_var' and some values are assigned here based on other constrains
###
# then I want the product of those assigned values in 'decision_var'
model.AddMultiplicationEquality(product_var, constant, decision_var)
这样,我得到的模型错误为:
Invalid model: An int_prod constraint should have exactly 2 terms: int_prod
然后我try 了一些链接:
for i in range(4):
model.AddMultiplicationEquality(product_var, [product_var, decision_var[i])
因此,我在预解算后得到以下错误:
Unsat after presolving constraint #17 (warning, dump might be inconsistent): int_prod...
我需要一些关于如何进行乘法和获得乘积的建议.这将对我非常有帮助:)
提前感谢:)