diff --git a/src/annealing.jl b/src/annealing.jl index 9265d53..2ac41e3 100644 --- a/src/annealing.jl +++ b/src/annealing.jl @@ -29,7 +29,7 @@ function anneal(problem::Problem, schedule::Function, T::Float64) τ = T/(num_layers - 1) γ = map(schedule, τ .* (0:num_layers-1)) β = 1 .- γ - beta_and_gamma = vcat(β, γ) + beta_and_gamma = τ .* vcat(β, γ) circ = circuit(problem) circ = dispatch_parameters!(circ, problem, beta_and_gamma) probabilities = uniform_state(nqubits(circ)) |> circ |> probs diff --git a/test/annealing.jl b/test/annealing.jl index efcd39c..6289648 100644 --- a/test/annealing.jl +++ b/test/annealing.jl @@ -1,12 +1,12 @@ @testset "Toy Annealing" begin J = [0.0 0.5428970107716381 -1.3951405027746535 0.13375702345533; 0.5428970107716381 0.0 -0.9460077791129564 0.0036930338557504432; -1.3951405027746535 -0.9460077791129564 0.0 0.5303622417454488; 0.13375702345533 0.0036930338557504432 0.5303622417454488 0.0] - T_anneal = 8. - p = 256 + T_anneal = 128. + p = 1024 linear_schedule(t) = t / T_anneal annealing_problem = QAOA.Problem(p, zeros(size(J)[1]), J) probabilities = anneal(annealing_problem, linear_schedule, T_anneal) max_p = maximum(probabilities) - @test isapprox(max_p, 0.498292289, atol=1e-10) + @test isapprox(max_p, 0.4999, atol=1e-4) @test probabilities[findfirst(x -> x == max_p, probabilities)] == probabilities[findlast(x -> x == max_p, probabilities)] end \ No newline at end of file