# Naming constraints error

**URL:** <https://discourse.julialang.org/t/naming-constraints-error/97959>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [April 26, 2023, 5:33pm UTC](https://discourse.julialang.org/t/naming-constraints-error/97959 "2023-04-26T17:33:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![irene\_ub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/irene_ub/32/49289_2.png) [@irene\_ub](https://discourse.julialang.org/u/irene_ub)\
**Post date:** [April 26, 2023, 5:33pm UTC](https://discourse.julialang.org/t/naming-constraints-error/97959/1 "2023-04-26T17:33:11Z")

</div>

Hello,  
I have an optimization model, for which I’m trying to give names to its constraints so that I can write them to an lp file and find them easily. However, I’m having some trouble.  
The constraint specifically that I’m trying to name looks like this:

@constraint(m, [ms in millStorageDayIndexes, pm in prodMills], millStorageDayLevel[ms] == pm.amountDay0)

where millStorageDayIndexes and prodMIills are both tuples with multiple fields each. I’ve tried to put a name, in the following way:

@constraint(m, millStorageConst[ms in millStorageDayIndexes, pm in prodMills], millStorageDayLevel[ms] == pm.amountDay0)

but I get the error: ERROR: Gurobi Error 10003: Name too long (maximum name length is 255 characters)  
which I understand corresponds to the fact that the tuples used as indexes are too long to be a name.

Is there anyway I can choose specific fields of the tuple to use for the name, instead of the whole tuple, or anyother way of giving them a name?

---

<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:** [April 26, 2023, 10:57pm UTC](https://discourse.julialang.org/t/naming-constraints-error/97959/2 "2023-04-26T22:57:36Z")

</div>

Hi @irene_ub, welcome to the forum 😄

Here’s an error that I don’t see often. Typically, people don’t have such long names!

You can change the name of a constraint: [Constraints · JuMP](https://jump.dev/JuMP.jl/dev/manual/constraints/#Constraint-names)

Perhaps something like this:

```julia
@constraint(m, millStorageConst[ms in millStorageDayIndexes, pm in prodMills], millStorageDayLevel[ms] == pm.amountDay0)
for con in millStorageConst
    set_name(con, name(con)[1:255])
end

```

I’ll open an issue in Gurobi.jl so we don’t run into this issue in future.

But it might be easier just to disable passing the names to Gurobi:

> **[Performance tips · JuMP](https://jump.dev/JuMP.jl/dev/tutorials/getting_started/performance_tips/#Disable-string-names)**
>
> Documentation for JuMP.

```plaintext
using JuMP, Gurobi
model = Model(Gurobi.Optimizer)
set_string_names_on_creation(model, false)

```
