Skip to content

Commit

Permalink
Merge pull request #1137 from NASA-AMMOS/981-incomplete-activity-inst…
Browse files Browse the repository at this point in the history
…ances

Array/List parameters are working again in scheduling
  • Loading branch information
adrienmaillard authored Sep 13, 2023
2 parents 5156052 + cb6062d commit 3aa7da3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ else if ((argument instanceof Discrete) || (argument instanceof Real)) {
}
else if(Array.isArray(argument)){
const arr: any[] = [];
argument.every((element) => { arr.push(makeAllDiscreteProfile(element))});
argument.forEach((element) => { arr.push(makeAllDiscreteProfile(element))});
return Discrete.List(arr).__astNode;
} else if (typeof argument === "object" ){
const obj: { [k: string]: any } = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ else if ((argument instanceof Discrete) || (argument instanceof Real)) {
}
else if(Array.isArray(argument)){
const arr: any[] = [];
argument.every((element) => { arr.push(makeAllDiscreteProfile(element))});
argument.forEach((element) => { arr.push(makeAllDiscreteProfile(element))});
return Discrete.List(arr).__astNode;
} else if (typeof argument === "object" ){
const obj: { [k: string]: any } = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.junit.jupiter.api.Assertions.*;

import gov.nasa.jpl.aerie.constraints.time.Interval;
import gov.nasa.jpl.aerie.foomissionmodel.mappers.FooValueMappers;
import gov.nasa.jpl.aerie.merlin.driver.ActivityDirective;
import gov.nasa.jpl.aerie.merlin.driver.ActivityDirectiveId;
import gov.nasa.jpl.aerie.merlin.driver.MissionModelLoader;
Expand Down Expand Up @@ -2657,4 +2658,34 @@ export default () => Goal.CoexistenceGoal({
assertEquals(1, peels.size());
assertEquals(peels.iterator().next().startOffset(), Duration.of(5, MINUTE).plus(Duration.of(2, activityDuration)));
}

@Test
void testListOfListParam() {
final var results = runScheduler(FOO, List.of(), List.of(new SchedulingGoal(new GoalId(0L), """
export default function myGoal() {
return Goal.CardinalityGoal({
activityTemplate: ActivityTemplates.foo({
x: 1,
y:"test2",
z:3,
vecs: [[1, 2, 3], [4, 5, 6]]
}),
specification : {occurrence: 1}
})
}
""", true)),List.of(), PLANNING_HORIZON);
assertEquals(1, results.scheduleResults.goalResults().size());
final var goalResult = results.scheduleResults.goalResults().get(new GoalId(0L));

assertTrue(goalResult.satisfied());

final var activitiesByType = partitionByActivityType(results.updatedPlan());

final var foos = activitiesByType.get("foo");
assertEquals(1, foos.size());
final var insertedFoo = foos.iterator().next();
final var vecs = insertedFoo.serializedActivity().getArguments().get("vecs").asList();
assertTrue(vecs.isPresent());
assertEquals(2, vecs.get().size());
}
}

0 comments on commit 3aa7da3

Please sign in to comment.