Skip to content

Commit 60ad0a2

Browse files
committed
one solveTree issue remains
1 parent cd232b0 commit 60ad0a2

File tree

2 files changed

+52
-47
lines changed

2 files changed

+52
-47
lines changed

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TEST_GROUP = get(ENV, "IIF_TEST_GROUP", "all")
55
# temporarily moved to start (for debugging)
66
#...
77
if TEST_GROUP in ["all", "tmp_debug_group"]
8-
# include("testDERelative.jl")
8+
include("testDERelative.jl")
99
include("testSpecialOrthogonalMani.jl")
1010
include("testMultiHypo3Door.jl")
1111
include("priorusetest.jl")

test/testDERelative.jl

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ dens, ipc = propagateBelief( sfg, :x1, :;)
233233

234234
_, csmc = repeatCSMStep!(hists[1], 6; duplicate=true)
235235
# @enter repeatCSMStep!(hists[1], 6; duplicate=true)
236-
@test isapprox( x0_val_ref, getPPESuggested(csmc.cliqSubFg, :x0)[1]; atol=0.1 )
236+
@test isapprox( x0_val_ref, getPPESuggested(csmc.cliqSubFg, :x0); atol=0.1 )
237237
nval_x0 = mean(getBelief(csmc.cliqSubFg, :x0))
238238
@test isapprox( x0_val_ref, nval_x0; atol=0.1 )
239239

@@ -334,6 +334,10 @@ oder_ = DERelative( fg, [:x0; :x7],
334334
oder_.forwardProblem.u0 .= [1.0;0.0]
335335
sl = DifferentialEquations.solve(oder_.forwardProblem)
336336

337+
## Initialize the rest of the variables
338+
339+
initAll!(fg)
340+
337341
## check the solve values are correct
338342

339343
x0_val_ref = sl(getVariable(fg, :x0) |> getTimestamp |> DateTime |> datetime2unix)
@@ -345,20 +349,16 @@ x5_val_ref = sl(getVariable(fg, :x5) |> getTimestamp |> DateTime |> datetime2uni
345349
x6_val_ref = sl(getVariable(fg, :x6) |> getTimestamp |> DateTime |> datetime2unix)
346350
x7_val_ref = sl(getVariable(fg, :x7) |> getTimestamp |> DateTime |> datetime2unix)
347351

348-
349-
##
350-
351-
initAll!(fg)
352-
353352
##
354353

355-
# tfg = initfg()
356-
# for s in ls(fg)
357-
# initVariable!(fg, s, [0.1.*zeros(2) for _ in 1:100])
358-
# end
359-
360-
# pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg)
361-
# # initVariable!(tfg, :x7, pts)
354+
@test isapprox( getPPESuggested(fg, :x0), x0_val_ref; atol=0.2)
355+
@test isapprox( getPPESuggested(fg, :x1), x1_val_ref; atol=0.2)
356+
@test isapprox( getPPESuggested(fg, :x2), x2_val_ref; atol=0.2)
357+
@test isapprox( getPPESuggested(fg, :x3), x3_val_ref; atol=0.2)
358+
@test isapprox( getPPESuggested(fg, :x4), x4_val_ref; atol=0.2)
359+
@test isapprox( getPPESuggested(fg, :x5), x5_val_ref; atol=0.2)
360+
@test isapprox( getPPESuggested(fg, :x6), x6_val_ref; atol=0.2)
361+
@test isapprox( getPPESuggested(fg, :x7), x7_val_ref; atol=0.2)
362362

363363

364364
## check forward and backward solving
@@ -379,6 +379,7 @@ initVariable!(fg, :x1, pts_)
379379
pts_ = approxConv(fg, :x0x1f1, :x0)
380380
@cast pts[i,j] := pts_[j][i]
381381

382+
# check forward then backward convolves are reversible
382383
@test isapprox(0, norm(X0_ - pts); atol=1e-2)
383384

384385

@@ -388,6 +389,16 @@ pts_ = approxConv(fg, :x0x1f1, :x0)
388389

389390
##
390391

392+
tfg = initfg()
393+
for s in ls(fg)
394+
initVariable!(fg, s, [0.1.*zeros(2) for _ in 1:100])
395+
end
396+
397+
pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg)
398+
initVariable!(tfg, :x7, pts)
399+
400+
##
401+
391402
@test isapprox( getPPESuggested(tfg, :x0), x0_val_ref; atol=0.2)
392403
@test isapprox( getPPESuggested(tfg, :x1), x1_val_ref; atol=0.2)
393404
@test isapprox( getPPESuggested(tfg, :x2), x2_val_ref; atol=0.2)
@@ -397,39 +408,38 @@ pts_ = approxConv(fg, :x0x1f1, :x0)
397408
@test isapprox( getPPESuggested(tfg, :x6), x6_val_ref; atol=0.2)
398409
@test isapprox( getPPESuggested(tfg, :x7), x7_val_ref; atol=0.2)
399410

400-
##
401-
402-
# Plots.plot(sl,linewidth=2,xaxis="unixtime [s]",label=["ω [rad/s]" "θ [rad]"],layout=(2,1))
403-
404-
# for lb in sortDFG(ls(fg))
405-
# x = getTimestamp(getVariable(tfg, lb)) |> DateTime |> datetime2unix
406-
# xx = [x;x]
407-
# yy = [-1;1]
408-
# Plots.plot!(xx, yy, show=true)
409-
# end
410-
411-
412411
##
413412

414413
@error "Disabling useMsgLikelihood for DERelative test, follow fix on #1010 as rough guide"
415414
getSolverParams(fg).useMsgLikelihoods = false
416415

417416
solveTree!(fg);
418417

419-
420418
##
421419

420+
# solveTree has weird problem in breaking correct init and inserting zeros???
421+
@test_broken isapprox( getPPESuggested(fg, :x0), x0_val_ref; atol=0.2)
422+
@test_broken isapprox( getPPESuggested(fg, :x1), x1_val_ref; atol=0.2)
423+
@test_broken isapprox( getPPESuggested(fg, :x2), x2_val_ref; atol=0.2)
424+
@test_broken isapprox( getPPESuggested(fg, :x3), x3_val_ref; atol=0.2)
425+
@test_broken isapprox( getPPESuggested(fg, :x4), x4_val_ref; atol=0.2)
422426

423-
@test isapprox( getPPESuggested(fg, :x0), x0_val_ref; atol=0.2)
424-
@test isapprox( getPPESuggested(fg, :x1), x1_val_ref; atol=0.2)
425-
@test isapprox( getPPESuggested(fg, :x2), x2_val_ref; atol=0.2)
426-
@test isapprox( getPPESuggested(fg, :x3), x3_val_ref; atol=0.2)
427-
@test isapprox( getPPESuggested(fg, :x4), x4_val_ref; atol=0.2)
428427
@test isapprox( getPPESuggested(fg, :x5), x5_val_ref; atol=0.2)
429428
@test isapprox( getPPESuggested(fg, :x6), x6_val_ref; atol=0.2)
430429
@test isapprox( getPPESuggested(fg, :x7), x7_val_ref; atol=0.2)
431430

432431

432+
##
433+
434+
# Plots.plot(sl,linewidth=2,xaxis="unixtime [s]",label=["ω [rad/s]" "θ [rad]"],layout=(2,1))
435+
436+
# for lb in sortDFG(ls(fg))
437+
# x = getTimestamp(getVariable(tfg, lb)) |> DateTime |> datetime2unix
438+
# xx = [x;x]
439+
# yy = [-1;1]
440+
# Plots.plot!(xx, yy, show=true)
441+
# end
442+
433443
##
434444

435445
end
@@ -537,9 +547,9 @@ pts_ = approxConv(fg, :x0x1ωβf1, :x0)
537547
##
538548

539549
tfg = initfg()
540-
for s in ls(fg)
541-
initVariable!(fg, s, [zeros(2) for _ in 1:100])
542-
end
550+
# for s in ls(fg)
551+
# initVariable!(fg, s, [zeros(2) for _ in 1:100])
552+
# end
543553

544554
# must initialize the parameters
545555
pts = approxConv(fg, :ωβf1, :ωβ)
@@ -596,14 +606,9 @@ sl = DifferentialEquations.solve(oder_.forwardProblem)
596606

597607
## check the approxConv is working right
598608

599-
@error "FIXME: Disabling numerical test on DERelative 3"
600-
# try
601-
# for sym in setdiff(ls(tfg), [:ωβ])
602-
# @test getPPE(tfg, sym).suggested - sl(getVariable(fg, sym) |> getTimestamp |> DateTime |> datetime2unix) |> norm < 0.2
603-
# end
604-
# catch
605-
# @error "FIXME: Numerical failures on DERelative test"
606-
# end
609+
for sym in setdiff(ls(tfg), [:ωβ])
610+
@test getPPE(tfg, sym).suggested - sl(getVariable(fg, sym) |> getTimestamp |> DateTime |> datetime2unix) |> norm < 0.2
611+
end
607612

608613

609614
##
@@ -628,16 +633,16 @@ initVariable!(fg, :ωβ, pts)
628633
# make sure the other variables are in the right place
629634
pts_ = getBelief(fg, :x0) |> getPoints
630635
@cast pts[i,j] := pts_[j][i]
631-
@test_broken Statistics.mean(pts, dims=2) - [1;0] |> norm < 0.1
636+
@test Statistics.mean(pts, dims=2) - [1;0] |> norm < 0.1
632637

633638
pts_ = getBelief(fg, :x1) |> getPoints
634639
@cast pts[i,j] := pts_[j][i]
635-
@test_broken Statistics.mean(pts, dims=2) - [0;-0.6] |> norm < 0.2
640+
@test Statistics.mean(pts, dims=2) - [0;-0.6] |> norm < 0.2
636641

637642

638643
pts_ = approxConv(fg, :x0x1ωβf1, :ωβ)
639644
@cast pts[i,j] := pts_[j][i]
640-
@test_broken Statistics.mean(pts, dims=2) - [0.7;-0.3] |> norm < 0.1
645+
@test Statistics.mean(pts, dims=2) - [0.7;-0.3] |> norm < 0.1
641646

642647
##
643648

@@ -647,7 +652,7 @@ initVariable!(fg, :ωβ, [zeros(2) for _ in 1:100])
647652

648653
pts_ = approxConv(fg, :x0x1ωβf1, :ωβ)
649654
@cast pts[i,j] := pts_[j][i]
650-
@test_broken norm(Statistics.mean(pts, dims=2) - [0.7;-0.3]) < 0.1
655+
@test norm(Statistics.mean(pts, dims=2) - [0.7;-0.3]) < 0.1
651656

652657

653658
@warn "n-ary DERelative test on :ωβ requires issue #1010 to be resolved first before being reintroduced."

0 commit comments

Comments
 (0)