void CirculateToTargetLocationNextDayEvent::execute() { Person* person = (Person*) dispatcher(); person->set_location(target_location_); if (target_location_ != person->residence_location()) { //if person already have return trip then no need to reschedule it //elase //Schedule for a return trip in next several days base on gamma distribution if (!person->has_return_to_residence_event()) { int length_of_trip = 0; while (length_of_trip < 1) { length_of_trip = Model::RANDOM->random_gamma(Model::CONFIG->spatial_information().length_of_stay_theta, Model::CONFIG->spatial_information().length_of_stay_k); } // std::cout << length_of_trip << std::endl; ReturnToResidenceEvent::schedule_event(Model::SCHEDULER, person, Model::SCHEDULER->current_time() + length_of_trip); } } else { //return by chance so we cancel all return event //cancel return trip and do nothing person->cancel_all_return_to_residence_events(); } }