Class OptimizationReporter¶
Defined in File optimizationProblem.h
Inheritance Relationships¶
Base Type¶
public parpe::GradientFunction
(Class GradientFunction)
Derived Type¶
public parpe::HierarchicalOptimizationReporter
(Class HierarchicalOptimizationReporter)
Class Documentation¶
-
class
parpe
::
OptimizationReporter
: public parpe::GradientFunction¶ The OptimizationReporter class is called from the optimizer and takes care of calling the actual objective function, thereby keeping track of iterations, computation time, logging intermediate results, timing and can tell the optimizer to exit.
This extra level of abstraction is added to avoid reimplementing timing, and other things for each supported optimizer. The indirection of cost function evaluation is added to allow caching previous cost function values.
Subclassed by parpe::HierarchicalOptimizationReporter
Public Functions
-
OptimizationReporter
(GradientFunction *gradFun, std::unique_ptr<Logger> logger)¶
-
OptimizationReporter
(GradientFunction *gradFun, std::unique_ptr<OptimizationResultWriter> rw, std::unique_ptr<Logger> logger)¶
-
virtual FunctionEvaluationStatus
evaluate
(gsl::span<double const> parameters, double &fval, gsl::span<double> gradient, Logger *logger = nullptr, double *cpuTime = nullptr) const override¶
-
virtual int
numParameters
() const override¶
-
virtual bool
starting
(gsl::span<const double> initialParameters) const¶ Is called just before the optimizer starts. Must be called before other functions.
- Return
Quit optimization?
- Parameters
numParameters
:initialParameters
:
-
virtual bool
iterationFinished
(gsl::span<const double> parameters, double objectiveFunctionValue, gsl::span<const double> objectiveFunctionGradient) const¶ Is called after each iteration except for the last one.
- Return
Quit optimization?
- Parameters
numParameters
:parameters
:currentIter
:
-
virtual bool
beforeCostFunctionCall
(gsl::span<const double> parameters) const¶
-
virtual bool
afterCostFunctionCall
(gsl::span<const double> parameters, double objectiveFunctionValue, gsl::span<double const> objectiveFunctionGradient) const¶
-
virtual void
finished
(double optimalCost, gsl::span<const double> parameters, int exitStatus) const¶ Is called after optimization finished.
-
virtual double
getFinalCost
() const¶
-
virtual std::vector<double> const &
getFinalParameters
() const¶
-
void
setGradientFunction
(GradientFunction *gradFun) const¶
-
virtual std::vector<std::string>
getParameterIds
() const override¶
Public Members
-
std::unique_ptr<OptimizationResultWriter>
result_writer_
¶
-
mutable double
cpu_time_total_sec_
= 0.0¶
-
mutable double
cpu_time_iteration_sec_
= 0.0¶
Protected Functions
-
void
printObjectiveFunctionFailureMessage
() const¶
Protected Attributes
-
mutable int
num_function_calls_
= 0¶
-
mutable int
num_iterations_
= 0¶
-
mutable int
num_parameters_
= 0¶
-
mutable bool
started_
= false¶
-
mutable GradientFunction *
grad_fun_
= nullptr¶
-
mutable bool
have_cached_cost_
= false¶
-
mutable bool
have_cached_gradient_
= false¶
-
mutable std::vector<double>
cached_gradient_
¶
-
mutable double
cached_cost_
= std::numeric_limits<double>::infinity()¶
-
mutable FunctionEvaluationStatus
cached_status_
= functionEvaluationSuccess¶
-
mutable double
final_cost_
= std::numeric_limits<double>::quiet_NaN()¶
-
mutable std::vector<double>
cached_parameters_
¶
-
std::string
default_logger_prefix_
¶
-