Miscellaneous scripts
This repository contains miscellaneous scripts that does not fit in one repository, yet I will use them sometimes for my personal use. Note that some of the scripts might contain hardcoded paths and opinionated presets, and you are advised to inspect them before actually using.
 
Loading...
Searching...
No Matches
Lift Class Reference
Collaboration diagram for Lift:

Public Member Functions

 Lift (unsigned int _id, unsigned int _meanWaitingTime, unsigned int _stdDevWaitingTime)
 
auto generateWaitingTime () const -> unsigned int
 
auto getAvailableTime (unsigned int currentTime) const -> unsigned int
 

Public Attributes

const unsigned int capacity = liftCapacity
 
const unsigned int id
 
const unsigned int meanWaitingTime
 
const unsigned int stdDevWaitingTime
 

Friends

auto operator<< (std::ostream &os, const Lift &lift) -> std::ostream &
 

Detailed Description

Definition at line 40 of file lift.cpp.

Constructor & Destructor Documentation

◆ Lift()

Lift::Lift ( unsigned int _id,
unsigned int _meanWaitingTime,
unsigned int _stdDevWaitingTime )
inline

Definition at line 47 of file lift.cpp.

48 : id(_id), meanWaitingTime(_meanWaitingTime), stdDevWaitingTime(_stdDevWaitingTime) {};
const unsigned int stdDevWaitingTime
Definition lift.cpp:44
const unsigned int meanWaitingTime
Definition lift.cpp:43
const unsigned int id
Definition lift.cpp:42

References id, meanWaitingTime, and stdDevWaitingTime.

Referenced by operator<<.

Here is the caller graph for this function:

Member Function Documentation

◆ generateWaitingTime()

auto Lift::generateWaitingTime ( ) const -> unsigned int
inlinenodiscard

Definition at line 58 of file lift.cpp.

58 {
60
61 unsigned int const seed = std::chrono::system_clock::now().time_since_epoch().count();
62 std::default_random_engine generator(seed);
63 std::normal_distribution<double> distribution(meanWaitingTime, stdDevWaitingTime);
64 double waitingTime = distribution(generator);
65
68 }
69 else if (waitingTime > meanWaitingTime + stdDevWaitingTime * normDistSDBound) {
71 }
72 return static_cast<unsigned int>(waitingTime);
73 }
@ normDistSDBound
Definition lift.cpp:22

References meanWaitingTime, normDistSDBound, and stdDevWaitingTime.

Referenced by getAvailableTime().

Here is the caller graph for this function:

◆ getAvailableTime()

auto Lift::getAvailableTime ( unsigned int currentTime) const -> unsigned int
inlinenodiscard

Definition at line 76 of file lift.cpp.

76 {
77 return currentTime + generateWaitingTime();
78 }
auto generateWaitingTime() const -> unsigned int
Definition lift.cpp:58

References generateWaitingTime().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

auto operator<< ( std::ostream & os,
const Lift & lift ) -> std::ostream &
friend

Definition at line 51 of file lift.cpp.

51 {
52 os << lift.id << " " << lift.meanWaitingTime << " " << lift.stdDevWaitingTime;
53 return os;
54 }

References Lift().

Member Data Documentation

◆ capacity

const unsigned int Lift::capacity = liftCapacity

Definition at line 45 of file lift.cpp.

◆ id

const unsigned int Lift::id

Definition at line 42 of file lift.cpp.

Referenced by Lift().

◆ meanWaitingTime

const unsigned int Lift::meanWaitingTime

Definition at line 43 of file lift.cpp.

Referenced by Lift(), and generateWaitingTime().

◆ stdDevWaitingTime

const unsigned int Lift::stdDevWaitingTime

Definition at line 44 of file lift.cpp.

Referenced by Lift(), and generateWaitingTime().


The documentation for this class was generated from the following file: