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

ForEach activity template parameter from anchor #546

Merged
merged 23 commits into from
Jan 26, 2023

Conversation

adrienmaillard
Copy link
Contributor

@adrienmaillard adrienmaillard commented Dec 20, 2022

Resolves #443
Resolves #445

  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

Features

  • The parameters in activity templates passed to a coexistence goal can now be assigned to values from the anchoring activity. Approach here is similar to the ForEachActivity pattern where an alias is defined for the coexistence goal and the activity template is a function of an ActivityInstance (from the constraints eDSL) with this alias as a parameter. This allows to express the reference to the anchoring activity to the backend and to evaluate expressions.
  • More generally, the parameters in activity templates can now be assigned to expressions producing a parameter of the desired type. And allow mixed definition in the case of complex data types (a subfield of a subfield can be an expression while the rest stay absolute values). Commit 3 add the building blocks for hierarchy of expressions. What happen is that even if the user is providing an absolute value, the activity template constructor is turning it into an Expression that will be evaluated. Activity template do not directly contain SerializedValue anymore.
  • The valueAt(profile, spans):DiscreteProfile is a new expression returning the value of a profile at a specific time. In this case, the passed spans must be a single instant. I believe this solves Choose the parameter of a “to be scheduled activity” based on a resource #445.

Fixes/changes:

  • AssignGaps now evaluates on the forever horizon.
  • Discrete and Real activity parameters expressions are defined on the forever horizon. Queried at a time outside the activity bounds, they can return the desired parameter. This allows instantiating a new activity that is not overlapping with an anchoring activity but references a parameter of the anchor activity.
  • ActivityInstance (in scheduler-driver) has been refactored into a record.
  • Obsolete constraints have been removed and replaced with appropriate global constraints
  • CoexistenceGoal now takes an Expression<Spans> as input
  • ActivityExpression now implements Expressions<Spans> so it can be used by CoexistenceGoal
  • Because CoexistenceGoal takes an Expression<Spans>, AerieLander tests have been commented. The constraints does not have the necessary expressive power yet to express what was expressed in these tests.

Verification

A few tests were added but more are needed. I just want this PR to start.

Documentation

Probably quite a lot of scheduling doc has to be updated.

Future work

  • Better representation of timepoints in the eDSL (some kind of DurationExpression) instead of Spans.
  • ?

@adrienmaillard adrienmaillard requested a review from a team as a code owner December 20, 2022 00:26
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 933567d to 7c63501 Compare December 20, 2022 00:40
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 7c63501 to 15f58cd Compare December 21, 2022 00:23
@camargo camargo added the feature A new feature or feature request label Dec 21, 2022
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 15f58cd to 34f0188 Compare December 21, 2022 00:39
@adrienmaillard adrienmaillard temporarily deployed to e2e-test December 21, 2022 00:39 — with GitHub Actions Inactive
@adrienmaillard adrienmaillard temporarily deployed to e2e-test December 21, 2022 01:25 — with GitHub Actions Inactive
@camargo
Copy link
Member

camargo commented Dec 21, 2022

@adrienmaillard provided the following examples for the Banananation model:

export default () =>
  Goal.CoexistenceGoal({
    forEach: ActivityExpression.ofType(ActivityTypes.GrowBanana),
    activityTemplate: growBananaActivity =>
      ActivityTemplates.PickBanana({ quantity: growBananaActivity.parameters.quantity }),
    startsAt: TimingConstraint.singleton(WindowProperty.END).plus(Temporal.Duration.from({ minutes: 5 })),
  });
export default () =>
  Goal.CoexistenceGoal({
    forEach: ActivityExpression.ofType(ActivityTypes.GrowBanana),
    activityTemplate: growBananaActivity =>
      ActivityTemplates.ChangeProducer({
        producer: Discrete.Resource('/producer').valueAt(growBananaActivity.span().starts()),
      }),
    startsAt: TimingConstraint.singleton(WindowProperty.END).plus(Temporal.Duration.from({ minutes: 5 })),
  });

Copy link
Contributor

@JoelCourtney JoelCourtney left a comment

Choose a reason for hiding this comment

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

Here's a review of the constraints side of things. I won't have time to go through all of the scheduler things today. Nice work!

@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 9b44bd9 to 094c837 Compare January 24, 2023 20:55
@adrienmaillard adrienmaillard temporarily deployed to e2e-test January 24, 2023 20:55 — with GitHub Actions Inactive
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 094c837 to f3f6c3a Compare January 24, 2023 20:58
@adrienmaillard adrienmaillard temporarily deployed to e2e-test January 24, 2023 20:58 — with GitHub Actions Inactive
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from f3f6c3a to d52594e Compare January 25, 2023 01:06
@adrienmaillard adrienmaillard temporarily deployed to e2e-test January 25, 2023 01:06 — with GitHub Actions Inactive
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from d52594e to 66ef552 Compare January 25, 2023 22:20
@adrienmaillard adrienmaillard temporarily deployed to e2e-test January 25, 2023 22:20 — with GitHub Actions Inactive
Conflicts carry EvaluationEnvironment to solver
Activity expression implements Expression<Spans>
As a result of the immediate above, aerie lander have been commented out, the constraints language do not have enough components to write the goals.
@adrienmaillard adrienmaillard force-pushed the 443-activity-template-parameter-from-anchro branch from 66ef552 to 3ab6974 Compare January 26, 2023 01:19
@adrienmaillard adrienmaillard temporarily deployed to e2e-test January 26, 2023 01:20 — with GitHub Actions Inactive
@JoelCourtney JoelCourtney self-requested a review January 26, 2023 01:39
Copy link
Contributor

@JoelCourtney JoelCourtney left a comment

Choose a reason for hiding this comment

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

noice

@adrienmaillard adrienmaillard merged commit 8f9baf3 into develop Jan 26, 2023
@adrienmaillard adrienmaillard deleted the 443-activity-template-parameter-from-anchro branch January 26, 2023 17:36
@camargo camargo added the scheduling Anything related to the scheduling domain label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or feature request scheduling Anything related to the scheduling domain
Projects
None yet
4 participants