![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in sims.hpp
.
This class implements Stephen's procedure for constructing the WordGraph corresponding to the left factors of a word in a finitely presented semigroup or a finitely presented inverse semigroup. The algorithm implemented in this class is closely related to the Todd-Coxeter algorithm (as implemented in ToddCoxeter) and originates in [56].
PresentationType | a type derived from PresentationBase. This is the type of the underlying presentation used in the Stephen algorithm. Common choices include Presentation<word_type>, Presentation<std::string>, InversePresentation<word_type> and InversePresentation<std::string>. If an InversePresentation is supplied, then the Stephen class will use the Stephen procedure for inverse semigroups when run. Otherwise the Stephen procedure for general semigroups is used instead. |
Public Types | |
using | node_type = word_graph_type::node_type |
The node type of word_graph_type. | |
using | presentation_type = PresentationType |
The underlying presentation type. | |
using | word_graph_type = WordGraph<uint32_t> |
The return type of the function word_graph. | |
![]() | |
enum class | state { never_run = 0 , running_to_finish = 1 , running_for = 2 , running_until = 3 , timed_out = 4 , stopped_by_predicate = 6 , not_running = 7 , dead = 8 } |
Enum class for the state of the Runner. More... | |
![]() | |
using | nanoseconds = std::chrono::nanoseconds |
Alias for std::chrono::nanoseconds. | |
using | time_point = std::chrono::high_resolution_clock::time_point |
Alias for std::chrono::high_resolution_clock::time_point. | |
Public Member Functions | |
Stephen () | |
Default constructor. | |
Stephen (PresentationType &&p) | |
Construct from a presentation (move). | |
Stephen (PresentationType const &p) | |
Construct from a presentation (copy). | |
Stephen (std::shared_ptr< PresentationType > const &ptr) | |
Construct from a shared pointer to presentation (copy). | |
Stephen (Stephen &&)=default | |
Default move constructor. | |
Stephen (Stephen const &that)=default | |
Default copy constructor. | |
node_type | accept_state () |
Get the accept state of the word graph. | |
void | append_no_checks (Stephen< PresentationType > &that) |
Append a Stephen instance (no checks). | |
Stephen & | init () |
Reinitialize an existing Stephen instance. | |
Stephen & | init (PresentationType &&p) |
Initialize from a presentation (move). | |
Stephen & | init (PresentationType const &p) |
Initialize from a presentation (copy). | |
Stephen & | init (std::shared_ptr< PresentationType > const &ptr) |
Initialize from a shared pointer to presentation (copy). | |
bool | is_word_set () const noexcept |
Check if the initial word is set. | |
void | operator*= (Stephen< PresentationType > &that) |
Append a Stephen instance. | |
Stephen & | operator= (Stephen &&)=default |
Default move assignment operator. | |
Stephen & | operator= (Stephen const &)=default |
Default copy assignment operator. | |
presentation_type const & | presentation () const noexcept |
Get the input presentation. | |
template<typename Iterator1, typename Iterator2> | |
Stephen & | set_word (Iterator1 first, Iterator2 last) |
Set the initial word. | |
template<typename Iterator1, typename Iterator2> | |
Stephen & | set_word_no_checks (Iterator1 first, Iterator2 last) |
Set the initial word (no checks). | |
word_type const & | word () const |
Get the initial word. | |
word_graph_type const & | word_graph () const |
Get the word graph. | |
![]() | |
Runner () | |
Default constructor. | |
Runner (Runner &&other) | |
Move constructor. | |
Runner (Runner const &other) | |
Copy constructor. | |
state | current_state () const noexcept |
Return the current state. | |
bool | dead () const noexcept |
Check if the runner is dead. | |
bool | finished () const |
Check if run has been run to completion or not. | |
Runner & | init () |
Initialize an existing Runner object. | |
void | kill () noexcept |
Stop run from running (thread-safe). | |
Runner & | operator= (Runner &&other) |
Move assignment operator. | |
Runner & | operator= (Runner const &other) |
Copy assignment operator. | |
void | report_why_we_stopped () const |
Report why run stopped. | |
void | run () |
Run until finished. | |
void | run_for (std::chrono::nanoseconds t) |
Run for a specified amount of time. | |
template<typename Time> | |
void | run_for (Time t) |
Run for a specified amount of time. | |
void | run_until (bool(*func)()) |
Run until a nullary predicate returns true or finished. | |
template<typename Func> | |
void | run_until (Func &&func) |
Run until a nullary predicate returns true or finished. | |
bool | running () const noexcept |
Check if currently running. | |
bool | running_for () const noexcept |
Check if the runner is currently running for a particular length of time. | |
bool | running_until () const noexcept |
Check if the runner is currently running until a nullary predicate returns true . | |
bool | started () const noexcept |
Check if run has been called at least once before. | |
bool | stopped () const |
Check if the runner is stopped. | |
bool | stopped_by_predicate () const |
Check if the runner was stopped, or should stop, because of the argument last passed to run_until. | |
virtual bool | success () const |
Check if run has been run to completion successfully. | |
bool | timed_out () const |
Check if the amount of time passed to run_for has elapsed. | |
![]() | |
Reporter () | |
Default constructor. | |
Reporter (Reporter &&that) | |
Default move constructor. | |
Reporter (Reporter const &that) | |
Default copy constructor. | |
void | emit_divider () |
Reporter & | init () |
Initialize an existing Reporter object. | |
time_point | last_report () const noexcept |
Get the time point of the last report. | |
Reporter & | operator= (Reporter &&that) |
Default move assignment operator. | |
Reporter & | operator= (Reporter const &that) |
Default copy assignment operator. | |
bool | report () const |
Check if it is time to report. | |
std::string const & | report_divider () const noexcept |
Reporter & | report_divider (std::string const &val) |
nanoseconds | report_every () const noexcept |
Get the minimum elapsed time between reports. | |
Reporter & | report_every (nanoseconds val) noexcept |
Set the minimum elapsed time between reports in nanoseconds. | |
template<typename Time> | |
Reporter & | report_every (Time t) noexcept |
Set the minimum elapsed time between reports in a unit of time other than nanoseconds. | |
std::string const & | report_prefix () const noexcept |
Get the current prefix string for reporting. | |
Reporter & | report_prefix (std::string const &val) |
Set the prefix string for reporting. | |
Reporter const & | reset_last_report () const |
Set the last report time point to now. | |
Reporter const & | reset_start_time () const |
Reset the start time (and last report) to now. | |
time_point | start_time () const noexcept |
Get the start time. | |
Static Public Member Functions | |
static constexpr node_type | initial_state () noexcept |
Get the initial state of the word graph. | |
Additional Inherited Members | |
![]() | |
static std::chrono::nanoseconds | delta (std::chrono::high_resolution_clock::time_point const &t) |
The time between a given point and now. | |
Stephen | ( | ) |
Default constructs an empty instance, use init and set_word to specify the presentation and the word, respectively.
|
inlineexplicit |
Construct an instance from the presentation p
. This constructor copies p
.
PresentationType | a type derived from PresentationBase. |
p | the presentation. |
|
inlineexplicit |
Construct an instance from the presentation p
. This constructor moves p
.
PresentationType | a type derived from PresentationBase. |
p | the presentation. |
|
inlineexplicit |
Construct an instance from the shared pointer ptr
to a shared presentation object. This constructor copies ptr
.
PresentationType | a type derived from PresentationBase. |
ptr | a shared pointer to a presentation. |
node_type accept_state | ( | ) |
This function triggers the algorithm implemented in this class (if it hasn't been triggered already), and then returns the accept state of the produced word graph.
LibsemigroupsException | if no presentation was set at the construction or with Stephen::init or if no word was set with Stephen::set_word . |
void append_no_checks | ( | Stephen< PresentationType > & | that | ) |
This function appends the Stephen instance that
to this
. This modifies the current Stephen instance in-place. The result is a Stephen instance with underlying word equal to the concatenation of this.word()
and that.word()
.
The advantage of this is that if either this
or that
have already been (partially) run, then we can reuse the underlying word graphs instead of having to recompute them completely from scratch.
that | the Stephen instance to append. |
this
and that
have different underlying presentations or if either of them is not ready.Stephen & init | ( | ) |
This function puts a Stephen instance back into the same state as if it had been newly default constructed.
this
.
|
inline |
This function puts a Stephen instance back into the same state as if it had been newly constructed from the presentation p
. This initializer moves p
.
PresentationType | a type derived from PresentationBase. |
p | the presentation. |
this
.
|
inline |
This function puts a Stephen instance back into the same state as if it had been newly constructed from the presentation p
. This initializer copies p
.
PresentationType | a type derived from PresentationBase. |
p | the presentation. |
this
. Stephen & init | ( | std::shared_ptr< PresentationType > const & | ptr | ) |
This function puts a Stephen instance back into the same state as if it had been newly constructed from the shared pointer to a presentation ptr
. This initializer copies ptr
.
PresentationType | a type derived from PresentationBase. |
ptr | a shared pointer to a presentation. |
this
.
|
inlinestaticconstexprnoexcept |
This function return the initial state of word_graph.
noexcept
and is guaranteed never to throw.
|
inlinenoexcept |
Returns true if a word has been set with set_word since the last presentation change and false otherwise.
noexcept
and is guaranteed never to throw. void operator*= | ( | Stephen< PresentationType > & | that | ) |
This function appends the Stephen instance that
to this
. This modifies the current Stephen instance in-place. The result is a Stephen instance with underlying word equal to the concatenation of this.word()
and that.word()
.
The advantage of this is that if either this
or that
have already been (partially) run, then we can reuse the underlying word graphs instead of having to recompute them completely from scratch.
that | the Stephen instance to append. |
LibsemigroupsException | if no presentation was set at the construction of this or that or with Stephen::init or if no word was set with Stephen::set_word . |
LibsemigroupsException | if the presentations for this and that differ. |
|
inlinenoexcept |
This function returns a const reference to the input presentation.
noexcept
and is guaranteed never to throw.
|
inline |
This function sets the word whose left factors, or equivalent words, are sought.
Iterator1 | the type of the argument first1 . |
Iterator2 | the type of the argument last1 . |
first | iterator pointing at the first letter of the word. |
last | iterator pointing one beyond the last letter in the word. |
this
.LibsemigroupsException | if any of the values pointed at by the iterators is out of range, i.e. they do not belong to presentation().alphabet() and Presentation::validate_word throws. |
Stephen & set_word_no_checks | ( | Iterator1 | first, |
Iterator2 | last ) |
This function sets the word whose left factors, or equivalent words, are sought.
Iterator1 | the type of the argument first1 . |
Iterator2 | the type of the argument last1 . |
first | iterator pointing at the first letter of the word. |
last | iterator pointing one beyond the last letter in the word. |
this
.presentation().alphabet()
.
|
inline |
Returns a const reference to the word set by set_word.
LibsemigroupsException | if no presentation was set at the construction or with Stephen::init or if no word was set with Stephen::set_word . |
|
inline |
Returns a const reference to the word graph in its present state. The algorithm implemented in this class is not triggered by calls to this function.
LibsemigroupsException | if no presentation was set at the construction or with Stephen::init or if no word was set with Stephen::set_word . |