A Definition Class for Real-Interval Constraints

The class RIDefinition is derived from the CPI class OZ_CtDefinition. It gathers all information needed to handle real-interval constraints properly by the runtime system. It allows the runtime system to distinguish real-interval constraint from other constraints by calling the member function getKind(). Note that _kind is static and to obtain a unique identifier the function OZ_getUniqueId() is recommended to be used. For testing Oz values to be compatible with real-intervals isValidValue(), is to be defined appropriately.

Further, RIDefinition allows the runtime system to determine the number of possible events causing suspending computation to be woken up. There are two possible events for which a suspending computation may want to be notified: the lower bound is increased or the upper bound is decreased (or both). Therefore, two wake-up lists are used (see getNoOfWakeUpLists()).

class RIDefinition : public OZ_CtDefinition {
private:
  static int _kind;  
 
public:  
  virtual int getKind(void) { return _kind; }
  virtual char * getName(void) { return "real interval"; }
  virtual int getNoOfWakeUpLists(void) { return 2; }
  virtual char ** getNamesOfWakeUpLists(void) {
    static char * names[2] = {"lower""upper"};
    return names;
  }
  virtual OZ_Ct * leastConstraint(void) {
    return RI::leastConstraint();
  }
  virtual OZ_Boolean isValidValue(OZ_Term f) {
    return RI::isValidValue(f);
  }                                   
};
 
int RIDefinition::_kind = OZ_getUniqueId();

The function leastConstraint() is required to enable the runtime system to constrain a variable to a real-interval with greatest possible width, i. e., ranging from RI_FLOAT_MIN to RI_FLOAT_MAX. For example this is necessary when nested variables are to be constrained.


Tobias Müller
Version 1.4.0 (20080702)