Conversation
|
Hi @SCiarella, very nice, I like how this would drop the Looking at this, I have been thinking about the following: what if we would move the functionality to update the external states in the kiosk (essentially, what is currently in the class Engine(...):
def __init__(self, ..., update_external_states):
...
self.kiosk = VariableKiosk()
self.update_external_states = update_external_states
...
def _run(self):
"""Make one time step of the simulation."""
# Update timer
self.day, delt = self.timer()
# The following updates the external states in the kiosk for each day,
# - everything afterwards follow as it is (integration, agromanagement, rate calculation, ...)
self.update_external_states(day, self.kiosk)
...An advantage of this approach would be that one can more easily update the state/rate variables, using a rather generic procedure. Until now, one expects the external states for all dates to be known at the beginning of the simulation, but with the approach described above one could use What do you think? Of course what I am describing above could be added as part of a new PR! |
|
Your suggestion looks clean! I agree with you that it makes more sense for the Yes, let's open a new issue for this suggestion and include it in the development of the new |
Thanks for the suggestion. It sounds like a good idea to move the functionality of updating the kiosk with external states outside of the kiosk. In the current form of
I'm not sure if this is the case because at the beginning of the simulation (initialization) the kiosk selects only the external states of the "first day", see here. And later in
The function There are two scenarios:
If something not clear, please let me know.
|
|
Thanks for the feedback @SCiarella and @SarahAlidoost!
Right, what I meant is that the current implementation requires all time steps to be provided at the beginning of the simulation, but this is actually not necessary, as only one time step at the time is loaded in the kiosk.
But how would the pre-trained ML model be able to pass the states/rates to the other physical crop model components? I am thinking that we could make it possible via this
Right, you could also use But I might be overlooking something, good to discuss this in person! |
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella Thanks for implementing this. Please see my suggestions, mainly refactoring. Also, can you please make an issue for adding update_external_states to Engine as mentioned here.
Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com>
Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com>
Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com>
Co-authored-by: SarahAlidoost <55081872+SarahAlidoost@users.noreply.github.com>
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella thanks! 👍
|


Closes #22
Previously, running an individual sub-module like
DVS_Partitioningin isolation was only possible throughVariableKioskTestHelper, a test-only subclass living inutils.py. This PR promotes that capability into a properVariableKioskclass fordiffWOFOSTand removes the helper entirely.The new class accepts an optional
external_state_lista list of per-day dicts containing values for variables that would normally come from other sub-modules. Callingkiosk(day)advances to that day's entry and makes the values transparently available through the normal kiosk interface (kiosk["VAR"],kiosk.VAR,"VAR" in kiosk).Main changes:
__call__always returns False so the kiosk has no opinion on whether the simulation should stop. Callers that need to detect exhaustion of external states (like theTestEngine) use theexternal_states_exhaustedproperty instead. This makes the class usable outside of test contexts too.external_state_listcan be sparse: days with entries inject their values, days without entries simply clearcurrent_externalsand fall back to whatever is registered in the kiosk by other modules. This makes the class usable in partial-override scenarios where most variables come from the running model, but a few are forced externally.EngineTestHelpernow checkskiosk.external_states_exhaustedexplicitly to decide when to stop the test run, keeping that responsibility in the engine rather than the kiosk.VariableKiosksubclassespcse.VariableKioskVariableKioskTestHelperhas been removed andEngineTestHelperusesVariableKioskdirectlyVariableKioskhave been added.