jssm 5.152.0 → 5.154.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/custom-elements.json +293 -7
- package/dist/cdn/instance.js +352 -11
- package/dist/cdn/viz.js +374 -16
- package/dist/cli/fsl-export-system-prompt.cjs +1 -1
- package/dist/cli/fsl-render.cjs +1 -1
- package/dist/cli/fsl.cjs +1 -1
- package/dist/cli/lib.cjs +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/deno/README.md +7 -7
- package/dist/deno/jssm.d.ts +70 -5
- package/dist/deno/jssm.js +1 -1
- package/dist/deno/jssm_types.d.ts +31 -1
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm_viz.cjs +1 -1
- package/dist/jssm_viz.iife.cjs +1 -1
- package/dist/jssm_viz.mjs +1 -1
- package/dist/wc/instance.js +2 -0
- package/dist/wc/widgets.define.js +3 -2
- package/dist/wc/widgets.js +331 -34
- package/jssm.es5.d.cts +100 -5
- package/jssm.es6.d.ts +100 -5
- package/jssm_viz.es5.d.cts +95 -4
- package/jssm_viz.es6.d.ts +95 -4
- package/package.json +1 -1
package/jssm.es5.d.cts
CHANGED
|
@@ -524,6 +524,34 @@ declare type JssmEditorConfig = {
|
|
|
524
524
|
stochastic_run_count?: number;
|
|
525
525
|
panels?: Array<string>;
|
|
526
526
|
};
|
|
527
|
+
/** Which stochastic view a run batch produces. */
|
|
528
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
529
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
530
|
+
declare type JssmStochasticOptions = {
|
|
531
|
+
mode?: JssmStochasticMode;
|
|
532
|
+
runs?: number;
|
|
533
|
+
max_steps?: number;
|
|
534
|
+
seed?: number;
|
|
535
|
+
};
|
|
536
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
537
|
+
declare type JssmStochasticRun = {
|
|
538
|
+
states: Array<string>;
|
|
539
|
+
edges: Array<string>;
|
|
540
|
+
length: number;
|
|
541
|
+
terminated: boolean;
|
|
542
|
+
};
|
|
543
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
544
|
+
declare type JssmStochasticSummary = {
|
|
545
|
+
mode: JssmStochasticMode;
|
|
546
|
+
runs: number;
|
|
547
|
+
seed: number;
|
|
548
|
+
state_visits: Map<string, number>;
|
|
549
|
+
state_visit_fraction: Map<string, number>;
|
|
550
|
+
edge_traversals: Map<string, number>;
|
|
551
|
+
path_lengths?: Array<number>;
|
|
552
|
+
terminal_reached?: number;
|
|
553
|
+
capped?: number;
|
|
554
|
+
};
|
|
527
555
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
528
556
|
graph_layout?: JssmLayout;
|
|
529
557
|
complete?: Array<StateType>;
|
|
@@ -571,6 +599,8 @@ declare type JssmGenericConfig<StateType, DataType> = {
|
|
|
571
599
|
arrange_declaration?: Array<Array<StateType>>;
|
|
572
600
|
arrange_start_declaration?: Array<Array<StateType>>;
|
|
573
601
|
arrange_end_declaration?: Array<Array<StateType>>;
|
|
602
|
+
oarrange_declaration?: Array<Array<StateType>>;
|
|
603
|
+
farrange_declaration?: Array<Array<StateType>>;
|
|
574
604
|
machine_author?: string | Array<string>;
|
|
575
605
|
machine_comment?: string;
|
|
576
606
|
machine_contributor?: string | Array<string>;
|
|
@@ -1989,6 +2019,10 @@ declare function transfer_state_properties(state_decl: JssmStateDeclaration): Js
|
|
|
1989
2019
|
*
|
|
1990
2020
|
*/
|
|
1991
2021
|
declare function state_style_condense(jssk: JssmStateStyleKeyList, machine?: any): JssmStateConfig;
|
|
2022
|
+
/** Default number of independent Monte-Carlo runs when none is declared. */
|
|
2023
|
+
declare const STOCHASTIC_DEFAULT_RUNS = 1000;
|
|
2024
|
+
/** Default per-run step cap (montecarlo) / walk length (steady_state). */
|
|
2025
|
+
declare const STOCHASTIC_DEFAULT_MAX_STEPS = 1000;
|
|
1992
2026
|
declare class Machine<mDT> {
|
|
1993
2027
|
_state: StateType;
|
|
1994
2028
|
_states: Map<StateType, JssmGenericState>;
|
|
@@ -2032,6 +2066,8 @@ declare class Machine<mDT> {
|
|
|
2032
2066
|
_arrange_declaration: Array<Array<StateType>>;
|
|
2033
2067
|
_arrange_start_declaration: Array<Array<StateType>>;
|
|
2034
2068
|
_arrange_end_declaration: Array<Array<StateType>>;
|
|
2069
|
+
_oarrange_declaration: Array<Array<StateType>>;
|
|
2070
|
+
_farrange_declaration: Array<Array<StateType>>;
|
|
2035
2071
|
_themes: FslTheme[];
|
|
2036
2072
|
_flow: FslDirection;
|
|
2037
2073
|
_has_hooks: boolean;
|
|
@@ -2114,7 +2150,7 @@ declare class Machine<mDT> {
|
|
|
2114
2150
|
_firing_error: boolean;
|
|
2115
2151
|
_boundary_depth: number;
|
|
2116
2152
|
_boundary_depth_limit: number;
|
|
2117
|
-
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
2153
|
+
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, oarrange_declaration, farrange_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
2118
2154
|
/********
|
|
2119
2155
|
*
|
|
2120
2156
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -2280,13 +2316,13 @@ declare class Machine<mDT> {
|
|
|
2280
2316
|
* `;
|
|
2281
2317
|
*
|
|
2282
2318
|
* traffic_light.state(); // Off
|
|
2283
|
-
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true
|
|
2319
|
+
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true }
|
|
2284
2320
|
*
|
|
2285
2321
|
* traffic_light.go('Red');
|
|
2286
|
-
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true
|
|
2322
|
+
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true }
|
|
2287
2323
|
*
|
|
2288
2324
|
* traffic_light.go('Green');
|
|
2289
|
-
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false
|
|
2325
|
+
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false }
|
|
2290
2326
|
* ```
|
|
2291
2327
|
*
|
|
2292
2328
|
* @returns An object mapping every known property name to its current value
|
|
@@ -2915,6 +2951,65 @@ declare class Machine<mDT> {
|
|
|
2915
2951
|
* @returns A `Map` from state name to visit count.
|
|
2916
2952
|
*/
|
|
2917
2953
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2954
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2955
|
+
*
|
|
2956
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2957
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2958
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2959
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2960
|
+
*
|
|
2961
|
+
* @param start - State to begin the walk from.
|
|
2962
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2963
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2964
|
+
*/
|
|
2965
|
+
private _stochastic_one_walk;
|
|
2966
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2967
|
+
*
|
|
2968
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2969
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2970
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2971
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2972
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2973
|
+
*
|
|
2974
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2975
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2976
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2977
|
+
*
|
|
2978
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2979
|
+
* @returns A generator of per-run results.
|
|
2980
|
+
*
|
|
2981
|
+
* @example
|
|
2982
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2983
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2984
|
+
*/
|
|
2985
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2986
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2987
|
+
*
|
|
2988
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2989
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2990
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2991
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2992
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2993
|
+
* mode runs one long walk and omits those fields.
|
|
2994
|
+
*
|
|
2995
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2996
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2997
|
+
*
|
|
2998
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2999
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
3000
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
3001
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
3002
|
+
*
|
|
3003
|
+
* @see Machine.stochastic_runs
|
|
3004
|
+
* @see Machine.probabilistic_walk
|
|
3005
|
+
* @see Machine.editor_config
|
|
3006
|
+
*
|
|
3007
|
+
* @example
|
|
3008
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
3009
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
3010
|
+
* s.terminal_reached; // => 100
|
|
3011
|
+
*/
|
|
3012
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2918
3013
|
/********
|
|
2919
3014
|
*
|
|
2920
3015
|
* List all actions available from this state. Please note that the order of
|
|
@@ -4687,4 +4782,4 @@ declare function compareVersions(v1: string, v2: string): number;
|
|
|
4687
4782
|
*/
|
|
4688
4783
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
4689
4784
|
|
|
4690
|
-
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
4785
|
+
export { FslDirections, Machine, STOCHASTIC_DEFAULT_MAX_STEPS, STOCHASTIC_DEFAULT_RUNS, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
package/jssm.es6.d.ts
CHANGED
|
@@ -524,6 +524,34 @@ declare type JssmEditorConfig = {
|
|
|
524
524
|
stochastic_run_count?: number;
|
|
525
525
|
panels?: Array<string>;
|
|
526
526
|
};
|
|
527
|
+
/** Which stochastic view a run batch produces. */
|
|
528
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
529
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
530
|
+
declare type JssmStochasticOptions = {
|
|
531
|
+
mode?: JssmStochasticMode;
|
|
532
|
+
runs?: number;
|
|
533
|
+
max_steps?: number;
|
|
534
|
+
seed?: number;
|
|
535
|
+
};
|
|
536
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
537
|
+
declare type JssmStochasticRun = {
|
|
538
|
+
states: Array<string>;
|
|
539
|
+
edges: Array<string>;
|
|
540
|
+
length: number;
|
|
541
|
+
terminated: boolean;
|
|
542
|
+
};
|
|
543
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
544
|
+
declare type JssmStochasticSummary = {
|
|
545
|
+
mode: JssmStochasticMode;
|
|
546
|
+
runs: number;
|
|
547
|
+
seed: number;
|
|
548
|
+
state_visits: Map<string, number>;
|
|
549
|
+
state_visit_fraction: Map<string, number>;
|
|
550
|
+
edge_traversals: Map<string, number>;
|
|
551
|
+
path_lengths?: Array<number>;
|
|
552
|
+
terminal_reached?: number;
|
|
553
|
+
capped?: number;
|
|
554
|
+
};
|
|
527
555
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
528
556
|
graph_layout?: JssmLayout;
|
|
529
557
|
complete?: Array<StateType>;
|
|
@@ -571,6 +599,8 @@ declare type JssmGenericConfig<StateType, DataType> = {
|
|
|
571
599
|
arrange_declaration?: Array<Array<StateType>>;
|
|
572
600
|
arrange_start_declaration?: Array<Array<StateType>>;
|
|
573
601
|
arrange_end_declaration?: Array<Array<StateType>>;
|
|
602
|
+
oarrange_declaration?: Array<Array<StateType>>;
|
|
603
|
+
farrange_declaration?: Array<Array<StateType>>;
|
|
574
604
|
machine_author?: string | Array<string>;
|
|
575
605
|
machine_comment?: string;
|
|
576
606
|
machine_contributor?: string | Array<string>;
|
|
@@ -1989,6 +2019,10 @@ declare function transfer_state_properties(state_decl: JssmStateDeclaration): Js
|
|
|
1989
2019
|
*
|
|
1990
2020
|
*/
|
|
1991
2021
|
declare function state_style_condense(jssk: JssmStateStyleKeyList, machine?: any): JssmStateConfig;
|
|
2022
|
+
/** Default number of independent Monte-Carlo runs when none is declared. */
|
|
2023
|
+
declare const STOCHASTIC_DEFAULT_RUNS = 1000;
|
|
2024
|
+
/** Default per-run step cap (montecarlo) / walk length (steady_state). */
|
|
2025
|
+
declare const STOCHASTIC_DEFAULT_MAX_STEPS = 1000;
|
|
1992
2026
|
declare class Machine<mDT> {
|
|
1993
2027
|
_state: StateType;
|
|
1994
2028
|
_states: Map<StateType, JssmGenericState>;
|
|
@@ -2032,6 +2066,8 @@ declare class Machine<mDT> {
|
|
|
2032
2066
|
_arrange_declaration: Array<Array<StateType>>;
|
|
2033
2067
|
_arrange_start_declaration: Array<Array<StateType>>;
|
|
2034
2068
|
_arrange_end_declaration: Array<Array<StateType>>;
|
|
2069
|
+
_oarrange_declaration: Array<Array<StateType>>;
|
|
2070
|
+
_farrange_declaration: Array<Array<StateType>>;
|
|
2035
2071
|
_themes: FslTheme[];
|
|
2036
2072
|
_flow: FslDirection;
|
|
2037
2073
|
_has_hooks: boolean;
|
|
@@ -2114,7 +2150,7 @@ declare class Machine<mDT> {
|
|
|
2114
2150
|
_firing_error: boolean;
|
|
2115
2151
|
_boundary_depth: number;
|
|
2116
2152
|
_boundary_depth_limit: number;
|
|
2117
|
-
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
2153
|
+
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, oarrange_declaration, farrange_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
2118
2154
|
/********
|
|
2119
2155
|
*
|
|
2120
2156
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -2280,13 +2316,13 @@ declare class Machine<mDT> {
|
|
|
2280
2316
|
* `;
|
|
2281
2317
|
*
|
|
2282
2318
|
* traffic_light.state(); // Off
|
|
2283
|
-
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true
|
|
2319
|
+
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true }
|
|
2284
2320
|
*
|
|
2285
2321
|
* traffic_light.go('Red');
|
|
2286
|
-
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true
|
|
2322
|
+
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true }
|
|
2287
2323
|
*
|
|
2288
2324
|
* traffic_light.go('Green');
|
|
2289
|
-
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false
|
|
2325
|
+
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false }
|
|
2290
2326
|
* ```
|
|
2291
2327
|
*
|
|
2292
2328
|
* @returns An object mapping every known property name to its current value
|
|
@@ -2915,6 +2951,65 @@ declare class Machine<mDT> {
|
|
|
2915
2951
|
* @returns A `Map` from state name to visit count.
|
|
2916
2952
|
*/
|
|
2917
2953
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2954
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2955
|
+
*
|
|
2956
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2957
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2958
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2959
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2960
|
+
*
|
|
2961
|
+
* @param start - State to begin the walk from.
|
|
2962
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2963
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2964
|
+
*/
|
|
2965
|
+
private _stochastic_one_walk;
|
|
2966
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2967
|
+
*
|
|
2968
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2969
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2970
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2971
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2972
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2973
|
+
*
|
|
2974
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2975
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2976
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2977
|
+
*
|
|
2978
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2979
|
+
* @returns A generator of per-run results.
|
|
2980
|
+
*
|
|
2981
|
+
* @example
|
|
2982
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2983
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2984
|
+
*/
|
|
2985
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2986
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2987
|
+
*
|
|
2988
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2989
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2990
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2991
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2992
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2993
|
+
* mode runs one long walk and omits those fields.
|
|
2994
|
+
*
|
|
2995
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2996
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2997
|
+
*
|
|
2998
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2999
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
3000
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
3001
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
3002
|
+
*
|
|
3003
|
+
* @see Machine.stochastic_runs
|
|
3004
|
+
* @see Machine.probabilistic_walk
|
|
3005
|
+
* @see Machine.editor_config
|
|
3006
|
+
*
|
|
3007
|
+
* @example
|
|
3008
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
3009
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
3010
|
+
* s.terminal_reached; // => 100
|
|
3011
|
+
*/
|
|
3012
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2918
3013
|
/********
|
|
2919
3014
|
*
|
|
2920
3015
|
* List all actions available from this state. Please note that the order of
|
|
@@ -4687,4 +4782,4 @@ declare function compareVersions(v1: string, v2: string): number;
|
|
|
4687
4782
|
*/
|
|
4688
4783
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
4689
4784
|
|
|
4690
|
-
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
4785
|
+
export { FslDirections, Machine, STOCHASTIC_DEFAULT_MAX_STEPS, STOCHASTIC_DEFAULT_RUNS, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
package/jssm_viz.es5.d.cts
CHANGED
|
@@ -519,6 +519,34 @@ declare type JssmEditorConfig = {
|
|
|
519
519
|
stochastic_run_count?: number;
|
|
520
520
|
panels?: Array<string>;
|
|
521
521
|
};
|
|
522
|
+
/** Which stochastic view a run batch produces. */
|
|
523
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
524
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
525
|
+
declare type JssmStochasticOptions = {
|
|
526
|
+
mode?: JssmStochasticMode;
|
|
527
|
+
runs?: number;
|
|
528
|
+
max_steps?: number;
|
|
529
|
+
seed?: number;
|
|
530
|
+
};
|
|
531
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
532
|
+
declare type JssmStochasticRun = {
|
|
533
|
+
states: Array<string>;
|
|
534
|
+
edges: Array<string>;
|
|
535
|
+
length: number;
|
|
536
|
+
terminated: boolean;
|
|
537
|
+
};
|
|
538
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
539
|
+
declare type JssmStochasticSummary = {
|
|
540
|
+
mode: JssmStochasticMode;
|
|
541
|
+
runs: number;
|
|
542
|
+
seed: number;
|
|
543
|
+
state_visits: Map<string, number>;
|
|
544
|
+
state_visit_fraction: Map<string, number>;
|
|
545
|
+
edge_traversals: Map<string, number>;
|
|
546
|
+
path_lengths?: Array<number>;
|
|
547
|
+
terminal_reached?: number;
|
|
548
|
+
capped?: number;
|
|
549
|
+
};
|
|
522
550
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
523
551
|
graph_layout?: JssmLayout;
|
|
524
552
|
complete?: Array<StateType>;
|
|
@@ -566,6 +594,8 @@ declare type JssmGenericConfig<StateType, DataType> = {
|
|
|
566
594
|
arrange_declaration?: Array<Array<StateType>>;
|
|
567
595
|
arrange_start_declaration?: Array<Array<StateType>>;
|
|
568
596
|
arrange_end_declaration?: Array<Array<StateType>>;
|
|
597
|
+
oarrange_declaration?: Array<Array<StateType>>;
|
|
598
|
+
farrange_declaration?: Array<Array<StateType>>;
|
|
569
599
|
machine_author?: string | Array<string>;
|
|
570
600
|
machine_comment?: string;
|
|
571
601
|
machine_contributor?: string | Array<string>;
|
|
@@ -1269,6 +1299,8 @@ declare class Machine<mDT> {
|
|
|
1269
1299
|
_arrange_declaration: Array<Array<StateType>>;
|
|
1270
1300
|
_arrange_start_declaration: Array<Array<StateType>>;
|
|
1271
1301
|
_arrange_end_declaration: Array<Array<StateType>>;
|
|
1302
|
+
_oarrange_declaration: Array<Array<StateType>>;
|
|
1303
|
+
_farrange_declaration: Array<Array<StateType>>;
|
|
1272
1304
|
_themes: FslTheme[];
|
|
1273
1305
|
_flow: FslDirection;
|
|
1274
1306
|
_has_hooks: boolean;
|
|
@@ -1351,7 +1383,7 @@ declare class Machine<mDT> {
|
|
|
1351
1383
|
_firing_error: boolean;
|
|
1352
1384
|
_boundary_depth: number;
|
|
1353
1385
|
_boundary_depth_limit: number;
|
|
1354
|
-
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
1386
|
+
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, oarrange_declaration, farrange_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
1355
1387
|
/********
|
|
1356
1388
|
*
|
|
1357
1389
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -1517,13 +1549,13 @@ declare class Machine<mDT> {
|
|
|
1517
1549
|
* `;
|
|
1518
1550
|
*
|
|
1519
1551
|
* traffic_light.state(); // Off
|
|
1520
|
-
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true
|
|
1552
|
+
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true }
|
|
1521
1553
|
*
|
|
1522
1554
|
* traffic_light.go('Red');
|
|
1523
|
-
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true
|
|
1555
|
+
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true }
|
|
1524
1556
|
*
|
|
1525
1557
|
* traffic_light.go('Green');
|
|
1526
|
-
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false
|
|
1558
|
+
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false }
|
|
1527
1559
|
* ```
|
|
1528
1560
|
*
|
|
1529
1561
|
* @returns An object mapping every known property name to its current value
|
|
@@ -2152,6 +2184,65 @@ declare class Machine<mDT> {
|
|
|
2152
2184
|
* @returns A `Map` from state name to visit count.
|
|
2153
2185
|
*/
|
|
2154
2186
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2187
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2188
|
+
*
|
|
2189
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2190
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2191
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2192
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2193
|
+
*
|
|
2194
|
+
* @param start - State to begin the walk from.
|
|
2195
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2196
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2197
|
+
*/
|
|
2198
|
+
private _stochastic_one_walk;
|
|
2199
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2200
|
+
*
|
|
2201
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2202
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2203
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2204
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2205
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2206
|
+
*
|
|
2207
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2208
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2209
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2210
|
+
*
|
|
2211
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2212
|
+
* @returns A generator of per-run results.
|
|
2213
|
+
*
|
|
2214
|
+
* @example
|
|
2215
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2216
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2217
|
+
*/
|
|
2218
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2219
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2220
|
+
*
|
|
2221
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2222
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2223
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2224
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2225
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2226
|
+
* mode runs one long walk and omits those fields.
|
|
2227
|
+
*
|
|
2228
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2229
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2230
|
+
*
|
|
2231
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2232
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
2233
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
2234
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
2235
|
+
*
|
|
2236
|
+
* @see Machine.stochastic_runs
|
|
2237
|
+
* @see Machine.probabilistic_walk
|
|
2238
|
+
* @see Machine.editor_config
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2242
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
2243
|
+
* s.terminal_reached; // => 100
|
|
2244
|
+
*/
|
|
2245
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2155
2246
|
/********
|
|
2156
2247
|
*
|
|
2157
2248
|
* List all actions available from this state. Please note that the order of
|
package/jssm_viz.es6.d.ts
CHANGED
|
@@ -519,6 +519,34 @@ declare type JssmEditorConfig = {
|
|
|
519
519
|
stochastic_run_count?: number;
|
|
520
520
|
panels?: Array<string>;
|
|
521
521
|
};
|
|
522
|
+
/** Which stochastic view a run batch produces. */
|
|
523
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
524
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
525
|
+
declare type JssmStochasticOptions = {
|
|
526
|
+
mode?: JssmStochasticMode;
|
|
527
|
+
runs?: number;
|
|
528
|
+
max_steps?: number;
|
|
529
|
+
seed?: number;
|
|
530
|
+
};
|
|
531
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
532
|
+
declare type JssmStochasticRun = {
|
|
533
|
+
states: Array<string>;
|
|
534
|
+
edges: Array<string>;
|
|
535
|
+
length: number;
|
|
536
|
+
terminated: boolean;
|
|
537
|
+
};
|
|
538
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
539
|
+
declare type JssmStochasticSummary = {
|
|
540
|
+
mode: JssmStochasticMode;
|
|
541
|
+
runs: number;
|
|
542
|
+
seed: number;
|
|
543
|
+
state_visits: Map<string, number>;
|
|
544
|
+
state_visit_fraction: Map<string, number>;
|
|
545
|
+
edge_traversals: Map<string, number>;
|
|
546
|
+
path_lengths?: Array<number>;
|
|
547
|
+
terminal_reached?: number;
|
|
548
|
+
capped?: number;
|
|
549
|
+
};
|
|
522
550
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
523
551
|
graph_layout?: JssmLayout;
|
|
524
552
|
complete?: Array<StateType>;
|
|
@@ -566,6 +594,8 @@ declare type JssmGenericConfig<StateType, DataType> = {
|
|
|
566
594
|
arrange_declaration?: Array<Array<StateType>>;
|
|
567
595
|
arrange_start_declaration?: Array<Array<StateType>>;
|
|
568
596
|
arrange_end_declaration?: Array<Array<StateType>>;
|
|
597
|
+
oarrange_declaration?: Array<Array<StateType>>;
|
|
598
|
+
farrange_declaration?: Array<Array<StateType>>;
|
|
569
599
|
machine_author?: string | Array<string>;
|
|
570
600
|
machine_comment?: string;
|
|
571
601
|
machine_contributor?: string | Array<string>;
|
|
@@ -1269,6 +1299,8 @@ declare class Machine<mDT> {
|
|
|
1269
1299
|
_arrange_declaration: Array<Array<StateType>>;
|
|
1270
1300
|
_arrange_start_declaration: Array<Array<StateType>>;
|
|
1271
1301
|
_arrange_end_declaration: Array<Array<StateType>>;
|
|
1302
|
+
_oarrange_declaration: Array<Array<StateType>>;
|
|
1303
|
+
_farrange_declaration: Array<Array<StateType>>;
|
|
1272
1304
|
_themes: FslTheme[];
|
|
1273
1305
|
_flow: FslDirection;
|
|
1274
1306
|
_has_hooks: boolean;
|
|
@@ -1351,7 +1383,7 @@ declare class Machine<mDT> {
|
|
|
1351
1383
|
_firing_error: boolean;
|
|
1352
1384
|
_boundary_depth: number;
|
|
1353
1385
|
_boundary_depth_limit: number;
|
|
1354
|
-
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
1386
|
+
constructor({ start_states, end_states, failed_outputs, initial_state, start_states_no_enforce, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, oarrange_declaration, farrange_declaration, theme, flow, graph_layout, instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }: JssmGenericConfig<StateType, mDT>);
|
|
1355
1387
|
/********
|
|
1356
1388
|
*
|
|
1357
1389
|
* Internal method for fabricating states. Not meant for external use.
|
|
@@ -1517,13 +1549,13 @@ declare class Machine<mDT> {
|
|
|
1517
1549
|
* `;
|
|
1518
1550
|
*
|
|
1519
1551
|
* traffic_light.state(); // Off
|
|
1520
|
-
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true
|
|
1552
|
+
* traffic_light.props(); // { can_go: true, hesitate: true, stop_first: true }
|
|
1521
1553
|
*
|
|
1522
1554
|
* traffic_light.go('Red');
|
|
1523
|
-
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true
|
|
1555
|
+
* traffic_light.props(); // { can_go: false, hesitate: true, stop_first: true }
|
|
1524
1556
|
*
|
|
1525
1557
|
* traffic_light.go('Green');
|
|
1526
|
-
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false
|
|
1558
|
+
* traffic_light.props(); // { can_go: true, hesitate: false, stop_first: false }
|
|
1527
1559
|
* ```
|
|
1528
1560
|
*
|
|
1529
1561
|
* @returns An object mapping every known property name to its current value
|
|
@@ -2152,6 +2184,65 @@ declare class Machine<mDT> {
|
|
|
2152
2184
|
* @returns A `Map` from state name to visit count.
|
|
2153
2185
|
*/
|
|
2154
2186
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2187
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2188
|
+
*
|
|
2189
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2190
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2191
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2192
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2193
|
+
*
|
|
2194
|
+
* @param start - State to begin the walk from.
|
|
2195
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2196
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2197
|
+
*/
|
|
2198
|
+
private _stochastic_one_walk;
|
|
2199
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2200
|
+
*
|
|
2201
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2202
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2203
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2204
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2205
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2206
|
+
*
|
|
2207
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2208
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2209
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2210
|
+
*
|
|
2211
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2212
|
+
* @returns A generator of per-run results.
|
|
2213
|
+
*
|
|
2214
|
+
* @example
|
|
2215
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2216
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2217
|
+
*/
|
|
2218
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2219
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2220
|
+
*
|
|
2221
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2222
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2223
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2224
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2225
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2226
|
+
* mode runs one long walk and omits those fields.
|
|
2227
|
+
*
|
|
2228
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2229
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2230
|
+
*
|
|
2231
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2232
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
2233
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
2234
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
2235
|
+
*
|
|
2236
|
+
* @see Machine.stochastic_runs
|
|
2237
|
+
* @see Machine.probabilistic_walk
|
|
2238
|
+
* @see Machine.editor_config
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2242
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
2243
|
+
* s.terminal_reached; // => 100
|
|
2244
|
+
*/
|
|
2245
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2155
2246
|
/********
|
|
2156
2247
|
*
|
|
2157
2248
|
* List all actions available from this state. Please note that the order of
|