diff --git a/docs/scheduling-and-constraints/procedural/constraints.mdx b/docs/scheduling-and-constraints/procedural/constraints.mdx index bce4809..ae85c12 100644 --- a/docs/scheduling-and-constraints/procedural/constraints.mdx +++ b/docs/scheduling-and-constraints/procedural/constraints.mdx @@ -22,7 +22,7 @@ just return it. They can be created with some provided static constructor functi @ConstraintProcedure class BatteryAboveZero: Constraint { override fun run(plan: Plan, simResults: SimulationResults) = Violations.inside( - plan.resource("/battery_soc", Real.deserialize()).lessThan(0).highlightTrue() + plan.resource("/battery_soc", Real.deserializer()).lessThan(0).highlightTrue() ) } ``` @@ -37,7 +37,7 @@ public class BatterAboveZero implements Constraint { @Override public Violations run(@NotNull Plan plan, @NotNull SimulationResults simResults) { return Violations.inside( - plan.resource("/battery_soc", Real.deserialize()).lessThan(0).highlightTrue() + plan.resource("/battery_soc", Real.deserializer()).lessThan(0).highlightTrue() ); } } @@ -69,7 +69,7 @@ For example, to violate whenever `MyActivity` occurs when `/my/resource < 0`, yo @ConstraintProcedure class MyConstraint: GeneratorConstraint() { override fun generate(plan: Plan, simResults: SimulationResults) { - val myResource = simResults.resource("/my/resource", Real.deserialize()).cache() + val myResource = simResults.resource("/my/resource", Real.deserializer()).cache() for (activity in plan.directives("MyActivity")) { if (myResource.sample(activity.startTime) < 0) violate(Violation(activity.interval)) @@ -86,7 +86,7 @@ class MyConstraint: GeneratorConstraint() { public class MyConstraint extends GeneratorConstraint { @Override public void generate(@NotNull Plan plan, @NotNull SimulationResults simResults) { - final var myResource = simResults.resource("/my/resource", Real.deserialize()).cache(); + final var myResource = simResults.resource("/my/resource", Real.deserializer()).cache(); for (final var activity: plan.directives("MyActivity")) { if (myResource.sample(activity.startTime) < 0) violate(Violation(activity.interval)); @@ -107,7 +107,7 @@ normally. @ConstraintProcedure class BatteryAboveZero: GeneratorConstraint() { override fun generate(plan: Plan, simResults: SimulationResults) { - simResults.resource("/battery_soc", Real.deserialize()) + simResults.resource("/battery_soc", Real.deserializer()) .greaterThan(0) // Only works in a generator constraint! @@ -135,7 +135,7 @@ class MyConstraint: GeneratorConstraint() { override fun message() = "MyActivity cannot start when /my/resource < 0" override fun generate(plan: Plan, simResults: SimulationResults) { - val myResource = simResults.resource("/my/resource", Real.deserialize()).cache() + val myResource = simResults.resource("/my/resource", Real.deserializer()).cache() for (activity in plan.directives("MyActivity")) { if (myResource.sample(activity.startTime) < 0) violate(Violation(activity.interval)) @@ -157,7 +157,7 @@ public class MyConstraint extends GeneratorConstraint { @Override public void generate(@NotNull Plan plan, @NotNull SimulationResults simResults) { - final var myResource = simResults.resource("/my/resource", Real.deserialize()).cache(); + final var myResource = simResults.resource("/my/resource", Real.deserializer()).cache(); for (final var activity: plan.directives("MyActivity")) { if (myResource.sample(activity.startTime) < 0) violate(Violation(activity.interval)); 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 ffb3cb8..52e765b 100644 --- a/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx +++ b/docs/scheduling-and-constraints/procedural/plan-and-sim-results.mdx @@ -53,11 +53,11 @@ You can query instances the same way as directives, using `simResults.instances( You can query resources with `simResults.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.deserialize())`. +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. 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.deserialize`: +but this will return `Constants`. To do proper deserialization, call `Constants.deserializer`: @@ -67,7 +67,7 @@ but this will return `Constants`. To do proper deserialization, data class Point2(x: Double, y: Double) {} // note the use of . instead of :: here! v -val myResource = plan.resource("/my/object", Constants.deserialize { +val myResource = plan.resource("/my/object", Constants.deserializer { val fields = it.asMap().get() Point2(fields.get("x").asReal().get(), fields.get("y").asReal().get()) }) @@ -81,7 +81,7 @@ val myResource = plan.resource("/my/object", Constants.deserialize { record Point2(double x, double y) {} // note the use of . instead of :: here! v -final var myResource = plan.resource("/my/object", Constants.deserialize($ -> { +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()); })); diff --git a/docs/scheduling-and-constraints/procedural/timelines/basics/common-operations.mdx b/docs/scheduling-and-constraints/procedural/timelines/basics/common-operations.mdx index 62c912f..90223be 100644 --- a/docs/scheduling-and-constraints/procedural/timelines/basics/common-operations.mdx +++ b/docs/scheduling-and-constraints/procedural/timelines/basics/common-operations.mdx @@ -66,7 +66,7 @@ Highlighting is often used to iterate through the regions when a certain conditi ```kotlin -val myResource = plan.resource("my_resource", Real.deserialize()) +val myResource = plan.resource("my_resource", Real.deserializer()) for (interval in myResource.highlightEqualTo(3)) { // Do something with the interval // `interval` is JUST an interval, the original segment has been lost. @@ -77,7 +77,7 @@ for (interval in myResource.highlightEqualTo(3)) { ```java -final var myResource = plan.resource("my_resource", Real.deserialize()); +final var myResource = plan.resource("my_resource", Real.deserializer()); for (final var interval: myResource.highlightEqualTo(3)) { // Do something with the interval // `interval` is JUST an interval, the original segment has been lost. diff --git a/docs/scheduling-and-constraints/procedural/timelines/basics/sampling-and-caching.mdx b/docs/scheduling-and-constraints/procedural/timelines/basics/sampling-and-caching.mdx index d1f373e..121cbef 100644 --- a/docs/scheduling-and-constraints/procedural/timelines/basics/sampling-and-caching.mdx +++ b/docs/scheduling-and-constraints/procedural/timelines/basics/sampling-and-caching.mdx @@ -18,8 +18,8 @@ but sometimes a collect call is hidden inside another operation. Let's take the ```kotlin -val n1 = plan.resource("int_resource_1", Numbers.deserialize()) -val n2 = plan.resource("int_resource_2", Numbers.deserialize()) +val n1 = plan.resource("int_resource_1", Numbers.deserializer()) +val n2 = plan.resource("int_resource_2", Numbers.deserializer()) // Construct a very expensive profile that we should only evaluate once. val superExpensiveProfile = n1.map2Values(n2) { l, r, _ -> ackermann(l, r) } @@ -29,8 +29,8 @@ val superExpensiveProfile = n1.map2Values(n2) { l, r, _ -> ackermann(l, r) } ```java -final var n1 = plan.resource("int_resource_1", Numbers.deserialize()); -final var n2 = plan.resource("int_resource_2", Numbers.deserialize()); +final var n1 = plan.resource("int_resource_1", Numbers.deserializer()); +final var n2 = plan.resource("int_resource_2", Numbers.deserializer()); // Construct a very expensive profile that we should only evaluate once. final var expensiveProfile = n1.map2Values(n2, (l, r, _) -> ackermann(l, r)); diff --git a/docs/scheduling-and-constraints/procedural/timelines/basics/windows.mdx b/docs/scheduling-and-constraints/procedural/timelines/basics/windows.mdx index 870d7bc..7ffa768 100644 --- a/docs/scheduling-and-constraints/procedural/timelines/basics/windows.mdx +++ b/docs/scheduling-and-constraints/procedural/timelines/basics/windows.mdx @@ -17,7 +17,7 @@ use it in a for-each loop (which calls `.collect` under the hood). For example, ```kotlin -val myResource = plan.resource("my_resource", Real.deserialize()) +val myResource = plan.resource("my_resource", Real.deserializer()) for (interval in myResource.highlightEqualTo(3)) { // do something with the interval } @@ -27,7 +27,7 @@ for (interval in myResource.highlightEqualTo(3)) { ```java -final var myResource = plan.resource("my_resource", Real.deserialize()); +final var myResource = plan.resource("my_resource", Real.deserializer()); for (final var interval: myResource.highlightEqualTo(3)) { // do something with the interval }