# Declare two exceptions in an equation

**URL:** <https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [November 7, 2020, 9:11pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755 "2020-11-07T21:11:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlos](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@carlos](https://discourse.julialang.org/u/carlos)\
**Post date:** [November 7, 2020, 9:11pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755/1 "2020-11-07T21:11:49Z")

</div>

Hi, I’m trying to declare two exceptions in the following equation but it doesn’t work like this:

> e52[i=1:29,k=1:29;i != L,k != L], -lambdaVI[i] \<= M\*BCC[i,k]

---

<div class="post-metadata">

**Author:** ![AndiMD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andimd/32/6531_2.png) [@AndiMD](https://discourse.julialang.org/u/AndiMD)\
**Post date:** [November 7, 2020, 9:18pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755/2 "2020-11-07T21:18:37Z")

</div>

Hi!  
Could you provide more details, ideally a minimal working example?  
See also

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![carlos](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@carlos](https://discourse.julialang.org/u/carlos)\
**Post date:** [November 7, 2020, 9:38pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755/3 "2020-11-07T21:38:07Z")

</div>

Thanks for answer. For example the model could be likes this

> using JuMP  
> using CPLEX
> 
> ICC = Model(CPLEX.Optimizer)
> 
> M = 6e5  
> L = 1
> 
> @variables(ICC,begin  
> lambdaVI[1:29]  
> BCC[1:29,1:29], Bin  
> end)
> 
> @constraints(ICC,begin  
> e51[i=1:29;i != L], lambdaVI[i] \>= 0  
> e52[i=1:29,k=1:29;i != L,k != L], -lambdaVI[i] \<= M\*(BCC[i,k])  
> end)

e51 will generate equations for i=2:29 and I want it to do the same in e52 for i=2:29 and k=2:29. I know I can declare them like that, but what I want to do next is a loop changing L = 1:29.

---

<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:** [November 7, 2020, 10:45pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755/4 "2020-11-07T22:45:11Z")

</div>

Use binary logic:

```nohighlight
[i=1:29, k=1:29; (i != L) && (k != L)]

```

---

<div class="post-metadata">

**Author:** ![carlos](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@carlos](https://discourse.julialang.org/u/carlos)\
**Post date:** [November 7, 2020, 10:54pm UTC](https://discourse.julialang.org/t/declare-two-exceptions-in-an-equation/49755/5 "2020-11-07T22:54:40Z")

</div>

Thanks, it worked.
