我正在尝试在 JuMP 环境中实现以下约束:
@constraint(m, ((c*x) + (p*o)) + (r.*z) - d .== g')
不幸的是,我收到以下错误ERROR: MethodError: no method matching append
但是单独尝试元素乘法不会返回任何错误并将其正确地实现到模型中。
在这里,您有我正在使用的最小示例。
m = Model(solver = GLPKSolverLP());
np = 3; #number of products
c = [3 7 5;
6 5 7;
3 6 5;
-28 -40 -32];
g = [200 200 200 -1500];
n = length(g);
o = [1 1 1]';
@variable(m, x[1:np] >= 0);
@variable(m, d[1:n] >= 0);
@variable(m, z[1:n] >= 0);
@variable(m, r[1:n] >= 0);
@variable(m, p[1:n,1:np] >= 0);
@objective(m, Min, sum(d));
@constraint(m, ((c*x) + (p*o)) + (r.*z) - d .== g')