# Solver argument (MosekModel) must be an AbstractMathProgSolver

This is an SDP problem or Mosek problem.

``````using JuMP, Mosek, Plots, MosekTools
# 生成一个200x200的稠密随机对称矩阵Q
Q = randn(200,200)
Q = Q + Q'
# 负责进行抽样实验的函数
function SampleBQP(Q,N)
naive_fval = zeros(N,1)
GW_fval = zeros(N,1)
n = size(Q,1)
# 这里先解出SDP，使用了Mosek求解器
GW_SDP = Model(solver =Mosek.Optimizer(MSK_IPAR_LOG = 0) #=MosekSolver(MSK_IPAR_LOG = 0)=#)
@variable(GW_SDP, X[1:n,1:n])
@SDconstraint(GW_SDP, X>=0)
@constraint(GW_SDP, diag(X).== ones(n,1) )
@objective(GW_SDP, Min, trace(Q*X))
solve(GW_SDP)
X_SDP = getvalue(X)
V_SDP = cholfact(X_SDP.+1e-4*eye(n))[:U]
for i = 1:N
# Naive算法
naive_x = rand([-1,1], n)
naive_fval[i] = sum(naive_x' * Q * naive_x)
# 随机生成超平面，其实像这样用高斯随机数就好啦
random_norm_vec = randn(n,1)
random_norm_vec = random_norm_vec/norm(random_norm_vec,2)
GW_sol = [if (dot(random_norm_vec,V_SDP[:,j])>=0) 1 else -1 end for j = 1:n]
GW_fval[i] = sum(GW_sol' * Q * GW_sol)
end
return naive_fval, GW_fval, X_SDP
end
# 进行10000次实验，输出所有的目标函数
naive_f, GW_f, X_SDP = SampleBQP(Q,10000)
# 画出结果的直方图
histogram(naive_f,label = "Naive samples")
histogram(GW_f,label = "GW samples")
``````

Firstly, the code in line 14 is:
`GW_SDP = Model(solver =MosekSolver(MSK_IPAR_LOG = 0)`
But it shows me an error:
LoadError: UndefVarError: MosekSolver not defined
So I try to change `GW_SDP = Model(solver =MosekSolver(MSK_IPAR_LOG = 0)` into`GW_SDP = Model(solver =Mosek.Optimizer(MSK_IPAR_LOG = 0)`. It shows me another error:
LoadError: solver argument (MosekModel) must be an AbstractMathProgSolver
What is the problem, please? What’s wrong with my arguments?

The correct syntax is

``````using JuMP, MosekTools
GW_SDP = Model(Mosek.Optimizer)
set_optimizer_attribute(model, "MSK_IPAR_LOG", 0)
``````

I have change `GW_SDP = Model(solver =Mosek.Optimizer(MSK_IPAR_LOG = 0)` to ` GW_SDP = Model(Mosek.Optimizer) set_optimizer_attribute(GW_SDP, "MSK_IPAR_LOG", 0)`.
It shows a new error:
LoadError: MethodError: no method matching Model(::typeof(Mosek.Optimizer))

You need to update to the latest version of JuMP.

JuMPeR does not support the latest version of JuMP. You need to uninstall it.

Solve it. Thanks for your help very much~

1 Like