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

Global cfg, model configuration

parent 5eb3dfdc
......@@ -51,75 +51,74 @@ main([[maybe_unused]] int argc, char *argv[])
{
cfg_file = argv[1];
}
Loco::Cfg cfg;
if (!cfg.ParseFile(cfg_file))
if (!Loco::global_cfg.ParseFile(cfg_file))
{
std::cerr << "Failed to parse the configuration file" << std::endl;
return 1;
}
process_file<Loco::NodeParser>(
cfg.input.nodes, input_data,
Loco::global_cfg.input.nodes, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintNodes(os, prefix);
});
process_file<Loco::EdgeParser>(
cfg.input.edges, input_data,
Loco::global_cfg.input.edges, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintEdges(os, prefix);
});
process_file<Loco::PointParser>(
cfg.input.points, input_data,
Loco::global_cfg.input.points, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintPoints(os, prefix);
});
process_file<Loco::SectionParser>(
cfg.input.sections, input_data,
Loco::global_cfg.input.sections, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintSections(os, prefix);
});
process_file<Loco::AreaParser>(
cfg.input.regions, input_data,
Loco::global_cfg.input.regions, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintAreas(os, prefix);
});
process_file<Loco::TrafficPointParser>(
cfg.input.traffic_points, input_data,
Loco::global_cfg.input.traffic_points, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintTrafficPoints(os, prefix);
});
process_file<Loco::TrainParser>(
cfg.input.trains, input_data,
Loco::global_cfg.input.trains, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintTrains(os, prefix);
});
process_file<Loco::TrainListParser>(
cfg.message.lists, input_data,
Loco::global_cfg.message.lists, input_data,
[&input_data](std::ostream &os, const std::string &prefix) {
input_data.PrintTrainList(os, prefix);
});
Loco::PhysicalGraph g(input_data);
{
std::ofstream f(cfg.debug.phys_graph);
std::ofstream f(Loco::global_cfg.debug.phys_graph);
g.PrintGraph(f);
}
{
std::ofstream f(cfg.debug.phys_line_graph);
std::ofstream f(Loco::global_cfg.debug.phys_line_graph);
g.PrintLineGraph(f);
}
Loco::LogicalGraph lg(input_data);
{
std::ofstream f(cfg.debug.logical_graph);
std::ofstream f(Loco::global_cfg.debug.logical_graph);
lg.PrintGraph(f);
}
Loco::SectionGraphCPtr sg =
std::make_shared<const Loco::SectionGraph>(input_data, lg);
{
std::ofstream f(cfg.debug.section_graph);
std::ofstream f(Loco::global_cfg.debug.section_graph);
sg->PrintGraph(f);
}
{
std::ofstream f(cfg.debug.section_graph_info);
std::ofstream f(Loco::global_cfg.debug.section_graph_info);
sg->PrintSectionInfo(f);
}
auto tp_zababov = input_data.mTrafficPoints.Find("Bod Zababov");
......@@ -148,7 +147,7 @@ main([[maybe_unused]] int argc, char *argv[])
Loco::TrainRoutes routes(input_data, sg);
routes.UpdateActivities(input_data.mTrainList);
{
std::ofstream f(cfg.output.model_data);
std::ofstream f(Loco::global_cfg.output.model_data);
routes.PrintModelData(f, "");
// routes.PrintActivities(f, "", true);
}
......
......@@ -39,3 +39,5 @@ default-directory = data
min-duration-addition = 60
max-duration-multiplier = 1.0
max-duration-addition = 300
min-stop-duration = 60
allowed-delay = 60
......@@ -13,6 +13,8 @@
#include "cfgfile.h"
Loco::Cfg Loco::global_cfg;
bool
Loco::Cfg::ParseFile(const std::filesystem::path &fname)
{
......@@ -139,5 +141,8 @@ Loco::CfgModel::Parse(const INISection &sect)
.value_or(max_duration_multiplier);
max_duration_addition = sect.UnsignedValue("max-duration-addition")
.value_or(max_duration_addition);
min_stop_duration =
sect.UnsignedValue("min-stop-duration").value_or(min_stop_duration);
allowed_delay = sect.UnsignedValue("allowed-delay").value_or(allowed_delay);
return true;
}
......@@ -14,6 +14,7 @@
#include <filesystem>
#include "iniparser.h"
#include "loco_types.h"
namespace Loco
{
......@@ -65,9 +66,11 @@ namespace Loco
struct CfgModel
{
double min_duration_multiplier{0.1};
unsigned min_duration_addition{60};
activity_time_type min_duration_addition{60};
double max_duration_multiplier{1.0};
unsigned max_duration_addition{300};
activity_time_type max_duration_addition{300};
activity_time_type min_stop_duration{60};
activity_time_type allowed_delay{60};
bool Parse(const INISection &sect);
};
......@@ -87,6 +90,8 @@ namespace Loco
bool ParseFile(const std::filesystem::path &fname);
};
extern Cfg global_cfg;
} // namespace Loco
#endif
......@@ -498,6 +498,7 @@ Loco::TrainRouteGraph::CollectPlaces(UsedPlaces &used_places,
bool only_used) const
{
// TODO: Using DFS starting from the last activity, we could save some time.
// TODO: Also, usable places could be collected during activity update
if (only_used && !HasUsableActivity())
{
return;
......
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