AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
utils.h
1#ifndef PROBFD_ALGORITHMS_UTILS_H
2#define PROBFD_ALGORITHMS_UTILS_H
3
4#include "probfd/value_type.h"
5
6#include <cassert>
7#include <cstddef>
8#include <tuple>
9#include <utility>
10
11// Forward Declarations
12namespace probfd {
13struct Interval;
14}
15
16namespace probfd::algorithms {
17
22template <typename... T>
24 std::tuple<T&...> containers_;
25
26public:
27 explicit ClearGuard(T&... containers)
28 : containers_(containers...)
29 {
30 assert((containers.empty() && ...));
31 }
32
34 {
35 std::apply([](auto&... c) { (c.clear(), ...); }, containers_);
36 }
37};
38
43template <size_t n>
44struct get_t {
45 template <typename T>
46 decltype(auto) operator()(T&& t) const
47 {
48 using std::get;
49 return get<n>(std::forward<T>(t));
50 }
51};
52
53template <size_t n>
54inline constexpr get_t<n> project;
55
58
61
64
67
74bool set_min(Interval& lhs, Interval rhs);
75
81bool set_min(value_t& lhs, value_t rhs);
82
93bool update(Interval& lhs, Interval rhs, value_t epsilon = g_epsilon);
94
95// Value update
96bool update(value_t& lhs, value_t rhs, value_t epsilon = g_epsilon);
97
98} // namespace probfd::algorithms
99
100#endif
Helper RAII class that ensures that containers are cleared when going out of scope.
Definition utils.h:23
This namespace contains implementations of SSP search algorithms.
Definition acyclic_value_iteration.h:22
Interval as_interval(value_t lower_bound)
Returns the interval with the given lower bound and infinte upper bound.
bool update(Interval &lhs, Interval rhs, value_t epsilon=g_epsilon)
Intersects two intervals and assigns the result to the left operand.
bool set_min(Interval &lhs, Interval rhs)
Computes the assignments lhs.lower <- min(lhs.lower, rhs.lower) and lower <- min(lhs....
value_t as_lower_bound(Interval interval)
Returns the lower bound of the interval.
The top-level namespace of probabilistic Fast Downward.
Definition command_line.h:8
double value_t
Typedef for the state value type.
Definition aliases.h:7
value_t g_epsilon
The default tolerance value for approximate comparisons.
Represents a closed interval over the extended reals as a pair of lower and upper bound.
Definition interval.h:12
Function object calling std::get<n> on its argument. Useful in ranges algorithms.
Definition utils.h:44