Cannot set an array of constraints @constraint, getting an error

Hi, I want to create a constraint in my model where I have np particles with a mass m at position x,y as variables. I want to set the constraint that the mass of particles is >0 and I wrote the code below but I get an error

my_model = Model(Ipopt.Optimizer)
set_optimizer_attribute(my_model, “print_level”, 0)

Define the variables for the m, x and y coordinates of each particle

@variables(my_model, begin
m[1:np]
x[1:np]
y[1:np]
end)

set mass constraint to be >0

@constraint(my_model,c[i=1:np], m[i]>0)

The error I am getting is the following
LoadError: At /Users/Greg/Documents/OneDrive/Documents/Julia Code/Scalar points optimizer:32: @constraint(my_model, c[i = 1:np], m[i] > 0): Unrecognized sense >

Any help super appreciated. Cheers, Greg

You cannot use strict inequalities in JuMP. You need to use >=. I should improve this error message.

Edit: Fix error message for unrecognized sense by odow · Pull Request #3311 · jump-dev/JuMP.jl · GitHub

1 Like

Thank you! I’ll adjust my constraint accordingly with some epsilon boundary. Have a great day

1 Like