# Nonlinear constraints in SDDP

**URL:** https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626
**Category:** Optimization (Mathematical)
**Tags:** jump, sddp
**Created:** [October 31, 2023, 6:11pm UTC](https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626 "2023-10-31T18:11:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sorooshsa](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Sorooshsa](https://discourse.julialang.org/u/Sorooshsa)
#### Post date: [October 31, 2023, 6:11pm UTC](https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626/1 "2023-10-31T18:11:41Z")

</div>

Hi,  
I have read the similar topics here:

> [@SDDP: how to use Juniper.jl for optimizer](https://discourse.julialang.org/t/sddp-how-to-use-juniper-jl-for-optimizer/82719/4):
>
> You might want to revisit the theory behind SDDP.jl: [Introductory theory · SDDP.jl](https://odow.github.io/SDDP.jl/stable/tutorial/theory/21_theory_intro/) It approximates convex functions, so things like 1 / level.in and sqrt(level.in) or nonlinear equality constraints will not work. SDDP.jl lets you formulate nonlinear models, because in some cases you can formulates and solve convex nonlinear problems, but if you write a non-convex constraint, SDDP.jl will give you a suboptimal answer. If you don’t have integer variables, try solving it with Ipopt, but there is …

But my case is a bit different.  
I have a constraint with this formula:  
gen \<= efficiency\*water\_discharged  
gen is a continuous control variable,  
efficiency is a continuous state variable, and  
water\_discharged is the other continuous control variable.  
As we can see this constraint is non-linear but all of the variables are continuous.  
I know SDDP.jl can sometimes deal with non-linearity.  
The other possibility is to linearize the constraint by defining binary state variables.

So, my question is that which one is preferable? Non-linear constraints with continuous variables vs Linear constraints with mixed of binary state variables and continuous controls in terms of optimality and running time?

---

<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: [October 31, 2023, 7:06pm UTC](https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626/2 "2023-10-31T19:06:18Z")

</div>

SDDP.jl assumes that the problem is convex.

> Non-linear constraints with continuous variables

This will make the problem non-convex, so you will end up with a suboptimal policy, and it can be very bad.

> vs Linear constraints with mixed of binary state variables and continuous controls in terms of optimality and running time?

Integrality is also non-convex, so you will also end up with a suboptimal policy, but it’s usually better than the bilinearity.

The reason is that we can solve linear problems with binary variables to optimality. In general, we cannot do that for `x * y` (except if you use Gurobi, and even then it is hard).

> So, my question is that which one is preferable?

From the perspective of SDDP, neither. We cannot solve this problem to optimality, so you should be very cautious and treat it as a reasonable heuristic.

---

<div class="post-metadata">

### Author: ![Sorooshsa](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Sorooshsa](https://discourse.julialang.org/u/Sorooshsa)
#### Post date: [October 31, 2023, 8:08pm UTC](https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626/3 "2023-10-31T20:08:51Z")

</div>

Thank you.  
I got it.  
Based on your answer, I have one more question.  
As you said, non-linear constraints with continuous variables will lead to non-convexity. This is why SDDP is not a good choice for these kinds of problems. However, what about constraints that aren’t linear but still give convex sets by definition? My exact question is which step of SDDP algorithm or (SDDP.jl) makes us keep all the constraints linear.

---

<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: [October 31, 2023, 8:14pm UTC](https://discourse.julialang.org/t/nonlinear-constraints-in-sddp/105626/4 "2023-10-31T20:14:53Z")

</div>

> However, what about constraints that aren’t linear but still give convex sets by definition?

These are okay.

> My exact question is which step of SDDP algorithm or (SDDP.jl) makes us keep all the constraints linear.

See [Introductory theory · SDDP.jl](https://sddp.dev/stable/explanation/theory_intro/)
