我正在尝试在PuLP中编写以下约束。
请问您如何写这些约束?
答案 0 :(得分:0)
关于10个二进制变量的简单表述如下(对应于A-J)
x1=LpVariable("x1",0,1,LpInteger)
x2=LpVariable("x2",0,1,LpInteger)
...
x10=LpVariable("x10",0,1,LpInteger)
# add an appropriate objective
...
# A or B or none but not both
prob += x1 + x2 <= 1
# At least 3 out of 10
prob += x1 + x2 + ... + x10 >= 3