Skip to content

Commit

Permalink
[DNM] add variables and bound in a single shot
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimg committed Oct 25, 2024
1 parent ee313be commit 4714a12
Showing 1 changed file with 16 additions and 0 deletions.
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(

Check warning on line 130 in src/Utilities/variables.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/variables.jl#L130

Added line #L130 was not covered by tests
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))

Check warning on line 137 in src/Utilities/variables.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/variables.jl#L135-L137

Added lines #L135 - L137 were not covered by tests
end
if upper_bound !== nothing
MOI.add_constraint(model, v, MOI.LessThan(upper_bound))

Check warning on line 140 in src/Utilities/variables.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/variables.jl#L139-L140

Added lines #L139 - L140 were not covered by tests
end
return v

Check warning on line 142 in src/Utilities/variables.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/variables.jl#L142

Added line #L142 was not covered by tests
end

0 comments on commit 4714a12

Please sign in to comment.