Added measurements
This commit is contained in:
+21
-1
@@ -1,6 +1,7 @@
|
||||
#include "forces.hpp"
|
||||
#include <math.h>
|
||||
|
||||
// # 8 flops = 5 MULTs, 2 ADD, 1 SQRT
|
||||
double w(Vector2d e, Vector2d f) {
|
||||
if (e.dot(f) >= f.norm() * cos_phi)
|
||||
return 1.0;
|
||||
@@ -8,6 +9,7 @@ double w(Vector2d e, Vector2d f) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// # 2 DIVs
|
||||
double g(double v_max_alpha, double w_alpha_norm) {
|
||||
if (w_alpha_norm <= v_max_alpha) {
|
||||
return 1;
|
||||
@@ -15,12 +17,16 @@ double g(double v_max_alpha, double w_alpha_norm) {
|
||||
return v_max_alpha / w_alpha_norm;
|
||||
}
|
||||
|
||||
// # 8 flops
|
||||
void compute_acceleration_term(Pedestrian *p) {
|
||||
// # 2 flops
|
||||
Vector2d desired_velocity = p->e * p->desired_v0;
|
||||
Vector2d actual_velocity = p->curr_vel;
|
||||
// # 6 flops = 4 ADDs, 2 DIVs
|
||||
p->f_i += (desired_velocity - actual_velocity) / tau_alpha;
|
||||
}
|
||||
|
||||
// # 55(N - 1) = 55N - 55 flops
|
||||
void compute_repulsive_effects_from_pedestrians(Pedestrian *pedestrians, Pedestrian *p, int N) {
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -34,28 +40,39 @@ void compute_repulsive_effects_from_pedestrians(Pedestrian *pedestrians, Pedestr
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// # 2 ADDs
|
||||
Vector2d r_ab = p->curr_pos - pedestrians[i].curr_pos;
|
||||
|
||||
// # 4 flops = 1 SQRT, 2 MULTs, 1 ADD
|
||||
double r_ab_norm = r_ab.norm();
|
||||
|
||||
Vector2d e_b = pedestrians[i].e;
|
||||
|
||||
// # 2 MULTs
|
||||
double s_b = pedestrians[i].desired_v0 * delta_t;
|
||||
|
||||
// # 4 flops = 2 ADDs, 2 MULTs
|
||||
Vector2d r_ab2 = r_ab - (e_b * s_b);
|
||||
|
||||
// # 4 flops = 1 SQRT, 2 MULTs, 1 ADD
|
||||
double r_ab2_norm = r_ab2.norm();
|
||||
|
||||
double b = sqrt(pow(r_ab_norm + r_ab2_norm, 2) - pow(s_b, 2)) / 2;
|
||||
// # 7 flops = 1 SQRT, 3 ADDs, 2 MULTs, 1 DIV
|
||||
double b = sqrt((r_ab_norm + r_ab2_norm) * (r_ab_norm + r_ab2_norm) - s_b * s_b) / 2;
|
||||
|
||||
// # 12 flops = 6 DIVs, 3 ADDs, 3 MULTs
|
||||
Vector2d b_grad = (r_ab / r_ab_norm + r_ab2 / r_ab2_norm) * (r_ab_norm + r_ab2_norm) / (4 * b);
|
||||
|
||||
// # 6 flops = 3 MULTs, 2 DIVs, 1 EXP
|
||||
Vector2d f_ped = b_grad * ((V0_AB / SIGMA) * (exp(-b / SIGMA)));
|
||||
|
||||
// # 14 flops: 9 MULTs, 4 ADDs, 1 SQRT
|
||||
p->f_i += f_ped * w(p->e, f_ped * -1);
|
||||
}
|
||||
}
|
||||
|
||||
// # Assume that the four borders are also 4 obstacles
|
||||
// # 36 n_obstacles flops = 144 flops
|
||||
void compute_repulsive_effects_from_borders(Board &board, Pedestrian *p) {
|
||||
|
||||
Obstacle *obstacles = board.obstacles;
|
||||
@@ -65,10 +82,13 @@ void compute_repulsive_effects_from_borders(Board &board, Pedestrian *p) {
|
||||
|
||||
Obstacle obstacle = obstacles[i];
|
||||
|
||||
// # 17 flops
|
||||
Vector2d r_aB = p->curr_pos - obstacle.find_nearest_obstacle_point(p->curr_pos);
|
||||
|
||||
// # 17 flops = 2 DIVs, 1 SQRT, 2 MULTs, 1 ADD, 2 MULTs, 1 DIV, 2 MULTs, 1 EXP, 1 SQRT, 2 MULTs, 1 ADD, 1 DIV
|
||||
Vector2d f_obst = (r_aB / r_aB.norm()) * (U0_AB / R) * std::exp(-r_aB.norm() / R);
|
||||
|
||||
// # 2 ADDs
|
||||
p->f_i += f_obst;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user