LoopBodyFactory is an abstract base class used for generating instances of a predicate class used in the body of a loop. See the Loop class for details of how this is used.
More...
#include <pred.hpp>
LoopBodyFactory is an abstract base class used for generating instances of a predicate class used in the body of a loop. See the Loop class for details of how this is used.
◆ LoopBodyFactory()
| pl_search::LoopBodyFactory::LoopBodyFactory |
( |
Trail * |
trail | ) |
|
|
inline |
Constructs a LoopBodyFactory with the given trail.
- Parameters
-
| trail | Pointer to the trail. |
◆ ~LoopBodyFactory()
| virtual pl_search::LoopBodyFactory::~LoopBodyFactory |
( |
| ) |
|
|
inlinevirtual |
◆ loop_continues()
| virtual bool pl_search::LoopBodyFactory::loop_continues |
( |
int |
depth | ) |
|
|
inlinevirtual |
Determines if the loop should continue based on the current depth.
- Parameters
-
| depth | The current depth of the loop. |
- Returns
- True if the loop should continue, false otherwise.
This method is typically overridden in derived classes to implement specific loop continuation logic. By default, it returns false, indicating that the loop should not continue.
◆ make_body_pred()
| virtual PredPtr pl_search::LoopBodyFactory::make_body_pred |
( |
int |
depth | ) |
|
|
pure virtual |
Creates a new instance of the body predicate for the loop.
- Parameters
-
| depth | The current depth of the loop. |
- Returns
- A shared pointer to the newly created body predicate.
This method is pure virtual and must be implemented in derived classes to create specific body predicates for the loop. Note that the predicate constructed must satisfy the contract for predicates described in the documentation for the Pred class. The user will typically follow one of two techniques for implementing the body predicate:
- The problem constraints will be analysed to find one or more "interesting" variables and the possible choices for those variables. The body predicate will typically be a subclass of ChoicePred or VarChoicePred. loop_continues() will typically return false when all constraints are satisfied.
send_more_money.cpp in the examples directory is an example of this technique.
- The other case is where loop is treated more like
for (int depth = 0; depth < max_depth; depth++) {body;}. An example might be a 2D array of variables where the possible choices for the variables in the row at the given depth are determined. The generated body predicate will typically then be an instance of a subclass of ChoicePred.
◆ trail
| Trail* pl_search::LoopBodyFactory::trail |
The documentation for this class was generated from the following file: