id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,532,715
|
atomic_eq.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_eq.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_eq final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_eq(const key_t &k, const std::string &c_str)
: key(k), constant(std::stod(c_str)) {}
explicit atomic_eq(const kwargs &kw)
: atomic_eq(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = std::min(constant - new_data, new_data - constant);
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,562
|
C++
|
.h
| 42
| 33.880952
| 79
| 0.693891
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,716
|
atomic_number.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_number.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_number final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_number(const key_t &k, const std::string &c_str)
: key(k), constant(std::stod(c_str)) {}
explicit atomic_number(const kwargs &kw)
: atomic_number(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
if (new_data == constant) {
value = reelay::infinity<output_t>::value();
} else {
value = -reelay::infinity<output_t>::value();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,672
|
C++
|
.h
| 46
| 32.717391
| 79
| 0.684243
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,717
|
past_sometime_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_sometime_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_sometime_bounded final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
time_t ubound;
past_sometime_bounded(const std::vector<node_ptr_t> &args, time_t l=0, time_t u=0)
: first(args[0]), lbound(l), ubound(u) {
value.add(
std::make_pair(interval::closed(
-reelay::infinity<time_t>::value(),lbound),
-reelay::infinity<output_t>::value()));
}
explicit past_sometime_bounded(const kwargs &kw)
: past_sometime_bounded(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, time_t now) {
value.add(std::make_pair(
reelay::interval<time_t>::closed(now + lbound, now + ubound),
first->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 2,028
|
C++
|
.h
| 51
| 35.529412
| 84
| 0.676531
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,718
|
negation.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/negation.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct negation final : public discrete_timed_node<V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
node_ptr_t arg1;
explicit negation(const std::vector<node_ptr_t> &args) : arg1(args[0]) {}
explicit negation(const kwargs &kw)
: negation(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) { return -arg1->output(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,183
|
C++
|
.h
| 31
| 35.709677
| 77
| 0.716039
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,719
|
since_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/since_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct since_bounded_half final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
output_t value0 = -reelay::infinity<output_t>::value();
interval_map value1 = interval_map();
interval_map value2 = interval_map();
node_ptr_t first;
node_ptr_t second;
time_t lbound;
since_bounded_half(const std::vector<node_ptr_t> &args, time_t l=0)
: first(args[0]), second(args[1]), lbound(l) {
value1.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
-reelay::infinity<output_t>::value()));
value2.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
-reelay::infinity<output_t>::value()));
}
explicit since_bounded_half(const kwargs &kw)
: since_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
// This procedure is adapted from the rewriting technique
// introduced in "Efficient Robust Monitoring for STL"
// by Alexandre Donze, Thomas Ferrere, and Oded Maler.
value0 =
std::max(second->output(now), std::min(value0, first->output(now)));
value1.add(std::make_pair(
reelay::interval<time_t>::closed(now, now + lbound), -value0));
value2.add(
std::make_pair(reelay::interval<time_t>::closed(
now + lbound, reelay::infinity<time_t>::value()),
second->output(now)));
// Clean-up the past
value1 = value1 - interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now),
-reelay::infinity<output_t>::value()));
value2 = value2 - interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now),
-reelay::infinity<output_t>::value()));
}
output_t output(time_t now) { return std::min(-value1(now), value2(now)); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 2,992
|
C++
|
.h
| 68
| 37.720588
| 77
| 0.645884
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,720
|
atomic_lt.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_lt.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_lt final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_lt(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_lt(const kwargs &kw)
: atomic_lt(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = constant - new_data;
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,523
|
C++
|
.h
| 42
| 32.952381
| 79
| 0.693933
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,721
|
since_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/since_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct since_bounded final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
output_t value0 = -reelay::infinity<output_t>::value();
interval_map value1 = interval_map();
interval_map value2 = interval_map();
node_ptr_t first;
node_ptr_t second;
time_t lbound;
time_t ubound;
since_bounded(const std::vector<node_ptr_t> &args, time_t l=0, time_t u=0)
: first(args[0]), second(args[1]), lbound(l), ubound(u) {
value1.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
-reelay::infinity<output_t>::value()));
value2.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
-reelay::infinity<output_t>::value()));
}
explicit since_bounded(const kwargs &kw)
: since_bounded(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t&, time_t now) {
// This procedure is adapted from the rewriting technique
// introduced in "Efficient Robust Monitoring for STL"
// by Alexandre Donze, Thomas Ferrere, and Oded Maler.
value0 = std::max(second->output(now),std::min(value0, first->output(now)));
value1.add(std::make_pair(
reelay::interval<time_t>::closed(now, now + lbound), -value0));
value2.add(std::make_pair(
reelay::interval<time_t>::closed(now + lbound, now + ubound),
second->output(now)));
// Clean-up the past
value1 = value1 - interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now),
-reelay::infinity<output_t>::value()));
value2 = value2 - interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now),
-reelay::infinity<output_t>::value()));
}
output_t output(time_t now) { return std::min(-value1(now), value2(now)); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 3,020
|
C++
|
.h
| 67
| 38.835821
| 80
| 0.652338
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,722
|
past_sometime_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_sometime_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_sometime_bounded_half final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
past_sometime_bounded_half(const std::vector<node_ptr_t> &args, time_t l=0)
: first(args[0]), lbound(l) {
value.add(
std::make_pair(interval::closed(-reelay::infinity<time_t>::value(),
lbound),
-reelay::infinity<output_t>::value()));
}
explicit past_sometime_bounded_half(const kwargs &kw)
: past_sometime_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
value.add(
std::make_pair(reelay::interval<time_t>::closed(
now + lbound, reelay::infinity<time_t>::value()),
first->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 2,058
|
C++
|
.h
| 50
| 35.48
| 80
| 0.65429
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,723
|
since.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/since.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct since final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
node_ptr_t first;
node_ptr_t second;
output_t value = -reelay::infinity<output_t>::value();
explicit since(const std::vector<node_ptr_t> &args)
: first(args[0]), second(args[1]) {}
explicit since(const kwargs &kw)
: since(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) override {
value = std::max(second->output(now), std::min(value, first->output(now)));
}
output_t output(time_t) override { return value; }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,407
|
C++
|
.h
| 36
| 36.277778
| 79
| 0.703976
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,724
|
past_always_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_always_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_always_bounded_half final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
past_always_bounded_half(const std::vector<node_ptr_t> &args, time_t l=0)
: first(args[0]), lbound(l) {
value.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
-reelay::infinity<output_t>::value()));
}
explicit past_always_bounded_half(const kwargs &kw)
: past_always_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
value.add(
std::make_pair(reelay::interval<time_t>::closed(
now + lbound, reelay::infinity<time_t>::value()),
-first->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return -value(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,997
|
C++
|
.h
| 49
| 36.081633
| 78
| 0.670807
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,725
|
setting.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/setting.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "string"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
//
#include "reelay/settings/discrete_timed_robustness/atomic_any.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_eq.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_false.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_ge.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_gt.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_le.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_lt.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_ne.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_number.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_prop.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_string.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_true.hpp"
#include "reelay/settings/discrete_timed_robustness/atomic_map.hpp"
#include "reelay/settings/discrete_timed_robustness/conjunction.hpp"
#include "reelay/settings/discrete_timed_robustness/disjunction.hpp"
#include "reelay/settings/discrete_timed_robustness/implication.hpp"
#include "reelay/settings/discrete_timed_robustness/negation.hpp"
#include "reelay/settings/discrete_timed_robustness/past_always.hpp"
#include "reelay/settings/discrete_timed_robustness/past_sometime.hpp"
#include "reelay/settings/discrete_timed_robustness/previous.hpp"
#include "reelay/settings/discrete_timed_robustness/since.hpp"
#include "reelay/settings/discrete_timed_robustness/past_always_bounded.hpp"
#include "reelay/settings/discrete_timed_robustness/past_sometime_bounded.hpp"
#include "reelay/settings/discrete_timed_robustness/since_bounded.hpp"
#include "reelay/settings/discrete_timed_robustness/past_always_bounded_half.hpp"
#include "reelay/settings/discrete_timed_robustness/past_sometime_bounded_half.hpp"
#include "reelay/settings/discrete_timed_robustness/since_bounded_half.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename Y, typename T>
struct factory {
using input_t = X;
using time_t = T;
using value_t = Y;
using output_t = Y;
using function_t = std::function<output_t(const input_t&)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
using node_t = reelay::discrete_timed_node<output_t, time_t>;
using state_t = reelay::discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
constexpr static output_t top = std::numeric_limits<output_t>::max();
constexpr static output_t bottom = -std::numeric_limits<output_t>::max();
static node_ptr_t make_node(const std::string &name, const kwargs &kw) {
node_ptr_t result;
if (name == "disjunction") {
result = std::make_shared<disjunction<input_t, output_t, time_t>>(kw);
} else if (name == "conjunction") {
result = std::make_shared<conjunction<input_t, output_t, time_t>>(kw);
} else if (name == "negation") {
result = std::make_shared<negation<input_t, output_t, time_t>>(kw);
} else if (name == "implication") {
result = std::make_shared<implication<input_t, output_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the discrete timed robustness setting");
}
return result;
}
static state_ptr_t make_state(const std::string &name, const kwargs &kw) {
state_ptr_t result;
if (name == "atomic_map") {
result = std::make_shared<atomic_map<input_t, output_t, time_t>>(kw);
} else if(name == "mapping_prop") {
result = std::make_shared<atomic_prop<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_false") {
result = std::make_shared<atomic_false<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_true") {
result = std::make_shared<atomic_true<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_string") {
result = std::make_shared<atomic_string<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_number") {
result = std::make_shared<atomic_number<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_eq") {
result = std::make_shared<atomic_eq<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_ne") {
result = std::make_shared<atomic_ne<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_ge") {
result = std::make_shared<atomic_ge<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_gt") {
result = std::make_shared<atomic_gt<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_le") {
result = std::make_shared<atomic_le<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_lt") {
result = std::make_shared<atomic_lt<input_t, output_t, time_t>>(kw);
} else if (name == "mapping_any") {
result = std::make_shared<atomic_any<input_t, output_t, time_t>>(kw);
} else if (name == "previous") {
result = std::make_shared<previous<input_t, output_t, time_t>>(kw);
} else if (name == "past_sometime") {
result = std::make_shared<past_sometime<input_t, output_t, time_t>>(kw);
} else if (name == "past_always") {
result = std::make_shared<past_always<input_t, output_t, time_t>>(kw);
} else if (name == "since") {
result = std::make_shared<since<input_t, output_t, time_t>>(kw);
} else if (name == "past_sometime_bounded") {
result =
std::make_shared<past_sometime_bounded<input_t, output_t, time_t>>(
kw);
} else if (name == "past_always_bounded") {
result =
std::make_shared<past_always_bounded<input_t, output_t, time_t>>(kw);
} else if (name == "since_bounded") {
result = std::make_shared<since_bounded<input_t, output_t, time_t>>(kw);
} else if (name == "past_sometime_bounded_half") {
result = std::make_shared<
past_sometime_bounded_half<input_t, output_t, time_t>>(kw);
} else if (name == "past_always_bounded_half") {
result =
std::make_shared<past_always_bounded_half<input_t, output_t, time_t>>(
kw);
} else if (name == "since_bounded_half") {
result =
std::make_shared<since_bounded_half<input_t, output_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the discrete timed robustness setting");
}
return result;
}
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 7,043
|
C++
|
.h
| 139
| 46.244604
| 83
| 0.691704
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,726
|
past_always.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_always.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_always final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
output_t value = std::numeric_limits<output_t>::max();
node_ptr_t first;
explicit past_always(const std::vector<node_ptr_t> &args) : first(args[0]) {}
explicit past_always(const kwargs &kw)
: past_always(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) {
value = std::min(value, first->output(now));
}
output_t output(time_t) { return value; }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,304
|
C++
|
.h
| 33
| 36.818182
| 80
| 0.706116
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,727
|
past_always_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_always_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_always_bounded final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::robustness_interval_map<time_t, output_t>;
interval_map value = interval_map(); // true
node_ptr_t first;
time_t lbound;
time_t ubound;
past_always_bounded(const std::vector<node_ptr_t> &args, time_t l=0, time_t u=0)
: first(args[0]), lbound(l), ubound(u) {
value.add(
std::make_pair(interval::closed(-reelay::infinity<time_t>::value(),
lbound),
-reelay::infinity<output_t>::value()));
}
explicit past_always_bounded(const kwargs &kw)
: past_always_bounded(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, time_t now) {
value.add(std::make_pair(
reelay::interval<time_t>::closed(now + lbound, now + ubound),
-first->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return -value(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 2,071
|
C++
|
.h
| 51
| 35.568627
| 82
| 0.659352
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,728
|
atomic_true.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_true.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_true final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_true(const key_t &key) : key(key) {}
explicit atomic_true(const kwargs &kw)
: atomic_true(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
if (new_data) {
value = reelay::infinity<output_t>::value();
} else {
value = -reelay::infinity<output_t>::value();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,498
|
C++
|
.h
| 43
| 31.744186
| 79
| 0.693963
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,729
|
atomic_map.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_map.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "string"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct atomic_map final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
output_t value = -reelay::infinity<output_t>::value();
std::vector<node_ptr_t> mappings;
explicit atomic_map(const std::vector<node_ptr_t> &nodeptrs)
: mappings(nodeptrs) {}
explicit atomic_map(const kwargs &kw)
: atomic_map(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &args, time_t now) override {
value = mappings[0]->output(now);
for (std::size_t i = 1; i < mappings.size(); i++) {
value = std::min(value, mappings[i]->output(now));
}
}
output_t output(time_t) override { return value; }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,478
|
C++
|
.h
| 38
| 35.868421
| 79
| 0.696566
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,730
|
atomic_gt.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_gt.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_gt final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_gt(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_gt(const kwargs &kw)
: atomic_gt(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = new_data - constant;
}
output_t output(time_t) override { return value; }
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,527
|
C++
|
.h
| 42
| 33.047619
| 79
| 0.694086
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,731
|
previous.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/previous.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct previous final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
output_t prev_value = -std::numeric_limits<output_t>::max();
output_t value = -std::numeric_limits<output_t>::max();
node_ptr_t first;
explicit previous(const std::vector<node_ptr_t> &args) : first(args[0]) {}
explicit previous(const kwargs &kw)
: previous(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) override {
prev_value = value;
value = first->output(now);
}
output_t output(time_t) override { return prev_value; }
};
} // namespace discrete_timed_setting
} // namespace reelay
| 1,412
|
C++
|
.h
| 37
| 35.432432
| 77
| 0.706833
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,732
|
past_sometime.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/past_sometime.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct past_sometime final : public discrete_timed_state<X, V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
output_t value = -std::numeric_limits<output_t>::max();
node_ptr_t first;
explicit past_sometime(const std::vector<node_ptr_t> &args)
: first(args[0]) {}
explicit past_sometime(const kwargs &kw)
: past_sometime(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) {
value = std::max(value, first->output(now));
}
output_t output(time_t) { return value; }
};
} // namespace discrete_timed_setting
} // namespace reelay
| 1,308
|
C++
|
.h
| 34
| 35.647059
| 82
| 0.702853
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,733
|
disjunction.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/disjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct disjunction final : public discrete_timed_node<V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
std::vector<node_ptr_t> args;
explicit disjunction(const std::vector<node_ptr_t> &nodeptrs)
: args(nodeptrs) {}
explicit disjunction(const kwargs &kw)
: disjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) {
output_t result = args[0]->output(now);
for (size_t i = 1; i < args.size(); i++) {
result = std::max(result, args[i]->output(now));
}
return result;
}
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,365
|
C++
|
.h
| 38
| 32.947368
| 80
| 0.696809
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,734
|
atomic_le.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_le.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_le final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_le(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_le(const kwargs &kw)
: atomic_le(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = constant - new_data;
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,527
|
C++
|
.h
| 42
| 32.952381
| 79
| 0.693933
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,735
|
conjunction.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/conjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct conjunction final : public discrete_timed_node<V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
std::vector<node_ptr_t> args;
explicit conjunction(const std::vector<node_ptr_t> &nodeptrs)
: args(nodeptrs) {}
explicit conjunction(const kwargs &kw)
: conjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) {
output_t result = args[0]->output(now);
for (size_t i = 1; i < args.size(); i++) {
result = std::min(result, args[i]->output(now));
}
return result;
}
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,365
|
C++
|
.h
| 38
| 32.947368
| 80
| 0.696809
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,736
|
atomic_any.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_any.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_any final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_any(const key_t &key) : key(key) {}
explicit atomic_any(const kwargs &kw)
: atomic_any(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &args, time_t) override {
bool key_exists = datafield<input_t>::contains(args, key);
if (key_exists) {
value = reelay::infinity<output_t>::value();
} else {
value = -reelay::infinity<output_t>::value();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,356
|
C++
|
.h
| 40
| 31.05
| 71
| 0.69862
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,737
|
atomic_ge.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_ge.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_ge final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_ge(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_ge(const kwargs &kw)
: atomic_ge(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = new_data - constant;
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,523
|
C++
|
.h
| 42
| 32.952381
| 79
| 0.693933
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,738
|
implication.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/implication.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T>
struct implication final : public discrete_timed_node<V, T> {
using time_t = T;
using input_t = X;
using output_t = V;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
node_ptr_t arg1;
node_ptr_t arg2;
explicit implication(const std::vector<node_ptr_t> &args)
: arg1(args[0]), arg2(args[1]) {}
explicit implication(const kwargs &kw)
: implication(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) {
return std::max(-arg1->output(now), arg2->output(now));
}
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,270
|
C++
|
.h
| 35
| 33.6
| 80
| 0.709967
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,739
|
atomic_false.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_false.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_false final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_false(const key_t &key) : key(key) {}
explicit atomic_false(const kwargs &kw)
: atomic_false(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
if (not new_data) {
value = reelay::infinity<output_t>::value();
} else {
value = -reelay::infinity<output_t>::value();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,508
|
C++
|
.h
| 43
| 31.930233
| 79
| 0.694004
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,740
|
atomic_prop.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_prop.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_prop final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_prop(const key_t &key) : key(key) {}
explicit atomic_prop(const kwargs &kw)
: atomic_prop(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = new_data;
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,384
|
C++
|
.h
| 39
| 32.692308
| 79
| 0.70849
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,741
|
atomic_ne.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_ne.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_ne final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
double constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_ne(const key_t &k, const std::string &c_str)
: key(k), constant(std::stod(c_str)) {}
explicit atomic_ne(const kwargs &kw)
: atomic_ne(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = std::max(constant - new_data, new_data - constant);
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,562
|
C++
|
.h
| 42
| 33.880952
| 79
| 0.693891
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,742
|
atomic_string.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_robustness/atomic_string.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace discrete_timed_robustness_setting {
template <typename X, typename V, typename T, typename K = std::string>
struct atomic_string final : public discrete_timed_state<X, V, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using output_t = V;
key_t key;
std::string constant;
output_t value = -reelay::infinity<output_t>::value();
explicit atomic_string(const key_t &k, const std::string &c)
: key(k), constant(c) {}
explicit atomic_string(const kwargs &kw)
: atomic_string(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
std::string new_data = datafield<input_t>::as_string(args, key);
if (new_data == constant) {
value = reelay::infinity<output_t>::value();
} else {
value = -reelay::infinity<output_t>::value();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,661
|
C++
|
.h
| 46
| 32.478261
| 79
| 0.683323
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,743
|
atomic_number.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_number.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_number final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
double constant;
explicit atomic_number(const data_mgr_t &mgr, const key_t &k,
const std::string &c_str)
: manager(mgr), key(k), constant(std::stod(c_str)) {}
explicit atomic_number(const kwargs &kw)
: atomic_number(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data == constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,623
|
C++
|
.h
| 66
| 34.060606
| 79
| 0.652243
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,744
|
past_sometime_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_sometime_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_sometime_bounded final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
time_t lbound = 0;
time_t ubound = 0;
interval_map value = interval_map();
past_sometime_bounded(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l), ubound(u) {
value = interval_map(
std::make_pair(interval::left_open(-infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit past_sometime_bounded(const kwargs &kw)
: past_sometime_bounded(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(interval::left_open(intv.first.lower() + lbound,
intv.first.upper() + ubound),
intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,560
|
C++
|
.h
| 63
| 34.380952
| 80
| 0.636034
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,745
|
atomic_ref.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_ref.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_ref final : public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
std::string variable;
explicit atomic_ref(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), variable(c) {
manager->add_variable(variable);
}
explicit atomic_ref(const kwargs &kw)
: atomic_ref(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
std::string new_data = datafield<input_t>::as_string(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
value.add(
std::make_pair(interval::left_open(now, infinity<time_t>::value()),
manager->assign(variable, new_data)));
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace untimed_setting
} // namespace reelay
| 2,465
|
C++
|
.h
| 61
| 34.885246
| 80
| 0.660609
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,746
|
negation.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/negation.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct negation final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
node_ptr_t arg1;
explicit negation(const std::vector<node_ptr_t> &args) : arg1(args[0]) {}
explicit negation(const kwargs &kw)
: negation(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
auto result = interval_map();
for (const auto &intv : arg1->output(previous, now)) {
result.add(std::make_pair(intv.first, ~intv.second));
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 1,567
|
C++
|
.h
| 42
| 34.5
| 77
| 0.707865
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,747
|
since_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/since_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct since_bounded_half final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
time_t lbound;
interval_map value = interval_map();
since_bounded_half(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args,
time_t l = 0)
: manager(mgr), first(args[0]), second(args[1]), lbound(l) {
value.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit since_bounded_half(const kwargs &kw)
: since_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(value_t p1, value_t p2, time_t previous, time_t now) {
// Flush the future
value -= interval_map(std::make_pair(
interval::left_open(previous, infinity<time_t>::value()), p1));
// Resolve the present
value.add(std::make_pair(
interval::left_open(previous + lbound, now + lbound), p1 * p2));
value.add(std::make_pair(
interval::left_open(now + lbound, infinity<time_t>::value()), p2));
}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
/*
* The following code performs the sychronization between two arbitrary
* chunks and calls the update function for each constant period
* from past to future. The synchronization algorithm is a variant of
* plane sweep algorithms from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
auto active1 = first->output(previous, now);
auto active2 = second->output(previous, now);
auto it1 = active1.begin();
auto it2 = active2.begin();
while (it1 != active1.end() and it2 != active2.end()) {
if (it1->first.upper() < it2->first.upper()) {
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
} else if (it2->first.upper() < it1->first.upper()) {
update(it1->second, it2->second, time, it2->first.upper());
time = it2->first.upper();
it2++;
} else { // it1->first.upper() == it2->first.upper()
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
it2++;
}
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 3,784
|
C++
|
.h
| 94
| 34.957447
| 80
| 0.64929
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,748
|
forall.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/forall.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct forall final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
node_ptr_t arg1;
data_set_t cube;
explicit forall(const data_mgr_t &mgr, const std::vector<std::string> &vars,
const std::vector<node_ptr_t> &args)
: arg1(args[0]) {
cube = mgr->one();
for (const auto &name : vars) {
cube *= mgr->variables[name].cube;
}
}
explicit forall(const kwargs &kw)
: forall(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<std::string>>(kw.at("vars")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) override {
auto result = interval_map();
for (const auto &intv : arg1->output(previous, now)) {
result.add(std::make_pair(intv.first, intv.second.UnivAbstract(cube)));
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 1,936
|
C++
|
.h
| 52
| 33.307692
| 78
| 0.676816
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,749
|
since_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/since_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct since_bounded final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
using interval_map_segment = typename interval_map::segment_type;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
time_t lbound;
time_t ubound;
interval_map value = interval_map();
since_bounded(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args,
time_t l = 0, time_t u = 0)
: manager(mgr), first(args[0]), second(args[1]), lbound(l), ubound(u) {
value.add(std::make_pair(
interval::left_open(-reelay::infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit since_bounded(const kwargs &kw)
: since_bounded(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(value_t p1, value_t p2, time_t previous, time_t now) {
// Flush the future
value -= interval_map(std::make_pair(
interval::left_open(previous, infinity<time_t>::value()), p1));
// Resolve the present
value.add(std::make_pair(
interval::left_open(previous + lbound, now + lbound), p1 * p2));
value.add(
std::make_pair(interval::left_open(now + lbound, now + ubound), p2));
}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
/*
* The following code performs the sychronization between two arbitrary
* chunks and calls the update function for each constant period
* from past to future. The synchronization algorithm is a variant of
* plane sweep algorithms from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
auto active1 = first->output(previous, now);
auto active2 = second->output(previous, now);
auto it1 = active1.begin();
auto it2 = active2.begin();
while (it1 != active1.end() and it2 != active2.end()) {
if (it1->first.upper() < it2->first.upper()) {
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
} else if (it2->first.upper() < it1->first.upper()) {
update(it1->second, it2->second, time, it2->first.upper());
time = it2->first.upper();
it2++;
} else { // it1->first.upper() == it2->first.upper()
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
it2++;
}
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 3,931
|
C++
|
.h
| 96
| 35.4375
| 79
| 0.646364
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,750
|
past_sometime_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_sometime_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_sometime_bounded_half final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
time_t lbound;
interval_map value = interval_map();
past_sometime_bounded_half(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0)
: manager(mgr), first(args[0]), lbound(l) {
value = interval_map(
std::make_pair(interval::left_open(-infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit past_sometime_bounded_half(const kwargs &kw)
: past_sometime_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(interval::left_open(intv.first.lower() + lbound,
infinity<time_t>::value()),
intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,454
|
C++
|
.h
| 60
| 34.933333
| 79
| 0.646341
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,751
|
since.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/since.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct since final : public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
using interval_map_segment = typename interval_map::segment_type;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
interval_map value = interval_map();
interval_map_segment last_pair;
explicit since(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args)
: manager(mgr), first(args[0]), second(args[1]) {
last_pair = std::make_pair(
interval::left_open(-infinity<time_t>::value(), 0), manager->zero());
}
explicit since(const kwargs &kw)
: since(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(value_t p1, value_t p2, time_t previous, time_t now) {
last_pair = std::make_pair(interval::left_open(previous, now),
p2 + (last_pair.second * p1));
value.add(last_pair);
value -= interval::closed(-infinity<time_t>::value(), previous);
}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
/*
* The following code performs the sychronization between two arbitrary
* chunks and calls the update function for each constant period
* from past to future. The synchronization algorithm is a variant of
* plane sweep algorithms from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
auto active1 = first->output(previous, now);
auto active2 = second->output(previous, now);
auto it1 = active1.begin();
auto it2 = active2.begin();
while (it1 != active1.end() and it2 != active2.end()) {
if (it1->first.upper() < it2->first.upper()) {
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
} else if (it2->first.upper() < it1->first.upper()) {
update(it1->second, it2->second, time, it2->first.upper());
time = it2->first.upper();
it2++;
} else { // it1->first.upper() == it2->first.upper()
update(it1->second, it2->second, time, it1->first.upper());
time = it1->first.upper();
it1++;
it2++;
}
}
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 3,488
|
C++
|
.h
| 87
| 34.816092
| 77
| 0.652161
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,752
|
atomic_lt_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_lt_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_lt_0 final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
double constant;
explicit atomic_lt_0(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), constant(std::stod(c)) {}
explicit atomic_lt_0(const kwargs &kw)
: atomic_lt_0(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data < constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,600
|
C++
|
.h
| 66
| 33.80303
| 79
| 0.651042
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,753
|
past_always_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_always_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_always_bounded_half final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
time_t lbound;
interval_map value;
past_always_bounded_half(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0)
: manager(mgr), first(args[0]), lbound(l) {
value = interval_map(std::make_pair(
interval::left_open(-infinity<time_t>::value(), lbound), mgr->zero()));
}
explicit past_always_bounded_half(const kwargs &kw)
: past_always_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(interval::left_open(intv.first.lower() + lbound,
infinity<time_t>::value()),
~intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
auto negated_value = interval_map();
for (const auto &intv : this->value) {
negated_value.add(std::make_pair(intv.first, ~intv.second));
}
return negated_value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,566
|
C++
|
.h
| 63
| 35.111111
| 79
| 0.650583
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,754
|
setting.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/setting.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "string"
#include "reelay/networks/basic_structure.hpp"
//
#include "reelay/settings/dense_timed_data/atomic_any.hpp"
#include "reelay/settings/dense_timed_data/atomic_false.hpp"
#include "reelay/settings/dense_timed_data/atomic_ge_0.hpp"
#include "reelay/settings/dense_timed_data/atomic_gt_0.hpp"
#include "reelay/settings/dense_timed_data/atomic_le_0.hpp"
#include "reelay/settings/dense_timed_data/atomic_lt_0.hpp"
// #include "reelay/settings/dense_timed_data/atomic_ne.hpp"
// #include "reelay/settings/dense_timed_data/atomic_eq.hpp"
#include "reelay/settings/dense_timed_data/atomic_number.hpp"
#include "reelay/settings/dense_timed_data/atomic_prop.hpp"
#include "reelay/settings/dense_timed_data/atomic_ref.hpp"
#include "reelay/settings/dense_timed_data/atomic_string.hpp"
#include "reelay/settings/dense_timed_data/atomic_true.hpp"
#include "reelay/settings/dense_timed_data/atomic_map.hpp"
#include "reelay/settings/dense_timed_data/exists.hpp"
#include "reelay/settings/dense_timed_data/forall.hpp"
#include "reelay/settings/dense_timed_data/conjunction.hpp"
#include "reelay/settings/dense_timed_data/disjunction.hpp"
#include "reelay/settings/dense_timed_data/implication.hpp"
#include "reelay/settings/dense_timed_data/negation.hpp"
#include "reelay/settings/dense_timed_data/past_always.hpp"
#include "reelay/settings/dense_timed_data/past_sometime.hpp"
#include "reelay/settings/dense_timed_data/since.hpp"
#include "reelay/settings/dense_timed_data/past_always_bounded.hpp"
#include "reelay/settings/dense_timed_data/past_sometime_bounded.hpp"
#include "reelay/settings/dense_timed_data/since_bounded.hpp"
#include "reelay/settings/dense_timed_data/past_always_bounded_half.hpp"
#include "reelay/settings/dense_timed_data/past_sometime_bounded_half.hpp"
#include "reelay/settings/dense_timed_data/since_bounded_half.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, int order=0> struct factory {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
static node_ptr_t make_node(const std::string &name, const kwargs &kw) {
node_ptr_t result;
if (name == "disjunction") {
result = std::make_shared<disjunction<input_t, time_t>>(kw);
} else if (name == "conjunction") {
result = std::make_shared<conjunction<input_t, time_t>>(kw);
} else if (name == "negation") {
result = std::make_shared<negation<input_t, time_t>>(kw);
} else if (name == "implication") {
result = std::make_shared<implication<input_t, time_t>>(kw);
} else if (name == "exists") {
result = std::make_shared<exists<input_t, time_t>>(kw);
} else if (name == "forall") {
result = std::make_shared<forall<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the dense timed data setting");
}
return result;
}
static state_ptr_t make_state(const std::string &name, kwargs &kw) {
state_ptr_t res;
if (name == "atomic_map") {
res = std::make_shared<atomic_map<input_t, time_t>>(kw);
} else if (name == "mapping_prop") {
res = std::make_shared<atomic_prop<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_false") {
res = std::make_shared<atomic_false<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_true") {
res = std::make_shared<atomic_true<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_string") {
res = std::make_shared<atomic_string<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_number") {
res = std::make_shared<atomic_number<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_eq") {
res = std::make_shared<atomic_number<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_ge" and order == 0) {
res = std::make_shared<atomic_ge_0<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_gt" and order == 0) {
res = std::make_shared<atomic_gt_0<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_le" and order == 0) {
res = std::make_shared<atomic_le_0<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_lt" and order == 0) {
res = std::make_shared<atomic_lt_0<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_any") {
res = std::make_shared<atomic_any<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_ref") {
res = std::make_shared<atomic_ref<input_t, time_t, std::string>>(kw);
} else if (name == "listing_false") {
res = std::make_shared<atomic_false<input_t, time_t, int>>(kw);
} else if (name == "listing_true") {
res = std::make_shared<atomic_true<input_t, time_t, int>>(kw);
} else if (name == "listing_string") {
res = std::make_shared<atomic_string<input_t, time_t, int>>(kw);
} else if (name == "listing_number") {
res = std::make_shared<atomic_number<input_t, time_t, int>>(kw);
} else if (name == "listing_eq") {
res = std::make_shared<atomic_number<input_t, time_t, int>>(kw);
} else if (name == "listing_ge" and order == 0) {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_ge_0<input_t, time_t, int>>(kw);
} else if (name == "listing_gt" and order == 0) {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_gt_0<input_t, time_t, int>>(kw);
} else if (name == "listing_le" and order == 0) {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_le_0<input_t, time_t, int>>(kw);
} else if (name == "listing_lt" and order == 0) {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_lt_0<input_t, time_t, int>>(kw);
} else if (name == "listing_any") {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_any<input_t, time_t, int>>(kw);
} else if (name == "listing_ref") {
kw["key"] = reelay::any_cast<int>(kw.at("key")) + 1;
res = std::make_shared<atomic_ref<input_t, time_t, int>>(kw);
} else if (name == "past_sometime") {
res = std::make_shared<past_sometime<input_t, time_t>>(kw);
} else if (name == "past_always") {
res = std::make_shared<past_always<input_t, time_t>>(kw);
} else if (name == "since") {
res = std::make_shared<since<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded") {
res = std::make_shared<past_sometime_bounded<input_t, time_t>>(kw);
} else if (name == "past_always_bounded") {
res = std::make_shared<past_always_bounded<input_t, time_t>>(kw);
} else if (name == "since_bounded") {
res = std::make_shared<since_bounded<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded_half") {
res = std::make_shared<past_sometime_bounded_half<input_t, time_t>>(kw);
} else if (name == "past_always_bounded_half") {
res = std::make_shared<past_always_bounded_half<input_t, time_t>>(kw);
} else if (name == "since_bounded_half") {
res = std::make_shared<since_bounded_half<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the dense timed data setting");
}
return res;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 8,218
|
C++
|
.h
| 160
| 46.8875
| 80
| 0.655215
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,755
|
past_always.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_always.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_always final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
interval_map value = interval_map();
explicit past_always(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args)
: manager(mgr), first(args[0]) {}
explicit past_always(const kwargs &kw)
: past_always(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(
interval::left_open(intv.first.lower(), infinity<time_t>::value()),
~intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
auto negated_value = interval_map();
for (const auto &intv : this->value) {
negated_value.add(std::make_pair(intv.first, ~intv.second));
}
return negated_value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,239
|
C++
|
.h
| 57
| 34.912281
| 80
| 0.673743
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,756
|
past_always_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_always_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_always_bounded final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
time_t lbound;
time_t ubound;
interval_map value;
past_always_bounded(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l), ubound(u) {
value = interval_map(std::make_pair(
interval::left_open(-infinity<time_t>::value(), lbound), mgr->zero()));
}
explicit past_always_bounded(const kwargs &kw)
: past_always_bounded(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(interval::left_open(intv.first.lower() + lbound,
intv.first.upper() + ubound),
~intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
auto negated_value = interval_map();
for (const auto &intv : this->value) {
negated_value.add(std::make_pair(intv.first, ~intv.second));
}
return negated_value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,662
|
C++
|
.h
| 66
| 34.454545
| 80
| 0.642248
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,757
|
atomic_true.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_true.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_true final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
explicit atomic_true(const data_mgr_t &mgr, const key_t &key)
: manager(mgr), key(key) {}
explicit atomic_true(const kwargs &kw)
: atomic_true(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t& pargs,
const input_t& args,
time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,437
|
C++
|
.h
| 65
| 32.430769
| 79
| 0.65365
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,758
|
atomic_map.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_map.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct atomic_map final : public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
data_mgr_t manager;
interval_map value;
std::vector<node_ptr_t> mappings;
explicit atomic_map(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &nodeptrs)
: manager(mgr), mappings(nodeptrs) {}
explicit atomic_map(const kwargs &kw)
: atomic_map(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
value = mappings[0]->output(previous, now);
for (size_t i = 1; i < mappings.size(); i++) {
value = value - mappings[i]->output(previous, now);
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,049
|
C++
|
.h
| 53
| 34.660377
| 80
| 0.680464
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,759
|
past_sometime.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/past_sometime.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct past_sometime final
: public dense_timed_state<X, data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
interval_map value = interval_map();
explicit past_sometime(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args)
: manager(mgr), first(args[0]) {}
explicit past_sometime(const kwargs &kw)
: past_sometime(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
for (const auto &intv : first->output(previous, now)) {
value.add(std::make_pair(
interval::left_open(intv.first.lower(), infinity<time_t>::value()),
intv.second));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value - interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,088
|
C++
|
.h
| 54
| 34.333333
| 77
| 0.675582
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,760
|
disjunction.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/disjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct disjunction final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
std::vector<node_ptr_t> args;
explicit disjunction(const std::vector<node_ptr_t> &args) : args(args) {}
explicit disjunction(const kwargs &kw)
: disjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) override {
auto result = args[0]->output(previous, now);
for (size_t i = 1; i < args.size(); i++) {
// Problem: Boost ICL interval_map calls identity element
// when operator+ used. We cannot define a static identity element
// for BDDs as BDD true/false depends on managers constructed at runtime.
//
// Ideal: result += args[i]->output(previous, now);
//
// Workaround: Adding does not call the identity but apply the operation.
for (const auto &intv : args[i]->output(previous, now)) {
result.add(intv);
}
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 2,014
|
C++
|
.h
| 51
| 35.882353
| 80
| 0.693333
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,761
|
exists.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/exists.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct exists final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
node_ptr_t arg1;
data_set_t cube;
exists(const data_mgr_t &mgr, const std::vector<std::string> &vars,
const std::vector<node_ptr_t> &args)
: arg1(args[0]) {
cube = mgr->one();
for (const auto &name : vars) {
cube *= mgr->variables[name].cube;
}
}
exists(const kwargs &kw)
: exists(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<std::string>>(kw.at("vars")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) override {
auto result = interval_map();
for (const auto &intv : arg1->output(previous, now)) {
result.add(std::make_pair(intv.first, intv.second.ExistAbstract(cube)));
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 1,910
|
C++
|
.h
| 52
| 32.980769
| 78
| 0.678223
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,762
|
conjunction.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/conjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct conjunction final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
std::vector<node_ptr_t> args;
explicit conjunction(const std::vector<node_ptr_t> &args) : args(args) {}
explicit conjunction(const kwargs &kw)
: conjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) override {
auto result = args[0]->output(previous, now);
for (size_t i = 1; i < args.size(); i++) {
result -= args[i]->output(previous, now);
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 1,590
|
C++
|
.h
| 42
| 35.047619
| 80
| 0.704427
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,763
|
atomic_any.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_any.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_any final : public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->one()));
key_t key;
explicit atomic_any(const data_mgr_t &mgr, const key_t &key)
: manager(mgr), key(key) {}
explicit atomic_any(const kwargs &kw)
: atomic_any(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t& pargs,
const input_t& args,
time_t previous,
time_t now) override {
bool key_exists = datafield<input_t>::contains(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (key_exists) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_robustness_0_setting
} // namespace reelay
| 2,303
|
C++
|
.h
| 61
| 32.737705
| 80
| 0.656334
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,764
|
implication.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/implication.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T>
struct implication final : public dense_timed_node<data_interval_map<T>, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using state_t = dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
node_ptr_t arg1;
node_ptr_t arg2;
explicit implication(const std::vector<node_ptr_t> &args)
: arg1(args[0]), arg2(args[1]) {}
explicit implication(const kwargs &kw)
: implication(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
auto result = interval_map();
for (const auto &intv : arg1->output(previous, now)) {
result.add(std::make_pair(intv.first, ~intv.second));
}
for (const auto &intv : arg2->output(previous, now)) {
result.add(intv);
}
return result;
}
};
} // namespace dense_timed_data_setting
} // namespace reelay
| 1,708
|
C++
|
.h
| 47
| 33.255319
| 80
| 0.699818
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,765
|
atomic_false.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_false.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_false final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
explicit atomic_false(const data_mgr_t &mgr, const key_t &key)
: manager(mgr), key(key) {}
explicit atomic_false(const kwargs &kw)
: atomic_false(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t& pargs,
const input_t& args,
time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (not new_data) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,468
|
C++
|
.h
| 65
| 32.553846
| 79
| 0.654123
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,766
|
atomic_le_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_le_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_le_0 final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
double constant;
explicit atomic_le_0(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), constant(std::stod(c)) {}
explicit atomic_le_0(const kwargs &kw)
: atomic_le_0(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data <= constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,601
|
C++
|
.h
| 66
| 33.818182
| 79
| 0.650781
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,767
|
atomic_prop.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_prop.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_prop final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
explicit atomic_prop(const data_mgr_t &mgr, const key_t &key)
: manager(mgr), key(key) {}
explicit atomic_prop(const kwargs &kw)
: atomic_prop(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,430
|
C++
|
.h
| 63
| 33.460317
| 79
| 0.661512
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,768
|
atomic_ge_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_ge_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_ge_0 final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
double constant;
explicit atomic_ge_0(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), constant(std::stod(c)) {}
explicit atomic_ge_0(const kwargs &kw)
: atomic_ge_0(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data >= constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,601
|
C++
|
.h
| 66
| 33.818182
| 79
| 0.650781
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,769
|
atomic_string.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_string.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_string final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
std::string constant;
explicit atomic_string(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), constant(c) {}
explicit atomic_string(const kwargs &kw)
: atomic_string(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
std::string new_data = datafield<input_t>::as_string(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data == constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,591
|
C++
|
.h
| 66
| 33.893939
| 79
| 0.651515
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,770
|
atomic_gt_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed_data/atomic_gt_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace dense_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_gt_0 final
: public dense_timed_state<X, data_interval_map<T>, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = reelay::data_interval_map<time_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map(
std::make_pair(interval::left_open(0, reelay::infinity<time_t>::value()),
manager->zero()));
key_t key;
double constant;
explicit atomic_gt_0(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), key(k), constant(std::stod(c)) {}
explicit atomic_gt_0(const kwargs &kw)
: atomic_gt_0(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value - interval::left_open(0, previous);
value = value - interval::left_open(now, infinity<time_t>::value());
if (new_data > constant) {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->one()));
} else {
value.add(std::make_pair(
interval::left_open(now, reelay::infinity<time_t>::value()),
manager->zero()));
}
}
output_t output(time_t previous, time_t now) override {
return (value - interval::left_open(0, previous)) -
interval::left_open(now, infinity<time_t>::value());
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,600
|
C++
|
.h
| 66
| 33.80303
| 79
| 0.651042
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,771
|
atomic_number.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_number.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_number final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
explicit atomic_number(const key_t &k, const std::string &c_str)
: key(k), constant(std::stod(c_str)) {}
explicit atomic_number(const kwargs &kw)
: atomic_number(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value & interval::left_open(previous, now);
if (new_data == constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,058
|
C++
|
.h
| 53
| 34.981132
| 80
| 0.68662
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,772
|
past_sometime_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_sometime_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_sometime_bounded final
: public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
node_ptr_t first;
time_t lbound = 0;
time_t ubound = 0;
past_sometime_bounded(const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: first(args[0]), lbound(l), ubound(u) {}
explicit past_sometime_bounded(const kwargs &kw)
: past_sometime_bounded(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
for (const auto& intv : first->output(previous, now)) {
value.add(
interval::left_open(intv.lower() + lbound, intv.upper() + ubound));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,912
|
C++
|
.h
| 51
| 32.490196
| 77
| 0.653492
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,773
|
negation.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/negation.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct negation final : public dense_timed_node<interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
node_ptr_t arg1;
explicit negation(const std::vector<node_ptr_t> &args) : arg1(args[0]) {}
explicit negation(const kwargs &kw)
: negation(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
return interval_set(interval::left_open(previous, now)) -
arg1->output(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,241
|
C++
|
.h
| 33
| 34.727273
| 77
| 0.708438
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,774
|
since_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/since_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct since_bounded_half final
: public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
node_ptr_t first;
node_ptr_t second;
time_t lbound = 0;
since_bounded_half(const std::vector<node_ptr_t> &args, time_t l)
: first(args[0]), second(args[1]), lbound(l) {}
explicit since_bounded_half(const kwargs &kw)
: since_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(bool p1, bool p2, time_t previous, time_t now) {
if (previous == now) {
return;
}
if (p1 and p2) {
value.add(
interval::left_open(previous + lbound, infinity<time_t>::value()));
} else if (!p1 and p2) {
value = interval_set(
interval::left_open(now + lbound, infinity<time_t>::value()));
} else if (p1 and !p2) {
// Nothing needed to do
} else {
value = interval_set();
}
}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) {
/*
* The following code performs the sychronization between two arbitrary
* chunks and calls the _update function for each constant period
* sequentially. The synchronization algorithm is a variant of the plane
* sweep algorithm from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
// Local variables
bool p1 = false;
bool p2 = false;
std::vector<T> bounds1; // bounds1.reserve(p1set.size()*2+1);
std::vector<T> bounds2; // bounds2.reserve(p2set.size()*2+1);
for (const auto& intv : first->output(previous, now)) {
bounds1.push_back(intv.lower());
bounds1.push_back(intv.upper());
}
for (const auto& intv : second->output(previous, now)) {
bounds2.push_back(intv.lower());
bounds2.push_back(intv.upper());
}
// Add the latest timepoint in the segment as the final bound
bounds1.push_back(now);
bounds2.push_back(now);
auto it1 = bounds1.begin();
auto it2 = bounds2.begin();
while (it1 != bounds1.end() and it2 != bounds2.end()) {
if (*it1 < *it2) {
// std::cout << time << ' '<< *it1 << '|' << p1 << p2 << std::endl;
update(p1, p2, time, *it1);
p1 = not p1;
time = *it1;
it1++;
} else if (*it1 > *it2) {
// std::cout << time << ' '<< *it2 << '|' << p1 << p2 << std::endl;
update(p1, p2, time, *it2);
p2 = not p2;
time = *it2;
it2++;
} else { // *it1 == *it2
// std::cout << time << ' '<< *it1 << '|' << p1 << p2 << std::endl;
update(p1, p2, time, *it1);
p1 = not p1;
p2 = not p2;
time = *it1;
it1++;
it2++;
}
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) {
return value & interval_set(interval::left_open(previous, now));
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 3,892
|
C++
|
.h
| 110
| 29.618182
| 77
| 0.60213
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,775
|
since_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/since_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct since_bounded final : public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
node_ptr_t first;
node_ptr_t second;
time_t lbound = 0;
time_t ubound = 0;
since_bounded(const std::vector<node_ptr_t> &args, time_t l, time_t u)
: first(args[0]), second(args[1]), lbound(l), ubound(u) {}
explicit since_bounded(const kwargs &kw)
: since_bounded(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(bool p1, bool p2, time_t previous, time_t now) {
if (previous == now) {
return;
}
if (p1 and p2) {
value.add(interval::left_open(previous + lbound, now + ubound));
} else if (!p1 and p2) {
value = interval_set(interval::left_open(now + lbound, now + ubound));
} else if (p1 and !p2) {
// Nothing needed to do
} else {
value = interval_set();
}
}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
/*
* The following code block performs the sychronization between two
* arbitrary chunks and calls the _update function for each constant period
* sequentially. The synchronization algorithm is a variant of the plane
* sweep algorithm from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
// Local variables
bool p1 = false;
bool p2 = false;
std::vector<T> bounds1; // bounds1.reserve(p1set.size()*2+1);
std::vector<T> bounds2; // bounds2.reserve(p2set.size()*2+1);
for (const auto& intv : first->output(previous, now)) {
bounds1.push_back(intv.lower());
bounds1.push_back(intv.upper());
}
for (const auto& intv : second->output(previous, now)) {
bounds2.push_back(intv.lower());
bounds2.push_back(intv.upper());
}
// Add the latest timepoint in the segment as the final bound
bounds1.push_back(now);
bounds2.push_back(now);
auto it1 = bounds1.begin();
auto it2 = bounds2.begin();
while (it1 != bounds1.end() and it2 != bounds2.end()) {
if (*it1 < *it2) {
update(p1, p2, time, *it1);
p1 = not p1;
time = *it1;
it1++;
} else if (*it1 > *it2) {
update(p1, p2, time, *it2);
p2 = not p2;
time = *it2;
it2++;
} else { // *it1 == *it2
update(p1, p2, time, *it1);
p1 = not p1;
p2 = not p2;
time = *it1;
it1++;
it2++;
}
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 3,705
|
C++
|
.h
| 105
| 29.552381
| 79
| 0.619754
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,776
|
past_sometime_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_sometime_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_sometime_bounded_half final
: public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
node_ptr_t first;
time_t lbound;
past_sometime_bounded_half(const std::vector<node_ptr_t> &args, time_t l=0)
: first(args[0]), lbound(l) {}
explicit past_sometime_bounded_half(const kwargs &kw)
: past_sometime_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
for (const auto& intv : first->output(previous, now)) {
value.add(interval::left_open(intv.lower() + lbound,
std::numeric_limits<time_t>::max()));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,838
|
C++
|
.h
| 48
| 33.3125
| 77
| 0.662352
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,777
|
since.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/since.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct since final : public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
node_ptr_t first;
node_ptr_t second;
explicit since(const std::vector<node_ptr_t> &args)
: first(args[0]), second(args[1]) {}
explicit since(const kwargs &kw)
: since(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(bool p1, bool p2, time_t previous, time_t now) {
if (previous == now) {
return;
}
if (p1 and p2) {
value.add(
interval::left_open(previous, infinity<time_t>::value()));
} else if (!p1 and p2) {
value = interval_set(
interval::left_open(now, infinity<time_t>::value()));
} else if (p1 and !p2) {
// Nothing needed to do
} else {
value = interval_set();
}
}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
/*
* The following code performs the sychronization between two arbitrary
* chunks and calls the _update function for each constant period
* sequentially. The synchronization algorithm is a variant of the plane
* sweep algorithm from computational geometry.
*/
// Sweep line starts from the earliest timepoint in the segment
time_t time = previous;
// Local variables
bool p1 = false;
bool p2 = false;
std::vector<T> bounds1; // bounds1.reserve(p1set.size()*2+1);
std::vector<T> bounds2; // bounds2.reserve(p2set.size()*2+1);
for (const auto& intv : first->output(previous, now)) {
bounds1.push_back(intv.lower());
bounds1.push_back(intv.upper());
}
for (const auto& intv : second->output(previous, now)) {
bounds2.push_back(intv.lower());
bounds2.push_back(intv.upper());
}
// Add the latest timepoint in the segment as the final bound
bounds1.push_back(now);
bounds2.push_back(now);
auto it1 = bounds1.begin();
auto it2 = bounds2.begin();
while (it1 != bounds1.end() and it2 != bounds2.end()) {
if (*it1 < *it2) {
update(p1, p2, time, *it1);
p1 = not p1;
time = *it1;
it1++;
} else if (*it1 > *it2) {
update(p1, p2, time, *it2);
p2 = not p2;
time = *it2;
it2++;
} else { // *it1 == *it2
update(p1, p2, time, *it1);
p1 = not p1;
p2 = not p2;
time = *it1;
it1++;
it2++;
}
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 3,490
|
C++
|
.h
| 103
| 28.349515
| 76
| 0.621469
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,778
|
atomic_lt_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_lt_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_lt_0 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
explicit atomic_lt_0(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_lt_0(const kwargs &kw)
: atomic_lt_0(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value & interval::left_open(previous, now);
if (new_data < constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,039
|
C++
|
.h
| 53
| 34.660377
| 80
| 0.684104
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,779
|
past_always_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_always_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_always_bounded_half final
: public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set(
interval::left_open(-std::numeric_limits<time_t>::max(), 0)); // true
node_ptr_t first;
time_t lbound;
past_always_bounded_half(const std::vector<node_ptr_t> &args, time_t l=0)
: first(args[0]), lbound(l) {}
explicit past_always_bounded_half(const kwargs &kw)
: past_always_bounded_half(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
auto complement = interval_set(interval::left_open(previous, now)) -
first->output(previous, now);
for (const auto& intv : complement) {
value.add(interval::left_open(intv.lower() + lbound,
std::numeric_limits<time_t>::max()));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return interval_set(interval::left_open(previous, now)) - value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,028
|
C++
|
.h
| 51
| 34.352941
| 76
| 0.655963
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,780
|
setting.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/setting.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "string"
#include "reelay/networks/basic_structure.hpp"
//
#include "reelay/settings/dense_timed/atomic_any.hpp"
#include "reelay/settings/dense_timed/atomic_false.hpp"
#include "reelay/settings/dense_timed/atomic_ge_0.hpp"
#include "reelay/settings/dense_timed/atomic_ge_1.hpp"
#include "reelay/settings/dense_timed/atomic_gt_0.hpp"
#include "reelay/settings/dense_timed/atomic_gt_1.hpp"
#include "reelay/settings/dense_timed/atomic_le_0.hpp"
#include "reelay/settings/dense_timed/atomic_le_1.hpp"
#include "reelay/settings/dense_timed/atomic_lt_0.hpp"
#include "reelay/settings/dense_timed/atomic_lt_1.hpp"
// #include "reelay/settings/dense_timed/atomic_ne.hpp"
// #include "reelay/settings/dense_timed/atomic_eq.hpp"
#include "reelay/settings/dense_timed/atomic_number.hpp"
#include "reelay/settings/dense_timed/atomic_prop.hpp"
#include "reelay/settings/dense_timed/atomic_string.hpp"
#include "reelay/settings/dense_timed/atomic_true.hpp"
#include "reelay/settings/dense_timed/atomic_map.hpp"
#include "reelay/settings/dense_timed/conjunction.hpp"
#include "reelay/settings/dense_timed/disjunction.hpp"
#include "reelay/settings/dense_timed/implication.hpp"
#include "reelay/settings/dense_timed/negation.hpp"
#include "reelay/settings/dense_timed/past_always.hpp"
#include "reelay/settings/dense_timed/past_sometime.hpp"
#include "reelay/settings/dense_timed/since.hpp"
#include "reelay/settings/dense_timed/past_always_bounded.hpp"
#include "reelay/settings/dense_timed/past_sometime_bounded.hpp"
#include "reelay/settings/dense_timed/since_bounded.hpp"
#include "reelay/settings/dense_timed/past_always_bounded_half.hpp"
#include "reelay/settings/dense_timed/past_sometime_bounded_half.hpp"
#include "reelay/settings/dense_timed/since_bounded_half.hpp"
namespace reelay {
namespace dense_timed_setting {
// enum interpolation_t {zero_order, first_order};
template <typename X, typename T>
struct factory {
using input_t = X;
using time_t = T;
using value_t = bool;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t&, const input_t&, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
using node_t = reelay::dense_timed_node<output_t, time_t>;
using state_t = reelay::dense_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
static node_ptr_t make_node(const std::string &name, const kwargs &kw) {
node_ptr_t result;
if (name == "disjunction") {
result = std::make_shared<disjunction<input_t, time_t>>(kw);
} else if (name == "conjunction") {
result = std::make_shared<conjunction<input_t, time_t>>(kw);
} else if (name == "negation") {
result = std::make_shared<negation<input_t, time_t>>(kw);
} else if (name == "implication") {
result = std::make_shared<implication<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the dense timed setting");
}
return result;
}
static state_ptr_t make_state(const std::string &name, const kwargs &kw) {
state_ptr_t result;
if (name == "atomic_map") {
result = std::make_shared<atomic_map<input_t, time_t>>(kw);
} else if (name == "mapping_prop") {
result = std::make_shared<atomic_prop<input_t, time_t>>(kw);
} else if (name == "mapping_false") {
result = std::make_shared<atomic_false<input_t, time_t>>(kw);
} else if (name == "mapping_true") {
result = std::make_shared<atomic_true<input_t, time_t>>(kw);
} else if (name == "mapping_string") {
result = std::make_shared<atomic_string<input_t, time_t>>(kw);
} else if (name == "mapping_number") {
result = std::make_shared<atomic_number<input_t, time_t>>(kw);
} else if (name == "mapping_ge" and any_cast<int>(kw.at("order")) == 0) {
result = std::make_shared<atomic_ge_0<input_t, time_t>>(kw);
} else if (name == "mapping_gt" and any_cast<int>(kw.at("order")) == 0) {
result = std::make_shared<atomic_gt_0<input_t, time_t>>(kw);
} else if (name == "mapping_le" and any_cast<int>(kw.at("order")) == 0) {
result = std::make_shared<atomic_le_0<input_t, time_t>>(kw);
} else if (name == "mapping_lt" and any_cast<int>(kw.at("order")) == 0) {
result = std::make_shared<atomic_lt_0<input_t, time_t>>(kw);
} else if (name == "mapping_ge" and any_cast<int>(kw.at("order")) == 1) {
result = std::make_shared<atomic_ge_1<input_t, time_t>>(kw);
} else if (name == "mapping_gt" and any_cast<int>(kw.at("order")) == 1) {
result = std::make_shared<atomic_gt_1<input_t, time_t>>(kw);
} else if (name == "mapping_le" and any_cast<int>(kw.at("order")) == 1) {
result = std::make_shared<atomic_le_1<input_t, time_t>>(kw);
} else if (name == "mapping_lt" and any_cast<int>(kw.at("order")) == 1) {
result = std::make_shared<atomic_lt_1<input_t, time_t>>(kw);
} else if (name == "mapping_any") {
result = std::make_shared<atomic_any<input_t, time_t>>(kw);
} else if (name == "past_sometime") {
result = std::make_shared<past_sometime<input_t, time_t>>(kw);
} else if (name == "past_always") {
result = std::make_shared<past_always<input_t, time_t>>(kw);
} else if (name == "since") {
result = std::make_shared<since<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded") {
result = std::make_shared<past_sometime_bounded<input_t, time_t>>(kw);
} else if (name == "past_always_bounded") {
result = std::make_shared<past_always_bounded<input_t, time_t>>(kw);
} else if (name == "since_bounded") {
result = std::make_shared<since_bounded<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded_half") {
result =
std::make_shared<past_sometime_bounded_half<input_t, time_t>>(kw);
} else if (name == "past_always_bounded_half") {
result = std::make_shared<past_always_bounded_half<input_t, time_t>>(kw);
} else if (name == "since_bounded_half") {
result = std::make_shared<since_bounded_half<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the dense timed setting");
}
return result;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 6,735
|
C++
|
.h
| 136
| 45.433824
| 79
| 0.674829
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,781
|
past_always.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_always.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_always final : public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
bool done = false;
interval_set value = interval_set(); // true
node_ptr_t first;
explicit past_always(const std::vector<node_ptr_t> &args) : first(args[0]) {}
explicit past_always(const kwargs &kw)
: past_always(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
if(done) {
return;
}
auto complement = interval_set(interval::left_open(previous, now)) -
first->output(previous, now);
if (complement.size() == 0) {
return;
}
time_t earliest_time = complement.begin()->lower();
value = interval_set(
interval::left_open(earliest_time, infinity<time_t>::value()));
done = true;
}
output_t output(time_t previous, time_t now) override {
return interval_set(interval::left_open(previous, now)) - value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,825
|
C++
|
.h
| 51
| 31.27451
| 80
| 0.666856
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,782
|
past_always_bounded.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_always_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_always_bounded final
: public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set(
interval::left_open(-std::numeric_limits<time_t>::max(), 0)); // true
node_ptr_t first;
time_t lbound;
time_t ubound;
past_always_bounded(const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: first(args[0]), lbound(l), ubound(u) {}
explicit past_always_bounded(const kwargs &kw)
: past_always_bounded(
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
auto complement = interval_set(interval::left_open(previous, now)) -
first->output(previous, now);
for (const auto& intv : complement) {
value.add(
interval::left_open(intv.lower() + lbound, intv.upper() + ubound));
}
value = value - interval::closed(-infinity<time_t>::value(), previous);
}
output_t output(time_t previous, time_t now) override {
return interval_set(interval::left_open(previous, now)) - value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,093
|
C++
|
.h
| 54
| 33.37037
| 77
| 0.650346
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,783
|
atomic_le_1.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_le_1.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_le_1 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
time_t t0 = 0;
double y0 = 0;
explicit atomic_le_1(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_le_1(const kwargs &kw)
: atomic_le_1(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
double y1 = datafield<input_t>::as_floating(args, key);
if (y0 < constant and y1 < constant) {
value = interval_set(interval::left_open(t0, now));
} else if (y0 > constant and y1 > constant) {
value = interval_set();
} else if (y0 > y1) {
time_t crossing = now - (now - t0) * ((constant - y1) / (y0 - y1));
value = interval_set(interval::left_open(crossing, now));
} else if (y0 < y1) {
time_t crossing = t0 + (now - t0) * ((constant - y0) / (y1 - y0));
value = interval_set(interval::left_open(t0, crossing));
} else { // y0 == y1 == c is true
value = interval_set(interval::left_open(t0, now));
}
t0 = now;
y0 = y1;
}
output_t output(time_t previous, time_t now) override {
return value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,355
|
C++
|
.h
| 63
| 33.269841
| 80
| 0.649956
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,784
|
atomic_true.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_true.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_true final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
explicit atomic_true(const key_t &key) : key(key) {}
explicit atomic_true(const kwargs &kw)
: atomic_true(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value & interval::left_open(previous, now);
if (new_data) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,884
|
C++
|
.h
| 50
| 34.28
| 80
| 0.694169
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,785
|
atomic_map.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_map.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "string"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct atomic_map final : public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
output_t value = interval_set();
std::vector<node_ptr_t> mappings;
explicit atomic_map(const std::vector<node_ptr_t> &nodeptrs)
: mappings(nodeptrs) {}
explicit atomic_map(const kwargs &kw)
: atomic_map(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, const input_t &, time_t previous,
time_t now) override {
value = mappings[0]->output(previous, now);
for (size_t i = 1; i < mappings.size(); i++) {
value = value & mappings[i]->output(previous, now);
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,580
|
C++
|
.h
| 42
| 34.309524
| 79
| 0.692459
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,786
|
past_sometime.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/past_sometime.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct past_sometime final : public dense_timed_state<X, interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
bool done = false;
interval_set value = interval_set();
node_ptr_t first;
explicit past_sometime(const std::vector<node_ptr_t> &args)
: first(args[0]) {}
explicit past_sometime(const kwargs &kw)
: past_sometime(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t&,
const input_t&,
time_t previous,
time_t now) override {
if(done) {
return;
}
if (first->output(previous, now).size() == 0){
return;
}
time_t earliest_time = first->output(previous, now).begin()->lower();
value = interval_set(
interval::left_open(earliest_time, infinity<time_t>::value()));
done = true;
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,724
|
C++
|
.h
| 50
| 30.34
| 82
| 0.671884
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,787
|
disjunction.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/disjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct disjunction final : public dense_timed_node<interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
std::vector<node_ptr_t> args;
explicit disjunction(const std::vector<node_ptr_t> &args)
: args(args) {}
explicit disjunction(const kwargs &kw)
: disjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
interval_set result = args[0]->output(previous, now);
for (size_t i = 1; i < args.size(); i++) {
result = result | args[i]->output(previous, now);
}
return result;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,353
|
C++
|
.h
| 37
| 33.540541
| 80
| 0.695785
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,788
|
conjunction.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/conjunction.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct conjunction final : public dense_timed_node<interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
std::vector<node_ptr_t> args;
explicit conjunction(const std::vector<node_ptr_t> &args) : args(args) {}
explicit conjunction(const kwargs &kw)
: conjunction(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
interval_set result = args[0]->output(previous, now);
for (size_t i = 1; i < args.size(); i++) {
result = result & args[i]->output(previous, now);
}
return result;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,347
|
C++
|
.h
| 36
| 34.5
| 80
| 0.698462
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,789
|
atomic_any.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_any.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_any final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t&, const input_t&, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
explicit atomic_any(const key_t &key) : key(key) {}
explicit atomic_any(const kwargs &kw)
: atomic_any(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t& pargs,
const input_t& args,
time_t previous,
time_t now) override {
bool key_exists = datafield<input_t>::contains(args, key);
value = value & interval::left_open(previous, now);
if (key_exists) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,772
|
C++
|
.h
| 49
| 32.428571
| 78
| 0.68717
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,790
|
atomic_gt_1.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_gt_1.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_gt_1 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
time_t t0 = 0;
double y0 = 0;
explicit atomic_gt_1(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_gt_1(const kwargs &kw)
: atomic_gt_1(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
double y1 = datafield<input_t>::as_floating(args, key);
if (y0 < constant and y1 < constant) {
value = interval_set();
} else if (y0 > constant and y1 > constant) {
value = interval_set(interval::left_open(t0, now));
} else if (y0 > y1) {
time_t crossing = now - (now - t0) * ((constant - y1) / (y0 - y1));
value = interval_set(interval::left_open(t0, crossing));
} else if (y0 < y1) {
time_t crossing = t0 + (now - t0) * ((constant - y0) / (y1 - y0));
value = interval_set(interval::left_open(crossing, now));
} else { // y0 == y1 == c is true
value = interval_set();
}
t0 = now;
y0 = y1;
}
output_t output(time_t previous, time_t now) override {
return value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,327
|
C++
|
.h
| 63
| 32.825397
| 80
| 0.648709
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,791
|
implication.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/implication.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "vector"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T>
struct implication final : public dense_timed_node<interval_set<T>, T> {
using time_t = T;
using input_t = X;
using output_t = reelay::interval_set<time_t>;
using node_t = dense_timed_node<output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
node_ptr_t arg1;
node_ptr_t arg2;
explicit implication(const std::vector<node_ptr_t> &args)
: arg1(args[0]), arg2(args[1]) {}
explicit implication(const kwargs &kw)
: implication(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t previous, time_t now) {
return (interval_set(interval::left_open(previous, now)) -
arg1->output(previous, now)) |
arg2->output(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,337
|
C++
|
.h
| 36
| 33.861111
| 80
| 0.699225
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,792
|
atomic_false.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_false.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_false final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
explicit atomic_false(const key_t &key) : key(key) {}
explicit atomic_false(const kwargs &kw)
: atomic_false(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value & interval::left_open(previous, now);
if (not new_data) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,892
|
C++
|
.h
| 50
| 34.44
| 80
| 0.694962
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,793
|
atomic_le_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_le_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_le_0 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
explicit atomic_le_0(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_le_0(const kwargs &kw)
: atomic_le_0(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value & interval::left_open(previous, now);
if (new_data <= constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,040
|
C++
|
.h
| 53
| 34.679245
| 80
| 0.683756
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,794
|
atomic_ge_1.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_ge_1.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_ge_1 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
time_t t0 = 0;
double y0 = 0;
explicit atomic_ge_1(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_ge_1(const kwargs &kw)
: atomic_ge_1(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
double y1 = datafield<input_t>::as_floating(args, key);
if (y0 < constant and y1 < constant) {
value = interval_set();
} else if (y0 > constant and y1 > constant) {
value = interval_set(interval::left_open(t0, now));
} else if (y0 > y1) {
time_t crossing = now - (now - t0) * ((constant - y1) / (y0 - y1));
value = interval_set(interval::left_open(t0, crossing));
} else if (y0 < y1) {
time_t crossing = t0 + (now - t0) * ((constant - y0) / (y1 - y0));
value = interval_set(interval::left_open(crossing, now));
} else { // y0 == y1 == c is true
value = interval_set(interval::left_open(t0, now));
}
t0 = now;
y0 = y1;
}
output_t output(time_t previous, time_t now) override {
return value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,355
|
C++
|
.h
| 63
| 33.269841
| 80
| 0.649956
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,795
|
atomic_prop.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_prop.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_prop final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
key_t key;
interval_set value = interval_set();
explicit atomic_prop(const key_t &key) : key(key) {}
explicit atomic_prop(const kwargs &kw)
: atomic_prop(reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
value = value & interval::left_open(previous, now);
if (new_data) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 1,885
|
C++
|
.h
| 50
| 34.28
| 80
| 0.694169
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,796
|
atomic_ge_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_ge_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_ge_0 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
explicit atomic_ge_0(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_ge_0(const kwargs &kw)
: atomic_ge_0(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value & interval::left_open(previous, now);
if (new_data >= constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,040
|
C++
|
.h
| 53
| 34.679245
| 80
| 0.683756
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,797
|
atomic_lt_1.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_lt_1.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_lt_1 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
time_t t0 = 0;
double y0 = 0;
explicit atomic_lt_1(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_lt_1(const kwargs &kw)
: atomic_lt_1(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
double y1 = datafield<input_t>::as_floating(args, key);
if (y0 < constant and y1 < constant) {
value = interval_set(interval::left_open(t0, now));
} else if (y0 > constant and y1 > constant) {
value = interval_set();
} else if (y0 > y1) {
time_t crossing = now - (now - t0) * ((constant - y1) / (y0 - y1));
value = interval_set(interval::left_open(crossing, now));
} else if (y0 < y1) {
time_t crossing = t0 + (now - t0) * ((constant - y0) / (y1 - y0));
value = interval_set(interval::left_open(t0, crossing));
} else { // y0 == y1 == c is true
value = interval_set();
}
t0 = now;
y0 = y1;
}
output_t output(time_t previous, time_t now) override {
return value;
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,328
|
C++
|
.h
| 63
| 32.825397
| 80
| 0.64842
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,798
|
atomic_string.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_string.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_string final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
std::string constant;
explicit atomic_string(const key_t &k, const std::string &c)
: key(k), constant(c) {}
explicit atomic_string(const kwargs &kw)
: atomic_string(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
std::string new_data = datafield<input_t>::as_string(args, key);
value = value & interval::left_open(previous, now);
if (new_data == constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,046
|
C++
|
.h
| 53
| 34.773585
| 80
| 0.685888
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,799
|
atomic_gt_0.hpp
|
doganulus_reelay/include/reelay/settings/dense_timed/atomic_gt_0.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "vector"
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
namespace reelay {
namespace dense_timed_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_gt_0 final : public dense_timed_state<X, interval_set<T>, T> {
using key_t = K;
using input_t = X;
using time_t = T;
using base_t = reelay::interval_set<time_t>;
using output_t = reelay::interval_set<time_t>;
using function_t =
std::function<output_t(const input_t &, const input_t &, time_t, time_t)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
interval_set value = interval_set();
key_t key;
double constant;
explicit atomic_gt_0(const key_t &k, const std::string &c)
: key(k), constant(std::stod(c)) {}
explicit atomic_gt_0(const kwargs &kw)
: atomic_gt_0(reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &pargs, const input_t &args, time_t previous,
time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
value = value & interval::left_open(previous, now);
if (new_data > constant) {
value.add(interval::left_open(now, reelay::infinity<time_t>::value()));
}
}
output_t output(time_t previous, time_t now) override {
return value & interval::left_open(previous, now);
}
};
} // namespace dense_timed_setting
} // namespace reelay
| 2,039
|
C++
|
.h
| 53
| 34.660377
| 80
| 0.684104
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,800
|
atomic_number.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/atomic_number.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_number final : public discrete_timed_state<X, data_set_t, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
data_mgr_t manager;
data_set_t value;
key_t key;
double constant;
explicit atomic_number(const data_mgr_t &mgr, const key_t &k,
const std::string &c_str)
: manager(mgr), value(mgr->zero()), key(k),
constant(std::stod(c_str)) {}
explicit atomic_number(const kwargs &kw)
: atomic_number(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
if (new_data == constant) {
value = manager->one();
} else {
value = manager->zero();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,795
|
C++
|
.h
| 50
| 31.24
| 79
| 0.659341
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,801
|
past_sometime_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/past_sometime_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct past_sometime_bounded final
: public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
time_t ubound;
past_sometime_bounded(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l), ubound(u) {
value.add(
std::make_pair(interval::closed(
-reelay::infinity<time_t>::value(), lbound),
mgr->zero()));
}
explicit past_sometime_bounded(const kwargs &kw)
: past_sometime_bounded(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, time_t now) {
value.add(std::make_pair(
reelay::interval<time_t>::closed(now + lbound, now + ubound),
first->output(now)));
value -= interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now), manager->zero()));
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 2,263
|
C++
|
.h
| 59
| 33.288136
| 74
| 0.653565
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,802
|
atomic_ref.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/atomic_ref.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_ref final : public discrete_timed_state<X, data_set_t, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
data_mgr_t manager;
data_set_t value;
key_t key;
std::string variable;
explicit atomic_ref(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), value(mgr->zero()), key(k), variable(c) {
manager->add_variable(variable);
}
explicit atomic_ref(const kwargs &kw)
: atomic_ref(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
std::string new_data = datafield<input_t>::as_string(args, key);
value = manager->assign(variable, new_data);
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,731
|
C++
|
.h
| 47
| 32.617021
| 79
| 0.674251
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,803
|
negation.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/negation.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include <memory>
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct negation final : public discrete_timed_node<data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
node_ptr_t arg1;
explicit negation(const std::vector<node_ptr_t> &args) : arg1(args[0]) {}
explicit negation(const kwargs &kw)
: negation(reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) { return ~arg1->output(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,250
|
C++
|
.h
| 33
| 35.454545
| 77
| 0.716418
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,804
|
since_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/since_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct since_bounded_half final
: public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
time_t lbound;
interval_map value = interval_map();
since_bounded_half(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args,
time_t l = 0)
: manager(mgr), first(args[0]), second(args[1]), lbound(l) {
value.add(std::make_pair(
interval::left_open(-reelay::infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit since_bounded_half(const kwargs &kw)
: since_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
// Eliminate the first argument from the future if it does not now
value = value - interval_map(std::make_pair(
interval::closed(now, infinity<time_t>::value()),
first->output(now)));
// Add satisfying bindings to the future
value.add(std::make_pair(
interval::closed(now + lbound, infinity<time_t>::value()),
second->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 2,406
|
C++
|
.h
| 60
| 35
| 80
| 0.661505
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,805
|
atomic_lt.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/atomic_lt.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_lt final : public discrete_timed_state<X, data_set_t, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
data_mgr_t manager;
data_set_t value;
key_t key;
double constant;
explicit atomic_lt(const data_mgr_t &mgr, const key_t &k,
const std::string &c)
: manager(mgr), value(mgr->zero()), key(k),
constant(std::stod(c)) {}
explicit atomic_lt(const kwargs &kw)
: atomic_lt(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key")),
reelay::any_cast<std::string>(kw.at("constant"))) {}
void update(const input_t &args, time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
double new_data = datafield<input_t>::as_floating(args, key);
if (new_data < constant) {
value = manager->one();
} else {
value = manager->zero();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,772
|
C++
|
.h
| 51
| 30.470588
| 79
| 0.662566
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,806
|
forall.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/forall.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct forall final : public discrete_timed_node<data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
node_ptr_t arg1;
data_set_t cube;
explicit forall(const data_mgr_t &mgr, const std::vector<std::string> &vars,
const std::vector<node_ptr_t> &args)
: arg1(args[0]) {
cube = mgr->one();
for (const auto &name : vars) {
cube *= mgr->variables[name].cube;
}
}
explicit forall(const kwargs &kw)
: forall(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<std::string>>(kw.at("vars")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
output_t output(time_t now) override {
data_set_t value = arg1->output(now);
return value.UnivAbstract(cube);
}
};
} // namespace untimed_data_setting
} // namespace reelay
| 1,641
|
C++
|
.h
| 46
| 31.782609
| 78
| 0.67298
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,807
|
since_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/since_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct since_bounded final : public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
time_t lbound;
time_t ubound;
interval_map value = interval_map();
since_bounded(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args,
time_t l = 0, time_t u = 0)
: manager(mgr), first(args[0]), second(args[1]), lbound(l), ubound(u) {
value.add(std::make_pair(
interval::left_open(-reelay::infinity<time_t>::value(), lbound),
manager->zero()));
}
explicit since_bounded(const kwargs &kw)
: since_bounded(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t&, time_t now) {
// Eliminate the first argument from the future if it does not now
value = value - interval_map(
std::make_pair(interval::closed(now, infinity<time_t>::value()),
first->output(now)));
// Add satisfying bindings to the future
value.add(std::make_pair(interval::closed(now + lbound, now + ubound),
second->output(now)));
value = value - interval::right_open(-infinity<time_t>::value(), now);
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 2,477
|
C++
|
.h
| 59
| 36.525424
| 79
| 0.655273
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,808
|
past_sometime_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/past_sometime_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct past_sometime_bounded_half final
: public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
past_sometime_bounded_half(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l) {
value.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
mgr->zero()));
}
explicit past_sometime_bounded_half(const kwargs &kw)
: past_sometime_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
value.add(
std::make_pair(reelay::interval<time_t>::closed(
now + lbound, reelay::infinity<time_t>::value()),
first->output(now)));
value -= interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now), manager->zero()));
}
output_t output(time_t now) { return value(now); }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 2,250
|
C++
|
.h
| 57
| 33.982456
| 76
| 0.649977
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,809
|
since.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/since.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct since final : public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
data_mgr_t manager;
node_ptr_t first;
node_ptr_t second;
data_set_t value;
explicit since(const data_mgr_t &mgr, const std::vector<node_ptr_t> &args)
: manager(mgr), value(mgr->zero()), first(args[0]), second(args[1]) {}
explicit since(const kwargs &kw)
: since(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) override {
value = second->output(now) + (first->output(now) * value);
}
output_t output(time_t) override { return value; }
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 1,530
|
C++
|
.h
| 39
| 36.102564
| 76
| 0.694181
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,810
|
past_always_bounded_half.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/past_always_bounded_half.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct past_always_bounded_half final
: public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
past_always_bounded_half(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l) {
value.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
mgr->zero()));
}
explicit past_always_bounded_half(const kwargs &kw)
: past_always_bounded_half(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound"))) {}
void update(const input_t &, time_t now) {
value.add(
std::make_pair(reelay::interval<time_t>::closed(
now + lbound, reelay::infinity<time_t>::value()),
~first->output(now)));
value -= interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now), manager->zero()));
}
output_t output(time_t now) { return ~value(now); }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 2,250
|
C++
|
.h
| 57
| 33.877193
| 77
| 0.646302
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,811
|
setting.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/setting.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "functional"
#include "memory"
#include "string"
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
//
#include "reelay/settings/discrete_timed_data/atomic_any.hpp"
#include "reelay/settings/discrete_timed_data/atomic_false.hpp"
#include "reelay/settings/discrete_timed_data/atomic_ge.hpp"
#include "reelay/settings/discrete_timed_data/atomic_gt.hpp"
#include "reelay/settings/discrete_timed_data/atomic_le.hpp"
#include "reelay/settings/discrete_timed_data/atomic_lt.hpp"
#include "reelay/settings/discrete_timed_data/atomic_ne.hpp"
#include "reelay/settings/discrete_timed_data/atomic_number.hpp"
#include "reelay/settings/discrete_timed_data/atomic_prop.hpp"
#include "reelay/settings/discrete_timed_data/atomic_ref.hpp"
#include "reelay/settings/discrete_timed_data/atomic_string.hpp"
#include "reelay/settings/discrete_timed_data/atomic_true.hpp"
#include "reelay/settings/discrete_timed_data/atomic_map.hpp"
#include "reelay/settings/discrete_timed_data/exists.hpp"
#include "reelay/settings/discrete_timed_data/forall.hpp"
#include "reelay/settings/discrete_timed_data/conjunction.hpp"
#include "reelay/settings/discrete_timed_data/disjunction.hpp"
#include "reelay/settings/discrete_timed_data/implication.hpp"
#include "reelay/settings/discrete_timed_data/negation.hpp"
#include "reelay/settings/discrete_timed_data/past_always.hpp"
#include "reelay/settings/discrete_timed_data/past_sometime.hpp"
#include "reelay/settings/discrete_timed_data/previous.hpp"
#include "reelay/settings/discrete_timed_data/since.hpp"
#include "reelay/settings/discrete_timed_data/past_always_bounded.hpp"
#include "reelay/settings/discrete_timed_data/past_sometime_bounded.hpp"
#include "reelay/settings/discrete_timed_data/since_bounded.hpp"
#include "reelay/settings/discrete_timed_data/past_always_bounded_half.hpp"
#include "reelay/settings/discrete_timed_data/past_sometime_bounded_half.hpp"
#include "reelay/settings/discrete_timed_data/since_bounded_half.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct factory {
using input_t = X;
using time_t = T;
using value_t = reelay::data_set_t;
using output_t = reelay::data_set_t;
using function_t = std::function<output_t(const input_t&)>;
using interval = reelay::interval<time_t>;
using interval_set = reelay::interval_set<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
using node_t = reelay::discrete_timed_node<output_t, time_t>;
using state_t = reelay::discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
// constexpr static output_t top = std::numeric_limits<output_t>::max();
// constexpr static output_t bottom = -std::numeric_limits<output_t>::max();
static node_ptr_t make_node(const std::string &name, const kwargs &kw) {
node_ptr_t result;
if (name == "disjunction") {
result = std::make_shared<disjunction<input_t, time_t>>(kw);
} else if (name == "conjunction") {
result = std::make_shared<conjunction<input_t, time_t>>(kw);
} else if (name == "negation") {
result = std::make_shared<negation<input_t, time_t>>(kw);
} else if (name == "implication") {
result = std::make_shared<implication<input_t, time_t>>(kw);
} else if (name == "exists") {
result = std::make_shared<exists<input_t, time_t>>(kw);
} else if (name == "forall") {
result = std::make_shared<forall<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the discrete timed data setting");
}
return result;
}
static state_ptr_t make_state(const std::string &name, const kwargs &kw) {
state_ptr_t result;
if (name == "atomic_map") {
result = std::make_shared<atomic_map<input_t, time_t>>(kw);
} else if (name == "mapping_prop") {
result = std::make_shared<atomic_prop<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_false") {
result = std::make_shared<atomic_false<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_true") {
result = std::make_shared<atomic_true<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_string") {
result =
std::make_shared<atomic_string<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_number") {
result =
std::make_shared<atomic_number<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_eq") {
result =
std::make_shared<atomic_number<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_ne") {
result = std::make_shared<atomic_ne<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_ge") {
result = std::make_shared<atomic_ge<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_gt") {
result = std::make_shared<atomic_gt<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_le") {
result = std::make_shared<atomic_le<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_lt") {
result = std::make_shared<atomic_lt<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_any") {
result = std::make_shared<atomic_any<input_t, time_t, std::string>>(kw);
} else if (name == "mapping_ref") {
result = std::make_shared<atomic_ref<input_t, time_t, std::string>>(kw);
} else if (name == "listing_false") {
result = std::make_shared<atomic_false<input_t, time_t, int>>(kw);
} else if (name == "listing_true") {
result = std::make_shared<atomic_true<input_t, time_t, int>>(kw);
} else if (name == "listing_string") {
result = std::make_shared<atomic_string<input_t, time_t, int>>(kw);
} else if (name == "listing_number") {
result = std::make_shared<atomic_number<input_t, time_t, int>>(kw);
} else if (name == "listing_eq") {
result = std::make_shared<atomic_number<input_t, time_t, int>>(kw);
} else if (name == "listing_ne") {
result = std::make_shared<atomic_ne<input_t, time_t, int>>(kw);
} else if (name == "listing_ge") {
result = std::make_shared<atomic_ge<input_t, time_t, int>>(kw);
} else if (name == "listing_gt") {
result = std::make_shared<atomic_gt<input_t, time_t, int>>(kw);
} else if (name == "listing_le") {
result = std::make_shared<atomic_le<input_t, time_t, int>>(kw);
} else if (name == "listing_lt") {
result = std::make_shared<atomic_lt<input_t, time_t, int>>(kw);
} else if (name == "listing_any") {
result = std::make_shared<atomic_any<input_t, time_t, int>>(kw);
} else if (name == "listing_ref") {
result = std::make_shared<atomic_ref<input_t, time_t, int>>(kw);
} else if (name == "previous") {
result = std::make_shared<previous<input_t, time_t>>(kw);
} else if (name == "past_sometime") {
result = std::make_shared<past_sometime<input_t, time_t>>(kw);
} else if (name == "past_always") {
result = std::make_shared<past_always<input_t, time_t>>(kw);
} else if (name == "since") {
result = std::make_shared<since<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded") {
result = std::make_shared<past_sometime_bounded<input_t, time_t>>(kw);
} else if (name == "past_always_bounded") {
result = std::make_shared<past_always_bounded<input_t, time_t>>(kw);
} else if (name == "since_bounded") {
result = std::make_shared<since_bounded<input_t, time_t>>(kw);
} else if (name == "past_sometime_bounded_half") {
result =
std::make_shared<past_sometime_bounded_half<input_t, time_t>>(kw);
} else if (name == "past_always_bounded_half") {
result = std::make_shared<past_always_bounded_half<input_t, time_t>>(kw);
} else if (name == "since_bounded_half") {
result = std::make_shared<since_bounded_half<input_t, time_t>>(kw);
} else {
throw std::invalid_argument(
"Unsupported operator for the discrete timed data setting");
}
return result;
}
};
} // namespace discrete_timed_robustness_setting
} // namespace reelay
| 8,527
|
C++
|
.h
| 169
| 45.970414
| 80
| 0.669506
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,812
|
past_always.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/past_always.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "reelay/common.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct past_always final : public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
data_mgr_t manager;
output_t value;
node_ptr_t first;
explicit past_always(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args)
: manager(mgr), value(mgr->one()), first(args[0]) {}
explicit past_always(const kwargs &kw)
: past_always(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args"))) {}
void update(const input_t &, time_t now) { value *= first->output(now); }
output_t output(time_t) { return value; }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 1,481
|
C++
|
.h
| 37
| 36.162162
| 80
| 0.682739
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,813
|
past_always_bounded.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/past_always_bounded.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <vector>
#include "reelay/common.hpp"
#include "reelay/intervals.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T>
struct past_always_bounded final
: public discrete_timed_state<X, data_set_t, T> {
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
using node_t = discrete_timed_node<output_t, time_t>;
using state_t = discrete_timed_state<input_t, output_t, time_t>;
using node_ptr_t = std::shared_ptr<node_t>;
using state_ptr_t = std::shared_ptr<state_t>;
using interval = reelay::interval<time_t>;
using interval_map = reelay::data_interval_map<time_t>;
data_mgr_t manager;
interval_map value = interval_map();
node_ptr_t first;
time_t lbound;
time_t ubound;
past_always_bounded(const data_mgr_t &mgr,
const std::vector<node_ptr_t> &args, time_t l = 0,
time_t u = 0)
: manager(mgr), first(args[0]), lbound(l), ubound(u) {
value.add(std::make_pair(
interval::closed(-reelay::infinity<time_t>::value(), lbound),
mgr->one()));
}
explicit past_always_bounded(const kwargs &kw)
: past_always_bounded(
reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<std::vector<node_ptr_t>>(kw.at("args")),
reelay::any_cast<time_t>(kw.at("lbound")),
reelay::any_cast<time_t>(kw.at("ubound"))) {}
void update(const input_t &, time_t now) {
value.add(std::make_pair(
reelay::interval<time_t>::closed(now + lbound, now + ubound),
~first->output(now)));
value -= interval_map(std::make_pair(
reelay::interval<time_t>::right_open(0, now), manager->zero()));
}
output_t output(time_t now) { return ~value(now); }
};
} // namespace discrete_timed_data_setting
} // namespace reelay
| 2,238
|
C++
|
.h
| 58
| 33.724138
| 72
| 0.656654
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,814
|
atomic_true.hpp
|
doganulus_reelay/include/reelay/settings/discrete_timed_data/atomic_true.hpp
|
/*
* Copyright (c) 2019-2023 Dogan Ulus
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <memory>
#include <vector>
#include "reelay/common.hpp"
#include "reelay/datafield.hpp"
#include "reelay/networks/basic_structure.hpp"
#include "reelay/unordered_data.hpp"
namespace reelay {
namespace discrete_timed_data_setting {
template <typename X, typename T, typename K = std::string>
struct atomic_true final : public discrete_timed_state<X, data_set_t, T> {
using key_t = K;
using time_t = T;
using input_t = X;
using value_t = data_set_t;
using output_t = data_set_t;
data_mgr_t manager;
data_set_t value;
key_t key;
explicit atomic_true(const data_mgr_t &mgr, const key_t &key)
: manager(mgr), value(mgr->zero()), key(key) {}
explicit atomic_true(const kwargs &kw)
: atomic_true(reelay::any_cast<data_mgr_t>(kw.at("manager")),
reelay::any_cast<key_t>(kw.at("key"))) {}
void update(const input_t &args, time_t now) override {
if (not datafield<input_t>::contains(args, key)) {
return; // Do nothing if the key does not exist - existing value persists
}
bool new_data = datafield<input_t>::as_bool(args, key);
if (new_data) {
value = manager->one();
} else {
value = manager->zero();
}
}
output_t output(time_t) override { return value; }
};
} // namespace untimed_setting
} // namespace reelay
| 1,590
|
C++
|
.h
| 46
| 30.934783
| 79
| 0.677778
|
doganulus/reelay
| 33
| 5
| 3
|
MPL-2.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.