linear programming - How to assign binary variable in AMPL in respect to another variable -
i have problem ampl modelling. can me how define binary variable u suppose equall 0 when variable x equall 0 , 1 when x different 0?
i trying use logical expressions solver working (cplex , minos) doesn't allow it.
my idea was:
subject to: u || x != u && x
take m 'big' constant such x < m holds, , assume x integer (or x >= 1 if x continuous). can use 2 constraints:
u <= x (if x=0, u=0) x <= m*u (if x>0, u=1) with u binary variable.
if x continuous , not greater 1, have adapt constraints above (for example, first constraint here not verified x=0.3 , u=1).
the general idea can (in many cases) replace logical constraints inequalities, using fact if a , b boolean variables, statement "a implies b" can written b>=a (if a=1, b=1).
Comments
Post a Comment