-
Notifications
You must be signed in to change notification settings - Fork 42
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
init with event list clears the list #5
Comments
Good catch @matthewsowders ! @pierrelecuyer: Do you know why it is coded this way? We can call
Otherwise, we'll have to remove that sentence from the javadoc. |
@matthewsowders : Could you describe/explain the reason you would need to initialize the simulator with a non-empty event list (instead of adding the events after initialization)? |
I would like to run simulations that will run for 12 hours or more. I would like to make the system fault tolerant so I'd like to be able to serialize the state of the simulator (time, event data and schedule) at certain events. I would store the intermediate state in some service like S3 and use SimpleWorkflowService to manage the long running process that way if the simulation fails 11 hours into a 12 hour simulation, I can take the most recent state and continue the simulation from that point. I've attached some sample code. Let me know if I'm trying to do this a dumb way. |
Matthew:
It makes sense that you may want to do checkpoints in your simulations
for potential restarts.
The role of the current init method is just to empty the event list and
reset the simulation clock. The documentation you mentioned is indeed
misleading and would have to be changed. To do what you want, it seems
you will need a method that clones the event list completely, clone all
the events inside, and clone all objects in the simulation. We do not
have that at this time, so I think you will have to implement it (which
you can do, of course).
…-- Pierre L'Ecuyer
On 2/13/2017 3:49 PM, Matthew Sowders wrote:
I would like to run simulations that will run for 12 hours or more. I
would like to make the system fault tolerant so I'd like to be able to
serialize the state of the simulator (time, event data and schedule)
at certain events. I would store the intermediate state in some
service like S3 and use SimpleWorkflowService to manage the long
running process that way if the simulation fails 11 hours into a 12
hour simulation, I can take the most recent state and continue the
simulation from that point. I've attached some sample code. Let me
know if I'm trying to do this a dumb way.
sample-code.zip
<https://github.com/umontreal-simul/ssj/files/772344/sample-code.zip>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKp1oxnxarRkFBYIj8q9H-qvd7iNaJwuks5rcMHmgaJpZM4L8y0l>.
--
Pierre L'Ecuyer, Professeur Titulaire
Chaire du Canada en Simulation et Optimisation Stochastique
CIRRELT, GERAD, and DIRO, Université de Montréal, Canada
http://www.iro.umontreal.ca/~lecuyer
|
I had a quick look at your code and it seems this is what you did:
redefine a method that restores the event list to a list that was saved
earlier. I suggest this method could be called restoreEventList (...)
to avoid confusion with init() that already exists. You can just have
a class extension that does this (and perhaps something else...) for
you. If you really insist, we could add such a method in SSJ; however
we are a bit concerned that could be dangerous for bugs, because one
must make sure that all the objects to which the event list refers
indirectly haev been saved and restored!
Regards,
…-- Pierre L.
On 2/13/2017 4:54 PM, Pierre Lecuyer wrote:
Matthew:
It makes sense that you may want to do checkpoints in your simulations
for potential restarts.
The role of the current init method is just to empty the event list
and reset the simulation clock. The documentation you mentioned is
indeed misleading and would have to be changed. To do what you want,
it seems you will need a method that clones the event list completely,
clone all the events inside, and clone all objects in the simulation.
We do not have that at this time, so I think you will have to
implement it (which you can do, of course).
-- Pierre L'Ecuyer
On 2/13/2017 3:49 PM, Matthew Sowders wrote:
>
> I would like to run simulations that will run for 12 hours or more. I
> would like to make the system fault tolerant so I'd like to be able
> to serialize the state of the simulator (time, event data and
> schedule) at certain events. I would store the intermediate state in
> some service like S3 and use SimpleWorkflowService to manage the long
> running process that way if the simulation fails 11 hours into a 12
> hour simulation, I can take the most recent state and continue the
> simulation from that point. I've attached some sample code. Let me
> know if I'm trying to do this a dumb way.
>
> sample-code.zip
> <https://github.com/umontreal-simul/ssj/files/772344/sample-code.zip>
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#5 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AKp1oxnxarRkFBYIj8q9H-qvd7iNaJwuks5rcMHmgaJpZM4L8y0l>.
>
--
Pierre L'Ecuyer, Professeur Titulaire
Chaire du Canada en Simulation et Optimisation Stochastique
CIRRELT, GERAD, and DIRO, Université de Montréal, Canada
http://www.iro.umontreal.ca/~lecuyer
--
Pierre L'Ecuyer, Professeur Titulaire
Chaire du Canada en Simulation et Optimisation Stochastique
CIRRELT, GERAD, and DIRO, Université de Montréal, Canada
http://www.iro.umontreal.ca/~lecuyer
|
pierrelecuyer@ It could be made as an extension point such that the client is responsible for passing in a serializer/deserializer (I used jackson, but other users might want java serialization or something else). Then again, it was easy to write so maybe it is best left out of the simulation package. Maybe it would be better as an extension package outside SSJ, something like SSJ-serialization. Do you think it will be useful to others? |
Matthew:
Maybe would be useful to add it, maybe not, not sure. If you want to
add and submit an extension you are welcome! What I believe would be
even more useful are facilities for simulations running in parallel.
Unfortunately, on our side we are very busy with other work.
Sincerely,
Pierre L.
…On 2/14/2017 5:19 PM, Matthew Sowders wrote:
pierrelecuyer@
It could be made as an extension point such that the client is
responsible for passing in a serializer/deserializer (I used jackson,
but other users might want java serialization or something else). Then
again, it was easy to write so maybe it is best left out of the
simulation package. Maybe it would be better as an extension package
outside SSJ, something like SSJ-serialization. Do you think it will be
useful to others?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKp1o_9sCOcNXP-yt5W5Rci5g_QVG2XDks5rcih5gaJpZM4L8y0l>.
--
Pierre L'Ecuyer, Professeur Titulaire
Chaire du Canada en Simulation et Optimisation Stochastique
CIRRELT, GERAD, and DIRO, Université de Montréal, Canada
http://www.iro.umontreal.ca/~lecuyer
|
I have corrected the javadoc: 2d82af5 There are many ways to manage serialization, and it is likely implementation dependent. It is best left for advanced user to extend the Simulator, which is not too difficult as shown by @matthewsowders. |
Thanks to both of you for looking into this! |
Merge pull request #45 from pierrelecuyer/master
https://github.com/umontreal-simul/ssj/blob/master/src/main/java/umontreal/ssj/simevents/Simulator.java#L122
The method comment says 'To initialize the current
Simulator
with a not empty eventList is also possible, but the events scheduled in the eventList will be linked with the current simulator only.', but the method calls init() on line 129 which in turn clears the event list on line 110 so it does not look like it is possible to initialize the simulator with a non-empty event list.The text was updated successfully, but these errors were encountered: