diff --git a/src/decomposition.jl b/src/decomposition.jl index 973cf04..b0e00e3 100644 --- a/src/decomposition.jl +++ b/src/decomposition.jl @@ -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 @@ -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 @@ -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 diff --git a/test/dantzigwolfe.jl b/test/dantzigwolfe.jl index 727df9e..a9df99a 100644 --- a/test/dantzigwolfe.jl +++ b/test/dantzigwolfe.jl @@ -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) @@ -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