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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Estimation::Discrete::ModeEstimation::ModeEstimator Class Reference

`#include <ModeEstimator.h>`

Inheritance diagram for Mers::Estimation::Discrete::ModeEstimation::ModeEstimator:

[legend]
Collaboration diagram for Mers::Estimation::Discrete::ModeEstimation::ModeEstimator:

[legend]
List of all members.

## Public Member Functions
| ModeEstimator (const Mers::Models::CCA::CCAModel &cca, Mers::Estimation::Discrete::Trajectories *initialTrajectories=NULL)
virtual | ~ModeEstimator ()
void | setDebug (const unsigned short db)
## Protected Member Functions
virtual bool | generateTrajectories (void)
virtual const Mers::Models::Base::BaseModelAssignmentArray * | generateBestSolution (unsigned int generatorNum, long int maximumVisitedNodeCount, long int maxQueueSize)
virtual bool | addEstimate (Mers::Estimation::Discrete::Estimate *theEst, Mers::Estimation::Discrete::EstimateHeap *nextTrajsEstHeap=NULL)
virtual bool | releaseMemoryAndNormalize (Mers::Models::Base::BaseModelClauseArray *currentObservationAssignments, Mers::Estimation::Discrete::EstimateHeap *nextTrajsEstHeap=NULL)
void | resetOpsats (void)
## Static Protected Member Functions
static std::vector< const Mers::Estimation::Discrete::Dissent * > | emptyDissentVector (void)
static std::vector< const Mers::Estimation::Discrete::CompiledTransition * > | extractTransitionsFromCCA (const Mers::Models::CCA::CCAModel &aCCAmodel)
static void | extractDNFTransitions (const Mers::Models::CCA::CCAAutomaton *auton, const Mers::Models::CCA::CCATransition *trans, const Mers::Models::Base::BaseModelAssignmentArray *guards, std::vector< const Mers::Estimation::Discrete::CompiledTransition * > &compTransitions)
static bool | addGuardAssign (const Mers::Models::Base::BaseModelAssignment *constraint, Mers::Utils::Containers::DynamicArrayTemplate< Mers::Models::Base::BaseModelAssignmentArray > &gv)
## Protected Attributes
std::vector< Mers::Solvers::SAT::GATSAT::OpSAT::Opsat * > | opsats
| A vector of OPSATs; one for each trajectory. Opsat memory is allocated as the number of trajectories grows and is freed only on deletion of ModeEstimation. For a well formed model, there should always be at least one consistent state transition so the total number of trajectories should not decrease without intervension.
const Mers::Models::CCA::CCAModel & | myCCAmodel
| The complete CCA model. Used to provide the model constraints when constructing an opsat object.
Mers::Models::Base::BaseModelVariableArray * | observationVariables
| An array of pointers to all observation variables in the model. Used to quickly query the compiledObjectTrigger for the current observation assignments which are then added as temporary constraints in opsat.
Mers::Models::CCA::CCASentence * | globalConstraints
| A handle to all of the constraints of the Model.

## Detailed Description

The ModeEstimator is an HHM estimation engine that generates estimates that are consistent with the CCA model, commands, and observations. Estimates are generated in best-first order (highest posterior probability first) by using Opsat to find the most likely diagnoses. This implimentation of ModeEstimator tracks the k most likely trajectories over time.

Definition at line 75 of file ModeEstimator.h.

## Constructor & Destructor Documentation

ModeEstimator::ModeEstimator | ( | const Mers::Models::CCA::CCAModel & | cca,
|  | Mers::Estimation::Discrete::Trajectories * | initialTrajectories = `NULL` |
| ) |  |  |

Creates a new ModeEstimator. The core functionality is derived from the ModeEstimatorBase. The only major addition to the base class is the generateTrajectories method using OPSAT to enumerate estimates in best-first order.

Parameters:

  | cca | the complete CCAModel of the system including all variables, domains, transitions, and constraints
  | initialTrajectories | the initial probability distribution across states.

