Regina 7.0 Calculation Engine
|
The main entry point for the tree traversal / branching algorithm to locate a single non-trivial normal surface satisfying given constraints within a 3-manifold triangulation. More...
#include <enumerate/treetraversal.h>
Public Member Functions | |
TreeSingleSoln (const Triangulation< 3 > &tri, NormalEncoding enc) | |
Creates a new object for running the tree traversal / branching algorithm to locate a non-trivial surface that satisfies the chosen constraints. More... | |
bool | find () |
Runs the tree traversal algorithm until it finds some non-trivial surface that satisfies the chosen constraints, or else proves that no such solution exists. More... | |
void | cancel () |
Cancels the current find() operation. More... | |
TreeSingleSoln (const TreeSingleSoln &)=delete | |
TreeSingleSoln & | operator= (const TreeSingleSoln &)=delete |
size_t | visited () const |
Returns the total number of nodes in the search tree that we have visited thus far in the tree traversal. More... | |
void | dumpTypes (std::ostream &out) const |
Writes the current type vector to the given output stream. More... | |
std::string | typeString () const |
Returns the current type vector in string form. More... | |
void | writeTextShort (std::ostream &out) const |
Writes a short text representation of this object to the given output stream. More... | |
NormalSurface | buildSurface () const |
Reconstructs the full normal surface that is represented by the type vector at the current stage of the search. More... | |
AngleStructure | buildStructure () const |
Reconstructs the full taut angle structure that is represented by the type vector at the current stage of the search. More... | |
void | writeTextLong (std::ostream &out) const |
A default implementation for detailed output. More... | |
std::string | str () const |
Returns a short text representation of this object. More... | |
std::string | utf8 () const |
Returns a short text representation of this object using unicode characters. More... | |
std::string | detail () const |
Returns a detailed text representation of this object. More... | |
Static Public Member Functions | |
static bool | supported (NormalEncoding enc) |
Indicates whether the given normal surface or angle structure vector encoding is supported by this tree traversal infrastructure. More... | |
Protected Member Functions | |
void | setNext (int nextType) |
Rearranges the search tree so that nextType becomes the next type that we process. More... | |
int | nextUnmarkedTriangleType (int startFrom) |
Returns the next unmarked triangle type from a given starting point. More... | |
int | feasibleBranches (int quadType) |
Determines how many different values we could assign to the given quadrilateral or angle type and still obtain a feasible system. More... | |
double | percent () const |
Gives a rough estimate as to what percentage of the way the current type vector is through a full enumeration of the search tree. More... | |
Protected Attributes | |
const LPInitialTableaux< LPConstraintNone > | origTableaux_ |
The original starting tableaux that holds the adjusted matrix of matching equations, before the tree traversal algorithm begins. More... | |
const NormalEncoding | enc_ |
The normal surface or angle structure vector encoding that we are using for our enumeration task. More... | |
const BanNone | ban_ |
Details of any banning/marking constraints that are in use. More... | |
const int | nTets_ |
The number of tetrahedra in the underlying triangulation. More... | |
const int | nTypes_ |
The total length of a type vector. More... | |
const int | nTableaux_ |
The maximum number of tableaux that we need to keep in memory at any given time during the backtracking search. More... | |
char * | type_ |
The current working type vector. More... | |
int * | typeOrder_ |
A permutation of 0,...,nTypes_-1 that indicates in which order we select types: the first type we select (at the root of the tree) is type_[typeOrder_[0]], and the last type we select (at the leaves of the tree) is type_[typeOrder_[nTypes_-1]]. More... | |
int | level_ |
The current level in the search tree. More... | |
int | octLevel_ |
The level at which we are enforcing an octagon type (with a strictly positive number of octagons). More... | |
LPData< LPConstraintNone, Integer > * | lp_ |
Stores tableaux for linear programming at various nodes in the search tree. More... | |
LPData< LPConstraintNone, Integer > ** | lpSlot_ |
Recall from above that the array lp_ stores tableaux for the current node in the search tree and all of its ancestors. More... | |
LPData< LPConstraintNone, Integer > ** | nextSlot_ |
Points to the next available tableaux in lp_ that is free to use at each level of the search tree. More... | |
size_t | nVisited_ |
Counts the total number of nodes in the search tree that we have visited thus far. More... | |
LPData< LPConstraintNone, Integer > | tmpLP_ [4] |
Temporary tableaux used by the function feasibleBranches() to determine which quadrilateral types or angle types have good potential for pruning the search tree. More... | |
The main entry point for the tree traversal / branching algorithm to locate a single non-trivial normal surface satisfying given constraints within a 3-manifold triangulation.
The constraints are passed using a combination of the template arguments LPConstraint and BanConstraint. Note that some constraint classes may cause the TreeSingleSoln class constructor to throw an exception; see the constructor documentation for details.
A common application of this algorithm is to find a surface of positive Euler characteristic, using the template argument LPConstraintEulerPositive. This is useful for tasks such as 0-efficiency testing and prime decomposition (when this is done in standard normal coordinates), and also 3-sphere recognition (when this is done in standard almost normal coordinates). Indeed, the underlying algorithm is optimised for precisely this application.
By a "non-trivial" surface, we mean that at least one triangle coordinate is zero. Philosophically this is to avoid vertex linking surfaces, though if the triangulation has more than one vertex then this takes on a different meaning. See the warning on this matter below.
Be warned that this routine does not eliminate the zero vector, and so the template argument LPConstraint should include at least one constraint that eliminates the zero vector (e.g., positive Euler characteristic). Otherwise this algorithm may simply return the zero vector, and the information gained will not be very useful.
For any given normal coordinate, this routine will always try setting that coordinate to zero before it tries setting it to non-zero. In other words, if it does find a surface satisfying the given constraints, then it is guaranteed that the set of non-zero coordinate positions will be minimal (though not necessary a global minimum). In many settings (such as when using LPConstraintEulerPositive), this guarantees that the final surface (if it exists) will be a vertex normal or almost normal surface.
The underlying algorithm is described in "A fast branching algorithm for unknot recognition with experimental polynomial-time behaviour", Burton and Ozlen, arXiv:1211.1079, and uses significant material from "A tree traversal algorithm for decision problems in knot theory and 3-manifold topology", Burton and Ozlen, Algorithmica 65:4 (2013), pp. 772-801.
To use this class, i.e., to locate a non-trivial normal or almost normal surface under the given constraints or to prove that no such surface exists, you can simply construct a TreeSingleSoln object and call find(). You can then call buildSurface() to extract the details of the surface that was found.
If you wish to enumerate all vertex surfaces in a 3-manifold triangulation (instead of finding just one), you should use the class TreeEnumeration instead.
This tree traversal can only enumerate surfaces in quadrilateral normal coordinates (NS_QUAD), standard normal coordinates (NS_STANDARD), quadrilateral-octagon almost normal coordinates (NS_AN_QUAD_OCT), or standard almost normal coordinates (NS_AN_STANDARD). For almost normal surfaces, we allow any number of octagons (including zero), but we only allow at most one octagon type in the entire triangulation. No coordinate systems other than these are supported.
The template argument IntType indicates the integer type that will be used throughout the underlying linear programming machinery. Unless you have a good reason to do otherwise, you should use the arbitrary-precision Integer class (in which integers can grow arbitrarily large, and overflow can never occur).
This class is designed to manage the execution of a significant search operation, and so it does not support copying, moving or swapping.
TreeSingleSoln_EulerPositive
. You are encouraged to look through the Regina namespace to see which combinations of constraint classes are supported under Python. In all cases, the IntType parameter is taken to be regina::Integer.
|
inline |
Creates a new object for running the tree traversal / branching algorithm to locate a non-trivial surface that satisfies the chosen constraints.
This constructor prepares the algorithm; in order to run the algorithm you should call find(), which returns true
or false
according to whether or not such a surface was found.
InvalidArgument | it was not possible to add the extra constraints from the LPConstraint template argument, due to an error which should have been preventable with the right checks in advance. Such exceptions are generated by the LPConstraint class, and so you should consult the class documentation for your chosen LPConstraint template argument to see if this is a possibility. |
InvalidArgument | it was not possible to add the extra constraints from the LPConstraint template argument, due to an error that was "genuinely" unforseeable. Again, such exceptions are generated by your chosen LPConstraint class, and you should consult its documentation to see if this is a possibility. |
tri | the triangulation in which we wish to search for a non-trivial surface. |
enc | the normal (or almost normal) surface vector encoding that we are working with. |
|
inherited |
Reconstructs the full taut angle structure that is represented by the type vector at the current stage of the search.
This routine is for use only with taut angle structures, not normal or almost normal surfaces.
There will always be a unique taut angle structure corresponding to this type vector (this follows from the preconditions below).
true
, or any time that TautEnumeration::run() calls its callback function.FailedPrecondition | we are not working with angle structure coordinates (i.e., the coordinate system passed to the TreeTraversal constructor was not NS_ANGLE). |
|
inherited |
Reconstructs the full normal surface that is represented by the type vector at the current stage of the search.
This routine is for use only with normal (or almost normal) surfaces, not taut angle structures.
If the current type vector does not represent a vertex normal surface (which may be the case when calling TreeSingleSoln::find()), then there may be many normal surfaces all represented by the same type vector; in this case there are no further guarantees about which of these normal surfaces you will get.
The surface that is returned will use the same vector encoding that was passed to the TreeTraversal class constructor.
true
, or any time that TreeEnumeration::run() calls its callback function.FailedPrecondition | we are not working with normal or almost normal surfaces (i.e., the coordinate system passed to the TreeTraversal constructor was NS_ANGLE). |
|
inline |
|
inherited |
Returns a detailed text representation of this object.
This text may span many lines, and should provide the user with all the information they could want. It should be human-readable, should not contain extremely long lines (which cause problems for users reading the output in a terminal), and should end with a final newline. There are no restrictions on the underlying character set.
|
inlineinherited |
Writes the current type vector to the given output stream.
There will be no spaces between the types, and there will be no final newline.
This routine outputs the same information that typeString() returns.
out | the output stream to which to write. |
|
protectedinherited |
Determines how many different values we could assign to the given quadrilateral or angle type and still obtain a feasible system.
This will involve solving three or four linear programs, all based on the current state of the tableaux at the current level of the search tree. These assign 0, 1, 2 and 3 to the given quadrilateral or angle type in turn (here 0 is not used for angle types), and then enforce the corresponding constraints. For quadrilateral types, we count types 0 and 1 separately as in TreeEnumeration, not merged together as in TreeSingleSoln.
quadType | the quadrilateral or angle type to examine. |
bool regina::TreeSingleSoln< LPConstraint, BanConstraint, IntType >::find | ( | ) |
Runs the tree traversal algorithm until it finds some non-trivial surface that satisfies the chosen constraints, or else proves that no such solution exists.
Note that, if a solution is found, it will have a maximal (but not necessarily maximum) set of zero coordinates, which in some settings is enough to guarantee a vertex normal surface. See the TreeSingleSoln class notes for details.
If find() does return true
, you can extract details of the corresponding surface directly from this tree enumeration object: for instance, you can dump the type vector using dumpTypes(), or you can reconstruct the full surface using buildSurface(). Be warned that this class defines the type vector in an unusual way (see the TreeSingleSoln class notes for details).
true
if we found a non-trivial solution as described in the class notes, or false
if no such solution exists.
|
inlineprotectedinherited |
Returns the next unmarked triangle type from a given starting point.
Specifically, this routine returns the first unmarked triangle type whose type number is greater than or equal to startFrom. For more information on marking, see the BanConstraintBase class notes.
This routine simply searches through types by increasing index into the type vector; in particular, it does not make any use of the reordering defined by the typeOrder_ array.
startFrom | the index into the type vector of the triangle type from which we begin searching. |
|
protectedinherited |
Gives a rough estimate as to what percentage of the way the current type vector is through a full enumeration of the search tree.
This is useful for progress tracking.
This routine only attemps to determine the percentage within a reasonable range of error (at the time of writing, 0.01%). This allows it to be more efficient (in particular, by only examining the branches closest to the root of the search tree).
|
protectedinherited |
Rearranges the search tree so that nextType becomes the next type that we process.
Specifically, this routine will set typeOrder_[level_ + 1] to nextType_, and will move other elements of typeOrder_ back by one position to make space as required.
nextType | the next type to process. |
|
inherited |
Returns a short text representation of this object.
This text should be human-readable, should use plain ASCII characters where possible, and should not contain any newlines.
Within these limits, this short text ouptut should be as information-rich as possible, since in most cases this forms the basis for the Python str()
and repr()
functions.
str()
will use precisely this function, and for most classes the Python repr()
function will incorporate this into its output.
|
inlinestaticinherited |
Indicates whether the given normal surface or angle structure vector encoding is supported by this tree traversal infrastructure.
Any restrictions imposed by LPConstraint and BanConstraint will be taken into account.
Note that, even if an encoding is supported, this does not mean that the underlying tableaux will use the same encoding internally. See LPInitialTableaux for more details on this.
enc | the vector encoding being queried. In particular, this may be the special angle structure encoding. |
true
if and only if the given vector encoding is supported.
|
inlineinherited |
Returns the current type vector in string form.
There will be no spaces between the types.
This routine returns the same information that dumpTypes() writes.
the | type vector in string form. |
|
inherited |
Returns a short text representation of this object using unicode characters.
Like str(), this text should be human-readable, should not contain any newlines, and (within these constraints) should be as information-rich as is reasonable.
Unlike str(), this function may use unicode characters to make the output more pleasant to read. The string that is returned will be encoded in UTF-8.
|
inlineinherited |
Returns the total number of nodes in the search tree that we have visited thus far in the tree traversal.
This figure might grow much faster than the number of solutions, since it also counts traversals through "dead ends" in the search tree.
This counts all nodes that we visit, including those that fail any or all of the domination, feasibility and zero tests. The precise way that this number is calculated is subject to change in future versions of Regina.
If you called an "all at once" routine such as TreeEnumeration::run() or TreeSingleSoln::find(), then this will be the total number of nodes that were visited in the entire tree traversal. If you are calling an "incremental" routine such as TreeEnumeration::next() (i.e., you are generating one solution at time), then this will be the partial count of how many nodes have been visited so far.
|
inlineinherited |
A default implementation for detailed output.
This routine simply calls T::writeTextShort() and appends a final newline.
out | the output stream to which to write. |
|
inherited |
Writes a short text representation of this object to the given output stream.
out | the output stream to which to write. |
|
protectedinherited |
Details of any banning/marking constraints that are in use.
|
protectedinherited |
The normal surface or angle structure vector encoding that we are using for our enumeration task.
Note that the tableaux will not necessarily use this same encoding; see LPInitialTableaux for details.
|
protectedinherited |
The current level in the search tree.
As the search runs, this holds the index into typeOrder_ corresponding to the last type that we chose.
|
protectedinherited |
Stores tableaux for linear programming at various nodes in the search tree.
We only store a limited number of tableaux at any given time, and as the search progresses we overwrite old tableaux with new tableaux.
More precisely, we store a linear number of tableaux, essentially corresponding to the current node in the search tree and all of its ancestores, all the way up to the root node. In addition to these tableaux, we also store other immediate children of these ancestores that we have pre-prepared for future processing. See the documentation within routines such as TreeEnumeration::next() for details of when and how these tableaux are constructed.
|
protectedinherited |
Recall from above that the array lp_ stores tableaux for the current node in the search tree and all of its ancestors.
This means we have one tableaux for the root node, as well as additional tableaux at each level 0,1,...,level_.
The array lpSlot_ indicates which element of the array lp_ holds each of these tableaux. Specifically: lpSlot_[0] points to the tableaux for the root node, and for each level i in the range 0,...,level_, the corresponding tableaux is *lpSlot_[i+1]. Again, see the documentation within routines such as TreeEnumeration::next() for details of when and how these tableaux are constructed and later overwritten.
|
protectedinherited |
Points to the next available tableaux in lp_ that is free to use at each level of the search tree.
Specifically: nextSlot_[0] points to the next free tableaux at the root node, and for each level i in the range 0,...,level_, the corresponding next free tableaux is *nextSlot_[i+1].
The precise layout of the nextSlot_ array depends on the order in which we process quadrilateral, triangle and/or angle types.
|
protectedinherited |
The maximum number of tableaux that we need to keep in memory at any given time during the backtracking search.
|
protectedinherited |
The number of tetrahedra in the underlying triangulation.
|
protectedinherited |
The total length of a type vector.
|
protectedinherited |
Counts the total number of nodes in the search tree that we have visited thus far.
This may grow much faster than the number of solutions, since it also counts traversals through "dead ends" in the search tree.
|
protectedinherited |
The level at which we are enforcing an octagon type (with a strictly positive number of octagons).
If we are working with angle structures or normal surfaces only (and so we do not allow octagons at all), then octLevel_ = nTypes_. If we are allowing almost normal surfaces but we have not yet chosen an octagon type, then octLevel_ = -1.
|
protectedinherited |
The original starting tableaux that holds the adjusted matrix of matching equations, before the tree traversal algorithm begins.
|
protectedinherited |
Temporary tableaux used by the function feasibleBranches() to determine which quadrilateral types or angle types have good potential for pruning the search tree.
Other routines are welcome to use these temporary tableaux also (as "scratch space"); however, be aware that any call to feasibleBranches() will overwrite them.
|
protectedinherited |
The current working type vector.
As the search runs, we modify this type vector in-place. Any types beyond the current level in the search tree will always be set to zero.
|
protectedinherited |
A permutation of 0,...,nTypes_-1 that indicates in which order we select types: the first type we select (at the root of the tree) is type_[typeOrder_[0]], and the last type we select (at the leaves of the tree) is type_[typeOrder_[nTypes_-1]].
This permutation is allowed to change as the algorithm runs (though of course you can only change sections of the permutation that correspond to types not yet selected).