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

Annotation of anonymous constr/var is nothing #65

Merged
merged 2 commits into from
Jul 20, 2021
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/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function register_decomposition(model::JuMP.Model)
# Link to the tree
tree = gettree(model)
tree === nothing && return
for (key, jump_obj) in model.obj_dict
for (_, jump_obj) in model.obj_dict
_annotate_elements!(model, jump_obj, tree)
end
return
Expand Down Expand Up @@ -122,7 +122,7 @@ function MOI.get(
tree === nothing && return nothing

conattr = get(dest.conattr, attribute, nothing)
conattr === nothing && return tree.root.master
conattr === nothing && return nothing # anonymous constraint
return get(conattr, ci, tree.root.master)
end

Expand All @@ -134,7 +134,7 @@ function MOI.get(
tree === nothing && return nothing

varattr = get(dest.varattr, attribute, nothing)
varattr === nothing && return tree.root.master
varattr === nothing && return nothing # anonymous variable
return get(varattr, vi, tree.root.master)
end

Expand Down
12 changes: 7 additions & 5 deletions test/dantzigwolfe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ function dummymodel3()
model = BD.BlockModel()
BD.@axis(A, 1:5)
B = 1:6
@variable(model, x[a in A, b in B], Int)
mast = @constraint(model, sum(x[a,b] for a in A, b in B) >= 5)
x = @variable(model, [a in A, b in B], Int) # anonymous variables
mast = @constraint(model, sum(x[a,b] for a in A, b in B) >= 5) # anonymous constraints
sp = @constraint(model, [a in A], sum(x[a,b] for b in B) == 1) # anonymous constraints
@objective(model, Min, sum(x[a,b] for a in A, b in B))
@dantzig_wolfe_decomposition(model, dec, A)
Expand Down Expand Up @@ -209,17 +209,19 @@ function test_dummy_model_decompositions()
@test MOI.get(model, BD.ObjectiveDualBound()) === nothing
end

@testset "Model with anonymous constraint" begin
@testset "Model with anonymous variables & constraints" begin
model, x, mast, sp, dec = dummymodel3()
try
JuMP.optimize!(model)
catch e
@test e isa NoOptimizer
end
x_annotation = BD.annotation(model, x[1,1])
@test x_annotation === nothing
mast_annotation = BD.annotation(model, mast)
test_annotation(mast_annotation, BD.Master, BD.DantzigWolfe, 1, 1)
@test mast_annotation === nothing # anonymous constraint
sp_annotation = BD.annotation(model, sp[1])
test_annotation(sp_annotation, BD.Master, BD.DantzigWolfe, 1, 1)
@test sp_annotation === nothing # anonymous constraint
end
return
end