Accessing dual variables

Hi @heiwie, the key thing to remember is that you are not restricted to the data structures given by default in JuMP; you can (and often should) construct things that make sense for your problem.

I would do:

lattice_constraints = Dict()
for (m, parentnode) in enumerate(lattice_edges[2])
    lattice_constraints[m] = Dict()
    for (n, childnode) in enumerate(parentnode)
        lattice_constraints[m][n] = @constraint(
            model,
            B[3] * w_mB[lattice_nodes[2][m]] + eta[childnode] + (prices[2, n] - cost) * x[childnode] >= 0
        )
    end
end
lattice_constraints

or

lattice_constraints = Dict()
for (m, parentnode) in enumerate(lattice_edges[2])
    for (n, childnode) in enumerate(parentnode)
        lattice_constraints[m => n] = @constraint(
            model,
            B[3] * w_mB[lattice_nodes[2][m]] + eta[childnode] + (prices[2, n] - cost) * x[childnode] >= 0
        )
    end
end
lattice_constraints
2 Likes