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

Let TMJets options be passed outside the struct #214

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Algorithms/TMJets/TMJets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ then performs the disjointness check with that zonotope and the invariant.
For other options, see the documentation of `AbstractDisjointnessMethod`.
"""
@with_kw struct TMJets{N, DM<:AbstractDisjointnessMethod} <: AbstractContinuousPost
max_steps::Int=2000
abs_tol::N=1e-10
orderT::Int=8
orderQ::Int=2
max_steps::Int=DEFAULT_MAX_STEPS_TMJETS
abs_tol::N=DEFAULT_ABS_TOL_TMJETS
orderT::Int=DEFAULT_ORDER_T_TMJETS
orderQ::Int=DEFAULT_ORDER_Q_TMJETS
disjointness::DM=ZonotopeEnclosure()
adaptive::Bool=true
min_abs_tol::N=1e-29
end

const DEFAULT_MAX_STEPS_TMJETS = 2000
const DEFAULT_ABS_TOL_TMJETS = 1e-10
const DEFAULT_ORDER_T_TMJETS = 8
const DEFAULT_ORDER_Q_TMJETS = 2

using TaylorModels: TaylorModelN
using TaylorModels: fp_rpa, remainder

Expand Down
22 changes: 21 additions & 1 deletion src/Continuous/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,27 @@ function _default_cpost(ivp::AbstractContinuousSystem, tspan; kwargs...)
opC = GLGM06(δ=δ, static=static)
end
else
opC = TMJets()
# check additional kwargs options if they exist, allowing some aliases
if haskey(kwargs, :max_steps)
max_steps = kwargs[:max_steps]
elseif haskey(kwargs, :maxsteps)
max_steps = kwargs[:maxsteps]
else
max_steps = DEFAULT_MAX_STEPS_TMJETS
end

if haskey(kwargs, :abs_tol)
abs_tol = kwargs[:abs_tol]
elseif haskey(kwargs, :abstol)
abs_tol = kwargs[:abstol]
else
abs_tol = DEFAULT_ABS_TOL_TMJETS
end

orderT = haskey(kwargs, :orderT) ? kwargs[:orderT] : DEFAULT_ORDER_T_TMJETS
orderQ = haskey(kwargs, :orderQ) ? kwargs[:orderQ] : DEFAULT_ORDER_Q_TMJETS

opC = TMJets(max_steps=max_steps, abs_tol=abs_tol, orderT=orderT, orderQ=orderQ)
end
return opC
end
Expand Down
12 changes: 11 additions & 1 deletion test/algorithms/TMJets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
sol = solve(prob, tspan=tspan, TMJets())
@test sol.alg isa TMJets

# TODO: try other options
# pass options outside algorithm
sol = solve(prob, T=0.2, max_steps=2100)
@test sol.alg isa TMJets && sol.alg.max_steps == 2100
sol = solve(prob, T=0.2, maxsteps=2100) # alias
@test sol.alg isa TMJets && sol.alg.max_steps == 2100
sol = solve(prob, T=0.2, orderT=7, orderQ=1)
@test sol.alg isa TMJets && sol.alg.orderT == 7 && sol.alg.orderQ == 1
sol = solve(prob, T=0.2, abs_tol=1e-11)
@test sol.alg isa TMJets && sol.alg.abs_tol == 1e-11
sol = solve(prob, T=0.2, abstol=1e-11)
@test sol.alg isa TMJets && sol.alg.abs_tol == 1e-11

# split initial conditions
X0, S = initial_state(prob), system(prob)
Expand Down