Line data Source code
1 : #include "Dynamic/Policy/RewardFunction/RewardFunctionLocal.hpp" 2 : 3 : #include "Dynamic/Env/Env.hpp" 4 : 5 : using namespace std; 6 : using namespace Dynamic; 7 : 8 0 : Reward RewardFunctionLocal::operator()(const Env::Env &env, const Env::Vehicle &vehicle) { 9 0 : Time leftLane = env.getTime(); 10 : 11 0 : #pragma GCC diagnostic push 12 0 : #pragma GCC diagnostic ignored "-Wfloat-equal" 13 0 : assert(vehicle.enteredLane == vehicle.path.back().first); 14 0 : #pragma GCC diagnostic pop 15 : 16 0 : Time t = leftLane - vehicle.enteredLane; 17 : 18 0 : Env::Lane &lane = vehicle.position.lane; 19 : 20 0 : t *= (Time)(lane.moving.size() + lane.stopped.size()); 21 : 22 0 : return -t; 23 : } 24 : 25 : RewardFunctionLocal RewardFunctionLocal::INSTANCE;