In CVXPY, How to constract an 'OR' constraint like this ?
The constraint I am looking for is that x can be 1 or 2. The optimizer minimizes x and obtains the optimal x = 1.
For example, [x == 1 or x == 2] is invalid, and [x == 1, x == 2] means x == 1 AND x == 2 and does not work.
I am looking for a constraint that restricts x to be 1 or 2: x == 1 OR x == 2. Is it possible to create a CVXPY constraint like this?
import cvxpy as cp
x = cp.Variable(name='x')
## x is 1 or 2
## constraints = [ x...] # x is 1 or 2; for example, 'constraints = [x == 1 or x == 2]' does not work
objective = cp.Minimize(x)
problem = cp.Problem(objective, constraints)
problem.solve()
print("x.value = " , x.value)