wangjie212 / TSSOS

A sparse polynomial optimization tool based on the moment-SOS hierarchy.
MIT License
39 stars 14 forks source link

Error using save Variable 'cl' not found. #1

Closed jtorde closed 2 years ago

jtorde commented 4 years ago

When I try to run this code:

using DynamicPolynomials
using TSSOS
@polyvar x[1:2]
f=x[1]^4+x[2]^4-x[1]*x[2]
g_1=2-x[1]^2-2*x[2]^2
g_2=x[1]^2-x[2]^2-1
pop=[f,g_1,g_2]
d=2 # the order of Lasserre's hierarchy
opt,sol,data=blockcpop_first(pop,x,d,numeq=1,method="chordal")

I get the error

ERROR: LoadError: MATLAB.MEngineError("failed to get variable cl from MATLAB session")
Stacktrace:
 [1] get_mvariable(::MATLAB.MSession, ::Symbol) at /home/jtorde/.julia/packages/MATLAB/cVrxc/src/engine.jl:164
 [2] #cliquesFromSpMatD#36(::Int64, ::typeof(TSSOS.cliquesFromSpMatD), ::Array{UInt8,2}) at /home/jtorde/.julia/packages/TSSOS/FUCW7/src/blockpop_uncons.jl:358
 [3] #cliquesFromSpMatD at ./none:0 [inlined]
 [4] #get_ccliques#119(::Int64, ::Int64, ::Bool, ::String, ::typeof(get_ccliques), ::Int64, ::Int64, ::Array{UInt8,2}, ::Array{Array{UInt8,2},1}, ::Array{UInt32,1}, ::Array{UInt8,2}, ::Array{Array{UInt8,2},1}) at /home/jtorde/.julia/packages/TSSOS/FUCW7/src/blockpop_cons.jl:735
 [5] #get_ccliques at ./none:0 [inlined]
 [6] #blockcpop_first#89(::String, ::Int64, ::Int64, ::Bool, ::Int64, ::String, ::Bool, ::Bool, ::typeof(blockcpop_first), ::Array{Polynomial{true,Int64},1}, ::Array{PolyVar{true},1}, ::Int64) at /home/jtorde/.julia/packages/TSSOS/FUCW7/src/blockpop_cons.jl:77
 [7] (::getfield(TSSOS, Symbol("#kw##blockcpop_first")))(::NamedTuple{(:numeq, :method),Tuple{Int64,String}}, ::typeof(blockcpop_first), ::Array{Polynomial{true,Int64},1}, ::Array{PolyVar{true},1}, ::Int64) at ./none:0
 [8] top-level scope at /home/jtorde/example.jl:9
 [9] include at ./boot.jl:328 [inlined]
 [10] include_relative(::Module, ::String) at ./loading.jl:1094
 [11] include(::Module, ::String) at ./Base.jl:31
 [12] exec_options(::Base.JLOptions) at ./client.jl:295
 [13] _start() at ./client.jl:464

Thanks!

wangjie212 commented 4 years ago

It seems that something is wrong with your calling Matlab from Julia. Did you set the environment variable? Or you can use the option chor_alg="greedy" to generate a chordal extension which doesn't rely on Matlab: opt,sol,data=blockcpop_first(pop,x,d,numeq=1,method="chordal", chor_alg="greedy")