11#ifndef CDT_PLUSPLUS_MOVECOMMAND_HPP
12#define CDT_PLUSPLUS_MOVECOMMAND_HPP
17template <
typename ManifoldType,
18 typename ExpectedType = std::expected<ManifoldType, std::string>,
19 typename FunctionType = tl::function_ref<ExpectedType(ManifoldType&)>>
22 using Queue = std::deque<move_tracker::move_type>;
139 fmt::print(
"=== Executing: Before moves ===\n");
141 fmt::print(
"===============================\n");
146 auto move_type =
m_moves.back();
160 fmt::print(
"{}\n", result.error());
169 fmt::print(
"=== After moves ===\n");
173 fmt::print(
"===================\n");
187 case move_tracker::move_type::TWO_THREE:
return ergodic_moves::do_23_move;
188 case move_tracker::move_type::THREE_TWO:
return ergodic_moves::do_32_move;
189 case move_tracker::move_type::TWO_SIX:
return ergodic_moves::do_26_move;
190 case move_tracker::move_type::SIX_TWO:
return ergodic_moves::do_62_move;
191 default:
return ergodic_moves::do_44_move;
200 if (ManifoldType::dimension == 3)
203 "There were {} attempted (2,3) moves and {} attempted (3,2) moves "
205 "attempted (2,6) moves and {} attempted (6,2) moves and {} attempted "
216 "There were {} attempted (2,4) moves and {} attempted (4,2) moves "
218 "attempted (3,3) moves and {} attempted (4,6) moves and {} attempted "
220 "moves and {} attempted (2,8) moves and {} attempted (8,2) moves.\n",
233 if (ManifoldType::dimension == 3)
236 "There were {} successful (2,3) moves and {} successful (3,2) moves "
238 "successful (2,6) moves and {} successful (6,2) moves and {} "
250 "There were {} successful (2,4) moves and {} successful (4,2) moves "
252 "successful (3,3) moves and {} successful (4,6) moves and {} "
255 "moves and {} successful (2,8) moves and {} successful (8,2) "
270 [](
auto const& value) { return value == 0; }))
272 fmt::print(
"There were no failed moves.\n");
276 if (ManifoldType::dimension == 3)
279 "There were {} failed (2,3) moves and {} failed (3,2) moves and {} "
280 "failed (2,6) moves and {} failed (6,2) moves and {} failed (4,4) "
290 "There were {} failed (2,4) moves and {} failed (4,2) moves and {} "
291 "failed (3,3) moves and {} failed (4,6) moves and {} failed (6,4) "
292 "moves and {} failed (2,8) moves and {} failed (8,2) moves.\n",
Apply Pachner moves to foliated Delaunay triangulations.
auto constexpr apply_move(ManifoldType &&t_manifold, FunctionType t_move) noexcept -> decltype(auto)
An applicative function similar to std::apply on a manifold.
Pachner moves on 2+1 dimensional foliated Delaunay triangulations.
move_type
The types of 3D ergodic moves.
void execute()
Execute all moves in the queue on the manifold.
ManifoldType m_manifold
The manifold on which to perform moves.
void reset_counters()
Reset counters.
MoveCommand(ManifoldType t_manifold)
MoveCommand ctor.
auto get_attempted() const -> Counter const &
Attempted moves by MoveCommand.
auto get_results() -> ManifoldType &
Results of the moves invoked by MoveCommand.
void print_attempts() const
Print attempted moves.
Counter m_succeeded
The counter of successful moves.
void print_errors() const
Print move errors.
auto get_failed() const -> Counter const &
Failed moves by MoveCommand.
Counter m_attempted
The counter of attempted moves.
static auto as_move_function(move_tracker::move_type const move) -> FunctionType
Execute a move function on a manifold.
auto get_succeeded() const
Successful moves by MoveCommand.
MoveCommand()=delete
Remove default ctor.
void print_successful() const
Print successful moves.
auto get_const_results() const -> ManifoldType const &
A read-only reference to the manifold.
Counter m_failed
The counter of failed moves.
Queue m_moves
The queue of moves to perform.
void enqueue(move_tracker::move_type const t_move)
Push a Pachner move onto the move queue.
Queue m_moves_to_retry
The queue of moves to retry.
auto size() const
The number of moves on the queue.
The data and methods to track ergodic moves.
auto two_six_moves() -> auto &
Write access to (2,6) moves.
auto three_three_moves() -> auto &
Write access to (3,3) moves.
auto two_eight_moves() -> auto &
Write access to (2,8) moves.
auto two_four_moves() -> auto &
Write access to (2,4) moves.
auto four_six_moves() -> auto &
Write access to (4,6) moves.
auto four_two_moves() -> auto &
Write access to (4,2) moves.
auto moves_view() const
Get a view of the moves.
auto four_four_moves() -> auto &
Write access to (4,4) moves.
auto six_four_moves() -> auto &
Write access to (6,4) moves.
auto eight_two_moves() -> auto &
Write access to (8,2) moves.
void reset()
Reset all moves counts to zero.
auto six_two_moves() -> auto &
Write access to (6,2) moves.
auto three_two_moves() -> auto &
Write access to (3,2) moves.
auto two_three_moves() -> auto &
Write access to (2,3) moves.