I want to name different kinds of constraints for enhancing readability and debugging, what’s the right syntax to do it with @constraints, I know this is easy for @constraint(, base_name = “Name”). Below is my code with errors.

‘’’

using JuMP, HiGHS

M = Model(HiGHS.Optimizer)

I = [1, 2, 3]

J = [1, 2, 3]

@variable(M, x[I, J] ≥ 0)

@constraints(M, begin

[i in I], sum(x[i, :]) <= 5, base_name = “name1”

[j in J], sum(x[:, j]) >= 6, base_name = “name2”

end)

‘’’

I use something like this:

```
@constraint( M, name1[i in I], sum(x[i, :]) <= 5)
@constraint( M, name2[j in J], sum(x[:, j]) >= 6)
```

(Note: I did not test it for your case)

2 Likes

it works with @constraints syntax, thx!

1 Like

Keyword arguments in the plural macros need additional `()`

around them:

```
using JuMP, HiGHS
M = Model(HiGHS.Optimizer)
I = [1, 2, 3]
J = [1, 2, 3]
@variable(M, x[I, J] ≥ 0)
@constraints(M, begin
[i in I], sum(x[i, :]) <= 5, (base_name = “name1”)
[j in J], sum(x[:, j]) >= 6, (base_name = “name2”)
end)
```

I’ll update the documentation.

1 Like

Thx！