PrePostDependentDelay.cpp

Go to the documentation of this file.
00001 
00012 #include "PrePostDependentDelay.h"
00013 
00014 
00015 DelayCond::DelayCond(double v_mean, double v_SH, double v_min, double v_max)
00016     : v_mean(v_mean), v_SH(v_SH), v_min(v_min), v_max(v_max)
00017     , v_dist(v_mean, v_SH, v_min, v_max)
00018 {
00019 }
00020 
00021 
00022 DelayCond::~DelayCond()
00023 {
00024 }
00025 
00026 
00027 double DelayCond::generate(size_t src_idx, size_t dst_idx, RandomEngine *rnd)
00028 {
00029     if(rnd != NULL)
00030         rnd_eng=rnd;
00031 
00032     Point3D<double> s = m_sourcePopulation->getLocation(src_idx);
00033     Point3D<double> d = m_destinationPopulation->getLocation(dst_idx);
00034 
00035     return distance(s, d)/v_dist(*rnd_eng);
00036 }
00037 
00038 
00039 ConnObjectValueGenerator* DelayCond::clone(void) const
00040 {
00041     return new DelayCond(v_mean, v_SH, v_min, v_max);
00042 }
00043 
00044 
00045 
00046 DelayCondAndSyn::DelayCondAndSyn(double v_mean, double v_SH, double v_min, double v_max,
00047                                  double d_mean, double d_SH, double d_min, double d_max)
00048     : v_mean(v_mean), v_SH(v_SH), v_min(v_min), v_max(v_max)
00049     , d_mean(d_mean), d_SH(v_SH), d_min(d_min), d_max(d_max)
00050     , v_dist(v_mean, v_SH, v_min, v_max)
00051     , delay_dist(d_mean, d_SH, d_min, d_max)
00052 {
00053 }
00054 
00055 
00056 DelayCondAndSyn::~DelayCondAndSyn()
00057 {
00058 }
00059 
00060 
00061 double DelayCondAndSyn::generate(size_t src_idx, size_t dst_idx, RandomEngine *rnd)
00062 {
00063     if(rnd!=NULL)
00064         rnd_eng=rnd;
00065 
00066     Point3D<double> s = m_sourcePopulation->getLocation(src_idx);
00067     Point3D<double> d = m_destinationPopulation->getLocation(dst_idx);
00068 
00069     return distance(s, d)/v_dist(*rnd_eng)+delay_dist(*rnd_eng);
00070 }
00071 
00072 
00073 ConnObjectValueGenerator* DelayCondAndSyn::clone(void) const
00074 {
00075     return new DelayCondAndSyn(v_mean, v_SH, v_min, d_max, d_mean, d_SH, d_min, d_max);
00076 }
00077 
00078 
00079 
00080 LateralDelayCondAndSyn::LateralDelayCondAndSyn(double v_mean, double v_SH, double v_min, double v_max,
00081                                                double d_mean, double d_SH, double d_min, double d_max,
00082                                                bool toroid, double toroid_off, double z_scale,
00083                                                double src_scale, double dst_scale,
00084                                                double src_center_x, double src_center_y,
00085                                                double dst_center_x, double dst_center_y,
00086                                                double src_shape_x, double src_shape_y,
00087                                                double dst_shape_x, double dst_shape_y)
00088 
00089     : v_mean(v_mean), v_SH(v_SH), v_min(v_min), v_max(v_max)
00090     , d_mean(d_mean), d_SH(v_SH), d_min(d_min), d_max(d_max)       
00091     , m_toroid(toroid)
00092     , m_toroid_off(toroid_off)
00093     , m_z_scale(z_scale)
00094     , m_src_scale(src_scale)
00095     , m_dst_scale(dst_scale)
00096     , m_src_center_x(src_center_x)
00097     , m_src_center_y(src_center_y)
00098     , m_dst_center_x(dst_center_x)
00099     , m_dst_center_y(dst_center_y)
00100     , m_src_shape_x(src_shape_x)
00101     , m_src_shape_y(src_shape_y)
00102     , m_dst_shape_x(dst_shape_x)
00103     , m_dst_shape_y(dst_shape_y)
00104     , v_dist(v_mean, v_SH, v_min, v_max)
00105     , delay_dist(d_mean, d_SH, d_min, d_max)
00106 
00107 {
00108   min_sx=min_sy=max_sx=max_sy=0.0;
00109   min_dx=min_dy=max_dx=max_dy=0.0;
00110 
00111   if (m_toroid)
00112     {      
00113       //x in centered coordinates
00114       min_sx= m_src_scale * (-(m_src_shape_x - 1.0) / 2.0 ) - m_toroid_off;
00115       max_sx= m_src_scale * ((m_src_shape_x - 1.0) / 2.0);
00116       
00117       min_dx= m_dst_scale * (-(m_dst_shape_x - 1.0) / 2.0) - m_toroid_off;
00118       max_dx= m_dst_scale * ((m_dst_shape_x - 1.0) / 2.0);
00119       
00120       //y
00121       min_sy= m_src_scale * (-(m_src_shape_y - 1.0) / 2.0) - m_toroid_off;
00122       max_sy= m_src_scale * ((m_src_shape_y - 1.0) / 2.0);
00123       
00124       min_dy= m_dst_scale * (-(m_dst_shape_y - 1.0) / 2.0) - m_toroid_off;
00125       max_dy= m_dst_scale * ((m_dst_shape_y - 1.0) / 2.0);
00126     }
00127 
00128 }
00129 
00130 
00131 
00132 
00133 LateralDelayCondAndSyn::~LateralDelayCondAndSyn()
00134 {
00135 }
00136 
00137 
00138 double LateralDelayCondAndSyn::generate(size_t src_idx, size_t dst_idx, RandomEngine *rnd)
00139 {
00140     if(rnd!=NULL)
00141         rnd_eng=rnd;
00142 
00143     Point3D<double> s = m_sourcePopulation->getLocation(src_idx);
00144 
00145     s.x((s.x()-m_src_center_x)*m_src_scale);
00146     s.y((s.y()-m_src_center_y)*m_src_scale);
00147     s.z(s.z()*m_z_scale);
00148 
00149     Point3D<double> d = m_destinationPopulation->getLocation(dst_idx);
00150 
00151     d.x((d.x()-m_dst_center_x)*m_dst_scale);
00152     d.y((d.y()-m_dst_center_y)*m_dst_scale);
00153     d.z(d.z()*m_z_scale);
00154 
00155     double dist=0.0;
00156 
00157     if (!m_toroid)
00158     {
00159         dist=distance(s,d);
00160     }
00161     else
00162     {
00163         double d1 = fabs(d.x() - s.x());
00164         double d2 = fabs(max_dx - d.x()) + fabs(min_sx - s.x());
00165         double d3 = fabs(max_sx - s.x()) + fabs(min_dx - d.x());
00166         
00167             double dx = min(min(d1,d2), d3);
00168         
00169         d1 = fabs(d.y() - s.y());
00170         d2 = fabs(max_dy - d.y()) + fabs(min_sy - s.y());
00171         d3 = fabs(max_sy - s.y()) + fabs(min_dy - d.y());
00172         
00173         double dy = min(min(d1,d2), d3);
00174         double dz = fabs(d.z() - s.z());
00175 
00176         dist = sqrt(dx*dx + dy*dy + dz*dz);
00177     }
00178 
00179     return dist/v_dist(*rnd_eng)+delay_dist(*rnd_eng);
00180 }
00181 
00182 
00183 ConnObjectValueGenerator* LateralDelayCondAndSyn::clone(void) const
00184 {
00185     return new LateralDelayCondAndSyn(v_mean, v_SH, v_min, d_max, d_mean, d_SH, d_min, d_max, m_toroid,
00186                                       m_toroid_off, m_z_scale, m_src_scale, m_dst_scale, 
00187                                       m_src_center_x, m_src_center_y, 
00188                                       m_dst_center_x,  m_dst_center_y,
00189                                       m_src_shape_x, m_src_shape_y,
00190                                       m_dst_shape_x, m_dst_shape_y);
00191 }
00192 

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