# Forbidden range for a variable of a LP

**URL:** <https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071>\
**Category:** Optimization (Mathematical)\
**Created:** [September 23, 2019, 12:49pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071 "2019-09-23T12:49:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [September 23, 2019, 12:49pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/1 "2019-09-23T12:49:53Z")

</div>

I would like to express a **linear program** having a variable that can only be greater or equal than a constant P or equal to 0. Like :

```julia
x≥P or x=0

```

I know I could express it as a `mixed integer problem` but I really need to stay in a pure LP.  
Anyone know a kind of trick to workaround it on JuMP?

---

<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:** [September 23, 2019, 1:21pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/2 "2019-09-23T13:21:43Z")

</div>

Unfortunately no. It is not LP representable.

---

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [September 23, 2019, 2:16pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/3 "2019-09-23T14:16:18Z")

</div>

ok, thanks. Do you know if there’s the same limitation for a constraint like that:

```julia
if x1 == 0 
then x2==0

```

where `x1` and `x2` are variables of a LP problem ?  
Thanks.

---

<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:** [September 23, 2019, 3:25pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/4 "2019-09-23T15:25:23Z")

</div>

The only way to achieve something like that is as follows:

```nohighlight
model = Model()
@variable(model, x1 >= 0)
@variable(model, x2 >= 0)
@constraint(model, x2 <= x1)

```

In general, `if <condition>` type constraints are not LP representable. You may want to consult a linear programming textbook, e.g., [Textbook: Introduction to Linear Optimization](http://www.athenasc.com/linoptbook.html).

---

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [September 23, 2019, 4:05pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/5 "2019-09-23T16:05:27Z")

</div>

I see. The only problem is that I can maybe have a x1\>=x2 according to the project. So,I ended up with the same limitation of the LP problem 😕

---

<div class="post-metadata">

**Author:** ![jayce\_ram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayce_ram/32/3977_2.png) [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Post date:** [October 3, 2019, 10:37am UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/6 "2019-10-03T10:37:52Z")

</div>

> [@jayce\_ram](#):
>
> if x1 == 0 then x2==0

Do you know how I could express it by using the workaround with binary variables and a large number M? I have tried to think but I don’t have a good math background…x1 and x2 are not binary.

---

<div class="post-metadata">

**Author:** ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)\
**Post date:** [October 3, 2019, 3:01pm UTC](https://discourse.julialang.org/t/forbidden-range-for-a-variable-of-a-lp/29071/7 "2019-10-03T15:01:29Z")

</div>

Yes, but this question is not related to Julia or JuMP.  
The [OR StackExchange](https://or.stackexchange.com/) will have an answer to these kinds of modeling questions.
