# How to write conditional expression using JuMP

**URL:** https://discourse.julialang.org/t/how-to-write-conditional-expression-using-jump/83106
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [June 21, 2022, 7:56am UTC](https://discourse.julialang.org/t/how-to-write-conditional-expression-using-jump/83106 "2022-06-21T07:56:46Z")
**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: [June 21, 2022, 9:03am UTC](https://discourse.julialang.org/t/how-to-write-conditional-expression-using-jump/83106/2 "2022-06-21T09:03:55Z")

</div>

Take a read of [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757). It’s easier to help if you can provide a reproducible example that someone can copy-paste. If you don’t have that, then simplify the problem as much as possible and provide what you want to do in math. Your question is a little confusing, because there is a lot of other things going on.

What are your decision variables? What is the data? What is the math formulation you’re trying to achieve? I don’t see the piecewise linearity ([Piecewise linear function - Wikipedia](https://en.wikipedia.org/wiki/Piecewise_linear_function)), only two nonlinear constraints?

You should introduce `flow` and `level` as decision variables. Then you’ll need to add the constraints you have using `@NLconstraint`. You can’t use `@constraint` or `@expression` because you have a `1 / level` term in there.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-write-conditional-expression-using-jump/83106)._
