CDT++
Causal Dynamical Triangulations in C++
Loading...
Searching...
No Matches
Move_always.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 Causal Dynamical Triangulations in C++ using CGAL
3
4 Copyright © 2017 Adam Getchell
5 ******************************************************************************/
6
13
14#ifndef INCLUDE_MOVE_ALWAYS_HPP_
15#define INCLUDE_MOVE_ALWAYS_HPP_
16
17#include "Move_command.hpp"
18#include "Move_strategy.hpp"
19
21template <typename ManifoldType>
22class MoveStrategy<Strategies::MOVE_ALWAYS, ManifoldType> // NOLINT
23{
25
29 Int_precision m_passes{1};
30
34 Int_precision m_checkpoint{1};
35
38
41
45
46 public:
48 MoveStrategy() = default;
49
53 [[maybe_unused]] MoveStrategy(Int_precision const t_number_of_passes,
54 Int_precision const t_checkpoint)
55 : m_passes{t_number_of_passes}, m_checkpoint{t_checkpoint}
56 {}
57
59 [[nodiscard]] auto passes() const { return m_passes; }
60
62 [[nodiscard]] auto checkpoint() const { return m_checkpoint; }
63
65 auto get_attempted() const { return m_attempted_moves; }
66
68 auto get_succeeded() const { return m_successful_moves; }
69
71 auto get_failed() const { return m_failed_moves; }
72
74 auto operator()(ManifoldType const& t_manifold) -> ManifoldType
75 {
76#ifndef NDEBUG
77 spdlog::debug("{} called.\n", __PRETTY_FUNCTION__);
78#endif
79 fmt::print("Starting Move Always algorithm in {}+1 dimensions ...\n",
80 ManifoldType::dimension - 1);
81
82 // Start the move command
83 MoveCommand command(t_manifold);
84
85 fmt::print("Making random moves ...\n");
86
87 // Loop through passes
88 for (auto pass_number = 1; pass_number <= m_passes; ++pass_number)
89 {
90 fmt::print("=== Pass {} ===\n", pass_number);
91 auto total_simplices_this_pass = command.get_const_results().N3();
92 // Make a random move per simplex
93 for (auto move_attempt = 0; move_attempt < total_simplices_this_pass;
94 ++move_attempt)
95 {
96 // Pick a move to attempt
97 auto move_choice = utilities::generate_random_int(
98 0, move_tracker::moves_per_dimension(ManifoldType::dimension) - 1);
99#ifndef NDEBUG
100 fmt::print("Move choice = {}\n", move_choice);
101#endif
102 if (move_choice == 0 && ManifoldType::dimension == 3)
103 {
104 command.enqueue(move_tracker::move_type::TWO_THREE);
105 }
106
107 if (move_choice == 1 && ManifoldType::dimension == 3)
108 {
109 command.enqueue(move_tracker::move_type::THREE_TWO);
110 }
111
112 if (move_choice == 2 && ManifoldType::dimension == 3)
113 {
114 command.enqueue(move_tracker::move_type::TWO_SIX);
115 }
116
117 if (move_choice == 3 && ManifoldType::dimension == 3)
118 {
119 command.enqueue(move_tracker::move_type::SIX_TWO);
120 }
121
122 if (move_choice == 4 && ManifoldType::dimension == 3)
123 {
124 command.enqueue(move_tracker::move_type::FOUR_FOUR);
125 }
126 }
127 command.execute();
128 // Update attempted, successful, and failed moves
129 m_attempted_moves += command.get_attempted();
130 m_successful_moves += command.get_succeeded();
131 m_failed_moves += command.get_failed();
132 }
133 return command.get_results();
134 }
135
138 {
139 if (ManifoldType::dimension == 3)
140 {
141 fmt::print("=== Move Results ===\n");
142 fmt::print("(2,3) moves: {} attempted = {} successful and {} failed.\n",
143 m_attempted_moves.two_three_moves(),
144 m_successful_moves.two_three_moves(),
145 m_failed_moves.two_three_moves());
146 fmt::print("(3,2) moves: {} attempted = {} successful and {} failed.\n",
147 m_attempted_moves.three_two_moves(),
148 m_successful_moves.three_two_moves(),
149 m_failed_moves.three_two_moves());
150 fmt::print("(2,6) moves: {} attempted = {} successful and {} failed.\n",
151 m_attempted_moves.two_six_moves(),
152 m_successful_moves.two_six_moves(),
153 m_failed_moves.two_six_moves());
154 fmt::print("(6,2) moves: {} attempted = {} successful and {} failed.\n",
155 m_attempted_moves.six_two_moves(),
156 m_successful_moves.six_two_moves(),
157 m_failed_moves.six_two_moves());
158 fmt::print("(4,4) moves: {} attempted = {} successful and {} failed.\n",
159 m_attempted_moves.four_four_moves(),
160 m_successful_moves.four_four_moves(),
161 m_failed_moves.four_four_moves());
162 }
163 }
164};
165
166using MoveAlways_3 =
168using MoveAlways_4 =
170
171#endif // INCLUDE_MOVE_ALWAYS_HPP_
Do ergodic moves using the Command pattern.
Template class for move algorithms (strategies) on manifolds.
Strategies
The algorithms available to make ergodic moves on triangulations.
std::int_fast32_t Int_precision
Definition: Settings.hpp:31
void execute()
Execute all moves in the queue on the manifold.
auto get_attempted() const -> Counter const &
Attempted moves by MoveCommand.
auto get_results() -> ManifoldType &
Results of the moves invoked by MoveCommand.
auto get_failed() const -> Counter const &
Failed moves by MoveCommand.
auto get_succeeded() const
Successful moves by MoveCommand.
auto get_const_results() const -> ManifoldType const &
A read-only reference to the manifold.
void enqueue(move_tracker::move_type const t_move)
Push a Pachner move onto the move queue.
Counter m_successful_moves
The number of moves that succeeded in the MoveCommand.
Definition: Move_always.hpp:40
auto operator()(ManifoldType const &t_manifold) -> ManifoldType
Call operator.
Definition: Move_always.hpp:74
MoveStrategy(Int_precision const t_number_of_passes, Int_precision const t_checkpoint)
Constructor for MoveAlways.
Definition: Move_always.hpp:53
Counter m_attempted_moves
The number of moves that were attempted by a MoveCommand.
Definition: Move_always.hpp:37
Counter m_failed_moves
The number of moves that a MoveCommand failed to make due to an error.
Definition: Move_always.hpp:44
Select a move algorithm.
The data and methods to track ergodic moves.
auto two_six_moves() -> auto &
Write access to (2,6) moves.
auto four_four_moves() -> auto &
Write access to (4,4) moves.
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.