pl_search_cpp 2.2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
pl_search::LoopBodyFactory Class Referenceabstract

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>

Collaboration diagram for pl_search::LoopBodyFactory:
Collaboration graph
[legend]

Public Member Functions

 LoopBodyFactory (Trail *trail)
 Constructs a LoopBodyFactory with the given trail.
 
virtual ~LoopBodyFactory ()
 
virtual bool loop_continues (int depth)
 Determines if the loop should continue based on the current depth.
 
virtual PredPtr make_body_pred (int depth)=0
 Creates a new instance of the body predicate for the loop.
 

Public Attributes

Trailtrail
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ LoopBodyFactory()

pl_search::LoopBodyFactory::LoopBodyFactory ( Trail trail)
inline

Constructs a LoopBodyFactory with the given trail.

Parameters
trailPointer to the trail.

◆ ~LoopBodyFactory()

virtual pl_search::LoopBodyFactory::~LoopBodyFactory ( )
inlinevirtual

Member Function Documentation

◆ loop_continues()

virtual bool pl_search::LoopBodyFactory::loop_continues ( int  depth)
inlinevirtual

Determines if the loop should continue based on the current depth.

Parameters
depthThe 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
depthThe 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:

  1. 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.
  2. 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.

Member Data Documentation

◆ trail

Trail* pl_search::LoopBodyFactory::trail

The documentation for this class was generated from the following file: