Skip to content

Commit 5f92d2c

Browse files
dehannAffie
andcommitted
wip fixing DERelative
Co-authored-by: Johannes Terblanche <[email protected]>
1 parent 7b32292 commit 5f92d2c

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ IncrInfrInteractiveUtilsExt = "InteractiveUtils"
6565
IncrInfrInterpolationsExt = "Interpolations"
6666

6767
[compat]
68-
ApproxManifoldProducts = "0.7"
68+
ApproxManifoldProducts = "0.7, 0.8"
6969
BSON = "0.2, 0.3"
7070
BlockArrays = "0.16"
7171
Combinatorics = "1.0"

test/runtests.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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")
9+
include("testSpecialOrthogonalMani.jl")
810
include("testMultiHypo3Door.jl")
911
include("priorusetest.jl")
1012
end
@@ -18,7 +20,6 @@ include("testEuclidDistance.jl")
1820

1921
# regular testing
2022
include("testSphereMani.jl")
21-
include("testSpecialOrthogonalMani.jl")
2223
include("testBasicManifolds.jl")
2324

2425
# start as basic as possible and build from there
@@ -96,11 +97,11 @@ include("testCircular.jl")
9697
include("testMixtureLinearConditional.jl")
9798
include("testFluxModelsDistribution.jl")
9899
include("testAnalysisTools.jl")
99-
try
100-
include("testDERelative.jl")
101-
catch
102-
@error "[FAILED] Fix testDERelative.jl, likely just requires implementing DiffEqFactorExt.getSample(::CalcFactor{<:DERelative})."
103-
end
100+
# try
101+
# include("testDERelative.jl")
102+
# catch
103+
# @error "[FAILED] Fix testDERelative.jl, likely just requires implementing DiffEqFactorExt.getSample(::CalcFactor{<:DERelative})."
104+
# end
104105

105106
include("testBasicParametric.jl")
106107
include("testMixtureParametric.jl")

test/testDERelative.jl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ using TensorCast
2020

2121
##
2222

23-
function firstOrder!(dstate, state, force, t)
23+
# a user specified ODE in standard form
24+
# inplace `xdot = f(x, u, t)`
25+
# if linear, `xdot = F*x(t) + G*u(t)`
26+
function firstOrder!(dstate, state, u, t)
2427
β = -0.2
25-
dstate[1] = β*state[1] + force(t)
28+
dstate[1] = β*state[1] + u(t)
2629
nothing
2730
end
2831

@@ -34,7 +37,8 @@ tstForce(t) = 0
3437

3538
fg = initfg()
3639
# the starting points and "0 seconds"
37-
addVariable!(fg, :x0, ContinuousScalar, timestamp=DateTime(2000,1,1,0,0,0))
40+
# `accurate_time = trunc(getDatetime(var), Second) + (1e-9*getNstime(var) % 1)`
41+
addVariable!(fg, :x0, Position{1}, timestamp=DateTime(2000,1,1,0,0,0))
3842
# pin with a simple prior
3943
addFactor!(fg, [:x0], Prior(Normal(1,0.01)))
4044

@@ -47,15 +51,16 @@ for i in 1:3
4751
nextSym = Symbol("x$i")
4852

