-
Notifications
You must be signed in to change notification settings - Fork 110
H-5691: Simulation Timeline Visualizer #8211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7f0b7fe
771da53
f6725f0
993f6c7
aa25871
5f2136c
58226f8
8cfc104
bbd432c
5312010
d9ff655
fe16268
92364a9
c3062f2
064b811
0658fe8
3d4dc9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@hashintel/petrinaut": patch | ||
| --- | ||
|
|
||
| Add Simulation Timeline Visualizer |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| import { deriveDefaultParameterValues } from "../../hooks/use-default-parameter-values"; | ||
| import { | ||
| deriveDefaultParameterValues, | ||
| mergeParameterValues, | ||
| } from "../../hooks/use-default-parameter-values"; | ||
| import { SDCPNItemError } from "../errors"; | ||
| import type { | ||
| DifferentialEquationFn, | ||
|
|
@@ -52,7 +55,13 @@ function getPlaceDimensions( | |
| * @throws {Error} if user code fails to compile | ||
| */ | ||
| export function buildSimulation(input: SimulationInput): SimulationInstance { | ||
| const { sdcpn, initialMarking, seed, dt } = input; | ||
| const { | ||
| sdcpn, | ||
| initialMarking, | ||
| parameterValues: inputParameterValues, | ||
| seed, | ||
| dt, | ||
| } = input; | ||
|
|
||
| // Build maps for quick lookup | ||
| const placesMap = new Map(sdcpn.places.map((place) => [place.id, place])); | ||
|
|
@@ -61,8 +70,13 @@ export function buildSimulation(input: SimulationInput): SimulationInstance { | |
| ); | ||
| const typesMap = new Map(sdcpn.types.map((type) => [type.id, type])); | ||
|
|
||
| // Build parameter values from SDCPN parameters using the shared utility | ||
| const parameterValues = deriveDefaultParameterValues(sdcpn.parameters); | ||
| // Build parameter values: merge input values with SDCPN defaults | ||
| // Input values (from simulation store) take precedence over defaults | ||
| const defaultParameterValues = deriveDefaultParameterValues(sdcpn.parameters); | ||
| const parameterValues = mergeParameterValues( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
π€ Was this useful? React with π or π |
||
| inputParameterValues, | ||
| defaultParameterValues, | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Boolean parameters become NaN when merged in simulationThe new code path calls |
||
|
|
||
| // Validate that all places in initialMarking exist in SDCPN | ||
| for (const placeId of initialMarking.keys()) { | ||
|
|
@@ -111,9 +125,9 @@ export function buildSimulation(input: SimulationInput): SimulationInstance { | |
| differentialEquationFns.set(place.id, fn as DifferentialEquationFn); | ||
| } catch (error) { | ||
| throw new SDCPNItemError( | ||
| `Failed to compile differential equation for place \`${place.name}\`:\n\n${ | ||
| error instanceof Error ? error.message : String(error) | ||
| }`, | ||
| `Failed to compile differential equation for place \`${ | ||
| place.name | ||
| }\`:\n\n${error instanceof Error ? error.message : String(error)}`, | ||
| place.id, | ||
| ); | ||
| } | ||
|
|
@@ -129,9 +143,9 @@ export function buildSimulation(input: SimulationInput): SimulationInstance { | |
| lambdaFns.set(transition.id, fn as LambdaFn); | ||
| } catch (error) { | ||
| throw new SDCPNItemError( | ||
| `Failed to compile Lambda function for transition \`${transition.name}\`:\n\n${ | ||
| error instanceof Error ? error.message : String(error) | ||
| }`, | ||
| `Failed to compile Lambda function for transition \`${ | ||
| transition.name | ||
| }\`:\n\n${error instanceof Error ? error.message : String(error)}`, | ||
| transition.id, | ||
| ); | ||
| } | ||
|
|
@@ -164,9 +178,9 @@ export function buildSimulation(input: SimulationInput): SimulationInstance { | |
| transitionKernelFns.set(transition.id, fn as TransitionKernelFn); | ||
| } catch (error) { | ||
| throw new SDCPNItemError( | ||
| `Failed to compile transition kernel for transition \`${transition.name}\`:\n\n${ | ||
| error instanceof Error ? error.message : String(error) | ||
| }`, | ||
| `Failed to compile transition kernel for transition \`${ | ||
| transition.name | ||
| }\`:\n\n${error instanceof Error ? error.message : String(error)}`, | ||
| transition.id, | ||
| ); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.