-
Notifications
You must be signed in to change notification settings - Fork 21
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
Refactor RecurrenceGoal conflict production and solving #1510
Conversation
I faced some bugs that made me reconsider the semantics of the goal. @srschaffJPL helped me reflect on this subject, here is a summary. Alternative (easier) way of solving this issueWhen the user writes We could be explicit about this flexibility with additional operators which would have the user write something like
We would not have to depart from the current approach of independent conflict and activities could still be separated by more than 1 hour but it would be the user's problem, not ours. Note that the scheduler now schedules activities at their earliest start time. Important point: in Clipper recurrence goals are mostly concerned by enforcing that 2 activities are not separated by more than some duration. So the strictness is important which would go against this alternative way of solving the issue. Making
|
4e23719
to
1b61c27
Compare
1b61c27
to
2941d1e
Compare
2941d1e
to
51ff488
Compare
51ff488
to
3746b83
Compare
Discussed this with @adrienmaillard and @mattdailis earlier this week - looking good except it needs a rebase & potential conflict resolution. Also @adrienmaillard when you get a chance - please write a couple sentences for the Upgrade Guide when this is released, to advise users on the impact of the change. Thanks! |
3746b83
to
15e50ab
Compare
15e50ab
to
00070a4
Compare
00070a4
to
2b6dd23
Compare
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java
Fixed
Show fixed
Hide fixed
c0c52d1
to
3e5c12f
Compare
3e5c12f
to
1ef5466
Compare
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.
Did you make changes so that recurrence goal would add more activities if the minimum wasn't enough? I can't find it.
Nevermind, I found it.
...ver/src/main/java/gov/nasa/jpl/aerie/scheduler/conflicts/MissingActivityNetworkConflict.java
Show resolved
Hide resolved
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/ConflictSolverResult.java
Outdated
Show resolved
Hide resolved
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/goals/RecurrenceGoal.java
Show resolved
Hide resolved
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/gov/nasa/jpl/aerie/scheduler/conflicts/MissingActivityTemplateConflict.java
Outdated
Show resolved
Hide resolved
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java
Outdated
Show resolved
Hide resolved
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java
Outdated
Show resolved
Hide resolved
1ef5466
to
d70a59c
Compare
I have made the changes you mentioned. |
scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java
Show resolved
Hide resolved
Is there any check to make sure |
d70a59c
to
f94f50b
Compare
I have just added a check in |
Upgrade note for @dandelany RecurrenceGoal changes The behavior of the goal has been changed when setting its New parameters have been introduced to give more control over the behavior of the goal and how it is solved:
The solver will now try several combinations to solve this goal, starting with the least number of activities possible (separated by a greater distance), and increase the number of activities until either all the temporal constraints are satisfied or it reaches a dead-end. |
Description
See the ticket for the original issue. The cause for this issue is that
RecurrenceGoal
produces all the conflicts at onceBecause of this independence between conflicts, we had to find a way to specify temporal constraints for each conflict. What is done is that if the recurrence interval is 1 hour, each conflict is being given a 1-hour period to insert an activity. But you can see how this can result in 2 contiguous activities being separated by more than 1 hour (the first is scheduled at the start of its interval and the other at the end of its interval (because of a mutex possibly)).
I tried 2 approaches:
getConflicts
not only before but also after solving to see if new conflicts are discovered. I combined this with a change toRecurrenceGoal
so that it produces only one conflict at a time. Because conflicts would be produced one at a time, it would take into account the last activity insertion. Unfortunately, it required adding a specific block forRecurrenceGoal
in the solving loop and I had to update the definition ofRecurrenceGoal
at each iteration so it would not stay stuck in case one of the activity insertion fails. All of this just looked like a workaround for a bigger issue.MissingNetwork
conflict that contains a list of activities and their temporal constraints encoded as an STN. To solve this conflict, we go through each activity in the list, build aMissingActivityTemplateConflict
with the most up-to-date STN temporal constraints and give that to the regular solver for that type of conflict. Then, we update the STN bounds with the start/end times of the inserted activity, we propagate and we find the bounds for the next activity. And so on and so on.I ended up with 2 as this is more elegant and also will be useful to instantiate task networks in #1073 #870.
I am also updating how the API of this goal to include an explicit temporal flexibility definition. Instead of just the
every(Duration)
, I am addingseparatedByNoMoreThan(Duration)
andseparatedByNoLessThan(Duration)
. The first is the one leading to conflict production. Which means that there is no penalty by having smaller separations in existing plans but... when we create new activities we use the second operator to determine the minimum space between activities.I have refactored the
satisfyGoalGeneral
method ofPrioritySolver
to put the business logic of solving each type of conflict in its own method. It's just easier to read. And I needed to use one for this new work.I have also refactored the satisfaction concept in the scheduler so it's not just a ill-defined number.
Verification
Documentation
Future work
None.