Skip to content

Commit

Permalink
Variable bounds instead of affine constraint
Browse files Browse the repository at this point in the history
`@constraint(model, 0 <= x <= 1)` is transferred to the solver as a `ScalarAffineFunction`-in-`Interval` constraint.
Unless the solver has a presolve that detects that this is a variable bound, it might not see that these are variable bounds and hence this could negatively affect performance.
  • Loading branch information
blegat authored Apr 5, 2024
1 parent 2ed322d commit 96cd70c
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/decision_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ end

function path_compatibility_variable(model::Model, base_name::String="")
# Create a path compatiblity variable
x = @variable(model, base_name=base_name)

# Constraint on the lower and upper bounds.
@constraint(model, 0 x 1.0)

return x
return @variable(model, base_name=base_name, lower_bound = 0, upper_bound = 1)
end

struct PathCompatibilityVariables{N} <: AbstractDict{Path{N}, VariableRef}
Expand Down

0 comments on commit 96cd70c

Please sign in to comment.