double inefficiency_cost(int target_speed, int intended_lane, int final_lane, const std::vector<int> &lane_speeds);
#endif // COST_H
定义第二个损失函数
1 2 3 4 5 6 7 8 9 10
double inefficiency_cost(int target_speed, int intended_lane, int final_lane, const std::vector<int> &lane_speeds) { // Cost becomes higher for trajectories with intended lane and final lane // that have traffic slower than target_speed. double speed_intended = lane_speeds[intended_lane]; double speed_final = lane_speeds[final_lane]; double cost = (2.0*target_speed - speed_intended - speed_final)/target_speed;