Skip to content

[Bridges] fix deleting variable in bridged objective #2147

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

Merged
merged 5 commits into from
Apr 19, 2023

Conversation

odow
Copy link
Member

@odow odow commented Apr 17, 2023

This is a bit of a weird case: if you delete a variable that was an objective, does the type of the objective change, or do we remove one of the objective rows?

I obviously thought so when writing the tests

function test_multiobjective_vector_of_variables_delete(
model::MOI.ModelLike,
::Config{T},
) where {T}
F = MOI.VectorOfVariables
@requires MOI.supports(model, MOI.ObjectiveFunction{F}())
x = MOI.add_variables(model, 2)
f = MOI.VectorOfVariables(x)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(model, MOI.ObjectiveFunction{F}(), f)
@test MOI.get(model, MOI.ObjectiveFunctionType()) == F
@test MOI.get(model, MOI.ObjectiveFunction{F}()) == f
MOI.delete(model, x[1])
@test MOI.get(model, MOI.ObjectiveFunction{F}()) ==
MOI.VectorOfVariables([x[2]])

but I missed the case that this could also be bridged.

@odow odow mentioned this pull request Apr 17, 2023
5 tasks
@blegat
Copy link
Member

blegat commented Apr 17, 2023

This is a bit of a weird case: if you delete a variable that was an objective, does the type of the objective change, or do we remove one of the objective rows?

You remove the row, that's consistent with what happens in a VectorOfVariables-in-Nonnegatives constraint

@blegat
Copy link
Member

blegat commented Apr 18, 2023

Maybe create a utility function that is called with discard and isequal(vi) ?

@odow odow merged commit f7a7c0e into master Apr 19, 2023
@odow odow deleted the od/fix-delete-bridge-vov branch April 19, 2023 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants