LateralEuclidianDistanceConnectionPredicate.h

Go to the documentation of this file.
00001 
00011 #ifndef LATERALEUCLIDIANDISTANCECONNECTIONPREDICATE_H
00012 #define LATERALEUCLIDIANDISTANCECONNECTIONPREDICATE_H
00013 
00014 #include <ConnectionDecisionPredicateSpecialization.h>
00015 
00016 #include <cmath>
00017 #include "Point2D.h"
00018 
00020 
00025 class LateralEuclidianDistanceConnectionPredicate : public SpatialConnectionDecisionPredicate
00026 {
00027 public:
00028     LateralEuclidianDistanceConnectionPredicate(double C,
00029                                                 double lambd,
00030                                                 bool toroid=false,
00031                                                 double toroid_off=0.0,
00032                                                 int src_shape_x=1, int src_shape_y=1,
00033                                                 int dst_shape_x=1, int dst_shape_y=1,
00034                                                 double src_scale=1.0,
00035                                                 double dst_scale=1.0,
00036                                                 double src_center_x=0.0, double src_center_y=0.0,
00037                                                 double dst_center_x=0.0, double dst_center_y=0.0
00038                                                 )
00039         : m_C(C)
00040         , m_L2(lambd*lambd)
00041         , m_distance(toroid, toroid_off,
00042                      src_shape_x, src_shape_y,
00043                      dst_shape_x, dst_shape_y,
00044                      src_scale, dst_scale,
00045                      Point2D<double>(src_center_x, src_center_y),
00046                      Point2D<double>(dst_center_x, dst_center_y))
00047         , m_unirnd(0.0, 1.0)
00048     {
00049     };
00050 
00051 /*
00052     virtual void init( SimObjectPopulation const& src, SimObjectPopulation const& dst, RandomEngine *rnd)
00053     {
00054         SpatialConnectionDecisionPredicate::init(src, dst, rnd);
00055     };
00056 */
00057 
00059 
00062     virtual bool decide( size_t src, size_t dst, RandomEngine *rnd )
00063     {
00064         if (m_sourcePopulation->getID(src) == m_destinationPopulation->getID(dst))
00065             return false;
00066 
00067         Point2D<double> s(m_sourcePopulation->getLocation(src));
00068         Point2D<double> d(m_destinationPopulation->getLocation(dst));
00069 
00070         double sqr_dist=m_distance.sqr_distance(s, d);
00071 
00072         return (m_unirnd(*rnd) < m_C*exp(-0.5* sqr_dist/ m_L2));
00073     };
00074 
00075 private:
00076     double m_C;
00077     double m_L2;
00078 
00079     Point2DDistance<double> m_distance;
00080     UniformDistribution m_unirnd;
00081 };
00082 
00083 #endif

Generated on Wed Jul 9 16:34:37 2008 for PCSIM by  doxygen 1.5.5