Modify/reasign objective function of a model in JuMP

I’m implementing a consensus ADMM model, and for that I wold like to iteratively solve two models, exchange information between them and solve them again with a modified objective function.

The problem I’m facing right now is that once the objective function is assigned, trying to re-assign it prompts an error, and as far as I know there is no method to delete the objective function as a workaround.

Any recomendations?

Just call @objective again.

model = Model()
@variable(model, x >= 1)
@objective(model, Min, 2x + 1)
@objective(model, Max, -x)

p.s. in future, read the first post of PSA: make it easier to help you and provide a minimal working example. It makes it much easier to provide help.

1 Like