# Constraints not respected properly

**URL:** <https://discourse.julialang.org/t/constraints-not-respected-properly/98249>\
**Category:** New to Julia\
**Created:** [May 3, 2023, 12:34pm UTC](https://discourse.julialang.org/t/constraints-not-respected-properly/98249 "2023-05-03T12:34:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gianmarco\_Montillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gianmarco_montillo/32/49458_2.png) [@Gianmarco\_Montillo](https://discourse.julialang.org/u/Gianmarco_Montillo)\
**Post date:** [May 3, 2023, 12:34pm UTC](https://discourse.julialang.org/t/constraints-not-respected-properly/98249/1 "2023-05-03T12:34:55Z")

</div>

Hello! I am quite new to this world so I hope someone here can help me understand my problem.  
I want to pass a mathematical model formed by 3 arrays of different dimensions (e.g. X, Y, Z), I want these arrays to respect some constraints in the specific i want:  
-sum(X) == 450;  
-sum(Y) == 800;  
-sum(Z) == 650;  
-sum(X)+sum(Y)+sum(Z) \<= 1600

I know that all the constraints cannot be respected simultaneously, I want to maximize the sum of the 3 arrays, considering that if sum(array) is not equal to the declared value, then its values will all be 0.  
In this case for example, i want the model to discard X given that sum(Y)+sum(Z) is the maximum obtainable respecting the constraints.

First I thought the solver would handle the case by itself but by my surprise it doesn’t.  
Can someone please help me?

Thank you in advance 🙂