Definition at line 68 of file ModeEstimator.cpp.

References Mers::Estimation::Discrete::ModeEstimatorBase::decisionVariables, Mers::Models::CCA::CCAModel::get_all_constraints(), Mers::Utils::Containers::DynamicArray::getLength(), Mers::Models::CCA::CCAModel::getVariables(), globalConstraints, myCCAmodel, Mers::Estimation::Discrete::ModeEstimatorBase::objectiveFunction, observationVariables, and Mers::Models::Base::BaseModelVariableArray::pushBack().

Here is the call graph for this function:

ModeEstimator::~ModeEstimator | ( |  | ) | `[virtual]`

Destroys the mode estimator

Definition at line 104 of file ModeEstimator.cpp.

References globalConstraints, Mers::Estimation::Discrete::ModeEstimatorBase::objectiveFunction, observationVariables, and opsats.

## Member Function Documentation

void ModeEstimator::setDebug | ( | const unsigned short | db | ) | `[virtual]`

Sets the debug flag to the value specified

Parameters:

  | db | the value to set the debug flag to (higher numbers are more output)

Reimplemented from Mers::Estimation::Discrete::ModeEstimatorBase.

Definition at line 131 of file ModeEstimator.cpp.

References opsats, and Mers::Estimation::Discrete::ModeEstimatorBase::setDebug().

Referenced by generateTrajectories(), and Mers::Estimation::Discrete::ApproximateBeliefState::BFBSE::BFBSE::generateTrajectories().

Here is the call graph for this function:

bool ModeEstimator::generateTrajectories | ( | void |  | ) | `[protected, virtual]`

Calculates the next trajectories using OPSAT

Returns:
  true if successfully generated new trajectories, false otherwise

Implements Mers::Estimation::Discrete::ModeEstimatorBase.

Reimplemented in Mers::Estimation::Discrete::ApproximateBeliefState::BFBSE::BFBSE, and Mers::Estimation::Discrete::ModeEstimationPerformance::ModeEstimatorDebug.

Definition at line 148 of file ModeEstimator.cpp.

References Mers::Estimation::Discrete::Trajectories::addEstimate(), Mers::Estimation::Discrete::ModeEstimatorBase::cleanAfterFailure(), Mers::Estimation::Discrete::ModeEstimatorBase::compiledObjectTrigger, Mers::Estimation::Discrete::ModeEstimatorBase::currentTrajectories, Mers::Estimation::Discrete::ModeEstimatorBase::debug, Mers::Estimation::Discrete::ModeEstimatorBase::decisionVariables, Mers::Estimation::Discrete::ModeEstimatorBase::findNextBestStateAndPutInHeap(), Mers::Estimation::Discrete::Trajectories::getAccumulatedUncertainty(), Mers::Estimation::Discrete::Trigger::getCurrentCommandObservationValueUID(), Mers::Estimation::Discrete::Trajectories::getEstimate(), Mers::Estimation::Discrete::EstimateHeap::getFirst(), Mers::Utils::Containers::DynamicArray::getLength(), Mers::Estimation::Discrete::Trigger::getNormalizedEnabledTransitionProbabilities(), Mers::Estimation::Discrete::Trajectories::getNumberEstimates(), Mers::Estimation::Discrete::Estimate::getOriginatedTrajectoryNumber(), Mers::Estimation::Discrete::Estimate::getProbability(), Mers::Models::CCA::CCAModel::getVariables(), globalConstraints, Mers::Utils::Containers::DynamicArray::isEmpty(), Mers::Estimation::Discrete::ModeEstimatorBase::maxNumberEstimates, myCCAmodel, Mers::Estimation::Discrete::ModeEstimatorBase::nextTrajectories, Mers::Estimation::Discrete::ModeEstimatorBase::objectiveFunction, observationVariables, opsats, Mers::Estimation::Discrete::ModeEstimatorBase::probabilityMap, Mers::Models::Base::BaseModelClauseArray::pushBack(), Mers::Models::Base::BaseModelAssignmentArray::pushBack(), releaseMemoryAndNormalize(), setDebug(), Mers::Estimation::Discrete::Trigger::UNDEFINED, and Mers::Estimation::Discrete::MEObjectiveFunction::updateProbabilities().

