伙计们,我编写了代码并收到以下错误:@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
```
伙计们,我编写了代码并收到以下错误:@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
```
您使用的是在 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