Commit 43bab263 authored by Erik Andresen's avatar Erik Andresen

if two edges possess the same weight the nearer one will be preferred

parent 0d294c88
......@@ -63,7 +63,7 @@
<agents_distribution>
<!--group group_id="1" agent_parameter_id="1" room_id="0" subroom_id="0" number="20" router_id="1" /-->
<!--group group_id="2" agent_parameter_id="1" room_id="0" subroom_id="1" number="20" router_id="7" /-->
<group group_id="3" agent_parameter_id="1" room_id="0" subroom_id="3" number="1" router_id="7" />
<group group_id="3" agent_parameter_id="1" room_id="0" subroom_id="3" number="1" router_id="1" />
<!--group group_id="2" agent_parameter_id="1" room_id="0" subroom_id="16" number="20" router_id="1" /-->
</agents_distribution>
......@@ -92,7 +92,7 @@
</operational_models>
<route_choice_models>
<router router_id="1" description="quickest">
<router router_id="1" description="global_shortest">
<parameters>
<!--navigation_lines file="routing.xml" /-->
......
......@@ -81,7 +81,7 @@ private:
CognitiveMapStorage * cm_storage;
SensorManager * sensor_manager;
/// Optional options which are supposed to be used
// Optional options which are supposed to be used
optStorage options;
};
......
......@@ -84,9 +84,9 @@ void GraphEdge::CalcApproximateDistance()
double GraphEdge::GetWeight(const Point & position) const
{
//if(factors.empty()) {
// return GetApproximateDistance(position);
// }
// if(factors.empty()) {
// return GetApproximateDistance(position);
// }
//double weight = GetFactorWithDistance(GetApproximateDistance(position));
double weight = GetFactor();// GetApproximateDistance(position) * GetFactor();
return weight;
......
......@@ -233,11 +233,31 @@ const GraphEdge * GraphVertex::GetLocalCheapestDestination(const Point & positio
vector<std::pair<double, const GraphEdge *> >,
std::greater<std::pair<double, const GraphEdge *> >
> edges;
std::priority_queue<
std::pair<double, const GraphEdge *>,
vector<std::pair<double, const GraphEdge *> >,
std::greater<std::pair<double, const GraphEdge *> >
> sameFactorEdges;
for(EdgesContainer::const_iterator it = this->GetAllOutEdges()->begin(); it != this->GetAllOutEdges()->end(); ++it) {
edges.push(std::make_pair((*it)->GetFactor(), (*it)));
}
if(edges.size() >= 1) return edges.top().second;
// if two edges possess the same (lowest) weight
for(EdgesContainer::const_iterator itedge = this->GetAllOutEdges()->begin(); itedge != this->GetAllOutEdges()->end(); ++itedge)
{
if ((*itedge)==edges.top().second)
sameFactorEdges.push(std::make_pair((*itedge)->GetApproximateDistance(position),(*itedge)));
else if ((*itedge)->GetFactor()==edges.top().second->GetFactor())
sameFactorEdges.push(std::make_pair((*itedge)->GetApproximateDistance(position),(*itedge)));
}
// Log->Write("Crossing:");
// Log->Write(std::to_string(sameFactorEdges.top().second->GetCrossing()->GetCentre().GetX()));
// Log->Write(std::to_string(sameFactorEdges.top().second->GetCrossing()->GetCentre().GetY()));
if(edges.size() >= 1) return sameFactorEdges.top().second;
else return nullptr;
// if(edges.size() > 1) {
// double best_factor = edges.top().first;
......@@ -264,6 +284,6 @@ const GraphEdge * GraphVertex::GetLocalCheapestDestination(const Point & positio
// return act_edge;
// }
}
//}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment