Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using DQCType. #25

Open
HuynhTran0301 opened this issue Mar 7, 2024 · 1 comment
Open

Error when using DQCType. #25

HuynhTran0301 opened this issue Mar 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@HuynhTran0301
Copy link

I tried to solve the example of the package as follows:

using DifferentialEquations, Yao, QuantumNLDiffEq
# Making the ODEProblem
function f(u, p, t)
	λ, κ = p
	return -1*λ*u*(κ + tan(λ*t))
end
prob = ODEProblem(f, [1.0], (0.0, 0.9), [8.0, 0.1])
function loss_func(a, b)
	return (a - b)^2
end

#Making the DQC
DQC = [QuantumNLDiffEq.DQCType(afm = QuantumNLDiffEq.ChebyshevTower(2), fm = chain(6, [put(i=>Ry(0)) for i in 1:6]), cost = [Add([put(6, i=>Z) for i in 1:6])], var = dispatch(EasyBuild.variational_circuit(6,5), :random), N = 6)]
config = DQCConfig(abh = QuantumNLDiffEq.Floating(), loss = loss_func)
M = range(start=0; stop=0.9, length=21)
evalue(M) = [QuantumNLDiffEq.calculate_evalue(DQC[1], DQC[1].cost, prob.u0[1], config.abh, params[1], M[x], M[1]) for x in 1:length(M)]
params = [Yao.parameters(DQC[1].var)]

#Training the circuit
QuantumNLDiffEq.train!(DQC, prob, config, M, params, steps = 1000)

I got the error as follows:

MethodError: no method matching +(::NamedTuple{(:afm, :fm, :cost, :var, :N, :evol), Tuple{NamedTuple{(:pc,), Tuple{Float64}}, Vararg{Nothing, 5}}}, ::Base.RefValue{Any})

Closest candidates are:
  +(::Any, ::Any, ::Basic, ::Any...)
   @ SymEngine C:\Users\htran\.julia\packages\SymEngine\hozAR\src\mathops.jl:51
  +(::Any, ::Any, ::Any, ::Any...)
   @ Base operators.jl:578
  +(::Union{InitialValues.NonspecificInitialValue, InitialValues.SpecificInitialValue{typeof(+)}}, ::Any)
   @ InitialValues C:\Users\htran\.julia\packages\InitialValues\OWP8V\src\InitialValues.jl:154
  ...

This error happened even though I tried with Julia 1.8, 1.9, or 1.10 for ChebyshevTower and ChebyshevSparse and did not happen for Product
Please help me on how to fix it.

@HuynhTran0301 HuynhTran0301 added the bug Something isn't working label Mar 7, 2024
@VarLad
Copy link
Contributor

VarLad commented Jun 19, 2024

@HuynhTran0301 Ah, sorry for the long wait. I was unaware of the issues opened.
I'll take a deeper look at both this and your other issue tomorrow. Feel free to ping me for any issues or questions regarding this repo henceforth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants