# Problem with implementing the objective function with minimum and maximum functions simultaneously!

**URL:** <https://discourse.julialang.org/t/problem-with-implementing-the-objective-function-with-minimum-and-maximum-functions-simultaneously/72917>\
**Category:** Optimization (Mathematical)\
**Created:** [December 10, 2021, 11:55pm UTC](https://discourse.julialang.org/t/problem-with-implementing-the-objective-function-with-minimum-and-maximum-functions-simultaneously/72917 "2021-12-10T23:55:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [December 11, 2021, 12:42am UTC](https://discourse.julialang.org/t/problem-with-implementing-the-objective-function-with-minimum-and-maximum-functions-simultaneously/72917/2 "2021-12-11T00:42:28Z")

</div>

To model `min { max_{t in T} f(t)}`, you can use the trick

```nohighlight
T = 3
model = Model()
@variable(model, f_t[1:T])
@variable(model, f_t_max)
# Assume f_t[t] is defined by other constraints
@constraint(model, [t=1:T], f_t_max >= f_t[t])
@objective(model, Min, f_t_max)

```

you can use that for your two `max` terms. Then the `-min f(x)` term can be converted into `max -f(x)`.

If you get stuck, read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) and then provide an example of the JuMP code you are working on.

---

_[View the full topic](https://discourse.julialang.org/t/problem-with-implementing-the-objective-function-with-minimum-and-maximum-functions-simultaneously/72917)._
