Skip to content

Commit

Permalink
Implementation of time-relative intervals, represented as temporal in…
Browse files Browse the repository at this point in the history
…tervals with start and end times relative to a time point. The time-relative intervals are used to represent allen relations between two activities in a coexistence goal. Examples of the seven main relations have been implemented in SchedulingIntegrationTests.
  • Loading branch information
JMVictor authored and JMVictor committed Aug 4, 2023
1 parent 1d7c1b8 commit 49589d4
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public static Goal goalOfGoalSpecifier(
final var endConstraint = g.endConstraint().get();
if (endConstraint instanceof SchedulingDSL.TimingConstraint.ActivityTimingConstraint e) {
builder.endsAt(makeTimeExpressionRelativeFixed(e));
} if (endConstraint instanceof SchedulingDSL.TimingConstraint.ActivityTimingConstraintFlexibleRange e) {
builder.startsAt(new TimeExpressionBetween(makeTimeExpressionRelativeFixed(e.lowerBound()), makeTimeExpressionRelativeFixed(e.upperBound())));
} else if (endConstraint instanceof SchedulingDSL.TimingConstraint.ActivityTimingConstraintFlexibleRange e) {
builder.endsAt(new TimeExpressionBetween(makeTimeExpressionRelativeFixed(e.lowerBound()), makeTimeExpressionRelativeFixed(e.upperBound())));
} else {
throw new UnexpectedSubtypeError(SchedulingDSL.TimingConstraint.class, endConstraint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export interface ActivityCoexistenceGoal {
activityFinder: ActivityExpression<any> | undefined,
alias: string,
forEach: WindowsExpressions.WindowsExpression | ActivityExpression<any>,
startConstraint: ActivityTimingConstraintSingleton | ActivityTimingConstraintRange | ActivityTimingConstraintFlexibleRange | undefined,
endConstraint: ActivityTimingConstraintSingleton | ActivityTimingConstraintRange | ActivityTimingConstraintFlexibleRange | undefined,
startConstraint: ActivityTimingConstraintSingleton | ActivityTimingConstraintRange | ActivityTimingConstraintInterval | undefined,
endConstraint: ActivityTimingConstraintSingleton | ActivityTimingConstraintRange | ActivityTimingConstraintInterval | undefined,
shouldRollbackIfUnsatisfied: boolean
}

Expand Down Expand Up @@ -138,12 +138,11 @@ export interface ActivityTimingConstraintRange {
singleton: false
}

export interface ActivityTimingConstraintFlexibleRange {
lowerBound: ActivityTimingConstraintSingleton,
upperBound: ActivityTimingConstraintSingleton,
singleton: false
export interface ActivityTimingConstraintInterval {
lowerBound: ActivityTimingConstraintSingleton;
upperBound: ActivityTimingConstraintSingleton;
singleton: false;
}

export type GoalSpecifier =
| Goal
| GoalComposition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as WindowsEDSL from "./constraints-edsl-fluent-api.js";
import {ActivityInstance} from "./constraints-edsl-fluent-api.js";
import * as ConstraintsAST from "./constraints-ast.js";
import {makeArgumentsDiscreteProfiles} from "./scheduler-mission-model-generated-code";
import type {ActivityTimingConstraintFlexibleRange} from "./scheduler-ast.js";

type WindowProperty = AST.WindowProperty
type TimingConstraintOperator = AST.TimingConstraintOperator
Expand Down Expand Up @@ -520,7 +519,7 @@ export class Goal {
/**
* An StartTimingConstraint is a constraint applying on the start time of an activity template.
*/
export type StartTimingConstraint = { startsAt: SingletonTimingConstraint | SingletonTimingConstraintNoOperator } | { startsWithin: RangeTimingConstraint | FlexibleRangeTimingConstraint }
export type StartTimingConstraint = { startsAt: SingletonTimingConstraint | SingletonTimingConstraintNoOperator } | { startsWithin: RangeTimingConstraint | FlexibleRangeTimingConstraint}
/**
* An EndTimingConstraint is a constraint applying on the end time of an activity template.
*/
Expand Down Expand Up @@ -698,17 +697,17 @@ export class RangeTimingConstraint {
}

/**
* A flexible range timing constraint specifies that the start or the end time of an activity must be within certain bounds. Use {@link TimingConstraint.singleton} to specify the bounds.
* A FlexibleRange timing constraint specifies that the start or the end time of an activity must be within certain bounds. Use {@link TimingConstraint.bounds} to specify the bounds.
*/
export class FlexibleRangeTimingConstraint {
/** @internal **/
public readonly __astNode: AST.ActivityTimingConstraintFlexibleRange
public readonly __astNode: AST.ActivityTimingConstraintInterval
/** @internal **/
private constructor(__astNode: AST.ActivityTimingConstraintFlexibleRange) {
private constructor(__astNode: AST.ActivityTimingConstraintInterval) {
this.__astNode = __astNode;
}
/** @internal **/
public static new(__astNode: AST.ActivityTimingConstraintFlexibleRange): FlexibleRangeTimingConstraint {
public static new(__astNode: AST.ActivityTimingConstraintInterval): FlexibleRangeTimingConstraint {
return new FlexibleRangeTimingConstraint(__astNode);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ record MissionModelInfo(Path libPath, Path modelPath, String modelName, MissionM
private Optional<MissionModelInfo> missionModelInfo = Optional.empty();
private MerlinPlan initialPlan;
Collection<ActivityDirective> updatedPlan;
Plan plan;

MockMerlinService() {
this.initialPlan = new MerlinPlan();
Expand Down Expand Up @@ -87,7 +88,7 @@ public PlanMetadata getPlanMetadata(final PlanId planId)
this.missionModelInfo.get().config());
}

@Override
@Override
public MerlinPlan getPlanActivityDirectives(final PlanMetadata planMetadata, final Problem mission)
{
// TODO this gets the planMetadata from above
Expand Down Expand Up @@ -120,6 +121,7 @@ public Map<SchedulingActivityDirective, ActivityDirectiveId> updatePlanActivityD
)
{
this.updatedPlan = extractActivityDirectives(plan);
this.plan = plan;
final var res = new HashMap<SchedulingActivityDirective, ActivityDirectiveId>();
for (final var activity : plan.getActivities()) {
res.put(activity, new ActivityDirectiveId(activity.id().id()));
Expand Down
Loading

0 comments on commit 49589d4

Please sign in to comment.