-
Notifications
You must be signed in to change notification settings - Fork 122
Subnets/Components and Composition #8662
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
Draft
kube
wants to merge
4
commits into
main
Choose a base branch
from
cf/fe-522-basic-support-for-subnets-component-based-net-composition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
318b855
FE-522: Add basic subnet support for component-based net composition
kube 68ee2e6
FE-522: Add ActiveNetContext, component mode, and cursor tooltip
kube 9494599
FE-522: Add ComponentInstance type, rendering, wiring, and click-to-p…
kube 01705ea
FE-522: Add ComponentInstance properties panel
kube File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
218 changes: 218 additions & 0 deletions
218
libs/@hashintel/petrinaut/src/examples/hospital-network.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| import { SNAP_GRID_SIZE } from "../constants/ui"; | ||
| import type { SDCPN } from "../core/types/sdcpn"; | ||
|
|
||
| /** | ||
| * Hospital Network example — demonstrates subnets. | ||
| * | ||
| * The root net models patient flow between departments (ER → Ward → Discharge). | ||
| * A subnet models the internal triage process within the ER department. | ||
| */ | ||
| export const hospitalNetwork: { title: string; petriNetDefinition: SDCPN } = { | ||
| title: "Hospital Network", | ||
| petriNetDefinition: { | ||
| places: [ | ||
| { | ||
| id: "place__er", | ||
| name: "Emergency Room", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| showAsInitialState: true, | ||
| x: -20 * SNAP_GRID_SIZE, | ||
| y: 10 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "place__ward", | ||
| name: "Hospital Ward", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| x: 0 * SNAP_GRID_SIZE, | ||
| y: 10 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "place__discharged", | ||
| name: "Discharged", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| x: 20 * SNAP_GRID_SIZE, | ||
| y: 10 * SNAP_GRID_SIZE, | ||
| }, | ||
| ], | ||
| transitions: [ | ||
| { | ||
| id: "transition__admit", | ||
| name: "Admit", | ||
| inputArcs: [{ placeId: "place__er", weight: 1, type: "standard" }], | ||
| outputArcs: [{ placeId: "place__ward", weight: 1 }], | ||
| lambdaType: "stochastic", | ||
| lambdaCode: | ||
| "export default Lambda((tokens, parameters) => parameters.admission_rate)", | ||
| transitionKernelCode: | ||
| 'export default TransitionKernel(() => {\n return {\n "Hospital Ward": [{}],\n };\n});', | ||
| x: -10 * SNAP_GRID_SIZE, | ||
| y: 5 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "transition__discharge", | ||
| name: "Discharge", | ||
| inputArcs: [{ placeId: "place__ward", weight: 1, type: "standard" }], | ||
| outputArcs: [{ placeId: "place__discharged", weight: 1 }], | ||
| lambdaType: "stochastic", | ||
| lambdaCode: | ||
| "export default Lambda((tokens, parameters) => parameters.discharge_rate)", | ||
| transitionKernelCode: | ||
| "export default TransitionKernel(() => {\n return {\n Discharged: [{}],\n };\n});", | ||
| x: 10 * SNAP_GRID_SIZE, | ||
| y: 5 * SNAP_GRID_SIZE, | ||
| }, | ||
| ], | ||
| types: [], | ||
| differentialEquations: [], | ||
| parameters: [ | ||
| { | ||
| id: "param__admission_rate", | ||
| name: "Admission Rate", | ||
| variableName: "admission_rate", | ||
| type: "real", | ||
| defaultValue: "2", | ||
| }, | ||
| { | ||
| id: "param__discharge_rate", | ||
| name: "Discharge Rate", | ||
| variableName: "discharge_rate", | ||
| type: "real", | ||
| defaultValue: "1", | ||
| }, | ||
| ], | ||
| componentInstances: [ | ||
| { | ||
| id: "instance__er_triage", | ||
| name: "ER Triage Unit", | ||
| subnetId: "subnet__er_triage", | ||
| parameterValues: { | ||
| param__triage_rate: "5", | ||
| param__treatment_rate: "3", | ||
| }, | ||
| wiring: [ | ||
| { | ||
| externalPlaceId: "place__er", | ||
| internalPlaceId: "place__waiting", | ||
| }, | ||
| { | ||
| externalPlaceId: "place__ward", | ||
| internalPlaceId: "place__treated", | ||
| }, | ||
| ], | ||
| x: -10 * SNAP_GRID_SIZE, | ||
| y: 20 * SNAP_GRID_SIZE, | ||
| }, | ||
| ], | ||
| scenarios: [ | ||
| { | ||
| id: "scenario__normal_day", | ||
| name: "Normal Day", | ||
| description: "Typical daily patient flow through the hospital.", | ||
| scenarioParameters: [], | ||
| parameterOverrides: {}, | ||
| initialState: { | ||
| type: "per_place", | ||
| content: { | ||
| place__er: "10", | ||
| place__ward: "5", | ||
| place__discharged: "0", | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| subnets: [ | ||
| { | ||
| id: "subnet__er_triage", | ||
| name: "ER Triage", | ||
| places: [ | ||
| { | ||
| id: "place__waiting", | ||
| name: "Waiting", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| isPort: true, | ||
| showAsInitialState: true, | ||
| x: -15 * SNAP_GRID_SIZE, | ||
| y: 5 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "place__assessment", | ||
| name: "Assessment", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| x: 0 * SNAP_GRID_SIZE, | ||
| y: 5 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "place__treated", | ||
| name: "Treated", | ||
| colorId: null, | ||
| dynamicsEnabled: false, | ||
| differentialEquationId: null, | ||
| isPort: true, | ||
| x: 15 * SNAP_GRID_SIZE, | ||
| y: 5 * SNAP_GRID_SIZE, | ||
| }, | ||
| ], | ||
| transitions: [ | ||
| { | ||
| id: "transition__triage", | ||
| name: "Triage", | ||
| inputArcs: [ | ||
| { placeId: "place__waiting", weight: 1, type: "standard" }, | ||
| ], | ||
| outputArcs: [{ placeId: "place__assessment", weight: 1 }], | ||
| lambdaType: "stochastic", | ||
| lambdaCode: | ||
| "export default Lambda((tokens, parameters) => parameters.triage_rate)", | ||
| transitionKernelCode: | ||
| "export default TransitionKernel(() => {\n return {\n Assessment: [{}],\n };\n});", | ||
| x: -7 * SNAP_GRID_SIZE, | ||
| y: 0 * SNAP_GRID_SIZE, | ||
| }, | ||
| { | ||
| id: "transition__treat", | ||
| name: "Treat", | ||
| inputArcs: [ | ||
| { placeId: "place__assessment", weight: 1, type: "standard" }, | ||
| ], | ||
| outputArcs: [{ placeId: "place__treated", weight: 1 }], | ||
| lambdaType: "stochastic", | ||
| lambdaCode: | ||
| "export default Lambda((tokens, parameters) => parameters.treatment_rate)", | ||
| transitionKernelCode: | ||
| "export default TransitionKernel(() => {\n return {\n Treated: [{}],\n };\n});", | ||
| x: 7 * SNAP_GRID_SIZE, | ||
| y: 0 * SNAP_GRID_SIZE, | ||
| }, | ||
| ], | ||
| types: [], | ||
| differentialEquations: [], | ||
| parameters: [ | ||
| { | ||
| id: "param__triage_rate", | ||
| name: "Triage Rate", | ||
| variableName: "triage_rate", | ||
| type: "real", | ||
| defaultValue: "5", | ||
| }, | ||
| { | ||
| id: "param__treatment_rate", | ||
| name: "Treatment Rate", | ||
| variableName: "treatment_rate", | ||
| type: "real", | ||
| defaultValue: "3", | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libs/@hashintel/petrinaut/src/core/types/sdcpn.ts:L117 — The JSDoc for “An instance of a subnet…” currently sits above
Wire, so it looks like it’s documenting the wrong type (and theWiredocblock follows immediately after). Consider moving that first docblock ontoComponentInstanceto avoid misleading generated docs/tooltips.Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.