10 namespace rng = std::ranges;
12 namespace Antares::Solver::Simulation
14 inline bool operator<=(
const std::vector<double>& a,
const std::vector<double>& b)
16 return a.size() == b.size()
17 && rng::all_of(std::views::iota(
size_t{0}, a.size()),
18 [&](
size_t i) {
return a[i] <= b[i]; });
21 inline bool operator<=(
const std::vector<double>& v,
const double c)
23 return rng::all_of(v, [&c](
double e) {
return e <= c; });
26 inline bool operator>=(
const std::vector<double>& v,
const double c)
28 return rng::all_of(v, [&c](
double e) {
return e >= c; });
31 inline std::vector<double> operator+(
const std::vector<double>& v,
const double c)
33 std::vector<double> to_return = v;
34 rng::for_each(to_return, [&c](
double& e) { e = e + c; });
38 inline std::vector<double> operator-(
const std::vector<double>& v,
const double c)
40 std::vector<double> to_return = v;
41 rng::for_each(to_return, [&c](
double& e) { e = e - c; });
45 inline std::vector<double> operator+(std::vector<double> a,
const std::vector<double>& b)
47 rng::transform(a, b, a.begin(), std::plus<double>());
51 inline std::vector<double> operator-(std::vector<double> a,
const std::vector<double>& b)
53 rng::transform(a, b, a.begin(), std::minus<double>());
57 inline std::vector<double> operator*(std::span<const double> left,
const double scalar)
59 std::vector<double> to_return;
60 rng::transform(left, std::back_inserter(to_return), [&](
double e) {
return e * scalar; });
64 inline double min_on_subrange(std::vector<double>&& v,
unsigned h,
unsigned H)
68 throw std::invalid_argument(
"call min_on_subrange on an empty vector");
71 if (H >= v.size() || h >= v.size())
73 throw std::invalid_argument(
"call of min_on_subrange : hour out of bound");
78 throw std::invalid_argument(
"call min_on_subrange with inconsistant hours");
81 std::span<double> subset(v.begin() + h, v.begin() + H);
82 return *std::ranges::min_element(subset);
85 inline double sum(
const std::vector<double>& v)
87 return std::accumulate(v.begin(), v.end(), 0.);
97 bool operator==(
const std::vector<T>::iterator& other)
const;
103 void back_to_begin();
106 std::vector<T>::iterator it_;
117 CyclicIterator<T>& CyclicIterator<T>::operator++(
int)
125 T& CyclicIterator<T>::operator*()
131 bool CyclicIterator<T>::operator==(
const typename std::vector<T>::iterator& other)
const
137 void CyclicIterator<T>::back_to_begin()
146 CyclicIterator<T>& delete_current(CyclicIterator<T>& cyclicIt)
148 cyclicIt.it_ = cyclicIt.v_.erase(cyclicIt.it_);
149 cyclicIt.back_to_begin();
Definition: remix-utils.h:92