|
@@ -114,10 +114,12 @@ public:
|
|
|
|
|
|
void dint(const artis::common::DoubleTime::type &t) override
|
|
void dint(const artis::common::DoubleTime::type &t) override
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - dint" << std::endl;
|
|
|
|
+
|
|
_last_time = t;
|
|
_last_time = t;
|
|
_sigma = _distribution(_generator);
|
|
_sigma = _distribution(_generator);
|
|
_sigma = _sigma <= 0 ? 0.1 : _sigma;
|
|
_sigma = _sigma <= 0 ? 0.1 : _sigma;
|
|
-
|
|
|
|
_next_v_max = _v_max * _v_max_distribution(_generator);
|
|
_next_v_max = _v_max * _v_max_distribution(_generator);
|
|
_next_port = _port_distribution(_generator);
|
|
_next_port = _port_distribution(_generator);
|
|
++_index;
|
|
++_index;
|
|
@@ -125,6 +127,9 @@ public:
|
|
|
|
|
|
void start(const artis::common::DoubleTime::type &t) override
|
|
void start(const artis::common::DoubleTime::type &t) override
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - start" << std::endl;
|
|
|
|
+
|
|
_last_time = t;
|
|
_last_time = t;
|
|
_sigma = _distribution(_generator);
|
|
_sigma = _distribution(_generator);
|
|
_sigma = _sigma <= 0 ? 0.1 : _sigma;
|
|
_sigma = _sigma <= 0 ? 0.1 : _sigma;
|
|
@@ -142,6 +147,8 @@ public:
|
|
{
|
|
{
|
|
artis::common::Bag<artis::common::DoubleTime> bag;
|
|
artis::common::Bag<artis::common::DoubleTime> bag;
|
|
|
|
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - lambda" << std::endl;
|
|
|
|
+
|
|
if (t > 0) {
|
|
if (t > 0) {
|
|
Vehicle vehicle = {_index, _next_v_max, 0.5, State::STOP, t};
|
|
Vehicle vehicle = {_index, _next_v_max, 0.5, State::STOP, t};
|
|
|
|
|
|
@@ -206,19 +213,21 @@ public:
|
|
|
|
|
|
~Counter() override = default;
|
|
~Counter() override = default;
|
|
|
|
|
|
- void
|
|
|
|
- dext(const artis::common::DoubleTime::type & /* t */,
|
|
|
|
- const artis::common::DoubleTime::type & /* e */,
|
|
|
|
- const artis::common::Bag<artis::common::DoubleTime> &bag) override
|
|
|
|
|
|
+ void dext(const artis::common::DoubleTime::type & /* t */,
|
|
|
|
+ const artis::common::DoubleTime::type & /* e */,
|
|
|
|
+ const artis::common::Bag<artis::common::DoubleTime> &bag) override
|
|
{
|
|
{
|
|
|
|
|
|
-// std::cout << t << ": " << _counter << std::endl;
|
|
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - dext" << std::endl;
|
|
|
|
|
|
_counter += bag.size();
|
|
_counter += bag.size();
|
|
}
|
|
}
|
|
|
|
|
|
void start(const artis::common::DoubleTime::type & /* t */) override
|
|
void start(const artis::common::DoubleTime::type & /* t */) override
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - start" << std::endl;
|
|
|
|
+
|
|
_counter = 0;
|
|
_counter = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -228,8 +237,7 @@ public:
|
|
return artis::common::DoubleTime::infinity;
|
|
return artis::common::DoubleTime::infinity;
|
|
}
|
|
}
|
|
|
|
|
|
- artis::common::Value
|
|
|
|
- observe(const artis::common::DoubleTime::type & /* t */,
|
|
|
|
|
|
+ artis::common::Value observe(const artis::common::DoubleTime::type & /* t */,
|
|
unsigned int index) const override
|
|
unsigned int index) const override
|
|
{
|
|
{
|
|
if (index == vars::COUNTER) {
|
|
if (index == vars::COUNTER) {
|
|
@@ -239,8 +247,7 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- common::DoubleTime::type
|
|
|
|
- lookahead(const common::DoubleTime::type & /* t */) const override
|
|
|
|
|
|
+ common::DoubleTime::type lookahead(const common::DoubleTime::type & /* t */) const override
|
|
{
|
|
{
|
|
return common::DoubleTime::infinity;
|
|
return common::DoubleTime::infinity;
|
|
}
|
|
}
|
|
@@ -281,7 +288,9 @@ public :
|
|
|
|
|
|
void dint(const artis::common::DoubleTime::type &t) override
|
|
void dint(const artis::common::DoubleTime::type &t) override
|
|
{
|
|
{
|
|
- delay();
|
|
|
|
|
|
+// delay();
|
|
|
|
+
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - dint" << std::endl;
|
|
|
|
|
|
auto it = _vehicles.begin();
|
|
auto it = _vehicles.begin();
|
|
|
|
|
|
@@ -298,12 +307,10 @@ public :
|
|
switch (vehicle.state) {
|
|
switch (vehicle.state) {
|
|
case State::UP: {
|
|
case State::UP: {
|
|
double duration = vehicle.v_max / vehicle.acceleration;
|
|
double duration = vehicle.v_max / vehicle.acceleration;
|
|
- double acceleration_distance =
|
|
|
|
- 0.5 * vehicle.acceleration * duration * duration;
|
|
|
|
|
|
+ double acceleration_distance = 0.5 * vehicle.acceleration * duration * duration;
|
|
|
|
|
|
vehicle.state = State::MAX;
|
|
vehicle.state = State::MAX;
|
|
- vehicle.next_time = t +
|
|
|
|
- (_length - 2 * acceleration_distance) / vehicle.v_max;
|
|
|
|
|
|
+ vehicle.next_time = t + (_length - 2 * acceleration_distance) / vehicle.v_max;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case State::MAX: {
|
|
case State::MAX: {
|
|
@@ -330,14 +337,16 @@ public :
|
|
const artis::common::DoubleTime::type & /* e */,
|
|
const artis::common::DoubleTime::type & /* e */,
|
|
const artis::common::Bag<artis::common::DoubleTime> &bag) override
|
|
const artis::common::Bag<artis::common::DoubleTime> &bag) override
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - dext" << std::endl;
|
|
|
|
+
|
|
std::for_each(bag.begin(), bag.end(),
|
|
std::for_each(bag.begin(), bag.end(),
|
|
[this, t](const common::ExternalEvent<common::DoubleTime> &event) {
|
|
[this, t](const common::ExternalEvent<common::DoubleTime> &event) {
|
|
if (event.on_port(inputs::IN)) {
|
|
if (event.on_port(inputs::IN)) {
|
|
Vehicle vehicle;
|
|
Vehicle vehicle;
|
|
|
|
|
|
event.data()(vehicle);
|
|
event.data()(vehicle);
|
|
- vehicle.next_time =
|
|
|
|
- t + vehicle.v_max / vehicle.acceleration;
|
|
|
|
|
|
+ vehicle.next_time = t + vehicle.v_max / vehicle.acceleration;
|
|
vehicle.state = State::UP;
|
|
vehicle.state = State::UP;
|
|
_vehicles.push_back(vehicle);
|
|
_vehicles.push_back(vehicle);
|
|
}
|
|
}
|
|
@@ -345,8 +354,7 @@ public :
|
|
update_sigma(t);
|
|
update_sigma(t);
|
|
}
|
|
}
|
|
|
|
|
|
- artis::common::DoubleTime::type
|
|
|
|
- ta(const artis::common::DoubleTime::type & /* t */) const override
|
|
|
|
|
|
+ artis::common::DoubleTime::type ta(const artis::common::DoubleTime::type & /* t */) const override
|
|
{ return _sigma; }
|
|
{ return _sigma; }
|
|
|
|
|
|
artis::common::Bag<artis::common::DoubleTime>
|
|
artis::common::Bag<artis::common::DoubleTime>
|
|
@@ -354,6 +362,8 @@ public :
|
|
{
|
|
{
|
|
artis::common::Bag<artis::common::DoubleTime> bag;
|
|
artis::common::Bag<artis::common::DoubleTime> bag;
|
|
|
|
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - lambda" << std::endl;
|
|
|
|
+
|
|
for (auto vehicle: _vehicles) {
|
|
for (auto vehicle: _vehicles) {
|
|
if (vehicle.next_time == t and vehicle.state == State::STOP) {
|
|
if (vehicle.next_time == t and vehicle.state == State::STOP) {
|
|
bag.push_back(
|
|
bag.push_back(
|
|
@@ -364,12 +374,15 @@ public :
|
|
return bag;
|
|
return bag;
|
|
}
|
|
}
|
|
|
|
|
|
- void
|
|
|
|
- start(const artis::common::DoubleTime::type & /* t */) override
|
|
|
|
- {}
|
|
|
|
|
|
+ void start(const artis::common::DoubleTime::type & /* t */) override
|
|
|
|
+ {
|
|
|
|
|
|
- common::DoubleTime::type
|
|
|
|
- lookahead(const common::DoubleTime::type &t) const override
|
|
|
|
|
|
+// std::cout << get_full_name() << " at " << t << " - start" << std::endl;
|
|
|
|
+
|
|
|
|
+ _sigma = artis::common::DoubleTime::infinity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ common::DoubleTime::type lookahead(const common::DoubleTime::type &t) const override
|
|
{
|
|
{
|
|
double eot = artis::common::DoubleTime::infinity;
|
|
double eot = artis::common::DoubleTime::infinity;
|
|
|
|
|
|
@@ -384,8 +397,7 @@ public :
|
|
eot_i = vehicle.next_time + vehicle.v_max / vehicle.acceleration;
|
|
eot_i = vehicle.next_time + vehicle.v_max / vehicle.acceleration;
|
|
} else if (vehicle.state == State::UP) {
|
|
} else if (vehicle.state == State::UP) {
|
|
double duration = vehicle.v_max / vehicle.acceleration;
|
|
double duration = vehicle.v_max / vehicle.acceleration;
|
|
- double acceleration_distance =
|
|
|
|
- 0.5 * vehicle.acceleration * duration * duration;
|
|
|
|
|
|
+ double acceleration_distance = 0.5 * vehicle.acceleration * duration * duration;
|
|
|
|
|
|
eot_i = vehicle.next_time
|
|
eot_i = vehicle.next_time
|
|
+ (_length - 2 * acceleration_distance) / vehicle.v_max
|
|
+ (_length - 2 * acceleration_distance) / vehicle.v_max
|