recently i updated Julia to 1.7.2 which means that i had to update all the used packages, i am getting an assertion error, that is not clear to me knowing that the same exact code was running fine in Julia 1.5
using Plots
using Random
using SymPy
using CSV
using DataFrames
using Main.QuantumRelay
using Distributions
#calling the github code
function quantumrelay(alpha,delta,name::String,n) #n is the number of sources for 1 relay we have 2 sources
chi = fill(sqrt(0.06), n) # the parameter chi
phi = im*tanh.(chi)
omega = -log(prod(cosh.(chi)))
syms, op = qrelay_op(n, phi, alpha, delta) #operators.jl
op_a, op_ab, mat, coef = op_mat(op) #operators.jl
op_q2 = [syms.apH[1], syms.apV[1], syms.bpH[end], syms.bpV[end]] # array in operators.jl
op_q1 = [syms.apH[2:end]..., syms.apV[2:end]..., syms.bpH[1:end-1]..., syms.bpV[1:end-1]...] #array in operators.jl
mask_q1 = [op in op_q1 for op in op_a]; #array in operators.jl
mask_q2 = [op in op_q2 for op in op_a]; #array in operators.jl
qq = [x in syms.apH || x in syms.bpV ? 1 : 0 for x in op_a]; #array in operators.jl
pdet0 = pdet_maker(0.04, 3e-5) #function utility.jl
qrs = QRelaySampler(mat, coef, omega, pdet0). #QuantumRelay.jl
targetcache=Dict{Vector{Int}, Float64}()
target(x::Vector)= log(qrs.prob(qq, x, mask_q1))+ log(qrs.prob(x)) #the log target function of MCMC the function prob is in QuantumRelay.jl
Iteration=2^17
burnin=2^10
samples=Iteration+burnin
step=5
save_iter=burnin:samples
dist= qrs.psetproposal #the proposal distribution from the distribution.jl
selected=Array[]
Q = Float64[]
current_x = zeros(8)
@time for i in 2:samples #from this line the MCMC algorithm starts
proposed_x= rand(dist(current_x))
prop_proposed= logpdf(dist(current_x), proposed_x)
prop_current= logpdf(dist(proposed_x), current_x)
A= min(1,target(proposed_x)+prop_current-target(current_x)-prop_proposed)
if log(rand()) < A
#if i in save_iter
push!(selected, proposed_x)
push!(Q, qrs.prob(qq, proposed_x, mask_q2))
#end
current_x = proposed_x
else
current_x= current_x
end
end
return selected, Q
end
prob= Float64[]
accepted= Array[]
for i = 0:14
beta = i*pi/14
name = string(i)
selected, Q = quantumrelay(pi/4, beta, name,2)
push!(accepted,length(selected))
println("beta:", beta)
push!(prob,Q)
df=DataFrame(selected=selected)
end
i get this error:
2425.699067 seconds (737.51 M allocations: 57.773 GiB, 0.52% gc time, 0.38% compilation time)
beta:0.0
TaskFailedException
nested task error: AssertionError: termination_status(m) == MOI.OPTIMAL || termination_status(m) == MOI.DUAL_INFEASIBLE
Stacktrace:
[1] (::Main.QuantumRelay.var"#scan#6"{Vector{JuMP.VariableRef}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Int64, JuMP.Model})(c::Channel{Any})
@ Main.QuantumRelay ~/Downloads/Clp.jl:34
[2] (::Base.var"#560#561"{Main.QuantumRelay.var"#scan#6"{Vector{JuMP.VariableRef}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Int64, JuMP.Model}, Channel{Any}})()
@ Base ./channels.jl:132
Stacktrace:
[1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
@ Base ./task.jl:777
[2] wait()
@ Base ./task.jl:837
[3] wait(c::Base.GenericCondition{ReentrantLock})
@ Base ./condition.jl:123
[4] take_unbuffered(c::Channel{Any})
@ Base ./channels.jl:405
[5] take!
@ ./channels.jl:383 [inlined]
[6] iterate(c::Channel{Any}, state::Nothing)
@ Base ./channels.jl:466
[7] iterate
@ ./channels.jl:465 [inlined]
[8] (::Main.QuantumRelay.var"#prob#8"{Vector{Complex}, Float64, Main.QuantumRelay.var"#scan#6"{Vector{JuMP.VariableRef}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Int64, JuMP.Model}, Main.QuantumRelay.var"#setc#5"{Vector{JuMP.ConstraintRef{JuMP.Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}}, JuMP.ScalarShape}}}, Matrix{Float64}, Matrix{Float64}, Main.QuantumRelay.var"#pdet0#2"{Float64, Float64}})(na::Vector{Float64})
@ Main.QuantumRelay ./In[2]:63
[9] (::var"#target#7"{QRelaySampler, Vector{Int64}, Vector{Bool}})(x::Vector{Float64})
@ Main ./In[3]:28
[10] macro expansion
@ ./In[3]:48 [inlined]
[11] macro expansion
@ ./timing.jl:220 [inlined]
[12] quantumrelay(alpha::Float64, delta::Float64, name::String, n::Int64)
@ Main ./In[3]:39
[13] top-level scope
@ ./In[4]:6
[14] eval
@ ./boot.jl:373 [inlined]
[15] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
all the included files are at the begining of this code can be found here https://github.com/marouanehanhasse/QComm
from the error message it is indicated that there is a problem in the Clp.jl
file exactly in line 34 @ Main.QuantumRelay ~/Downloads/Clp.jl:34
termination_status(m) == MOI.OPTIMAL || termination_status(m) == MOI.DUAL_INFEASIBLE
and i don’t know what i am doing wrong there, it was totally working in the previous version of julia. The code has comment about the variables and where can they be found, i’ve been trying with it these past two days, i changed the syntax but i don’t know what to do in this kind of assertion errors.