Reputation: 1
I am trying to get solution for variable x using cplex in Matlab , but I'm confused how to write the syntax since I wanna the solution x∈{a,b}.
For example, assume that I have this LP problem:
Maximize x1 + 2 x2 + 3 x3
Subject to
- x1 + x2 + x3 <= 20
x1 - 3 x2 + x3 <= 30
Bounds
0 <= x1 <= 40
0 <= x2
0 <= x3
Retrieved from: http://www-01.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cplex.help/CPLEX/MATLAB/topics/example_cplexlpex.html
But, in this problem, I wanna add the constraint x∈{20,30} s.t solution values are 20 or 30. How could I write the syntax for this additional constraint? I wanna use ctype, but ctype can only be used for 'I,B,S,N,C'.
Upvotes: 0
Views: 150
Reputation: 336
I'm not overly familiar with the capabilities cplex in Matlab, but if all else fails you can always define
x = 20 + 10*B,
where B is a binary variable. That way x can only take 2 values. This approach gets messy when you want more options though, such as
x \in {20, 23, 30, 103}.
Then you would have to define
x = 20*B_1 + 23*B_2 etc
sum_i (B_i) = 1.
It works, but your solution speed would deteriorate fast.
Upvotes: 1