foxes_opt.callbacks.write_optimization_history¶
Classes¶
Write objective and constraint-violation counts to a CSV file. |
Module Contents¶
-
class foxes_opt.callbacks.write_optimization_history.WriteOptimizationHistoryCallback(file_path: str | pathlib.Path, objective: int =
0, iteration_offset: int =0, append: bool =False, write_initial: bool =False)[source]¶ Bases:
iwopy.core.OptimizerCallbackWrite objective and constraint-violation counts to a CSV file.
Population states report the individual with the best finite configured objective. Iterations without cached values retain their row with empty objective and constraint fields. By default initialization replaces an existing file. Append mode preserves rows only when the existing CSV header matches this callback’s schema. Enable
write_initialto evaluate the starting variables and record their objective and constraint-violation count before optimizer iterations.Initialize the optimization history callback.
- Parameters:¶
- file_path
Path of the CSV history file.
- objective
Objective component used to select and report an individual.
- iteration_offset
Non-negative offset added to reported iteration numbers.
- append
Whether to preserve and append to a non-empty existing history file. Missing and empty files receive a new header.
- write_initial
Evaluate the initial variables during initialization and write their objective and constraint-violation count at
iteration_offset. Leave disabled when appending a restart whose starting row already exists.
- Raises:¶
- TypeError
If
iteration_offsetis not an integer orappendorwrite_initialis not a boolean.- ValueError
If
objectiveis not a non-negative integer oriteration_offsetis negative.
- finalize(results: iwopy.core.opt_results.SingleObjOptResults | iwopy.core.opt_results.MultiObjOptResults) None¶
Process the completed optimization results.
- Parameters:¶
- results
The completed iwopy optimization results.
- initialize(optimizer: iwopy.core.Optimizer) None[source]¶
Prepare the history file and optionally record the starting values.
- Parameters:¶
- optimizer
Optimizer whose problem defines objective direction and constraint feasibility.
- Raises:¶
- IndexError
If the selected objective component does not exist.
- ValueError
If append mode encounters a non-empty file with another CSV header, or initial output is enabled and required initial variables are undefined.
- notify(data: iwopy.core.OptimizerCallbackData) None[source]¶
Append the current objective and violation count to the CSV file.
-
append =
False¶
- file_path¶
-
iteration_offset =
0¶
-
objective =
0¶
-
write_initial =
False¶