Rigorous.GuiReplay#

molass.Rigorous.GuiReplay

Reconstruct a legacy GUI optimizer run in-process for notebook introspection.

This module bridges the gap between the opaque LEG-GUI subprocess path and the notebook API. It reads the files produced by a completed GUI run (callback.txt, init_params.txt, optimizer.log, opt_settings.txt, ip_*.npy) and reconstructs the optimizer in the calling process so it can be:

  • queried for score_breakdown at any parameter vector

  • re-run with any solver for direct comparison

  • compared against LIB-IN results using compare_dsets()

Alignment with the refactor architecture: - molass-library is the home for active computational code (ARCHITECTURE.md) - This module calls molass-legacy’s DsetsDebug layer for raw reconstruction - Returns RunInfo so the result is consumable through the library’s API - Serves the data-object consolidation track: makes the GUI’s sd-based

landscape directly inspectable, creating pressure to replace sd with ssd

Usage example#

from molass.Rigorous.GuiReplay import load_gui_scenario

scenario = load_gui_scenario(r’C:PyToolsreportsanalysis-005’) print(‘fv_init from GUI callback:’, scenario.fv_init) print(‘fv_init reproduced :’, scenario.eval_init())

# Re-run in-process with BH for comparison run = scenario.run_inprocess(method=’BH’, niter=20) run.wait() bd = run.get_score_breakdown()

Copyright (c) 2026, SAXS Team, KEK-PF

class GuiScenario(analysis_folder, work_folder, optimizer, init_params, fv_init, n_components, class_code)#

Bases: object

Reconstructed GUI optimizer scenario, ready for in-process introspection.

analysis_folder#
Type:

str

work_folder#

Path to the job folder (e.g. analysis_folder/optimized/jobs/000).

Type:

str

optimizer#

Fully constructed and prepared (prepare_for_optimization already called with init_params).

Type:

legacy optimizer object

init_params#

Physical parameter vector from init_params.txt.

Type:

ndarray

fv_init#

Objective value at init_params as recorded in callback.txt.

Type:

float

n_components#
Type:

int

class_code#
Type:

str

eval_init()#

Evaluate the objective at init_params in-process.

Returns the reproduced fv_init. Compare with self.fv_init (from callback.txt) to verify the reconstruction is faithful.

get_score_breakdown(params=None)#

Return score breakdown at init_params (or any given params).

Returns:

dict {‘fv’ – Same structure as RunInfo.get_score_breakdown().

Return type:

float, ‘scores’: {name: value}}

run_inprocess(method='BH', niter=20, seed=1234, analysis_folder=None, **solver_kwargs)#

Re-run the optimizer in-process with any solver.

This lets you run BH or DE on exactly the GUI’s data and compare the result against the original LEG-GUI outcome.

Parameters:
  • method (str) – Solver name (‘BH’, ‘DE’, ‘CMA’, etc.).

  • niter (int) – Budget.

  • seed (int)

  • analysis_folder (str or None) – Where to write the new run’s output. Defaults to a temp folder inside work_folder.

  • **solver_kwargs – Forwarded to optimize_rigorously (e.g. de_variant, de_pop_size).

Return type:

RunInfo

load_gui_scenario(analysis_folder, job='000')#

Reconstruct a completed GUI run as a GuiScenario for notebook introspection.

Reads all files produced by the LEG-GUI subprocess (init_params.txt, optimizer.log, opt_settings.txt, ip_*.npy) and reconstructs the optimizer in the calling process with the same data the subprocess used.

Parameters:
  • analysis_folder (str) – Path to the analysis folder (e.g. r'C:\PyTools\reports\analysis-005').

  • job (str) – Job subfolder name, default '000'.

Return type:

GuiScenario

Raises:

FileNotFoundError – If required files are missing.