# Constraints using a matrix built from external function

**URL:** <https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [November 15, 2021, 12:56pm UTC](https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493 "2021-11-15T12:56:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chupin](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@chupin](https://discourse.julialang.org/u/chupin)\
**Post date:** [November 15, 2021, 12:56pm UTC](https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493/1 "2021-11-15T12:56:41Z")

</div>

Hi,  
To build a constraint from a NxM matrix variable (denoted by h), I need to build another NxM matrix so I wrote an external function `convexity(h)`. I tried this syntax (partial code):

```julia
    function convexity(h)
        #...
       return output
    end
    #... 
    @variables(
        model,
        begin
        h[1:N,1:M]<=b/2.0
        end
    )
    @NLobjective( # max perimeter
        model,
        Max,
        aireSurface(h)
    )
    @constraint(
        # convexity
        model,
        convexity(h) .> 0
    )

```

Unfortunately, I get the error: `@constraint(model, convexity(h) .> 0)`: Unrecognized sense \>`. What did I do wrong?

---

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [November 15, 2021, 3:14pm UTC](https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493/2 "2021-11-15T15:14:34Z")

</div>

replace `.>` with `.>=`

---

<div class="post-metadata">

**Author:** ![chupin](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@chupin](https://discourse.julialang.org/u/chupin)\
**Post date:** [November 15, 2021, 9:02pm UTC](https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493/3 "2021-11-15T21:02:15Z")

</div>

Thank you but I want every term of the matrix to be \>0 and not \>=0 (sorry I’m new with both julia and 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:** [November 15, 2021, 9:29pm UTC](https://discourse.julialang.org/t/constraints-using-a-matrix-built-from-external-function/71493/4 "2021-11-15T21:29:19Z")

</div>

You cannot use strict inequalities in JuMP because of floating point. If you want it non-zero, use `.>= 0.0001` or similar.
