Message Boards Message Boards

Set a variable to Binary?

GROUPS:

I want to optimize a function, with a constraint that requires a variable to be 0 or 1, not other value. How do I do that?

Depending on how I do this it may converge or not.

Thanks!

POSTED BY: Juan David
Answer
2 months ago

Hard to respond with no code showing an example. A guess: if the variable is x then add constraints 0<=x<=1 and Element[x,Integers].

POSTED BY: Daniel Lichtblau
Answer
2 months ago

Group Abstract Group Abstract