- Tickets addressed: AERIE-1656
- Review: By commit
- Merge strategy: Merge (no squash)
Description
Note: this PR does not actually change any functionality, per se. It merely requires activities to explicitly opt-in to having their durations controlled by the scheduler.
Currently, the scheduler assumes that all activities have a duration
parameter, which can be used to control their duration. This is not, in general, true.
One option to reconcile this is to have the scheduler inspect the parameters of an activity type, and check if there is a duration
parameter with the correct type. However, this feels wrong to me, since it ascribes a meaning to a particular parameter name - something we've managed to avoid thus far. Parameter names should be completely up to the mission modelers.
The option I chose to pursue is to add an annotation, @ControllableDuration(parameterName = "myDurationParam")
that allows an activity definition to opt-in to being controllable by the scheduler. I added a validateControllableDurationParameter
method to the MissionModelParser
that checks that the string provided:
- corresponds to an existing parameter name
- that parameter has type Duration
The scheduler will be able to call TaskSpecType::getDurationType
on a particular activity's TaskSpecType, and get back whether the activity has opted-in to having a controllable duration:
public sealed interface DurationType {
record Controllable(String parameterName) implements DurationType {}
record Uncontrollable() implements DurationType {}
}
The contract between the scheduler and the mission model is that after simulating any activity marked with @ControllableDuration
, its actual duration is expected to be equal to the value of the declared duration parameter. The scheduler will rely on this fact to satisfy certain goals (such as lining up the end time of one activity with the start time of another activity).
I modified the scheduler to use getDurationType
to look up what parameter to set for a desired duration. For activities with Uncontrollable duration, the scheduler prints a warning, but does not throw an exception. The main reason here is I do not want to impede uncontrollable activities in existing plans. Future work is to test that the scheduler works with an existing plan.
Verification
I ran the aerie lander tests, and they passed (though they don't seem to have very clear success criteria, so I want to spend some time in a future PR making the tests stricter).
I'll make a corresponding PR to aerielander momentarily.
Documentation
This will, of course, need to be documented, but it's still in flux. We have a meeting with some stakeholders next week, where we'll get some feedback.
Future work
- Focused testing of controllable activity durations
- Testing of the scheduler against existing plans (i.e. not just plans generated from procedural rules, as the tests do now)
- It may be desirable to schedule activities whose duration is uncontrollable. This will place restrictions on the kinds of goals that can place this activity.
- There are potential performance benefits from getting more fine grained than
Uncontrollable
. For example, if the scheduler knew that an activity's duration is "Context Independent", it would know that the activity's duration is invariant under translation in time, which could reduce the necessity to re-simulate.
- It may also turn out to be useful to allow gradations of "Controllable". Some activities cannot uphold the contract of matching the requested duration exactly. Perhaps they have a lower bound for how long they will take. Perhaps the activity can only take multiples of a certain amount of time, so requesting a duration between two multiples would require the activity to decide whether to treat the requested duration as a lower or upper bound. (E.g. take "N" pictures takes "N" times the amount of time it takes to take a picture).