Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -815,15 +815,15 @@
# delete any derivative constraints associated with this derivative
delete_derivative_constraints(dref)
# delete associated point variables and mapping
for index in _point_variable_dependencies(dref)
for index in copy(_point_variable_dependencies(dref))

Check warning on line 818 in src/derivatives.jl

View check run for this annotation

Codecov / codecov/patch

src/derivatives.jl#L818

Added line #L818 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# delete associated semi-infinite variables and mapping
for index in _semi_infinite_variable_dependencies(dref)
for index in copy(_semi_infinite_variable_dependencies(dref))

Check warning on line 822 in src/derivatives.jl

View check run for this annotation

Codecov / codecov/patch

src/derivatives.jl#L822

Added line #L822 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# delete associated derivative variables and mapping
for index in _derivative_dependencies(dref)
for index in copy(_derivative_dependencies(dref))

Check warning on line 826 in src/derivatives.jl

View check run for this annotation

Codecov / codecov/patch

src/derivatives.jl#L826

Added line #L826 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
return
Expand Down
6 changes: 3 additions & 3 deletions src/infinite_variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -815,15 +815,15 @@
end
end
# delete associated point variables and mapping
for index in _point_variable_dependencies(vref)
for index in copy(_point_variable_dependencies(vref))

Check warning on line 818 in src/infinite_variables.jl

View check run for this annotation

Codecov / codecov/patch

src/infinite_variables.jl#L818

Added line #L818 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# delete associated semi-infinite variables and mapping
for index in _semi_infinite_variable_dependencies(vref)
for index in copy(_semi_infinite_variable_dependencies(vref))

Check warning on line 822 in src/infinite_variables.jl

View check run for this annotation

Codecov / codecov/patch

src/infinite_variables.jl#L822

Added line #L822 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# delete associated derivative variables and mapping
for index in _derivative_dependencies(vref)
for index in copy(_derivative_dependencies(vref))

Check warning on line 826 in src/infinite_variables.jl

View check run for this annotation

Codecov / codecov/patch

src/infinite_variables.jl#L826

Added line #L826 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
return
Expand Down
2 changes: 1 addition & 1 deletion src/measures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@
end
end
# delete associated derivative variables and mapping
for index in _derivative_dependencies(mref)
for index in copy(_derivative_dependencies(mref))

Check warning on line 1444 in src/measures.jl

View check run for this annotation

Codecov / codecov/patch

src/measures.jl#L1444

Added line #L1444 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# Update that the variables used by it are no longer used by it
Expand Down
2 changes: 1 addition & 1 deletion src/scalar_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@
# delete dependence of measures on pref
_update_measures(model, gvref)
# delete any derivatives that use pref
for index in _derivative_dependencies(pref)
for index in copy(_derivative_dependencies(pref))

Check warning on line 1722 in src/scalar_parameters.jl

View check run for this annotation

Codecov / codecov/patch

src/scalar_parameters.jl#L1722

Added line #L1722 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# update constraints in mapping to remove the parameter
Expand Down
2 changes: 1 addition & 1 deletion src/semi_infinite_variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@
filter!(e -> e != JuMP.index(vref), _semi_infinite_variable_dependencies(ivref))
# delete associated derivative variables and mapping
model = JuMP.owner_model(vref)
for index in _derivative_dependencies(vref)
for index in copy(_derivative_dependencies(vref))

Check warning on line 815 in src/semi_infinite_variables.jl

View check run for this annotation

Codecov / codecov/patch

src/semi_infinite_variables.jl#L815

Added line #L815 was not covered by tests
JuMP.delete(model, dispatch_variable_ref(model, index))
end
# remove the lookup entry
Expand Down
2 changes: 1 addition & 1 deletion src/variable_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@
_delete_variable_dependencies(vref)
gvref = GeneralVariableRef(model, JuMP.index(vref))
# remove from measures if used
for mindex in _measure_dependencies(vref)
for mindex in copy(_measure_dependencies(vref))

Check warning on line 1104 in src/variable_basics.jl

View check run for this annotation

Codecov / codecov/patch

src/variable_basics.jl#L1104

Added line #L1104 was not covered by tests
mref = dispatch_variable_ref(model, mindex)
func = measure_function(mref)
data = measure_data(mref)
Expand Down
4 changes: 4 additions & 0 deletions test/deletion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ end
@variable(m, 0 <= x <= 1, Infinite(par), Bin)
@variable(m, y == 1, Infinite(par), Int)
@variable(m, x0, Point(x, 0))
@variable(m, xf, Point(x, 1))
var = build_variable(error, x, Dict{Int, Float64}(1 => 0.5), check = false)
rv = add_variable(m, var)
data = TestData(par, 0, 1)
Expand All @@ -570,6 +571,7 @@ end
@test InfiniteOpt._infinite_variable_dependencies(par) == [index(y)]
@test !is_valid(m, rv)
@test !is_valid(m, x0)
@test !is_valid(m, xf)
@test !is_valid(m, d1)
@test !haskey(InfiniteOpt._data_dictionary(m, InfiniteVariable), JuMP.index(x))
@test !is_valid(m, con3)
Expand Down Expand Up @@ -604,6 +606,7 @@ end
d2 = @deriv(y, par^2)
d3 = @deriv(d1, par2)
@variable(m, dx0, Point(d1, 0, 0))
@variable(m, dxf, Point(d1, 1, 1))
var = build_variable(error, d1, Dict{Int, Float64}(1 => 0.5), check = false)
rv = add_variable(m, var)
data = TestData(par, 0, 1)
Expand All @@ -625,6 +628,7 @@ end
@test InfiniteOpt._derivative_dependencies(par) == [index(d2)]
@test !is_valid(m, rv)
@test !is_valid(m, dx0)
@test !is_valid(m, dxf)
@test !is_valid(m, d3)
@test !is_valid(m, cref)
@test !is_valid(m, con3)
Expand Down
Loading