56 TclObject*
create(
int,
const char*
const*) {
63 if (
mod->
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::UpdateTimerPosition(" <<
mod->
maddr <<
"), timer expire, curr_state = UpdatePositionTime(), next_state = update()" << endl;
119 bind(
"zmin_", &
zmin_);
138 Tcl& tcl = Tcl::instance();
141 if(strcasecmp(argv[1],
"bound") == 0)
143 if (strcasecmp(argv[2],
"SPHERIC")==0)
147 if (strcasecmp(argv[2],
"THOROIDAL")==0)
151 if (strcasecmp(argv[2],
"HARDWALL")==0)
155 if (strcasecmp(argv[2],
"REBOUNCE")==0)
159 fprintf(stderr,
"GMPosition::command(%s), unrecognized bound_ type (%s)\n",argv[1],argv[2]);
167 if(strcasecmp(argv[1],
"speedMean") == 0)
172 if(strcasecmp(argv[1],
"maddr") == 0)
174 maddr = atoi(argv[2]);
177 if(strcasecmp(argv[1],
"startLatitude") == 0)
182 if(strcasecmp(argv[1],
"startLongitude") == 0)
187 if(strcasecmp(argv[1],
"mtrace") == 0)
192 if(strcasecmp(argv[1],
"mTraceOfNode") == 0)
197 if(strcasecmp(argv[1],
"leader") == 0)
199 WossPosition* lead = (WossPosition*)TclObject::lookup(argv[2]);
204 if(strcasecmp(argv[1],
"gm3dGroupTraceFile") == 0)
211 if(strcasecmp(argv[1],
"start") == 0)
219 return Position::command(argc, argv);
224 double xdiff, ydiff, zdiff;
227 xdiff = pos1->getX() - pos2->getX();
228 ydiff = pos1->getY() - pos2->getY();
229 zdiff = pos1->getZ() - pos2->getZ();
239 dist = (sqrt(xdiff*xdiff + ydiff*ydiff + zdiff*zdiff));
241 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::distance(" <<
maddr <<
"), distance between leader and follower is: " << dist << endl;
249 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::mirror_posx(" <<
maddr <<
"), calculating mirror position x " << endl;
253 d = fabs(x_coord_node - x_coord_leader);
257 return ( x_coord_leader - (
xFieldWidth_)*(
sgn(x_coord_leader - x_coord_node)) );
258 return x_coord_leader;
264 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::mirror_posy(" <<
maddr <<
"), calculating mirror position y " << endl;
268 d = fabs(y_coord_node - y_coord_leader);
272 return ( y_coord_leader - (
yFieldWidth_)*(
sgn(y_coord_leader - y_coord_node)) );
273 return y_coord_leader;
279 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::mirror_posz(" <<
maddr <<
"), calculating mirror position z " << endl;
283 d = fabs(z_coord_node - z_coord_leader);
287 return ( z_coord_leader - (
zFieldWidth_)*(
sgn(z_coord_leader - z_coord_node)) );
288 return z_coord_leader;
294 double x1, x2, w, y1;
296 static int cache = 0;
309 x1 = 2.0 * RNG::defaultrng()->uniform_double() - 1.0;
310 x2 = 2.0 * RNG::defaultrng()->uniform_double() - 1.0;
311 w = x1 * x1 + x2 * x2;
312 }
while ( w >= 1.0 );
314 w = sqrt( (-2.0 * log( w ) ) / w );
327 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::getStartX(" <<
maddr <<
"), values of x0: " << setprecision(12) <<
start_x << endl;
335 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::getStartY(" <<
maddr <<
"), values of y0: " << setprecision(12) <<
start_y << endl;
344 lati = 90.0 - (asin (
x_coord / ((
earth_radius - WossPosition::getDepth()) * cos ( longi * M_PI / 180.0 ))) * 180.0 / M_PI);
345 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::setLatitude(" <<
maddr <<
"), new latitude value: " << setprecision(12) << lati << endl;
346 WossPosition::setLatitude(lati);
353 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::setLongitude(" <<
maddr <<
"), new longitude value: " << setprecision(12) << longi << endl;
354 WossPosition::setLongitude(longi);
359 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), updating value. " << endl;
365 printf(
"GMPosition::Update(%d), Update at (%.3f) old speed %.2f old direction %.2f old pitch %.2f\n",
maddr, NOW,
speed_,
direction_,
pitch_);
375 if (
wossgroup_debug_) printf (
"previous z-coord(%d) value: %.6f \n",
maddr, WossPosition::getDepth());
376 z_coord = WossPosition::getDepth();
415 double cx, cy, cz, dist, gamma;
424 if((
galpha_ < 0) && (dist < 1)) dist = 1.0;
438 if (pr_pitch_ ==
pitch_) {
440 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new x-coord value (after leader attraction): " << setprecision(12) <<
newx << endl;
442 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new y-coord value (after leader attraction): " << setprecision(12) <<
newy << endl;
446 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new x-coord value (after leader attraction): " << setprecision(12) <<
newx << endl;
449 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new x-coord value (after leader attraction): " << setprecision(12) <<
newy << endl;
452 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new z-coord value (after leader attraction): " << setprecision(12) <<
newz << endl;
576 cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), error in postion! Abort!! " << endl;
580 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new x-coord value (after wrapping): " << setprecision(12) <<
newx << endl;
581 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new y-coord value (after wrapping): " << setprecision(12) <<
newy << endl;
582 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new z-coord value (after wrapping): " << setprecision(12) <<
newz << endl;
590 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new cartesian x-coord value: " << setprecision(12) <<
x_coord << endl;
591 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new cartesian y-coord value: " << setprecision(12) <<
y_coord << endl;
592 if (
wossgroup_debug_) cout << NOW <<
" WossGroupMob3D::update(" <<
maddr <<
"), new depth value: " << setprecision(12) <<
z_coord << endl;
599 WossPosition::setDepth(
z_coord);
602 printf(
" WossGroupMob3D::Update(%d), now %f, updateTime %f\n",
maddr,NOW,
updateTime_);
607 saveInFile << NOW <<
"\t" << setprecision(12) <<
newx <<
"\t" << setprecision(12) <<
newy <<
"\t" << WossPosition::getDepth() << endl;
double Gauss(double m, double sigma, int type)
TCL Hooks for the simulator.
WossGroupMob3DClass()
Class constructor.
TclObject * create(int, const char *const *)
virtual void schedule(double val)
Update Time is scheduled using this method.
WossGroupMob3D * mod
An Object pointer of WossGroupMob3D class.
virtual void expire(Event *e)
This method tell the node what to do when update timer expire.
Base class of Group Mobility Model.
double vz
new velocity of a node respectively in x-axis, y-axis and z-axis.
double alpha_
Parameter to be used to vary the randomness.
double eta_
A tunable variable which is the coefficient of the filter in that range between 0 and 1.
double mirror_posz(double z_coord_node, double z_coord_leader)
Approximate position at z-axis.
virtual void setLong(double x_coord, double y_coord)
Method that sets the longitude of the node after update.
double galpha_
It tells the intensity of the attraction filed.
double start_x
Internal variable.
string gm3dGroupTraceFile
Trace file information.
int maddr
Mac address of the node whose movement we would like to trace.
double speedM_
Mean of the speed which is used to compute a Gaussian random variable.
virtual void setLat(double x_coord, double y_coord)
Method that sets the latitude of the node after update.
UpdatePositionTimer update_position_timer
An object of UpdateTimerPosition class.
int wossgroup_debug_
Debug flag.
double updateTime_
Time between two update computation.
virtual double getStartX()
Method that return the starting projection of the node on the cartesian x-axis.
WossGroupMob3D()
Constructor of WossGroupMob3D class.
double pitchMean_
Defines the mean value of the shifting in z-axis.
virtual double getStartY()
Method that return the starting projection of the node on the cartesian y-axis.
double zmin_
Minimum z-axis value.
double speedMean_
Defines the mean value of the speed.
double newz
new position of a node respectively in x-axis, y-axis and z-axis.
double pitch_
Current value of the pitch.
virtual ~WossGroupMob3D()
Destructor of WossGroupMob3D class.
double leaderCharge_
Attraction charge of the leader.
double zFieldWidth_
Range of the z-axis of the field to be simulated.
double start_longitude
Starting longitude of the simualted area.
int count
A counting variable.
double Gaussian()
Method that returns a value from a normal random Gaussian variable (zero mean, unitary viariance)
double start_latitude
Starting latitude of the simualted area.
WossPosition * leader_
Position pointer of the leader.
double mirror_posy(double y_coord_node, double y_coord_leader)
Approximate position at y-axis.
virtual void update()
Method that updates both the position coordinates as function of the number of states to be evaluated...
double direction_
Current value of the direction.
double speedS_
Standard deviation of speed which is also used to compute a Gaussian random variable.
double mirror_posx(double x_coord_node, double x_coord_leader)
Approximate position at x-axis.
BoundType bound_
Defines the behaviour of the node when it reaches the edge.
int mtrace_
Flag to enable trace.
virtual int command(int argc, const char *const *argv)
TCL command intepreter.
double directionMean_
Defines the mean value of the direction.
double yFieldWidth_
Range of the y-axis of the field to be simulated.
double z_coord
position of the node.
double start_y
Internal variable.
double beta_
A variable which is employed to calculate attraction force towards the leader.
double xFieldWidth_
Range of the x-axis of the field to be simulated.
double sigmaPitch_
Standard deviation in the z-axis.
double distance(WossPosition *pos1, WossPosition *pos2)
Calculate the distance between two nodes.
double charge_
Attraction charge of the follower.
int mtrace_of_node_
The node whose movement pattern we want to trace.
double speed_
Current value of the speed.
WossGroupMob3DClass class_wossgroupmob3D
This is a implementation of a leader-follower mobility model for WOSS (World Ocean Simulation System)...