Generation

Instance generation utilities for dsbx.

class dsbx.Gen.FastPathConstructor(model, seed_manager)

Bases: object

Generates an event sequence, now including advanced dynamic events.

Parameters:
generate_events()

Main method to generate the full event list using the new refactored flow.

Return type:

List[Union[ArrivalEvent, DueDateEvent, BreakdownEvent, PriorityChangeEvent, OrderCancellationEvent, MachineRepairCompletionEvent, ProcessTimeChangeEvent, PreventiveMaintenanceEvent, RouteChangeEvent, DueDateChangeEvent]]

class dsbx.Gen.InputModel(**data)

Bases: BaseModel

Top-level input model for the v2.0 layered schema.

The schema includes metadata, plant structure, problem scale, dynamic behavior, target metrics, dynamic-event settings, evaluation mode, calibration strategy, tolerances, and output settings.

Parameters:
  • meta (Meta)

  • plant (Plant)

  • scale (Scale)

  • dynamics (Dynamics)

  • targets (Targets)

  • dynamic_scenarios (DynamicScenarios)

  • evaluation (EvaluationConfig)

  • calibration (CalibrationConfig)

  • tolerance (Tolerance)

  • outputs (Outputs)

meta: Meta
plant: Plant
scale: Scale
dynamics: Dynamics
targets: Targets
dynamic_scenarios: DynamicScenarios
evaluation: EvaluationConfig
calibration: CalibrationConfig
tolerance: Tolerance
outputs: Outputs
validate_cross_layer_constraints()
Return type:

InputModel

property seed_manager: SeedManager
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class dsbx.Gen.SeedManager(master_seed)

Bases: object

Manages random number generator streams for reproducibility.

Parameters:

master_seed (int)

get_rng(stream_name)

Get a dedicated RNG for a specific purpose (e.g., arrivals, ptimes).

Return type:

Generator

Parameters:

stream_name (str)

get_seed_map()

Return a map of stream names to their integer seeds.

Return type:

Dict[str, int]

dsbx.Gen.load_input_model(path)

Load and validate an input file in JSON or YAML format.

If required fields are missing, sensible defaults are filled and the model is validated again. The loader also migrates v1.0 configuration files to the v2.0 schema automatically.

Return type:

InputModel

dsbx.Gen.run_generation_pipeline(model, output_path, max_calib_steps, compare_metrics_paths=None, use_moo=False, use_hybrid=False, moo_population_size=60, moo_n_generations=40, hybrid_population_size=80, hybrid_n_generations=100, hybrid_convergence_window=10, hybrid_convergence_tol=0.0005, hybrid_max_sequential_steps=7, seq_early_stop_no_improve_steps=3, seq_early_stop_relax_factor=2.0, seq_min_relative_improvement=0.005, seq_tol_rho_global=None, seq_tol_scv_a=None, seq_tol_scv_p=None, seq_tol_ddt=None, seq_tol_disturbance=None, seq_tol_load_cv=None)

Encapsulates the full pipeline for generating a SINGLE instance. This function is called by both gen and gen-batch. Returns the final metrics dictionary on success, or None on failure.

Parameters:
  • model (InputModel) – Input configuration model

  • output_path (Path) – Where to save results

  • max_calib_steps (int) – Maximum calibration iterations (for sequential mode)

  • compare_metrics_paths (Optional[List[Path]]) – Optional pair of final_metrics.json file paths for comparison (BASELINE, CANDIDATE)

  • use_moo (bool) – If True, use Multi-Objective Optimization calibrator (NSGA-II) v3

  • use_hybrid (bool) – If True, use Hybrid calibrator (Sequential + MOO for coupled metrics)

  • moo_population_size (int)

  • moo_n_generations (int)

  • hybrid_population_size (int)

  • hybrid_n_generations (int)

  • hybrid_convergence_window (int)

  • hybrid_convergence_tol (float)

  • hybrid_max_sequential_steps (int)

  • seq_early_stop_no_improve_steps (int)

  • seq_early_stop_relax_factor (float)

  • seq_min_relative_improvement (float)

  • seq_tol_rho_global (float | None)

  • seq_tol_scv_a (float | None)

  • seq_tol_scv_p (float | None)

  • seq_tol_ddt (float | None)

  • seq_tol_disturbance (float | None)

  • seq_tol_load_cv (float | None)

Return type:

Optional[Dict[str, Any]]