5 #ifndef BPP_NUMERIC_FUNCTION_OPTIMIZER_H 6 #define BPP_NUMERIC_FUNCTION_OPTIMIZER_H 9 #include "../../Clonable.h" 10 #include "../../Io/OutputStream.h" 11 #include "../ParameterList.h" 17 class OptimizerInterface;
73 virtual void optimizationInitializationPerformed(
const OptimizationEvent& event) = 0;
78 virtual bool listenerModifiesParameters()
const = 0;
109 virtual bool isInitialized()
const = 0;
117 virtual double step() = 0;
128 virtual double getParameterValue(
const std::string& name)
const = 0;
135 virtual double getFunctionValue()
const = 0;
143 virtual double optimize() = 0;
150 virtual void setFunction(std::shared_ptr<FunctionInterface>
function) = 0;
173 virtual std::shared_ptr<const FunctionInterface> getFunction()
const = 0;
180 virtual std::shared_ptr<FunctionInterface> getFunction() = 0;
187 virtual bool hasFunction()
const = 0;
200 virtual void setMessageHandler(std::shared_ptr<OutputStream> mh) = 0;
205 virtual std::shared_ptr<OutputStream> getMessageHandler()
const = 0;
218 virtual void setProfiler(std::shared_ptr<OutputStream> profiler) = 0;
223 virtual std::shared_ptr<OutputStream> getProfiler()
const = 0;
231 virtual unsigned int getNumberOfEvaluations()
const = 0;
239 virtual void setStopCondition(std::shared_ptr<OptimizationStopCondition> stopCondition) = 0;
246 virtual std::shared_ptr<OptimizationStopCondition> getStopCondition() = 0;
253 virtual std::shared_ptr<const OptimizationStopCondition> getStopCondition()
const = 0;
260 virtual std::shared_ptr<OptimizationStopCondition> getDefaultStopCondition() = 0;
267 virtual std::shared_ptr<const OptimizationStopCondition> getDefaultStopCondition()
const = 0;
275 virtual bool isToleranceReached()
const = 0;
282 virtual bool isMaximumNumberOfEvaluationsReached()
const = 0;
289 virtual void setMaximumNumberOfEvaluations(
unsigned int max) = 0;
303 virtual void setVerbose(
unsigned int v) = 0;
310 virtual unsigned int getVerbose()
const = 0;
317 virtual void setConstraintPolicy(
const std::string& constraintPolicy) = 0;
324 virtual std::string getConstraintPolicy()
const = 0;
334 virtual void addOptimizationListener(std::shared_ptr<OptimizationListener> listener) = 0;
345 virtual void updateParameters(
bool yn) = 0;
356 virtual bool updateParameters()
const = 0;
371 backupFile_(backupFile) {}
380 std::ofstream bck(backupFile_.c_str(), std::ios::out);
381 bck <<
"f(x)=" << setprecision(20) <<
event.getOptimizer()->getFunction()->getValue() << endl;
382 ParameterList pl =
event.getOptimizer()->getFunction()->getParameters();
383 for (
unsigned int i = 0; i < pl.
size(); ++i)
385 bck << pl[i].getName() <<
"=" << setprecision(20) << pl[i].getValue() << std::endl;
393 #endif // BPP_NUMERIC_FUNCTION_OPTIMIZER_H
bool listenerModifiesParameters() const
OptimizationEvent(const OptimizationEvent &oe)
OptimizerInterface * getOptimizer()
OptimizationEvent & operator=(const OptimizationEvent &oe)
OptimizationEvent(OptimizerInterface *optimizer)
This is the function abstract class.
void optimizationStepPerformed(const OptimizationEvent &event)
virtual ~OptimizationListener()
The parameter list object.
The listener interface for receiving optimization events.
virtual ~BackupListener()
virtual ~OptimizationEvent()
Save intermediate optimization results to file.
An event object which indicates that an optimization event occured.
const OptimizerInterface * getOptimizer() const
The Clonable interface (allow an object to be cloned).
This is the basal interface for all optimization methods.
virtual ~OptimizerInterface()
OptimizerInterface * optimizer_
Stores a pointer toward the optimizer that cast the event.
void optimizationInitializationPerformed(const OptimizationEvent &event)
BackupListener(const string &backupFile)