Generalized Dynamic Resources #1645
Replies: 5 comments 2 replies
-
|
The streamline contrib library that David Legg developed has an |
Beta Was this translation helpful? Give feedback.
-
|
It's certainly possible to have some complex events emitted that can change a resource in creative ways. The Europa Clipper model often emits lambda functions to operate on a resource state just to avoid having to enumerate specific effect types. I suppose an |
Beta Was this translation helpful? Give feedback.
-
|
You ask how hard all this would be. I'm not sure if David's implementation addresses all of the things you mention, but what David did was really hard, at least for David. . . . I mean, even for David. ;-) |
Beta Was this translation helpful? Give feedback.
-
|
@JoelCourtney, @bradNASA . Here is an example of polynomial implemented by @ewferg that we use to model power production:
The main problem is the performance. In Endurance, I simulate a mission (>200k activities) in 30 seconds. When I add the power model with RTG and Battery, the simulation takes ~300 seconds, which is a huge impact. |
Beta Was this translation helpful? Give feedback.
-
|
To Brad's point - I think that the piecewise-dynamics part of this idea shouldn't be too hard to implement, actually. I think you could write an interface called One final note on implementation - for performance, you probably want the pieces in this piecewise object in something like a lazy list. Something that only computes a piece when it's asked for, unlike a List, but also stores that piece so it can be retrieved many times, unlike a Stream. I'm thinking of things like the approximation for the RTG - getting a piece of that dynamics is fairly expensive, because the approximation code runs optimizers and stuff. Also, there's no reason to limit how many pieces that dynamics could have - as the simulation goes on, it should just keep stacking more pieces onto that approximation, effectively expanding an ever-increasing slice of a theoretically infinite list of pieces. Another idea I'm stealing from Haskell 😄 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently Merlin's only type of resource that has dynamics (as in it represents a value that changes over time even when you're not touching it) is linear equations. There have been requests and complaints over the years about not being able to represent other types of functions like higher degree polynomials, sinusoids, exponential decay, etc., but I guess there's never been an extremely compelling use case to support them first-class. Users have always been able to work around this limitation by emitting linear approximations with a high enough sample rate for it to be "good enough".
But I think that by not working in that direction, we didn't notice some extremely useful advantages that we could get by supporting arbitrary dynamics. Specifically I'm talking about piecewise functions. Resources are already piecewise functions, but each of those pieces is emitted by a separate write operation, with its own
delayin the activity or daemon effect model. If a single write operation could emit many pieces into the future it could unlock some new patterns that would be very powerful.Hypotheticals
Emitting any behavior would allow modelers to more easily express the future evolution of a resource as it would be if nothing else changed. Say you want to write a preheat curve to a temperature resource. If all goes well this could be a pretty complicated function (on M20 this would be an exponential growth up to a high set point, followed by oscillation between between low and high set points for the rest of the preheat margin and subsequent activity). It would be nice to emit that whole thing in one event at the start of the preheat. But the cool part is if something goes wrong.
If the preheat is aborted (say something else triggers safe mode), we want to replace the future behavior with an exponential decay back to ambient temperature. In Merlin's current design, this means sending some sort of message to whatever routine is emitting the heat curve to tell it to stop, or having the routine constantly check for conditions that would make it abort. But if the entire preheat curve was emitted an hour ago and there's no ongoing routine, you can just overwrite the rest of it with the exponential decay.
Concurrent logic in a single activity
Say you want to model two concurrent behaviors in one activity (like heating and telecom, or driving and power). They both have effects over time, potentially with dynamic delays in between operations. Currently you have two options:
delayto jump to the next time something happens, because you have to juggle the dynamic delays of both behaviors and interleave them in monotonically increasing time. Just because these two behaviors belong in one activity doesn't mean they should be mixed together in the same control flow.If you could emit arbitrary functions in to the future, this would let the modeler express one behavior alone, then cognitively rewind time to express the other, without actually having to roll back simulation somehow.
How hard would this be?
Frankly I have no idea. I don't know how hard it would be because I haven't worked much with Merlin internals. Feel free to tell me this is a pipe dream or fundamentally incompatible with the resource framework.
Outside of Merlin, I do know that we could make things easier by flattening out the pieces in each profile, regardless of whether those pieces occurred at a write operation or in between.
Beta Was this translation helpful? Give feedback.
All reactions