Hi,
I've been using CPLEX with Python 3.7, and I have tried to do the following example:
x_var = integer_var(min=0, max=3, name="x")
model = CpoModel(name="MyModel")
model.add(modeler.allowed_assignments(x_var, [0]))
model.add(modeler.allowed_assignments(x_var, [1]))
params = CpoParameters(
RandomSeed=0,
SearchType="MultiPoint",
LogVerbosity="Quiet",
WarningLevel=3,
)
solver = CpoSolver(model, params=params)
solve_result = solver.solve()
x_sol = solve_result[x_var]
print(x_sol) # prints two
The code above outputs two, even that there are two constraints that specify that allowed assignments are "0" and "1".
Using the following three constraints does not change the output:
model.add(modeler.allowed_assignments(x_var, [0]))
model.add(modeler.allowed_assignments(x_var, [1]))
model.add(modeler.equal(x_var, 2))
But when removing one of the allowed_assignments I get an error
model.add(modeler.allowed_assignments(x_var, [0]))
model.add(modeler.equal(x_var, 2))
I thought that in the first example, adding two allowed assignments on the same expression with different values would make cplex fail, can someone explain to me the behavior of allowed_assigments? can it be used multiple times on the same variable?
------------------------------
Waad Nakhleh
------------------------------
#DecisionOptimization