diff --git a/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx b/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx index 52e765b..ec241e7 100644 --- a/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx +++ b/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem'; # The Plan & Simulation Results The two main interfaces you'll query data from are `Plan` and `SimulationResults`. In constraints, they are provided as -separate objects, they are combined into one object called `EditablePlan`. +separate objects, while in scheduling they are combined into one object called `EditablePlan`. ## `Plan` @@ -33,29 +33,14 @@ so we assume the duration of the anchor target is `0`. The directives are always up-to-date, even if the simulation results aren't. -## Simulation Results - -The `SimulationResults` object contains the activity instances and resource profiles of a simulation run. - -### Instances - -Activity instances are the simulated version of a directive; they have a duration, a definite grounded start time -(in the case of anchored activities), and any computed attributes the activity defines, in addition to all the data -stored in the directive. - -All instances have an `id: ActivityInstanceId` field, which usually, but not always matches the id of the corresponding -directive. For clarity, it also includes a `directiveId: ActivityDirectiveId?` field which *might be null*, because some -instances are spawned from other activities and don't have a corresponding directive. - -You can query instances the same way as directives, using `simResults.instances(...)`. +### External dataset profiles -### Resources - -You can query resources with `simResults.resource("/my/resource", )`. Unlike activities, there is no option +You can query resources from *externally uploaded datasets* with `plan.resource("/my/resource", )`. +Unlike activities, there is no option to use a default deserializer; you must pick one, because it determines the profile type. Each profile type provides a deserializer for you to use, so for example, you can get a string resource with `simResults.resource("/my/string", Strings.deserializer())`. -If you made your own data structure for your resource (say, `V`), you'll probably want to use the `Constants` profile. +If you made your own data structure to represent the resource values (say, `V`), you'll probably want to use the `Constants` profile. But unfortunately you have to do any deserialization yourself. If you don't want to, you can just use `.resource("/my/object", Constants::new)`, but this will return `Constants`. To do proper deserialization, call `Constants.deserializer`: @@ -66,7 +51,6 @@ but this will return `Constants`. To do proper deserialization, // Segment payload we will deserialize into. data class Point2(x: Double, y: Double) {} -// note the use of . instead of :: here! v val myResource = plan.resource("/my/object", Constants.deserializer { val fields = it.asMap().get() Point2(fields.get("x").asReal().get(), fields.get("y").asReal().get()) @@ -80,7 +64,6 @@ val myResource = plan.resource("/my/object", Constants.deserializer { // Segment payload we will deserialize into. record Point2(double x, double y) {} -// note the use of . instead of :: here! v final var myResource = plan.resource("/my/object", Constants.deserializer($ -> { final var fields = it.asMap().get(); return new Point2(fields.get("x").asReal().get(), fields.get("y").asReal().get()); @@ -89,3 +72,32 @@ final var myResource = plan.resource("/my/object", Constants.deserializer($ -> { + +:::tip + +The `Plan` object only has access to non-simulated resource uploaded in [external datasets](../../../planning/external-datasets). +To access simulated resources, use a `SimulationResults` object. (see below) + +::: + +## Simulation Results + +The `SimulationResults` object contains the activity instances and resource profiles of a simulation run. + +### Instances + +Activity instances are the simulated version of a directive; they have a duration, a definite grounded start time +(in the case of anchored activities), and any computed attributes the activity defines, in addition to all the data +stored in the directive. + +All instances have an `id: ActivityInstanceId` field, which usually, but not always matches the id of the corresponding +directive. For clarity, it also includes a `directiveId: ActivityDirectiveId?` field which *might be null*, because some +instances are spawned from other activities and don't have a corresponding directive. + +You can query instances the same way as directives, using `simResults.instances(...)`. + +### Resources + +Simulated resources can be accessed exactly the same way as [external resources](#external-dataset-profiles), but through the `SimulationResults` object. +So in the example above, if the `/my/object` resource was simulated instead of uploaded, +you would access it using `simResults.resource("/my/object", Constants.deserializer(...))`;