4953
# another point in the trajectory 5 seconds later
50-
addVariable!(fg, nextSym, ContinuousScalar, timestamp=DateTime(2000,1,1,0,0,5*i))
51-
oder = IIF.DERelative(fg, [prev; nextSym],
52-
ContinuousEuclid{1},
54+
addVariable!(fg, nextSym, Position{1}, timestamp=DateTime(2000,1,1,0,0,5*i))
55+
# build factor against manifold Manifolds.TranslationGroup(1)
56+
ode_fac = IIF.DERelative(fg, [prev; nextSym],
57+
Position{1},
5358
firstOrder!,
5459
tstForce,
5560
dt=0.05,
5661
problemType=ODEProblem )
5762
#
58-
addFactor!( fg, [prev;nextSym], oder, graphinit=false )
63+
addFactor!( fg, [prev;nextSym], ode_fac, graphinit=false )
5964
initVariable!(fg, nextSym, [zeros(1) for _ in 1:100])
6065

6166
prev = nextSym
@@ -94,7 +99,7 @@ ref_ = (getBelief(fg, :x0) |> getPoints)
9499
##
95100

96101
oder_ = DERelative( fg, [:x0; :x3],
97-
ContinuousEuclid{1},
102+
Position{1},
98103
firstOrder!,
99104
tstForce,
100105
dt=0.05,
@@ -185,7 +190,7 @@ tstForce(t) = 0
185190
fg = initfg()
186191

187192
# the starting points and "0 seconds"
188-
addVariable!(fg, :x0, ContinuousEuclid{2}, timestamp=DateTime(2000,1,1,0,0,0))
193+
addVariable!(fg, :x0, Position{2}, timestamp=DateTime(2000,1,1,0,0,0))
189194
# pin with a simple prior
190195
addFactor!(fg, [:x0], Prior(MvNormal([1;0],0.01*diagm(ones(2)))))
191196

@@ -201,9 +206,9 @@ for i in 1:7
201206
nextSym = Symbol("x$i")
202207

203208
# another point in the trajectory 5 seconds later
204-
addVariable!(fg, nextSym, ContinuousEuclid{2}, timestamp=DateTime(2000,1,1,0,0,DT*i))
209+
addVariable!(fg, nextSym, Position{2}, timestamp=DateTime(2000,1,1,0,0,DT*i))
205210
oder = DERelative( fg, [prev; nextSym],
206-
ContinuousEuclid{2},
211+
Position{2},
207212
dampedOscillator!,
208213
tstForce,
209214
# (state, var)->(state[1] = var[1]),
@@ -258,7 +263,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg)
258263

259264

260265
oder_ = DERelative( fg, [:x0; :x7],
261-
ContinuousEuclid{2},
266+
Position{2},
262267
dampedOscillator!,
263268
tstForce,
264269
# (state, var)->(state[1] = var[1]),
@@ -347,7 +352,7 @@ tstForce(t) = 0
347352
fg = initfg()
348353

349354
# the starting points and "0 seconds"
350-
addVariable!(fg, :x0, ContinuousEuclid{2}, timestamp=DateTime(2000,1,1,0,0,0))
355+
addVariable!(fg, :x0, Position{2}, timestamp=DateTime(2000,1,1,0,0,0))
351356
# pin with a simple prior
352357
addFactor!(fg, [:x0], Prior(MvNormal([1;0],0.01*diagm(ones(2)))))
353358
doautoinit!(fg, :x0)
@@ -357,7 +362,7 @@ doautoinit!(fg, :x0)
357362
β = -0.3
358363

359364
# these are the stochastic parameters
360-
addVariable!(fg, :ωβ, ContinuousEuclid{2}) # timestamp should not matter
365+
addVariable!(fg, :ωβ, Position{2}) # timestamp should not matter
361366
# pin with a simple prior
362367
addFactor!(fg, [:ωβ], Prior(MvNormal([ω;β],0.0001*diagm(ones(2)))))
363368
doautoinit!(fg, :ωβ)
@@ -373,9 +378,9 @@ for i in 1:7
373378
nextSym = Symbol("x$i")
374379

375380
# another point in the trajectory 5 seconds later
376-
addVariable!(fg, nextSym, ContinuousEuclid{2}, timestamp=DateTime(2000,1,1,0,0,DT*i))
381+
addVariable!(fg, nextSym, Position{2}, timestamp=DateTime(2000,1,1,0,0,DT*i))
377382
oder = DERelative( fg, [prev; nextSym; :ωβ],
378-
ContinuousEuclid{2},
383+
Position{2},
379384
dampedOscillatorParametrized!,
380385
tstForce, # this is passed in as `force_ωβ[1]`
381386
# (state, var)->(state[1] = var[1]),
@@ -458,7 +463,7 @@ pts = approxConv(fg, :x0f1, :x7, setPPE=true, tfg=tfg, path=forcepath)
458463

459464

460465
oder_ = DERelative( fg, [:x0; :x7; :ωβ],
461-
ContinuousEuclid{2},
466+
Position{2},
462467
dampedOscillatorParametrized!,
463468
tstForce,
464469
# (state, var)->(state[1] = var[1]),

0 commit comments

Comments
 (0)