- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/ProbabilityRules/Rule.cpp

    00001 //==============================================================================
    00002 // Copyright (c) 2005           Model-based Embedded and Robotic Systems Group
    00003 // All Rights Reserved          Massachusetts Institute of Technology
    00004 //
    00005 // This software is provided as is. Model-based Embedded and Robotic Systems
    00006 // (MERS) group does not assume any responsibility.
    00007 //==============================================================================
    00008
    00009 #include "Rule.h"
    00010
    00011 #ifdef _MSC_VER
    00012 #pragma warning( disable : 4786 )
    00013 #endif
    00014
    00015 #include <Mers/Models/Base/BaseModelAssignmentArray.h>
    00016
    00017 using namespace Mers::Estimation::Discrete::ProbabilityRules;
    00018 using Mers::Models::Base::BaseModelAssignmentArray;
    00019 using std::ostream;
    00020
    00021
    00022         //-----------------------------------------------
    00023         //      CONSTRUCTOR
    00024         //-----------------------------------------------
    00025
    00026
    00027 Rule::Rule(const Mers::Models::Base::BaseModelAssignmentArray * myAssigmentArray,
    00028                 unsigned short db)
    00029 : ruleAssignments(myAssigmentArray), debug(db)
    00030 {
    00031         numNotSatisfied = (int) ruleAssignments->getLength();
    00032 }
    00033         //-----------------------------------------------
    00034         //      DESTRUCTOR
    00035         //-----------------------------------------------
    00036
    00037
    00038 Rule::~Rule()
    00039 {
    00040         delete ruleAssignments;
    00041 }
    00042
    00043
    00044
    00045         //-----------------------------------------------
    00046         //      PUBLIC METHODS
    00047         //-----------------------------------------------
    00048
    00049 void
    00050 Rule::reset(void)
    00051 {
    00052         numNotSatisfied = (int) ruleAssignments->getLength();
    00053         return;
    00054 }
    00055
    00056 bool
    00057 Rule::increment(void)
    00058 {
    00059         if(numNotSatisfied == 0)
    00060                 return false;
    00061
    00062         numNotSatisfied--;
    00063         return true;
    00064 }
    00065
    00066
    00067 unsigned int
    00068 Rule::getNumberSatisfied(void) const
    00069 {
    00070         return ruleAssignments->getLength() - (unsigned int)numNotSatisfied;
    00071 }
    00072
    00073
    00074 unsigned int
    00075 Rule::getNumberNotSatisfied(void) const
    00076 {
    00077         return (unsigned int)numNotSatisfied;
    00078 }
    00079
    00080 const BaseModelAssignmentArray *
    00081 Rule::getAllAssignments(void) const
    00082 {
    00083         return ruleAssignments;
    00084 }
    00085
    00086
    00087 bool
    00088 Rule::isTriggered(void) const
    00089 {
    00090         if(numNotSatisfied == 0)
    00091                 return true;
    00092
    00093         return false;
    00094 }
    00095
    00096
    00097 void
    00098 Rule::setDebug(const unsigned short db)
    00099 {
    00100         debug = db;
    00101         return;
    00102 }
    00103
    00104
    00105 ostream&
    00106 Mers::Estimation::Discrete::ProbabilityRules::operator<<(ostream& os, Rule const & r)
    00107 {
    00108         if(r.debug > 0)
    00109                 os << r.ruleAssignments->getLength() - r.numNotSatisfied << " of " << r.ruleAssignments->getLength() << " : ";
    00110         os << "rule : " << *(r.ruleAssignments);
    00111
    00112         return os;
    00113 }
    00114         //-----------------------------------------------
    00115         //      PRIVATE METHODS
    00116         //-----------------------------------------------
    00117