Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Utilities/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,19 @@ function get_bounds(
bounds_cache[x] = (l, u)
return (l, u)
end

# fallback
function add_variable_and_bounds(
model::MOI.ModelLike,
lower_bound,
upper_bound,
)
v = MOI.add_variable(model)
if lower_bound !== nothing
MOI.add_constraint(model, v, MOI.GreaterThan(lower_bound))
end
if upper_bound !== nothing
MOI.add_constraint(model, v, MOI.LessThan(upper_bound))
end
return v
end