home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / SOLVE / CSP.H < prev    next >
C/C++ Source or Header  |  1996-01-05  |  23KB  |  679 lines

  1. /****************************************************************************
  2.     $Id: csp.h 501.0 1995/03/07 12:26:54 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:    Ron van der Wal
  8.  
  9.     Declarations for the basic classes that are used in CSP programming. The
  10.     file combines these declarations since they are mutually dependent. The
  11.     following classes are declared:
  12.  
  13.     TLConstraint    - abstract base class that represents a constraint
  14.                   in a CSP.
  15.     TLNodeCon        - represents a unary constraint on a variable
  16.     TLBinCon        - represents a binary constraint
  17.     TLDomain        - base class for copies of variable domains
  18.     TLVariable        - defines the behaviour of variables in a constraint
  19.                     propagation framework.
  20.     TLDomainMonitor    - stores domains of variables that are changed
  21.     TLPropagator    - base class for propagation algorithms
  22.     TLPropagatorAC3    - implements AC-3 algorithm
  23.     TLPropagatorFC    - implements forward-checking algorithm
  24.  
  25.     $Log: csp.h $
  26.     Revision 501.0  1995/03/07 12:26:54  RON
  27.     Updated for TLX 5.01
  28.     Revision 1.8  1995/02/22 12:18:38  RON
  29.     Update for release 012
  30.     Added partial support for SunPro C++ compiler
  31.     Revision 1.7  1995/01/13  15:26:02  ron
  32.     Switched from Constraint activation flag to activation count
  33.     Added activation count to debug version of Variable
  34.  
  35.     Revision 1.6  1995/01/12  13:34:01  ron
  36.     Small formatting change
  37.  
  38.     Revision 1.5  1995/01/08  11:51:19  ron
  39.     Renamed TLCSProblem to TLCSSubProblem
  40.  
  41.     Revision 1.4  1995/01/05  15:36:34  ron
  42.     Naming changes
  43.  
  44.     Revision 1.3  1994/11/16  15:31:00  ron
  45.     Added Propagate() member function
  46.  
  47.     Revision 1.2  1994/10/07  17:10:54  ron
  48.     Changed Unregister...() to Deregister...()
  49.  
  50.     Revision 1.1  1994/10/06  17:52:42  ron
  51.     Initial revision
  52.  
  53. ****************************************************************************/
  54.  
  55. #ifndef _TLX_CSP_H
  56. #define _TLX_CSP_H
  57.  
  58. //-----    System headers
  59.  
  60. #include <stdarg.h>
  61.  
  62. //-----    Project headers
  63.  
  64. #ifndef _TLX_ARRAYS_H
  65. #include <tlx\501\arrays.h>
  66. #endif
  67. #ifndef _TLX_ASSOC_H
  68. #include <tlx\501\assoc.h>
  69. #endif
  70. #ifndef _TLX_PTRARRAY_H
  71. #include <tlx\501\ptrarray.h>
  72. #endif
  73.  
  74. //-----    Auxiliary types and forward declarations
  75.  
  76. class _TLXCLASS TLProblemState;    // In searcher.h
  77. class _TLXCLASS TLConstraint;
  78. class _TLXCLASS TLVariable;
  79. class _TLXCLASS TLPropagator;
  80.  
  81. typedef TLPtrSeq<TLVariable>     TLVarList;         // List of variables
  82. typedef TLPtrSeq<TLConstraint>    TLConstraintList;   // List of constraints
  83.  
  84. /*---------------------------------------------------------------------------
  85.     TLConstraint -
  86.  
  87.     Abstract base class for all constraint types.
  88. ---------------------------------------------------------------------------*/
  89.  
  90. class _TLXCLASS TLConstraint
  91. {
  92.     static int32    sCheckCount;    // Number of constraint checks
  93.     int            mDeactiveCount;    // Number of deactivations
  94.  
  95. public:
  96.     virtual ~TLConstraint();
  97.  
  98.     // Propagation function: PropagateCond() is called to propagate the
  99.     // effects of the constraint. It will call the implementation-dependent
  100.     // Propagate() function, but only if the constraint is active.
  101.     //
  102.     // The other functions change and check the activation status of the
  103.     // constraint. All constraints start out active.
  104.  
  105.     bool        PropagateCond(TLVariable *);
  106.     void        Activate();
  107.     void        Deactivate();
  108.     bool        IsActive() const;
  109.  
  110.     // Functions to interrogate and update the constraint check count
  111.  
  112.     static int32    CheckCount();
  113.     static void        ResetCount();
  114.  
  115.     // Output operators
  116.  
  117.     virtual ostream &    PrintOn(ostream &aStream) const = 0;
  118.     friend ostream &     _TLXFUNC operator <<(ostream &, const TLConstraint &);
  119.  
  120. protected:
  121.     TLConstraint();
  122.  
  123.     // Derived classes should call the following function whenever they
  124.     // perform a constraint check.
  125.  
  126.     static void        CountCheck();
  127.  
  128. private:
  129.     // Propagate() is the constraint revision function that implements
  130.     // constraint-specific behavior. It must return nonzero if the revision
  131.     // succeeds, else zero (= constraint violated).
  132.  
  133.     virtual bool     Propagate(TLVariable *) = 0;
  134. };
  135.  
  136. /*---------------------------------------------------------------------------
  137.     TLNodeCon -
  138.  
  139.     Abstract base class for unary constraints.
  140. ---------------------------------------------------------------------------*/
  141.  
  142. class _TLXCLASS TLNodeCon: public TLConstraint
  143. {
  144.     TLVariable &    mVar;
  145.  
  146. public:
  147.     TLNodeCon(TLVariable &);
  148.  
  149.     // Functions to notify the variable involved in the constraint of
  150.     // our presence.
  151.  
  152.     void         WatchVar();
  153.     void         UnwatchVar();
  154.  
  155.     // Functions to obtain references to the variable.
  156.  
  157.     TLVariable &    Var();
  158.     const TLVariable &    Var() const;
  159. };
  160.  
  161. /*---------------------------------------------------------------------------
  162.     TLBinCon -
  163.  
  164.     Abstract base class for binary constraints.
  165. ---------------------------------------------------------------------------*/
  166.  
  167. class _TLXCLASS TLBinCon: public TLConstraint
  168. {
  169.     TLVariable &    mVar1;
  170.     TLVariable &    mVar2;
  171.  
  172. public:
  173.     TLBinCon(TLVariable &, TLVariable &);
  174.  
  175.     // Functions to notify the variables involved in the constraint of
  176.     // our presence.
  177.  
  178.     void         WatchVars();
  179.     void         UnwatchVars();
  180.  
  181.     // Functions to obtain references to the variables and their opposites.
  182.  
  183.     TLVariable &    Var1();
  184.     const TLVariable &    Var1() const;
  185.     TLVariable &    Var2();
  186.     const TLVariable &    Var2() const;
  187.     TLVariable &    OppositeOf(TLVariable &);
  188.     const TLVariable &    OppositeOf(const TLVariable &) const;
  189. };
  190.  
  191. /*---------------------------------------------------------------------------
  192.     TLDomain -
  193.  
  194.     Helper class that represents the domain of a variable.
  195. ---------------------------------------------------------------------------*/
  196.  
  197. class TLDomain
  198. {
  199. public:
  200.     virtual ~TLDomain();
  201.  
  202.     // Output-related functions
  203.  
  204.     virtual ostream &    PrintOn(ostream &) const = 0;
  205.     friend ostream &     _TLXFUNC operator <<(ostream &, const TLDomain &);
  206. };
  207.  
  208. /*---------------------------------------------------------------------------
  209.     TLVariable -
  210.  
  211.     Abstract base class for all variables. Contains various notification
  212.     functions that help the TLPropagator in controlling the constraint
  213.     propagation process.
  214. ---------------------------------------------------------------------------*/
  215.  
  216. class _TLXCLASS TLVariable
  217. {
  218.     friend class _TLXCLASS TLPropagator;
  219.     friend class _TLXCLASS TLDomainMonitor;
  220.  
  221.     char *        mName;        // Descriptive name
  222.     TLProblemState *    mProblem;    // Subproblem in search tree
  223.     TLConstraintList    mConstraints;    // Constraints on this variable
  224.   #ifdef _TLXDBG
  225.     int            mDeactiveCount;    // Number of deactivations
  226.   #endif
  227.  
  228.     // In case of a propagator-controlled propagation process, a pointer to
  229.     // the active propagator is stored. There can only be one active
  230.     // propagator at a time. If this pointer is 0 when a variable attempts
  231.     // to propagate, a stand-alone propagation process is performed.
  232.  
  233.     static TLPropagator *sPropagator;    // Current propagator (if any)
  234.  
  235.     // Data member to keep track of the current state monitor. There can only
  236.     // be one state monitor at a time for all variables in existence. It may
  237.     // also be 0, in which case changes to the states of variables are not
  238.     // captured.
  239.  
  240.     static TLDomainMonitor *sDomainMonitor;
  241.  
  242.     // Data members to keep track of stand-alone constraint propagation.
  243.     // We are careful not to perform recursive propagation of changes, but
  244.     // rather to restart the pending propagation.
  245.  
  246.     bool        mIsPropagating;    // True if currently propagating
  247.     index_t        mConIndex;    // Constraint index during propagation
  248.  
  249. public:
  250.     enum DomChanges    //-----    Constants that indicate domain changes
  251.     {
  252.         kDomChange    = 0x0001,    // General domain change
  253.         kDomLower    = 0x0002,    // Lower bound raised
  254.         kDomUpper    = 0x0004,    // Upper bound lowered
  255.         kDomSingle    = 0x0008,    // Domain reduced to a single value
  256.         kDomEmpty    = 0x8000    // Domain has become empty
  257.     };
  258.  
  259. public:
  260.     TLVariable(const char *);
  261.     virtual ~TLVariable();
  262.  
  263.     const char *    GetName() const;
  264.     void        SetName(const char *);
  265.  
  266.     // Operations on the list of constraints. Clients are not allowed to
  267.     // modify the constraint list directly.
  268.  
  269.     void         AddConstraint(TLConstraint *);
  270.     void         RemoveConstraint(TLConstraint *);
  271.     void        ActivateConstraints();
  272.     void        DeactivateConstraints();
  273.   #ifdef _TLXDBG
  274.     bool        IsActive() const;
  275.   #endif
  276.  
  277.     // Accessor function for the constraint list -- read-only access
  278.  
  279.     const TLConstraintList &Constraints() const;
  280.  
  281.     // The following functions can be used to determine which variable to
  282.     // select next. DomainSize() should be overridden by derived classes
  283.     // if they have a meaningful measure for their domain size.
  284.  
  285.     virtual size_t    DomainSize() const;
  286.     size_t        ConstraintCount() const;
  287.  
  288.     // Function to propagate the changes in the variable:
  289.     //
  290.     // - PropagateChanges() performs change propagation through all
  291.     //   constraints, with guards against recursive calls to itself.
  292.  
  293.     bool        PropagateChanges();
  294.  
  295.     // The following functions are call-backs.
  296.     //
  297.     // - SaveDomain() must be called before making any changes to the
  298.     //   domain of the variable, in order to ensure that the current domain
  299.     //   can be captured for restoration later on.
  300.     //
  301.     // - RegisterChanges() must be called after changes have been made to the
  302.     //   variable, in order to allow further propagation of those changes. If
  303.     //   there currently is a propagator, it is called to register the
  304.     //   changes; else PropagateChanges() is invoked to handle the propagation.
  305.  
  306.     void        SaveDomain();
  307.     void        RegisterChanges(DomChanges = kDomChange);
  308.  
  309.     // To interface with various searching algorithms, a variable may
  310.     // optionally store a pointer to the subproblem in which it was
  311.     // instantiated. The standard class TLCSProblemState will do this
  312.     // automatically.
  313.  
  314.     TLProblemState *    GetProblem() const;
  315.     void        SetProblem(TLProblemState *);
  316.  
  317.     // Output-related functions
  318.  
  319.     virtual ostream &    PrintOn(ostream &) const = 0;
  320.     friend ostream &     _TLXFUNC operator <<(ostream &, const TLVariable &);
  321.  
  322. private:
  323.     // The following functions must be implemented in such a way as to allow
  324.     // restoration of the variable's domain. They are called by instances
  325.     // of TLDomainMonitor.
  326.     //
  327.     // - CopyDomain() should return information to allow restoration of the
  328.     //   current domain;
  329.     //
  330.     // - RestoreDomain() should use this information to restore the domain;
  331.     //   it is assumed that a single copy can be restored more than once.
  332.  
  333.     virtual TLDomain *    CopyDomain() = 0;
  334.     virtual void     RestoreDomain(const TLDomain *) = 0;
  335. };
  336.  
  337. /*---------------------------------------------------------------------------
  338.     TLDomainMonitor -
  339.  
  340.     Class that captures changes to variables. It will store the domains of
  341.     variables just before they are changed. In order to do this, it relies
  342.     on the cooperation of the variables, in particular on the
  343.     TLVariable::SaveDomain() member function, that should be called
  344.     prior to any changes to the variable.
  345.  
  346.     A given instance of TLDomainMonitor will store only one copy of
  347.     the domain of a variable (in particular, the first one), on the
  348.     assumption that later changes can be restored by reverting to the
  349.     earliest captured domain.
  350.  
  351.     TLDomainMonitor instances can be nested (i.e. a new one can be
  352.     created while older ones still exist); in that case, the most recently
  353.     created one will capture all changes.
  354. ---------------------------------------------------------------------------*/
  355.  
  356. class _TLXCLASS TLDomainMonitor
  357. {
  358.     friend class _TLXCLASS TLVariable;
  359.  
  360.     // To allow nesting of domain monitors, we store a pointer to the
  361.     // monitor that was active at the time the current instance was
  362.     // activated. In conjunction with TLVariable::sDomainMonitor, this
  363.     // implements a stack of domain monitors.
  364.  
  365.     TLDomainMonitor *    mPrevMonitor;
  366.  
  367.     // The original domains of all variables that are changed during the
  368.     // execution of a propagation algorithm are stored here.
  369.  
  370.     TLDictionary<TLVariable *, TLDomain *> mDomains;
  371.  
  372. public:
  373.     TLDomainMonitor();
  374.     virtual ~TLDomainMonitor();
  375.  
  376.     // Functions to start and stop the capturing process. Of all
  377.     // TLDomainMonitor instances, the one with the most recently
  378.     // executed StartCapturing() without a corresponding StopCapturing()
  379.     // will be the one that actually captures changes to variables.
  380.     //
  381.     // - StartCapturing() starts the capturing process; this is only allowed
  382.     //   if the monitor is not currently capturing;
  383.     //
  384.     // - StopCapturing() stops the capturing process; this is only allowed
  385.     //   if the monitor is currently capturing;
  386.     //
  387.     // - IsCapturing() returns true iff the monitor has been started and
  388.     //   not stopped yet;
  389.     //
  390.     // - IsActive() returns true iff the monitor is the topmost
  391.     //   monitor, and hence the one that is currently capturing changes
  392.     //   to the domains of variables.
  393.     //
  394.     // - DomainCount() returns the number of domains captured by the monitor
  395.  
  396.     void        StartCapturing();
  397.     void        StopCapturing();
  398.     bool        IsCapturing() const;
  399.     bool        IsActive() const;
  400.     size_t        DomainCount() const;
  401.  
  402.     // Call-back function for variables. Calling this function will
  403.     // cause the monitor to store a copy of the variable's domain, if
  404.     // it is not stored yet.
  405.  
  406.     void        CaptureDomain(TLVariable *);
  407.  
  408.     // Utility functions that operate on the domains captured so far:
  409.     //
  410.     // - RestoreDomains() will restore the domains of all variables
  411.     //   that were captured;
  412.     //
  413.     // - DiscardDomains() will forget all captured information, without
  414.     //   restoring any domains.
  415.  
  416.     void         RestoreDomains();
  417.     void        DiscardDomains();
  418.  
  419. private:
  420.     // Helper function to unregister the monitor with the variables.
  421.  
  422.     void        DeregisterMonitor();
  423. };
  424.  
  425. /*---------------------------------------------------------------------------
  426.     TLPropagator -
  427.  
  428.     Base class for various constraint propagation classes.
  429. ---------------------------------------------------------------------------*/
  430.  
  431. class _TLXCLASS TLPropagator
  432. {
  433.     friend class _TLXCLASS TLVariable;
  434.  
  435.     TLPropagator *    mPrevProp;    // Previously active propagator
  436.     TLConstraint *    mFailed;    // First constraint that failed
  437.  
  438. public:
  439.     struct _TLXCLASS Stats
  440.     {
  441.     int32        mCheckCount;    // Total number of value checks
  442.     int32        mMaxPending;    // Maximum # pending constraints
  443.     };
  444.  
  445. protected:
  446.     Stats        mStats;        // Propagation statistics
  447.  
  448. public:
  449.     virtual ~TLPropagator();
  450.  
  451.     // Functions to manipulate the statistics gathered so far.
  452.  
  453.     void        GetStats(Stats &) const;
  454.     void        ClearStats();
  455.  
  456.     // Standard propagation interface:
  457.     //
  458.     // - Propagate(TLVariable *) propagates the effects of the domain of the
  459.     //   given variable to all reachable variables according to the
  460.     //   propagation algorithm under consideration.
  461.     //
  462.     // - Propagate(TLPtrIter<TLVariable> &) propagates the effects of all
  463.     //   variables accessible from the iterator in a similar manner.
  464.  
  465.     virtual const char *Description() const = 0;
  466.     virtual bool    Propagate(TLVariable *) = 0;
  467.     virtual bool    Propagate(TLPtrIter<TLVariable> &) = 0;
  468.  
  469. protected:
  470.     TLPropagator();
  471.  
  472.     // Functions to register the propagator as the active propagator for
  473.     // constraint propagation. There can only be one propagator active at
  474.     // any time; trying to activate another one is an error.
  475.     //
  476.     // - RegisterPropagator() must be called to register the current
  477.     //   propagator as the active one, prior to the start of the propagation
  478.     //   process.
  479.     //
  480.     // - DeregisterPropagator() must be called to reverse the previous action.
  481.     //
  482.     // - IsRegistered() returns true iff the current propagator is registered.
  483.     //
  484.     // - IsActive() returns true iff the current propagator is the active
  485.     //   propagator.
  486.  
  487.     void        RegisterPropagator();
  488.     void        DeregisterPropagator();
  489.     bool        IsRegistered() const;
  490.     bool        IsActive() const;
  491.  
  492.     // The propagator will store a pointer to the first constraint that fails
  493.     // during constraint propagation. It can be retrieved by means of the
  494.     // following function. The second function is available to explicitly
  495.     // set that constraint pointer; it should not normally be used.
  496.  
  497.     TLConstraint *    GetFailedConstraint() const;
  498.     void        SetFailedConstraint(TLConstraint *);
  499.  
  500. private:
  501.     // The following function is a call-back from Variables. It must be
  502.     // called after a variable's state has been changed, in order to allow
  503.     // propagation of those changes.
  504.  
  505.     virtual void     RegisterChanges(TLVariable *) {}
  506. };
  507.  
  508. /*---------------------------------------------------------------------------
  509.     TLPropagatorAC3 -
  510.  
  511.     Class that implements the AC-3 arc consistency algorithm.
  512. ---------------------------------------------------------------------------*/
  513.  
  514. class _TLXCLASS TLPropagatorAC3: public TLPropagator
  515. {
  516.     TLPtrQueue<TLVariable> mChanges;    // Keeps track of changes to variables
  517.  
  518. public:
  519.     TLPropagatorAC3();
  520.  
  521.     // Consistency checking and constraint propagation algorithms:
  522.     //
  523.     // - CheckAC3() propagates the effects of all constraints that
  524.     //   start with any of the variables in the given set. Propagation
  525.     //   continues until an inconsistency is detected or no more changes
  526.     //   occur.
  527.     //
  528.     // - CheckAC3Set() propagates the effects of the constraints within
  529.     //   a given set of variables. Variables outside this set may be
  530.     //   affected, but this will not lead to further constraint propagation.
  531.     //
  532.     // All functions return true if the system is still consistent,
  533.     // else (inconsistency detected) they return false.
  534.  
  535.     bool         CheckAC3(TLVariable &);
  536.     bool         CheckAC3(TLPtrIter<TLVariable> &);
  537.     bool         CheckAC3Set(TLPtrIter<TLVariable> &,
  538.                         TLPtrIter<TLVariable> &);
  539.  
  540.     // Implementation of generic propagation functions. For the AC-3
  541.     // algorithm, 'reachable' variables are all variables that can be
  542.     // reached (recursively) by following constraints from variables given
  543.     // or processed.
  544.  
  545.     virtual const char *Description() const;
  546.     virtual bool    Propagate(TLVariable *);
  547.     virtual bool    Propagate(TLPtrIter<TLVariable> &);
  548.  
  549. private:
  550.     // Override of call-back function inherited from TLPropagator. It
  551.     // must be called after the state of a variable has been changed,
  552.     // in order to allow further propagation of those changes.
  553.  
  554.     virtual void     RegisterChanges(TLVariable *);
  555.  
  556.     // Helper function that implements the actual AC-3 algorithm
  557.  
  558.     bool         PerformAC3(TLPtrIter<TLVariable> &,
  559.                        TLPtrIter<TLVariable> &, bool);
  560. };
  561.  
  562. /*---------------------------------------------------------------------------
  563.     TLPropagatorFC -
  564.  
  565.     Class that implements a forward-checking propagation algorithm.
  566. ---------------------------------------------------------------------------*/
  567.  
  568. class _TLXCLASS TLPropagatorFC: public TLPropagator
  569. {
  570. public:
  571.     TLPropagatorFC();
  572.  
  573.     // Consistency checking and constraint propagation algorithms:
  574.     //
  575.     // - CheckForward() propagates the effects of the constraints that
  576.     //   originate with the given variable (only).
  577.  
  578.     bool         CheckForward(TLVariable &);
  579.  
  580.     // Implementation of generic propagation functions. For the forward
  581.     // check algorithm, only the constraints connected immediately to the
  582.     // given (set of) variable(s) are considered.
  583.  
  584.     virtual const char *Description() const;
  585.     virtual bool    Propagate(TLVariable *);
  586.     virtual bool    Propagate(TLPtrIter<TLVariable> &);
  587. };
  588.  
  589. /*---------------------------------------------------------------------------
  590.     Inline functions
  591. ---------------------------------------------------------------------------*/
  592.  
  593. //-----    TLConstraint
  594.  
  595. inline bool TLConstraint::IsActive() const
  596.     { return mDeactiveCount == 0; }
  597.  
  598. inline int32 TLConstraint::CheckCount()
  599.     { return sCheckCount; }
  600.  
  601. inline void TLConstraint::ResetCount()
  602.     { sCheckCount = 0; }
  603.  
  604. inline void TLConstraint::CountCheck()
  605.     { sCheckCount++; }
  606.  
  607. inline ostream & _TLXFUNC operator <<(ostream &os, const TLConstraint &c)
  608.     { return c.PrintOn(os); }
  609.  
  610. //-----    TLNodeCon
  611.  
  612. inline TLVariable &TLNodeCon::Var()
  613.     { return mVar; }
  614.  
  615. inline const TLVariable &TLNodeCon::Var() const
  616.     { return mVar; }
  617.  
  618. //-----    TLBinCon
  619.  
  620. inline TLVariable &TLBinCon::Var1()
  621.     { return mVar1; }
  622.  
  623. inline const TLVariable &TLBinCon::Var1() const
  624.     { return mVar1; }
  625.  
  626. inline TLVariable &TLBinCon::Var2()
  627.     { return mVar2; }
  628.  
  629. inline const TLVariable &TLBinCon::Var2() const
  630.     { return mVar2; }
  631.  
  632. //-----    TLDomain
  633.  
  634. inline ostream & _TLXFUNC operator <<(ostream &os, const TLDomain &dom)
  635.     { return dom.PrintOn(os); }
  636.  
  637. //-----    TLVariable
  638.  
  639. inline const char *TLVariable::GetName() const
  640.     { return mName; }
  641.  
  642. inline const TLConstraintList &TLVariable::Constraints() const
  643.     { return mConstraints; }
  644.  
  645. #ifdef _TLXDBG
  646. inline bool TLVariable::IsActive() const
  647.     { return mDeactiveCount == 0; }
  648. #endif
  649.  
  650. inline size_t TLVariable::DomainSize() const
  651.     { return 0; }
  652.  
  653. inline size_t TLVariable::ConstraintCount() const
  654.     { return mConstraints.Count(); }
  655.  
  656. inline TLProblemState *TLVariable::GetProblem() const
  657.     { return mProblem; }
  658.  
  659. inline void TLVariable::SetProblem(TLProblemState *aProblem)
  660.     { mProblem = aProblem; }
  661.  
  662. inline ostream & _TLXFUNC operator <<(ostream &os, const TLVariable &v)
  663.     { return v.PrintOn(os); }
  664.  
  665. //-----    TLDomainMonitor
  666.  
  667. inline size_t TLDomainMonitor::DomainCount() const
  668.     { return mDomains.Count(); }
  669.  
  670. //-----    TLPropagator
  671.  
  672. inline void TLPropagator::GetStats(Stats &s) const
  673.     { s = mStats; }
  674.  
  675. inline TLConstraint *TLPropagator::GetFailedConstraint() const
  676.     { return mFailed; }
  677.  
  678. #endif    // _TLX_CSP_H
  679.