当我运行下面的Julia代码时:
using Convex
using DataFrames
using SCS
using JuMP
dim = 5
A = rand(dim,dim);
B = rand(dim,dim);
m = Model(solver=SCSSolver(max_iters=5000,eps=1e-4));
@variable(m,X[i=1:dim,j=1:dim]);
@objective(m,Min, vecnorm(A*X'-X'*B) + vecnorm(X*A-B*X) + lmda*vecnorm(I-X));
for i=1:dim
@constraint(m,sum(X[i,:]) == 1);
for j=1:dim
@constraint(m,sum(X[:,j] == 1);
@constraint(m, X >= 0);
@constraint(m, X <= 1);
status = solve(m);
P = getvalue(X);
if status == :Infeasible
error("No solution found!")
else
println("Objective Value: ", getobjectivevalue(m));
println("P: ", P);
我收到错误:
ERROR: LoadError: MethodError: no method matching +(::JuMP.GenericNormExpr{2,Float64,JuMP.Variable}, ::JuMP.GenericNormExpr{2,Float64,JuMP.Variable})
Closest candidates are:
+(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:138
+{C,V<:JuMP.Variable}(!Matched::JuMP.Variable, ::JuMP.GenericNormExpr{2,C,V<:JuMP.Variable})
任何帮助?