indii/ml/ode/ParameterCollection.hpp

00001 #ifndef INDII_ML_ODE_PARAMETERCOLLECTION_HPP
00002 #define INDII_ML_ODE_PARAMETERCOLLECTION_HPP
00003 
00004 #include <vector>
00005 
00006 #include "boost/serialization/serialization.hpp"
00007 
00008 namespace indii {
00009   namespace ml {
00010     namespace ode {
00011 
00012 /**
00013  * Collection of parameters.
00014  *
00015  * @author Lawrence Murray <lawrence@indii.org>
00016  * @version $Rev: 349 $
00017  * @date $Date: 2007-11-20 20:48:40 +0000 (Tue, 20 Nov 2007) $
00018  */
00019 class ParameterCollection {
00020 public:
00021   /**
00022    * Default constructor for restoring from serialization.
00023    */
00024   ParameterCollection();
00025 
00026   /**
00027    * Construct new parameter collection.
00028    *
00029    * @param N Number of parameters.
00030    */
00031   ParameterCollection(const unsigned int N);
00032 
00033   /**
00034    * Destructor.
00035    */
00036   virtual ~ParameterCollection();
00037 
00038   /**
00039    * Get the value of a parameter.
00040    *
00041    * @param index Index of the parameter to retrieve.
00042    *
00043    * @return The value of the parameter.
00044    */
00045   virtual double getParameter(const unsigned int index) const;
00046 
00047   /**
00048    * Set the value of a parameter.
00049    *
00050    * @param index Index of the parameter to set.
00051    * @param value The value to which to set the parameter.
00052    */
00053   virtual void setParameter(const unsigned int index, const double value);
00054 
00055 private:
00056   /**
00057    * Number of parameters.
00058    */
00059   unsigned int N;
00060 
00061   /**
00062    * Parameters.
00063    */
00064   std::vector<double> ps;
00065 
00066   /**
00067    * Serialize, or restore from serialization.
00068    */
00069   template<class Archive>
00070   void serialize(Archive& ar, const unsigned int version);
00071 
00072   /*
00073    * Boost.Serialization requirements.
00074    */
00075   friend class boost::serialization::access;
00076   
00077 };
00078 
00079     }
00080   }
00081 }
00082 
00083 #include <assert.h>
00084 
00085 inline
00086 double indii::ml::ode::ParameterCollection::getParameter(
00087     const unsigned int index) const {
00088   /* pre-condition */
00089   assert (index < N);
00090 
00091   return ps[index];
00092 }
00093 
00094 template<class Archive>
00095 void indii::ml::ode::ParameterCollection::serialize(Archive& ar,
00096     const unsigned int version) {
00097   ar & N;
00098   ar & ps;
00099 }
00100 
00101 #endif
00102 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3