Here is the call graph for this function:

const BaseModelAssignmentArray * ModeEstimator::generateBestSolution | ( | unsigned int | generatorNum,
|  | long int | maximumVisitedNodeCount,
|  | long int | maxQueueSize |
| ) |  |  | `[protected, virtual]`

This function was designed to only used by findNextBestStateAndPutInHeap. This virtual function is implemented using OpSat to generate the next most likely consistent solution.

Parameters:

  | generatorNum | the generator index from which to generate the next most likely state maximumVisitedNodeCount the maximum number of nodes to examine before giving up.
  | maxQueueSize | the largest number of nodes that can be kept in memory

Returns:
  the next best state found by OpSat # generatorNum

See also:
  ModeEstimatorBase::findNextBestStateAndPutInHeap

Implements Mers::Estimation::Discrete::ModeEstimatorBase.

Definition at line 281 of file ModeEstimator.cpp.

References opsats.

bool ModeEstimator::addEstimate | ( | Mers::Estimation::Discrete::Estimate * | theEst,
|  | Mers::Estimation::Discrete::EstimateHeap * | nextTrajsEstHeap = `NULL` |
| ) |  |  | `[protected, virtual]`

Simple function that is called by findNextBestStateAndPutInHeap to insert the estimate into the best-first heap

Parameters:

  | theEst | the estimate to add to the heap or trajectories
  | nextTrajsEstHeap | the Estimate Heap to add the estimate to. If NULL, the estimate will be placed in nextTrajectories.

Returns:
  true if successful, false otherwise

See also:
  findNextBestStateAndPutInHeap

Implements Mers::Estimation::Discrete::ModeEstimatorBase.

Reimplemented in Mers::Estimation::Discrete::ApproximateBeliefState::BFBSE::BFBSE.

Definition at line 290 of file ModeEstimator.cpp.

References Mers::Estimation::Discrete::EstimateHeap::insert().

Here is the call graph for this function:

bool ModeEstimator::releaseMemoryAndNormalize | ( | Mers::Models::Base::BaseModelClauseArray * | currentObservationAssignments,
|  | Mers::Estimation::Discrete::EstimateHeap * | nextTrajsEstHeap = `NULL` |
| ) |  |  | `[protected, virtual]`

This function was designed to only used by generateTrajectories. Once all the next best estimates have been generated and places into nextTrajectories, this function is called to normalize the trajectories and release the extra memory that was allocated and no longer needed. Specifically it deletes currentObservationAssignments, clears the estimate heap, and resets all the opsats.

Parameters:

  | currentObservationAssignments | the observation assignments to delete
  | nextTrajsEstHeap | the heap to clear

Returns:
  true

Reimplemented in Mers::Estimation::Discrete::ModeEstimationPerformance::ModeEstimatorDebug.

Definition at line 300 of file ModeEstimator.cpp.

References Mers::Estimation::Discrete::ModeEstimatorBase::releaseMemoryAndNormalize(), and resetOpsats().

Referenced by generateTrajectories().

Here is the call graph for this function:

vector< const Dissent * > ModeEstimator::emptyDissentVector | ( | void |  | ) | `[static, protected]`

Static function that creates an empty const dissent * vector. This is used to pass in an empty dissent vector to the ModeEstimatorBase constructor.

Returns:
  an empty vector<const Dissent *>

Definition at line 316 of file ModeEstimator.cpp.

vector< const CompiledTransition * > ModeEstimator::extractTransitionsFromCCA | ( | const Mers::Models::CCA::CCAModel & | aCCAmodel | ) | `[static, protected]`

