QuadraticModels.jl icon indicating copy to clipboard operation
QuadraticModels.jl copied to clipboard

Update bounds in qp without creating a new model?

Open nurkanovic opened this issue 7 months ago • 1 comments

Hi,

If I use a QuadraticModel for managing and storing data of a QP in an SQP loop I would also need to update not just the matrices H and A, which is possible, bout also all bounds (e.g. l <= c(x) <u linearized reads as l - c(x_k) <= J(x_k)' d <= u - c(x_k), where d is the decision var., x_k the lin. point). However, I am not allowed to change anything from qp.meta.* as this is immutable, hence I cannot update the full QP data.

One could construct in every iteration just a new model, but this seems quite inefficient. Are there known workarounds or ways to change lcon, ucon, lvar and uvar as well?

Thanks!

nurkanovic avatar Apr 07 '25 20:04 nurkanovic

In general, you can use broadcast for these:

nlp.meta.lvar .= new_lvar # same for lcon
nlp.meta.uvar .= new_uvar # same for ucon

tmigot avatar Apr 08 '25 20:04 tmigot