Search code examples
juliajulia-jump

How to specify a variable in JuMP that can only be 0 or 1?


What is the syntax for specifying a variable in a JuMP optimization problem that can only be 0 or 1?

I am using the following code:

@variable(mod, X == 1 || 0)

but it is not working.


Solution

  • Write:

    @variable(mod, x, Bin)
    

    You might also want to checkout the the documentation for more examples.