Gathers all the transitions in the model and creates CompiledTransition objects for each. All the information is available in the CCAModel. The only challenge is to convert all negative literals to positive literal disjunctive clauses as required by the trigger.

Parameters:

  | aCCAmodel | the CCAModel from which to extract the compiled transitions

Returns:
  a vector of const CompiledTransition * extracted from the CCAModel

Definition at line 324 of file ModeEstimator.cpp.

References extractDNFTransitions(), Mers::Models::CCA::CCAModel::get_ccAutomata_p(), Mers::Utils::Containers::DynamicArray::getLength(), and Mers::Models::Base::BaseModelAssignmentArray::pushBack().

Here is the call graph for this function:

static void Mers::Estimation::Discrete::ModeEstimation::ModeEstimator::extractDNFTransitions | ( | const Mers::Models::CCA::CCAAutomaton * | auton,
|  | const Mers::Models::CCA::CCATransition * | trans,
|  | const Mers::Models::Base::BaseModelAssignmentArray * | guards,
|  | std::vector< const Mers::Estimation::Discrete::CompiledTransition * > & | compTransitions |
| ) |  |  | `[static, protected]`

Takes a single automaton and one of the transitions in the automaton, and adds all the compiled transitions to the vector of compiled transitions. There can be multiple transitions if the transition guards are in CNF or if any of the literals are negated. This function is called by extractTransitionsFromCCA and calls addGuardAssign to deal with negative literals

Parameters:

  | auton | the automaton from which to extract the transitions
  | trans | the single transition from which to extract the compiled transitions
  | the | specific guards to use for the singe transition "trans" due to CNF converted to DNF
  | compTransitions | the vector of compiled transitions for the entire model to add to

Referenced by extractTransitionsFromCCA().

bool ModeEstimator::addGuardAssign | ( | const Mers::Models::Base::BaseModelAssignment * | constraint,
|  | Mers::Utils::Containers::DynamicArrayTemplate< Mers::Models::Base::BaseModelAssignmentArray > & | gv |
| ) |  |  | `[static, protected]`

If a new constraint assignment is a negation, the number of compiled transitions is multiplied by the the domain size of the variable-1 to get rid of the negation. As a result, all the guards are duplicated and then the negation is driven out of the new assignment and added to the guard list. If the constrain being added is a negative literal and the variable is already in the guard list, the assignment that is negated is removed from the guard list. If the variable exists in the guard but assignment that is now negated does not, an error is displayed because it is uncertain out to expand this negation (ideally the entire sentance should be considered at once). Note that this function should not be necessary with a proper compiler that generates transitions in the proper form.

Parameters:

  | constraint | the literal assignment to be added.
  | gv | a reference to the vector of guards for which the constraint will be added.

Returns:
  true if successful, false otherwise

Definition at line 424 of file ModeEstimator.cpp.

References Mers::Models::Base::BaseModelVariable::getDomain(), Mers::Utils::Containers::DynamicArray::getLength(), Mers::Models::Base::BaseModelAssignment::getOperator(), Mers::Models::Base::BaseModelValue::getUID(), Mers::Models::Base::BaseModelVariable::getUID(), Mers::Models::Base::BaseModelAssignment::getValue(), Mers::Models::Base::BaseModelAssignment::getVariable(), Mers::Models::Base::BaseModelVariable::getVariableType(), and Mers::Utils::Containers::DynamicArray::resize().

Here is the call graph for this function:

void ModeEstimator::resetOpsats | ( | void |  | ) | `[protected]`

Resets all the OPSAT objects by clearing the temporary constraints (observations) as well as reseting the BFIG search. Deletion of the OPSAT objects only occures when ModeEstimator is deleted.

Definition at line 515 of file ModeEstimator.cpp.

References opsats.

Referenced by releaseMemoryAndNormalize().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/ModeEstimation/ModeEstimator.h
- /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/ModeEstimation/ModeEstimator.cpp