TrainRoutePlanner::RoutingStep::RoutingStep(const RoutingStep *p):
time(p->time),
+ penalty(p->penalty),
cost_estimate(p->cost_estimate),
trains(p->trains),
prev(p)
new_steps.push_back(next);
}
+ new_steps.sort();
+ for(list<RoutingStep>::iterator i=new_steps.begin(); ++i!=new_steps.end(); )
+ {
+ i->penalty += 5*Time::sec;
+ i->update_estimate();
+ }
+
if(next_entry_ep.paths!=next_track->get_type().get_paths())
{
RoutingStep wait(this);
wait.advance(dt);
wait.trains[train_index].state = WAITING;
+ wait.penalty += 15*Time::sec;
+ wait.update_estimate();
if(wait.is_viable())
new_steps.push_back(wait);
}
void TrainRoutePlanner::RoutingStep::update_estimate()
{
- cost_estimate = Time::zero;
+ cost_estimate = penalty;
for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
if(i->remaining_estimate>=0)
cost_estimate += i->wait_time+((i->distance_traveled+i->remaining_estimate)/i->info->speed)*Time::sec;
struct RoutingStep
{
Msp::Time::TimeDelta time;
+ Msp::Time::TimeDelta penalty;
Msp::Time::TimeDelta cost_estimate;
std::vector<TrainRoutingState> trains;
const RoutingStep *prev;