Skip to content

Commit

Permalink
small edits to events docs: comments on examples, update External Eve…
Browse files Browse the repository at this point in the history
…nts page to link to scheduling docs and remove from 'coming soon' section
  • Loading branch information
dandelany committed Nov 6, 2024
1 parent dc0dbe8 commit 1a6b2e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
21 changes: 7 additions & 14 deletions docs/planning/external-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,13 @@ As a final note on the frontend, it is worth briefly detailing what parts of the
- _External Event Type filters_ - the External Event Type filters selected in the timeline editor,
- _External Event options_ - the options in the timeline editor filter.

## Scheduling Activities from Events
External events associated with a plan are accessible from the [Procedural Scheduling](../../scheduling-and-constraints/procedural/introduction/) API, just like resources and activities. This allows users to write scheduling goals which create activities based on the presence (or absence) of external events - for example, "create a downlink activity 5 minutes after the start of every 'DSN Contact' type event".

To access events in a procedural goal, you must create an External Events timeline object - see [Timelines: External Events](../../scheduling-and-constraints/procedural/timelines/basics/external-events/). A full example of a scheduling goal using events can be found on the [Procedural Scheduling Examples](../../scheduling-and-constraints/procedural/scheduling/examples/#scheduling-based-off-of-external-events) page.

Currently, external events are **not accessible from the [Declarative Scheduling EDSL](http://localhost:3000/aerie-docs/scheduling-and-constraints/declarative/scheduling/introduction/)** - but we may implement support for this in the future.

## What Remains
Here, we discuss briefly everything that is not currently implemented but that we do plan to in the future.

Expand All @@ -554,17 +561,3 @@ It might make sense to add ownership, i.e. a given user owns an External Source

That being said, as we move forward with more features relating to External Events, more nuance may come to the problem of ownership and roles. Once plans start actually depending on these plans, the rules surrounding ownership and permissions may need to change or be entirely rethought. Ultimately, we need something that justifies the implementation of such a scheme in that it provides more than the status quo.

### Scheduling/Constraints

This is the biggest "coming-next" feature, but also the least explored. It is planned to be part of the next batch of work relating to External Events. We would like External Events to get the same visibility that activities and resources get in the scheduling and constraints EDSLs and engines. Ideally, we could define a scheduling goal (or constraint), like the following:

```
export default () =>
Goal.CoexistenceGoal({
forEach: ExternalEventExpression.ofType(ExternalEventTypes.Eclipse),
activityTemplate: ActivityTemplates.SolarDisable({ rate: 0.5 }),
startsAt: TimingConstraint.singleton(WindowProperty.START)
});
```

which might be how one could write a scheduling goal to place an activity disabling a solar panel whenever an eclipse occurred.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public record ActivityRecurrenceGoal() implements Goal {
for (final var time: plan.totalBounds().step(Duration.hours(2))) {
if (!existingActivities.sample(time)) {
plan.create(
// use NewDirective() to specify names/arguments for activities
new NewDirective(
// parameters
new AnyDirective(Map.of(
Expand Down Expand Up @@ -115,6 +116,7 @@ public record ActivityCoexistenceGoal() implements Goal {
"quantity", SerializedValue.of(growQuantity)
)
);
// mock the effect of new activity on fruit resource, so we don't need to resimulate
mockedFruit = mockedFruit.plus(Real.step(biteInterval.start, growQuantity));
}
}
Expand All @@ -124,7 +126,7 @@ public record ActivityCoexistenceGoal() implements Goal {
}
```

## Scheduling Based off of External Events
## Scheduling From External Events

Consider this set of events:

Expand Down Expand Up @@ -157,7 +159,7 @@ public record ExternalEventsSourceQueryGoal() implements Goal {
null,
new ExternalSource("NewTest.json", "TestGroup_2")
);

// look for events where key contains "01"
final var events = plan.events(eventQuery).filter(false, $ -> $.key.contains("01"));

for (final var e: events) {
Expand Down

0 comments on commit 1a6b2e3

Please sign in to comment.