伙计们,我写了代码并得到以下错误:@constraint未定义。我怎么了如何解决?谢谢
@constraintref restrição[1:2]
for j=1:2
@constraint(m, restrição[j], sum(A[j,i]*x[i] for i=1:3) <= b[j])`
end
```
答案 0 :(得分:1)
您使用的是在JuMP 0.18中有效的旧语法(有关更多详细信息,请参见链接)
从今天起,您可以只使用赋值运算符代替@constraintref
宏,您的代码可能如下所示:
using GLPK
m = Model(with_optimizer(GLPK.Optimizer))
@variable(m, x[1:5] >= 0)
myCons = Vector{ConstraintRef}(undef, 5)
for i = 1:5
myCons[i] = @constraint(m, x[i] >= i)
end