Wikunia / ConstraintSolver.jl

ConstraintSolver in Julia: Blog posts ->
https://opensourc.es/blog/constraint-solver-1
MIT License
136 stars 13 forks source link

Allow binary variables to be evaluated as true or false #250

Closed Wikunia closed 2 years ago

Wikunia commented 3 years ago

Currently one often has to write

@constraint(m, bool_var == 1 || other_bool_var == 1)

instead of

@constraint(m, bool_var || other_bool_var)

one should also support

@constraint(m, !bool_var || other_bool_var)

I think this is fine when bool_var is binary even though there is no truthy and falsy in Julia.

One needs to create some JuMP parse functions for this and create a new linear equal to constraint and flag it as check_for_binary_variable to later check if it's a binary and otherwise throw an error.