Hello,
I need help to implement a constraint.
The goal is to assign students to courses. Some courses can have a maximum of 8 students, others can have a maximum of 12.
I first wrote my constraint like this:
For j in 1:s
if (ws2[j+1,3]==1)
@constraint(TB, contrainte2a[j=1:s], sum(x[i,j] for i in 1:e) <= 8)
else
@constraint(TB, contrainte2b[j=1:s], sum(x[i,j] for i in 1:e) <= 12)
end
end
The “ws2[j+1,3]==1” refers to a column in an excel table.
I get this error message:
LoadError: An object of name contrainte2a is already attached to this model. If this
is intended, consider using the anonymous construction syntax, e.g.,
`x = @variable(model, [1:N], ...)` where the name of the object does
not appear inside the macro.
Alternatively, use `unregister(model, :contrainte2a)` to first unregister
the existing name from the model. Note that this will not delete the
object; it will just remove the reference at `model[:contrainte2a]`.
I think the error comes from putting a constraint in an if.
Does anyone know how to fix this problem?
Thank you in advance for your help