EvaluateRoadSourceDynamic { public static double evaluate(RSParametersDynamic parameters) { double Compound; int FreqParam = parameters.getFreqParam(); double Temperature = parameters.getTemperature(); int RoadSurface = parameters.getRoadSurface(); boolean Stud = parameters.getStud(); double Junc_dist = parameters.getJunc_dist(); int Junc_type = parameters.getJunc_type(); int acc_type = parameters.getAcc_type(); int veh_type = parameters.getVeh_type(); int VehId = parameters.getVehId(); double acceleration = parameters.getAcceleration(); double speed = parameters.getSpeed(); double RoadLvl; RoadLvl = getNoiseLvl(getCoeff(0, FreqParam, veh_type), getCoeff(1, FreqParam, veh_type), parameters.getSpeed(), 70.); switch (veh_type) { case 1: RoadLvl = RoadLvl + 0.08 * (20 - Temperature); break; case 2: RoadLvl = RoadLvl + 0.04 * (20 - Temperature); break; case 3: RoadLvl = RoadLvl + 0.04 * (20 - Temperature); break; default: break; } int indJunc = (Junc_type == 2) ? 2 : 0; switch (acc_type) { case 1: if (veh_type <= 3) { RoadLvl = RoadLvl + Coeff_Acc[veh_type - 1][0 + indJunc] * Math.max(1 - Math.abs(Junc_dist) / 100, 0); } break; default: break; } if (veh_type == 1) { if (Stud) { double deltastud = 0; double speedstud = (speed >= 90) ? 90 : speed; speedstud = (speedstud <= 50) ? 50 : speedstud; deltastud = getNoiseLvl(getCoeff(4, FreqParam, 1), getCoeff(5, FreqParam, 1), speedstud, 70.); RoadLvl = RoadLvl + Math.pow(10, deltastud / 10); } } RoadLvl = RoadLvl + getNoiseLvl(getA_Roadcoeff(FreqParam, veh_type, RoadSurface), getB_Roadcoeff(veh_type, RoadSurface), parameters.getSpeed(), 70.); double MotorLvl; RoadLvl = (speed <= 20) ? 0 : RoadLvl; speed = (speed <= 20) ? 20 : speed; MotorLvl = getCoeff(2, FreqParam, veh_type) + getCoeff(3, FreqParam, veh_type) * (speed - 70) / 70; double amax=0; switch (acc_type) { case 1: if (veh_type <= 3) { MotorLvl = MotorLvl + Coeff_Acc[veh_type - 1][1 + indJunc] * Math.max(1 - Math.abs(Junc_dist) / 100, 0); } break; case 2: switch (veh_type) { case 1: amax = 2; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; case 2: amax = 1; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 7.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 3.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 7.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 3.0;} break; case 3: amax = 1; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 7.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 3.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 7.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 3.0;} break; case 41: amax = 4; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; case 42: amax = 4; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; default: break; } break; case 3: switch (veh_type) { case 1: amax = 10; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; case 2: amax = 10; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 7.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 3.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 7.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 3.0;} break; case 3: amax = 10; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 7.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 3.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 7.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 3.0;} break; case 41: amax = 10; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; case 42: amax = 10; if (acceleration >= -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 5.0;} if (acceleration >= -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + Math.min(acceleration,amax) * 2.0;} if (acceleration < -1 & FreqParam < 250 ){ MotorLvl = MotorLvl + -1 * 5.0;} if (acceleration < -1 & FreqParam >= 250 ){ MotorLvl = MotorLvl + -1 * 2.0;} break; default: break; } break; default: break; } switch (veh_type) { case 1: if (parameters.getSlopePercentage() < -6) { MotorLvl = MotorLvl + (Math.min(12, -parameters.getSlopePercentage()) - 6) / 1; } else if (parameters.getSlopePercentage() <= 2) { MotorLvl = MotorLvl + 0.; } else { MotorLvl = MotorLvl + ((speed / 100) * ((Math.min(12, parameters.getSlopePercentage()) - 2) / 1.5)); } break; case 2: if (parameters.getSlopePercentage() < -4) { MotorLvl = MotorLvl + ((speed - 20) / 100) * (Math.min(12, -1 * parameters.getSlopePercentage()) - 4) / 0.7; } else if (parameters.getSlopePercentage() <= 0) { MotorLvl = MotorLvl + 0.; } else { MotorLvl = MotorLvl + (speed / 100) * (Math.min(12, parameters.getSlopePercentage())) / 1; } break; case 3: if (parameters.getSlopePercentage() < -4) { MotorLvl = MotorLvl + ((speed - 10) / 100) * (Math.min(12, -1 * parameters.getSlopePercentage()) - 4) / 0.5; } else if (parameters.getSlopePercentage() <= 0) { MotorLvl = MotorLvl + 0.; } else { MotorLvl = MotorLvl + (speed / 100) * (Math.min(12, parameters.getSlopePercentage())) / 0.8; } break; default: break; } MotorLvl = MotorLvl + Math.min(getA_Roadcoeff(FreqParam, veh_type, RoadSurface), 0.); Random r = new Random(VehId); double deltaLwdistrib = 0.115*Math.pow(parameters.getLwStd(),2.0); Compound = sumDba(RoadLvl, MotorLvl) - deltaLwdistrib + r.nextGaussian()*parameters.getLwStd(); return Compound; }  static Double getA_Roadcoeff(int Freq, int VehCat, int RoadSurface); static Double getB_Roadcoeff(int VehCat, int RoadSurface); static Double getCoeff(int Coeff, int Freq, int VehCat); static double evaluate(RSParametersDynamic parameters);  }
@Test public void testRoadNoise1() { double speed = 50; int acc = 1; int FreqParam = 500; double Temperature = 0; int RoadSurface = 0; boolean Stud = true; double Junc_dist = 200; int Junc_type = 1; int veh_type = 1; int acc_type= 1; double LwStd= 1; int VehId = 10; RSParametersDynamic rsParameters = new RSParametersDynamic(speed, acc, veh_type, acc_type, FreqParam, Temperature, RoadSurface,Stud, Junc_dist, Junc_type,LwStd,VehId); rsParameters.setSlopePercentage(0); assertEquals(94.35, EvaluateRoadSourceDynamic.evaluate(rsParameters), EPSILON_TEST1); }
@Test public void testRoadNoise2_speed0() { double speed = 0; int acc = 1; int FreqParam = 500; double Temperature = 0; int RoadSurface = 0; boolean Stud = false; double Junc_dist = 200; int Junc_type = 1; int veh_type = 3; int acc_type= 1; double LwStd= 1; int VehId = 10; RSParametersDynamic rsParameters = new RSParametersDynamic(speed, acc, veh_type, acc_type, FreqParam, Temperature, RoadSurface,Stud, Junc_dist, Junc_type,LwStd,VehId); rsParameters.setSlopePercentage(0); assertEquals(98.18, EvaluateRoadSourceDynamic.evaluate(rsParameters), EPSILON_TEST1); }
@Test public void testRoadNoise3_speed0() { int[] f = {63, 125, 250, 500,1000,2000,4000,8000}; for (int FreqParam : f ) { double speed = 60; int acc = 0; double Temperature = 15; int RoadSurface = 8; boolean Stud = false; double Junc_dist = 200; int Junc_type = 1; int veh_type = 1; int acc_type = 1; double LwStd = 0; int VehId = 1; RSParametersDynamic rsParameters = new RSParametersDynamic(speed, acc, veh_type, acc_type, FreqParam, Temperature, RoadSurface, Stud, Junc_dist, Junc_type, LwStd, VehId); rsParameters.setSlopePercentage(0); System.out.println(EvaluateRoadSourceDynamic.evaluate(rsParameters)); } }