//////////////////////////////////////////////////////////////////////// /// \class RAT::Optimisers::Optimiser /// /// \brief Base class for optimisers /// /// \author Phil G Jones /// \author Matthew Mottram -- contact person /// /// REVISION HISTORY:\n /// 26/04/2011 : P G Jones - New file \n /// 02/05/2012 : P G Jones - New method optimizer relationship.\n /// 24/01/2013 : P G Jones - Changed to derive from the FitterComponent /// class. Allows variable setting.\n /// 2013-10-26 : P G Jones - Changed to use OptimisedComponent.\n /// 2014-03-29 : P G Jones - Updated lifetime, added BeginOfRun method\n /// /// \details All optimisers derive from this class /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_Optimiser_Optimiser_ #define __RAT_Optimiser_Optimiser_ #include #include #include #include namespace RAT { class OptimisedComponent; namespace Optimisers { class Optimiser : public FitterComponent { public: class OptimiserFailError : public std::runtime_error { public: /// Just sets up a std::runtime_error OptimiserFailError( const std::string& info ) : std::runtime_error( info ) {} }; /// Initialise the optimiser with a init string /// /// @param[in] param optional string virtual void Initialise( const std::string& param ) = 0; /// Minimise the component, return FOM virtual double Minimise() = 0; /// Maximise the component, return FOM virtual double Maximise() = 0; /// Set the FitterComponent to be optimised virtual void SetComponent( OptimisedComponent* component ) { fComponent = component; } /// Return the best parameter values std::vector GetParams() const { return fParams; } /// Return the best parameter positive errors std::vector GetPositiveErrors() const { return fPositiveErrors; } /// Return the best parameter negative errors std::vector GetNegativeErrors() const { return fNegativeErrors; } /// Return optimisation validity bool GetValid() { return fValid; } protected: OptimisedComponent* fComponent; ///< FitterComponent to be optimised std::vector fParams; ///< Current best (optimised) parameters std::vector fPositiveErrors; ///< Current best (optimised) positive errors std::vector fNegativeErrors; ///< Current best (optimised) negative errors bool fValid; ///< Has the optimisation been valid? }; } //::Optimiser } //::RAT #endif