-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use of ProgressMeter.jl and added a reset_callback
to DPWSolver
#69
Conversation
…state space progressive widening (defaults to true, i.e. previous behavior)
@mossr , thanks for the contribution! Do you know if the progress meter addition could have any performance consequences? There is a very wide variety of ways this package is used - some people use it to plan for minutes or hours; some use it to plan for 0.01 seconds. I am a bit concerned that if it is used for 0.01 seconds, the progress meter might take a significant portion of that. I would be more comfortable using code where we will be sure that julia will optimize out all progress meter code. (In the long run, it would be better to have a package that is designed for different use cases than just running POMDPs.jl simulations like this one 😄) I am not sure I understand the need for (In the long run, the solution to this would be to have a better package that uses an interface that does not assume that the mdp model and state are completely separate objects, like CommonRLInterface.jl 😄. I think with all the julia experience we have acquired, we could make a much much better MCTS package that is easier for people to use and extend for many different use cases. If you happen to be interested in working on this, let me know and we can zoom about it! I have wanted to work on it for a long time, but have had to focus on other things.) |
Count me in! 😉 |
src/dpw.jl
Outdated
@@ -15,9 +15,10 @@ POMDPs.action(p::DPWPlanner, s) = first(action_info(p, s)) | |||
""" | |||
Construct an MCTSDPW tree and choose the best action. Also output some information. | |||
""" | |||
function POMDPModelTools.action_info(p::DPWPlanner, s; tree_in_info=false) | |||
function POMDPModelTools.action_info(p::DPWPlanner, s; tree_in_info=false, show_progress=false) |
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.
I'd suggest using an Union{Progress, Nothing}
here. So that @zsunberg will have no concern about performance😁
@zsunberg Great point regarding performance. I modified my branch based on the suggestion from @findmyway to use the Regarding I am interested in a general MCTS package, but—like you—don't have the time at the moment. Maybe in 6-12 months time we can reconvene about this! 😄 |
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
==========================================
+ Coverage 85.30% 85.51% +0.20%
==========================================
Files 11 11
Lines 415 421 +6
==========================================
+ Hits 354 360 +6
Misses 61 61
Continue to review full report at Codecov.
|
Sorry for not responding for a while. I need to request a few more changes:
|
…ed finish! on progress meter after timeout
Hey @zsunberg, to counter your delay I delayed 🙃 Regarding your comments (which were all warranted):
mutable struct Obj value end # Some random structure
obj = Obj(0) # With an instantiation
# Function under test, which includes an inner call to `callback`
function perf_test(obj, callback::Function)
callback(obj)
return (10,20)
end First, it's cleaner to show the julia> @code_typed perf_test(obj, o->false)
CodeInfo(
1 ─ return (10, 20)
) => Tuple{Int64,Int64}
julia> @code_typed perf_test(obj, o->o.value+=1)
CodeInfo(
1 ─ invoke callback(_2::Obj)::Any
└── return (10, 20)
) => Tuple{Int64,Int64} Now to compare using function perf_test_empty(obj, callback::Function)
return (10,20)
end And running both functions, where each of them takes in the blind julia> @code_native perf_test(obj, o->false)
.text
; ┌ @ REPL[6]:2 within `perf_test'
pushq %rbp
movq %rsp, %rbp
; │ @ REPL[6]:3 within `perf_test'
movabsq $736989064, %rax # imm = 0x2BED8F88
vmovups (%rax), %xmm0
vmovups %xmm0, (%rcx)
movq %rcx, %rax
popq %rbp
retq
nopl (%rax,%rax)
; └
julia> @code_native perf_test_empty(obj, o->false)
.text
; ┌ @ REPL[7]:2 within `perf_test_empty'
pushq %rbp
movq %rsp, %rbp
movabsq $736990256, %rax # imm = 0x2BED9430
vmovups (%rax), %xmm0
vmovups %xmm0, (%rcx)
movq %rcx, %rax
popq %rbp
retq
nopl (%rax,%rax)
; └ We can also show what julia> @code_native perf_test(obj, o->o.value+=1)
.text
; ┌ @ REPL[6]:2 within `perf_test'
pushq %rbp
movq %rsp, %rbp
pushq %rsi
subq $40, %rsp
movq %rcx, %rsi
movq %rdx, -16(%rbp)
movabsq $"japi1_#27_17172", %rax
leaq -16(%rbp), %rdx
movl $811572056, %ecx # imm = 0x305F9B58
movl $1, %r8d
callq *%rax
; │ @ REPL[6]:3 within `perf_test'
movabsq $736989448, %rax # imm = 0x2BED9108
vmovups (%rax), %xmm0
vmovups %xmm0, (%rsi)
movq %rsi, %rax
addq $40, %rsp
popq %rsi
popq %rbp
retq
nopw (%rax,%rax)
; └
julia> @code_native perf_test_empty(obj, o->o.value+=1)
.text
; ┌ @ REPL[7]:2 within `perf_test_empty'
pushq %rbp
movq %rsp, %rbp
movabsq $736990128, %rax # imm = 0x2BED93B0
vmovups (%rax), %xmm0
vmovups %xmm0, (%rcx)
movq %rcx, %rax
popq %rbp
retq
nopl (%rax,%rax)
; └ Therefore, I now just call |
Note I relaxed the Colors.jl lower bound version requirement due to conflicts between Flux v0.10 and MCTS v0.4.3 (without issue) |
Ok, we are close... Thanks for being thorough! Unfortunately, I don't think I went ahead and fixed it by putting it into the planner object with a type parameter. (I am not sure if this is the absolute best pattern, but it is what I have been using and I am just maintaining consistency) I also added Colors 0.12 back into the compatibility in addition to 0.11. I don't think there is any reason to limit it to just 0.11. If the tests pass, I will merge this. |
Interesting and good to know—thanks for going ahead and fixing it! |
Ok, @mossr is there anything else to add before we register a new version? |
Being an "anytime" algorithm, it's nice to know how long MCTS will take :)
Therefore, I added support for using
@showprogress
from ProgressMeter.jl withinaction_info
for the DPWPlanner. Note the progress meter is off by default.I also added a
reset_callback(mdp, s)
option for the DWPSolver so you can specify a callback function to reset your MDP to a given state. I used these changes for a recent DASC 2020 paper.