Gurobi - 有没有办法访问惰性约束池?

Gurobi - Is there a way to access the lazy constraints pool?

我已搜索 all Gurobi's PDF documentation,但找不到我要搜索的内容。我想知道在搜索过程中是否有办法访问Gurobi中的惰性约束池?

在 MIP_NODE 中,在整数节点 GRB_CB_MIPSOL 的回调期间,我需要访问所有先前生成的惰性约束并将它们应用于某些值。我找不到访问惰性约束池的方法。我目前的解决方法是将我生成的所有惰性约束存储在一个数组中,但这对我来说听起来很糟糕,尤其是在 RAM 方面。如果我们可以直接访问它们,那么存储它们是很可惜的,因为我们知道 Gurobi 也存储它们。

            con = @build_constraint(λ ≥ sum([2(1-y[i])α[i] for i in V]) +
                sum([(x[mima(β[j][1],j)] + x[mima(β[j][2],j)] - 1)rp[mima(β[j][1],β[j][2])] for j in tildeV if length(β[j]) > 0]) - sum([y[j]γ[i,j] for i in V, j in V if i != j]))
                MOI.submit(m, MOI.LazyConstraint(cb_data), con)

                    function RHS_opt_cut(x,y)
                        sum_β = 0
                        for j in tildeV
                            if length(β[j]) > 0
                                sum_β += (x[mima(β[j][1],j)...] + x[mima(β[j][2],j)...] - 1)rp[mima(β[j][1],β[j][2])]
                            end
                        end
                        sum([2(1-y[i])α[i] for i in V]) + sum_β - sum([y[j]γ[i,j] for i in V, j in V if i != j])
                    end

                    push!(RHS_optimality_cuts, RHS_opt_cut)

前面的代码,测试所有之前存储的RHS

            λ_two_opt = 0.
                for RHS in RHS_optimality_cuts
                    if RHS(x_two_opt, ŷ) > λ_two_opt
                        λ_two_opt = RHS(x_two_opt, ŷ)
                    end
                end

不,我认为没有办法获取已添加的惰性约束列表。维护列表是最简单的解决方案。

但是你应该非常小心,仅仅因为你之前添加了一个约束,并不意味着当前正在使用该约束,或者该解决方案满足所有先前的惰性约束。唯一的保证是最终解决方案将尊重所有添加的惰性约束。

p.s., 如果你使用的是 Julia,你可以在 C API 中调用任何东西:https://www.gurobi.com/documentation/9.5/refman/c_api_details.html