# Check a variable within a range with a binary variable [closed]

I have a value, a, it can be any value from 0 to 1. In an integer linear program, how can I formulate a constraint that uses a binary variable, y, to determine whether a is within a range of 0 and 1 or not.

Thanks

## closed as unclear what you're asking by xskxzr, Evil, David Richerby, Discrete lizard♦Mar 4 at 9:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• I don't understand what you're asking. You say x can be any value from 0 to 1; if so, you already know that a is in that range -- there is nothing to determine. Please edit the question to explain more clearly what you're trying to do. Thank you! – D.W. Mar 1 at 22:38
• "it can be any value from 0 to 1", shouldn't a variable in an integer linear program only have integer values? – xskxzr Mar 2 at 6:34
• @D.W. I think the point is that, in valid solutions, the value of the variable is in $[0,1]$ and the asker wants constraints that ensure it really is in that range. But, still, with an integer linear program, the variable's value is either $0$ or $1$, so I'm not sure what's really going on, here. – David Richerby Mar 3 at 13:46

If I understand corectly, you want to formulate a system of linear constraints on a real variable $$a$$ and a $$\{0,1\}$$-variable $$y$$ such that the solutions are given by $$[0,1]\times\{1\} \bigcup [1,\infty)\times \{0\}.$$
This is impossible. No linear constraint can put an upper bound on $$a$$ for some values of $$y$$ without putting an upper bound on $$a$$ for all values of $$y$$.