Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

point_obs.hpp

Go to the documentation of this file.
00001 #ifndef _POINT_OBS_HPP
00002 #define _POINT_OBS_HPP
00003 
00004 #include <iostream>
00005 #include "properties.hpp"
00006 #include "query_point.hpp"
00007 #include "arak.hpp"
00008 
00009 namespace Arak {
00010 
00015   class QueryPointPotential : public QueryPointListener {
00016 
00020     double& potential;
00021 
00025     Color color;
00026 
00031     const double blackVal;
00032 
00037     const double whiteVal;
00038 
00039   public:
00040 
00050     QueryPointPotential(double &potential,
00051       double blackVal,
00052       double whiteVal) : 
00053       potential(potential), 
00054       color(INVALID_COLOR), 
00055       blackVal(blackVal), 
00056       whiteVal(whiteVal) { }
00057 
00064     virtual void recolor(Color color) {
00065       if (color == this->color) return;
00066       // Subtract off the old potential.
00067       switch (this->color) {
00068       case BLACK:
00069   potential -= blackVal; 
00070   break;
00071       case WHITE:
00072   potential -= whiteVal; 
00073   break;
00074       default:
00075   break;
00076       }
00077       // Add in the new potential.
00078       switch (color) {
00079       case BLACK:
00080   potential += blackVal; 
00081   break;
00082       case WHITE:
00083   potential += whiteVal; 
00084   break;
00085       default:
00086   break;
00087       }
00088       // Update the current color.
00089       this->color = color;
00090     }
00091   };
00092 
00110   class ArakPosteriorGaussianObs : public ArakProcess {
00111 
00112   protected:
00113 
00117     const ArakProcess& prior;
00118 
00122     std::vector<Geometry::Point> points;
00123 
00128     std::vector<double> obs;
00129 
00133     std::vector<QueryPointPotential*> potentials;
00134 
00138     double whiteMean;
00139   
00143     double blackMean;
00144 
00148     double whiteVar;
00149 
00153     double blackVar;
00154 
00158     double lp;
00159 
00160   public:
00161 
00180     ArakPosteriorGaussianObs(const ArakProcess& prior,
00181            const Arak::Util::PropertyMap& props);
00182 
00186     virtual ~ArakPosteriorGaussianObs();
00187 
00191     virtual double scale() const { return prior.scale(); }
00192 
00201     virtual double logMeasure() const;
00202 
00210     virtual double potential() const;
00211 
00219     virtual void visualize(CGAL::Qt_widget& widget) const;
00220   };
00221 
00231   CGAL::Qt_widget& operator<<(CGAL::Qt_widget& widget, 
00232             ArakPosteriorGaussianObs& p);
00233 
00251   class ArakPosteriorBernoulliObs : public ArakProcess {
00252 
00253   protected:
00254 
00258     const ArakProcess& prior;
00259 
00263     std::vector<Geometry::Point> points;
00264 
00268     std::vector<QueryPointPotential*> potentials;
00269 
00274     std::vector<bool> obs;
00275 
00280     double blackProb;
00281   
00286     double whiteProb;
00287 
00291     double lp;
00292 
00293   public:
00294 
00313     ArakPosteriorBernoulliObs(const ArakProcess& prior,
00314             const Arak::Util::PropertyMap& props);
00315 
00319     virtual ~ArakPosteriorBernoulliObs();
00320 
00324     virtual double scale() const { return prior.scale(); }
00325 
00334     virtual double logMeasure() const;
00335 
00343     virtual double potential() const;
00344 
00352     virtual void visualize(CGAL::Qt_widget& widget) const;
00353   };
00354 
00364   CGAL::Qt_widget& operator<<(CGAL::Qt_widget& widget, 
00365             ArakPosteriorBernoulliObs& p);
00366 
00367 }
00368 
00369 #endif

Generated on Wed May 25 14:39:18 2005 for Arak by doxygen 1.3.6