Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] add variables and bound in a single shot #2565

Closed
wants to merge 1 commit into from
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 @@
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
Loading