# Modify/reasign objective function of a model in JuMP

**URL:** <https://discourse.julialang.org/t/modify-reasign-objective-function-of-a-model-in-jump/36363>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [March 22, 2020, 8:55pm UTC](https://discourse.julialang.org/t/modify-reasign-objective-function-of-a-model-in-jump/36363 "2020-03-22T20:55:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martincornejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martincornejo/32/13436_2.png) [@martincornejo](https://discourse.julialang.org/u/martincornejo)\
**Post date:** [March 22, 2020, 8:55pm UTC](https://discourse.julialang.org/t/modify-reasign-objective-function-of-a-model-in-jump/36363/1 "2020-03-22T20:55:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 22, 2020, 9:19pm UTC](https://discourse.julialang.org/t/modify-reasign-objective-function-of-a-model-in-jump/36363/2 "2020-03-22T21:19:53Z")

</div>

Just call `@objective` again.

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

```

p.s. in future, read the first post of [Please read: make it easier to help you - #8](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/8) and provide a minimal working example. It makes it much easier to provide help.
