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

activity durations

parent 676bb37a
......@@ -9,11 +9,27 @@
*/
#include "places.h"
#include "cfgfile.h"
Loco::SectionGroupPlace::SectionGroupPlace(id_type cg_id,
std::vector<SectionCPtr> sections)
: mSectionGroupId(cg_id), mSections(std::move(sections))
std::vector<SectionCPtr> sections,
length_type len)
: mSectionGroupId(cg_id), mSections(std::move(sections)), mLength(len)
{
UpdateDurations();
}
void
Loco::SectionGroupPlace::UpdateDurations()
{
mMinDuration =
static_cast<activity_time_type>(global_cfg.model.min_duration_multiplier
* static_cast<double>(mLength))
+ global_cfg.model.min_duration_addition;
mMaxDuration =
static_cast<activity_time_type>(global_cfg.model.max_duration_multiplier
* static_cast<double>(mLength))
+ global_cfg.model.max_duration_addition;
}
std::ostream &
......
......@@ -28,9 +28,15 @@ namespace Loco
private:
id_type mSectionGroupId;
std::vector<SectionCPtr> mSections;
length_type mLength;
activity_time_type mMinDuration{0};
activity_time_type mMaxDuration{0};
void UpdateDurations();
public:
SectionGroupPlace(id_type sg_id, std::vector<SectionCPtr> sections);
SectionGroupPlace(id_type sg_id, std::vector<SectionCPtr> sections,
length_type len);
std::string Ident() const;
std::ostream &Print(std::ostream &os, const std::string &prefix) const;
......@@ -39,6 +45,17 @@ namespace Loco
const SectionCPtr &FrontSection() const;
bool SingleSection() const;
unsigned SectionGroupId() const;
activity_time_type
MinDuration() const
{
return mMinDuration;
}
activity_time_type
MaxDuration() const
{
return mMaxDuration;
}
};
class TrainPlace
......
......@@ -289,13 +289,18 @@ Loco::SectionGraph::BuildPlaces()
{
std::vector<SectionCPtr> sections;
id_type id = std::numeric_limits<id_type>::max();
length_type len = 0;
for (const auto &sect_id : mConflictGroups[cg_id])
{
if (mSections[sect_id].mLength > len)
{
len = mSections[sect_id].mLength;
}
sections.push_back(mSections[sect_id].mSection);
id = std::min(id, mSections[sect_id].mSection->Id());
}
mPlaces.push_back(
std::make_shared<SectionGroupPlace>(id, std::move(sections)));
std::make_shared<SectionGroupPlace>(id, std::move(sections), len));
}
}
......
......@@ -9,6 +9,7 @@
*/
#include "train_route.h"
#include "cfgfile.h"
#include "util.h"
Loco::TrainRoutes::TrainRoutes(const InputData &input_data,
......@@ -86,12 +87,16 @@ void
Loco::TrainRouteGraph::AddEnterActivity()
{
mActList.emplace_back(mTrain->Ident() + "Enter", mEnterPlace, false);
mActList.back().mMinDuration = kTrainActivityMinDuration;
mActList.back().mMaxDuration = kTrainActivityMaxDuration;
}
void
Loco::TrainRouteGraph::AddLeaveActivity()
{
mActList.emplace_back(mTrain->Ident() + "Leave", mLeavePlace, true);
mActList.back().mMinDuration = kTrainActivityMinDuration;
mActList.back().mMaxDuration = kTrainActivityMaxDuration;
}
void
......@@ -124,7 +129,18 @@ Loco::TrainRouteGraph::AddElementActivities(unsigned element_id)
: element_id);
element.mPlaceActivities[place] = mActList.size();
element.mSectActivities[sect] = mActList.size();
mActList.emplace_back(name, std::move(place), false);
mActList.emplace_back(name, place, false);
if (node_info.mNodeType == SGSubgraph::NODE_TYPE::INNER)
{
mActList.back().mMinDuration = place->MinDuration();
mActList.back().mMaxDuration = place->MaxDuration();
}
else
{
mActList.back().mMinDuration = global_cfg.model.min_stop_duration;
// TODO: Should be computed from the stop schedule
mActList.back().mMaxDuration = kMaxStopDuration;
}
}
}
......
......@@ -72,6 +72,10 @@ namespace Loco
}
};
activity_time_type kTrainActivityMinDuration = 0;
activity_time_type kTrainActivityMaxDuration = 10000;
activity_time_type kMaxStopDuration = 10000;
private:
TrainCPtr mTrain{};
unsigned mTrainId{};
......
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