romtools.workflows.greedy.run_greedy#
- romtools.workflows.greedy.run_greedy(fom_model, rom_model_builder, parameter_space, absolute_work_dir=None, tolerance=None, testing_sample_size=10, random_seed=1, calibrated_error=True, *, initial_sample_size=2, max_iterations=100, initial_samples=None, create_rom_run_directories=True, absolute_greedy_work_directory=None)[source]#
Train a ROM using adaptive error-indicator-based sample selection.
The builder receives
offline_data_dir,training_data_dirs,training_parametersof shape (N, parameter_dimension), andtraining_qoisof shape (N, qoi_dimension), all in matching training order. Every rebuild includes all completed training FOM runs. Scalars become one-component QoI rows; array QoIs are flattened. Copies of the training arrays are passed so builders cannot modify the sampling pool or accumulated QoI history.The returned ROM must implement
compute_error_estimatein addition to the QoiModel methods. Directory-only builders must be adapted to the four-argument QoiModelBuilderWithTrainingData interface.initial_sample_sizeselects the first training rows from the initial candidate pool (default two).max_iterationsbounds the number of subsequent greedy FOM enrichments and defaults to 100; zero builds only the initial ROM. Without explicit initial samples,testing_sample_sizemust exceedinitial_sample_sizefor enrichment so there is an untrained candidate. Calibration and convergence checks retain their existing behavior: the first convergence check follows one enrichment. Run directories are populated once, immediately before their model evaluation.initial_samples, if supplied, is a nonempty (N, parameter_dimension) array of parameter rows to simulate before adaptation. Its row count overridesinitial_sample_size;testing_sample_sizethen controls a separate adaptation candidate pool. Exact matches to accumulated training rows are excluded from this pool. No domain projection or reuse of existing FOM outputs is performed.create_rom_run_directories=Falseskips only per-evaluation ROM run directory creation. Model methods still receive their nominal paths and must support in-memory execution. FOM, offline-data, log, and statistics directories remain available. Returns the final ROM and training history in aGreedyResult, including for initial-only and limit exits.- Parameters:
fom_model (QoiModel)
rom_model_builder (QoiModelBuilderWithTrainingData)
parameter_space (ParameterSpace)
absolute_work_dir (str)
tolerance (float)
testing_sample_size (int)
random_seed (int)
calibrated_error (bool)
initial_sample_size (int)
max_iterations (int)
initial_samples (ndarray | None)
create_rom_run_directories (bool)
absolute_greedy_work_directory (str)
- Return type: