Class OptimizationResultWriter¶
Defined in File optimizationResultWriter.h
Class Documentation¶
-
class
parpe
::
OptimizationResultWriter
¶ The OptimizationResultWriter class receives results during an optimizer run. A new instance is to be created for each run.
TODO: change into interface; add OptimizationResultWriterHDF5
Public Functions
-
OptimizationResultWriter
(const H5::H5File &file, std::string rootPath)¶ Write to pre-opened HDF5 file (will be re-opened)
- Parameters
file
:rootPath
:
-
OptimizationResultWriter
(const std::string &filename, bool overwrite, std::string rootPath)¶ Open HDF5 file and write there.
- Parameters
filename
: Name of the result fileoverwrite
: Overwrite output file if already existsrootPath
:
-
OptimizationResultWriter &
operator=
(const OptimizationResultWriter &other) = delete¶
-
OptimizationResultWriter
(OptimizationResultWriter const &other)¶
-
virtual
~OptimizationResultWriter
() = default¶
-
virtual void
logObjectiveFunctionEvaluation
(gsl::span<const double> parameters, double objectiveFunctionValue, gsl::span<const double> objectiveFunctionGradient, int numIterations, int numFunctionCalls, double timeElapsedInSeconds)¶ Function to be called after each objective function f(x) or gradient f’(x) evaluation.
- Parameters
parameters
: Function parameters xobjectiveFunctionValue
: f(x)objectiveFunctionGradient
: f’(x) or NULLnumFunctionCalls
: Number of times the objective function has been called (f(x) and f’(x) are counted individually (?))timeElapsedInSeconds
: CPU time for the last objective function evaluation (wall time)
-
virtual void
logOptimizerIteration
(int numIterations, gsl::span<const double> parameters, double objectiveFunctionValue, gsl::span<const double> gradient, double wallSeconds, double cpuSeconds)¶ Function to be called after each optimizer iteration. (For parameters, see above or IpOpt intermediate function)
- Parameters
numIterations
:theta
:objectiveFunctionValue
:gradient
:timeElapsedInSeconds
:alg_mod
:inf_pr
:inf_du
:mu
:d_norm
:regularization_size
:alpha_du
:alpha_pr
:ls_trials
:
-
void
setLoggingEachIteration
(bool logGradient)¶
-
void
setLoggingEachFunctionEvaluation
(bool logGradient, bool logParameters)¶
-
virtual void
starting
(gsl::span<const double> initialParameters)¶ Log optimizer start.
- Parameters
initialParameters
:
-
virtual void
saveOptimizerResults
(double finalNegLogLikelihood, gsl::span<const double> optimalParameters, double wallSec, double cpuSec, int exitStatus) const¶ Function to be called when local optimization is finished.
- Parameters
finalNegLogLikelihood
: Final cost f(x)optimalParameters
: Final parameters xmasterTime
: Wall time for this optimizationexitStatus
: Exit status (cause of optimizer termination)
-
H5::H5File const &
getH5File
() const¶
-
virtual std::string const &
getRootPath
() const¶
-
void
setRootPath
(std::string const &path)¶ Set root path in HDF5 file and create the respective group.
- Parameters
path
:
Public Members
-
bool
logParametersEachFunctionEvaluation
= true¶
-
bool
logGradientEachFunctionEvaluation
= true¶
-
bool
logGradientEachIteration
= true¶
Protected Functions
-
virtual void
flushResultWriter
() const¶ Write buffered output to file.
-