Commit a58680e5 authored by Kučera Petr RNDr. Ph.D.'s avatar Kučera Petr RNDr. Ph.D.
Browse files

Bug fix

parent 51310559
......@@ -43,12 +43,12 @@ namespace Loco
using Vertex = std::variant<NodeCPtr, PointCPtr>;
private:
std::vector<std::vector<Neighbour>> mNeighbours;
std::vector<std::vector<Neighbour>> mNeighbours{};
std::vector<NodeCPtr> mNodes;
std::vector<PointCPtr> mPoints;
std::unordered_map<NodeCPtr, unsigned> mNodeId;
std::unordered_map<PointCPtr, unsigned> mPointId;
std::vector<NodeCPtr> mNodes{};
std::vector<PointCPtr> mPoints{};
std::unordered_map<NodeCPtr, unsigned> mNodeId{};
std::unordered_map<PointCPtr, unsigned> mPointId{};
static EdgePoints BuildEdgePoints(const InputData &data);
static EdgePoints SortEdgePoints(EdgePoints edge_points);
......
......@@ -45,10 +45,10 @@ namespace Loco
void TOVisit(unsigned node, std::unordered_set<unsigned> &visited);
public:
std::vector<unsigned> mSources;
std::vector<unsigned> mTargets;
std::unordered_map<unsigned, NodeInfo> mSections;
std::vector<unsigned> mTopoOrder;
std::vector<unsigned> mSources{};
std::vector<unsigned> mTargets{};
std::unordered_map<unsigned, NodeInfo> mSections{};
std::vector<unsigned> mTopoOrder{};
void BuildTopoOrder();
SGSubgraph(std::vector<unsigned> sources, std::vector<unsigned> targets,
......@@ -63,11 +63,11 @@ namespace Loco
{
SectionCPtr mSection{};
std::vector<LogicalGraph::Vertex> mVertices{};
length_type mLength;
length_type mLength{0};
unsigned mConflictGroupId{};
std::vector<unsigned> mNeighbours;
std::vector<unsigned> mConflicts;
bool mHasPhysicalNode;
std::vector<unsigned> mNeighbours{};
std::vector<unsigned> mConflicts{};
bool mHasPhysicalNode{false};
SectionInfo() = default;
SectionInfo(SectionCPtr sect,
......@@ -82,15 +82,15 @@ namespace Loco
};
private:
std::vector<SectionInfo> mSections;
std::unordered_map<SectionCPtr, unsigned> mSectionId;
std::vector<std::vector<unsigned>> mConflictGroups;
std::unordered_map<NodeCPtr, std::vector<unsigned>> mNodeSections;
std::unordered_map<PointCPtr, std::vector<unsigned>> mPointSections;
std::vector<SGPlaceCPtr> mPlaces;
std::vector<SectionInfo> mSections{};
std::unordered_map<SectionCPtr, unsigned> mSectionId{};
std::vector<std::vector<unsigned>> mConflictGroups{};
std::unordered_map<NodeCPtr, std::vector<unsigned>> mNodeSections{};
std::unordered_map<PointCPtr, std::vector<unsigned>> mPointSections{};
std::vector<SGPlaceCPtr> mPlaces{};
mutable std::map<std::pair<TrafficPointCPtr, TrafficPointCPtr>,
SGSubgraphCPtr>
mSubgraphs;
mSubgraphs{};
void AddInfoForSection(const LogicalGraph &logical_graph,
SectionCPtr sect);
......
......@@ -67,9 +67,9 @@ Loco::TrainRouteGraph::AddElement(unsigned start)
mElements.emplace_back(start, mSectionGraph->Subgraph(
mTrain->StopAt(start).TrafficPoint(),
mTrain->StopAt(start + 1).TrafficPoint()));
std::cout << "Element " << mTrain->Ident() << "@" << start << std::endl;
mSectionGraph->PrintSubgraph(std::cout, mElements.back().mSubgraph,
"subg_" + std::to_string(start));
// std::cout << "Element " << mTrain->Ident() << "@" << start << std::endl;
// mSectionGraph->PrintSubgraph(std::cout, mElements.back().mSubgraph,
//"subg_" + std::to_string(start));
}
void
......@@ -163,16 +163,25 @@ std::ostream &
Loco::TrainRoutes::PrintActivities(std::ostream &os, const std::string &prefix,
bool only_used) const
{
os << "activities = #[" << std::endl;
os << prefix << "activities = #[" << std::endl;
bool is_first = true;
for (const auto &[train, g] : mRouteGraphs)
{
if (is_first)
{
is_first = false;
}
else
{
os << ',' << std::endl;
}
if (only_used && !g.HasUsableActivity())
{
continue;
}
g.PrintActivities(os, prefix + kTabString, only_used);
}
return os << "]#" << std::endl;
return os << "\n" << prefix << "]#;" << std::endl;
}
std::ostream &
......@@ -295,7 +304,7 @@ Loco::TrainRouteGraph::PrintActivities(std::ostream &os,
}
if (has_used)
{
os << prefix << "}" << std::endl;
os << prefix << "}";
}
return os;
}
......@@ -335,7 +344,7 @@ Loco::TrainRouteGraph::PrintActNamesList(std::ostream &os,
{
print_comma = true;
}
os << mActList[act_ids.front()].mName;
os << mActList[id].mName;
}
return os << "}";
}
......
......@@ -55,8 +55,8 @@ namespace Loco
struct UsedPlaces
{
std::set<SGPlaceCPtr, SGPlaceComparator> mSGPlaces;
std::set<TPlaceCPtr, TPlaceComparator> mTPlaces;
std::set<SGPlaceCPtr, SGPlaceComparator> mSGPlaces{};
std::set<TPlaceCPtr, TPlaceComparator> mTPlaces{};
void AddPlace(const Place &place);
void Clear();
......@@ -75,15 +75,15 @@ namespace Loco
{
// Index within the list of train stops of the train
// We assume that the next stop is at index mStartStop+1.
unsigned mStartStop;
SGSubgraphCPtr mSubgraph;
unsigned mStartStop{0};
SGSubgraphCPtr mSubgraph{};
// For each place within the subgraph, mPlaceActivities contains the
// index of its activity
// - Activities associated with the sources are shared with the
// activities activities associated with the targets of the subgraph
// in the previous stop.
std::unordered_map<SGPlaceCPtr, unsigned> mPlaceActivities;
std::unordered_map<unsigned, unsigned> mSectActivities;
std::unordered_map<SGPlaceCPtr, unsigned> mPlaceActivities{};
std::unordered_map<unsigned, unsigned> mSectActivities{};
Element(unsigned start_stop, SGSubgraphCPtr subgraph)
: mStartStop(start_stop), mSubgraph(std::move(subgraph))
......@@ -101,10 +101,10 @@ namespace Loco
TPlaceCPtr mEnterPlace{};
TPlaceCPtr mLeavePlace{};
SectionGraphCPtr mSectionGraph{};
std::vector<Element> mElements;
std::vector<Element> mElements{};
// Enter activity is always the first in the list
// Leave activity is always the last in the list
std::vector<Activity> mActList;
std::vector<Activity> mActList{};
void AddElement(unsigned start);
void BuildElements();
......@@ -151,8 +151,8 @@ namespace Loco
class TrainRoutes
{
private:
std::unordered_map<TrainCPtr, TrainRouteGraph> mRouteGraphs;
UsedPlaces mUsedPlaces;
std::unordered_map<TrainCPtr, TrainRouteGraph> mRouteGraphs{};
UsedPlaces mUsedPlaces{};
void BuildRoutes(const InputData &input_data,
const SectionGraphCPtr &section_graph);
......
......@@ -11,6 +11,7 @@
#ifndef __UTIL_H
#define __UTIL_H
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
......
Supports Markdown
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