Skip to content
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

[AERIE-2142] Global scheduling condition in scheduling eDSL + mutex #410

Merged

Conversation

adrienmaillard
Copy link
Contributor

@adrienmaillard adrienmaillard commented Oct 31, 2022

  • Tickets addressed: AERIE-2142
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

A global scheduling condition is an expression returning Windows associated to a list of activity types. When the scheduler is trying to insert an activity with a type in the list, and only in this case, the condition is evaluated. The condition is an expression of when an activity CAN be scheduled. It is combined with potential other expressions that reduces the intervals during which the activity can be scheduled (e.g. applyWhen, forEach in CoexistenceGoal...).

The mutex (mutual exclusion) in its general form can be defined for two lists of activity types. It postulates that activities with type in one of the list cannot overlap with activities in the other lists.

Now that I am writing about it, I'd rather call that noOverlap than mutex but this can be discussed, I do not know what term seems most natural. Anyway.

mutex([ A, B, C ], [D, E ,F]) means that any activity with type A or B or C can't intersect with any activity with type D, E, F. It is a relationship and it is reflexive = activities with types D, E, F can't overlap with A, B, C.

From this definition, a self-mutex can be defined as mutex([ A ][ A ]) which means that two activities of type A cannot overlap.

To implement this mutex condition, we use the Windows.Duringexpression defined in #402 and for each mutex we build two global scheduling condition objects.

mutex([ A, B, C ], [D, E ,F]) :=

gbs1 = {
expression = not(duringAny([ D, E, F]))
activityTypes = [A, B, C]
}

and 

gbs2 = {
expression = not(duringAny([ A, B, C]))
activityTypes = [D, E, F]
}

and we make a conjunction of them.

As you can see, the mutex condition needs two global scheduling condition to be enforced. And they are combined with an and operation (that is not yet available to the user).

In the scheduler server processing a conjunction of scheduling condition consists only in adding the elements of the conjunction in the set of global conditions.

Now the commits.

  1. Generated activity types are exported from the ones generated from the mission model and used in the constraints.
    so we can use the same types in the scheduling edsl and the constraints edsl (global conditions are part of the scheduling edsl but use constraints internally).
  2. I added GlobalSchedulingCondition class in the scheduling edsl and the corresponding node in the AST. There is also an GlobalSchedulingConditionAnd node in the AST.
    I have added three possibilities for the user to define scheduling conditions:
    a) scheduleActivitiesOnlyWhen(expression: WindowsEDSL.Windows) : building a scheduling condition with the given expression as well as ALL activity types from the mission model. This replaces what kind of existed before this PR where global scheduling conditions were defined only as an expression and were applying to all activity types.
    b) scheduleOnlyWhen(activityTypes: WindowsEDSL.Gen.ActivityType[], expression: WindowsEDSL.Windows) : building a scheduling condition with the given expression and the given activity types.
    c) mutex(activityTypes1: WindowsEDSL.Gen.ActivityType[], activityTypes2: WindowsEDSL.Gen.ActivityType[]): building the conjunction of global conditions described above.
  3. parsers for these new nodes in the backend.
  4. Remove notion of blacklist/whitelist in the GlobalSchedulingCondition in the scheduler. Use the conditions in the scheduler server. Tests.
  5. Remove the default self-mutex on activity types that we put some time ago to ensure that the CardinalityGoal would "work" (not place all activities at the same start time in absence of other constraints).

Verification

Tests were added and many existing tests have been modified so they include self-mutex (that was previously defined by default).

Documentation

  • Update the scheduling documentation when this is accepted.

Future work

UI for defining global scheduling conditions

@adrienmaillard adrienmaillard requested a review from a team as a code owner October 31, 2022 17:36
@adrienmaillard adrienmaillard added draft DON'T MERGE Do Not Merge This Branch breaking change A change that will require updating downstream code labels Oct 31, 2022
@camargo camargo added feature A new feature or feature request and removed draft labels Nov 2, 2022
@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from af70838 to 8bf60a7 Compare November 2, 2022 22:14
@adrienmaillard adrienmaillard changed the title [DRAFT][AERIE-2142] Global scheduling condition in scheduling eDSL + mutex [AERIE-2142] Global scheduling condition in scheduling eDSL + mutex Nov 2, 2022
@adrienmaillard adrienmaillard removed the DON'T MERGE Do Not Merge This Branch label Nov 2, 2022
@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from 8bf60a7 to db7c7ee Compare November 2, 2022 22:24
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 2, 2022 22:24 Inactive
@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from db7c7ee to 66bd5b1 Compare November 2, 2022 23:52
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 2, 2022 23:52 Inactive
@mattdailis mattdailis self-requested a review November 3, 2022 17:35
@Mythicaeda Mythicaeda temporarily deployed to e2e-test November 3, 2022 18:19 Inactive
Copy link
Collaborator

@mattdailis mattdailis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - you've really become adept at wrangling the eDSL 💯

Holding off my approval until I can do a manual test - I'll try to do that right now.

Copy link
Collaborator

@mattdailis mattdailis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some manual testing, looks like this is working for me 👍

We can potentially remove the ActivityType enum from the generated scheduler code, since it's identical to the one in constraints. Here's a commit for what that might involve: b12563d

@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from 20c369a to 601d192 Compare November 8, 2022 17:45
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 8, 2022 17:45 Inactive
@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from 601d192 to 8f2e668 Compare November 8, 2022 17:46
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 8, 2022 17:47 Inactive
@adrienmaillard
Copy link
Contributor Author

I have added your suggested commit in the branch @mattdailis, thank you.

@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from 8f2e668 to c0965de Compare November 8, 2022 17:52
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 8, 2022 17:52 Inactive
@mattdailis mattdailis mentioned this pull request Nov 8, 2022
8 tasks
@adrienmaillard adrienmaillard force-pushed the feature/AERIE-214X--complete-global-scheduling-cond branch from c0965de to 006b0d0 Compare November 9, 2022 00:22
@adrienmaillard adrienmaillard temporarily deployed to e2e-test November 9, 2022 00:22 Inactive
@adrienmaillard adrienmaillard merged commit 0d70641 into develop Nov 9, 2022
@adrienmaillard adrienmaillard deleted the feature/AERIE-214X--complete-global-scheduling-cond branch November 9, 2022 01:06
@camargo camargo added breaking change A change that will require updating downstream code and removed breaking change A change that will require updating downstream code labels Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change A change that will require updating downstream code feature A new feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants