-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
Change controller handling with the adaptive option #2284
base: master
Are you sure you want to change the base?
Changes from 8 commits
5534a3e
46959eb
cc8aee8
ff64b87
65c6a78
97a4d6e
c8f8d9c
8300cbd
6f094f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,7 +364,11 @@ function DiffEqBase.__init( | |
end | ||
|
||
if controller === nothing | ||
controller = default_controller(_alg, cache, qoldinit, beta1, beta2) | ||
if adaptive | ||
controller = default_controller(_alg, cache, qoldinit, beta1, beta2) | ||
else | ||
controller = NonAdaptiveController() | ||
end | ||
Comment on lines
+366
to
+370
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will introduce an additional type instability since the type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a type instability ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. julia> function foo(; adaptive = true)
if adaptive
return 1.0
else
return 1
end
end
foo (generic function with 1 method)
julia> @code_warntype foo(adaptive = true)
MethodInstance for Core.kwcall(::@NamedTuple{adaptive::Bool}, ::typeof(foo))
from kwcall(::NamedTuple, ::typeof(foo)) @ Main REPL[1]:1
Arguments
_::Core.Const(Core.kwcall)
@_2::@NamedTuple{adaptive::Bool}
@_3::Core.Const(foo)
Locals
adaptive::Union{}
@_5::Bool
Body::Union{Float64, Int64}
1 ─ Core.NewvarNode(:(adaptive))
│ Core.NewvarNode(:(@_5))
│ %3 = Core.isdefined(@_2, :adaptive)::Core.Const(true)
└── goto #3 if not %3
2 ─ (@_5 = Core.getfield(@_2, :adaptive))
└── goto #4
3 ─ Core.Const(:(@_5 = true))
4 ┄ %8 = @_5::Bool
│ %9 = (:adaptive,)::Core.Const((:adaptive,))
│ %10 = Core.apply_type(Core.NamedTuple, %9)::Core.Const(NamedTuple{(:adaptive,)})
│ %11 = Base.structdiff(@_2, %10)::Core.Const(NamedTuple())
│ %12 = Base.pairs(%11)::Core.Const(Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}())
│ %13 = Base.isempty(%12)::Core.Const(true)
└── goto #6 if not %13
5 ─ goto #7
6 ─ Core.Const(:(Base.kwerr(@_2, @_3)))
7 ┄ %17 = Main.:(var"#foo#1")(%8, @_3)::Union{Float64, Int64}
└── return %17 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but is there no type instability due to the fact that the type of the controller depends also on the algorithm is adaptive is true ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ChrisRackauckas @oscardssmith What do you think about this ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is a minor problem. Are there settings of the normal PI controllers that will make them not adapt ever? It feels like there should be some combination of 0 and Inf that make it never adapt. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know, is it related to my changes ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A better strategy would be to add traits to controllers for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ChrisRackauckas I thought over this but for each things I tried, I do not succeed to prevent from a type instability. Can you explain a little more ? I think I have missunderstood something but I do not know what. |
||
end | ||
|
||
save_end_user = save_end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this file exist at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this was a mistake in the big refactors, we should delete it.