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

# /Users/fpy/titan-1-5-MBARI/Mers/Estimation/Discrete/Trigger.h

    00001 //=============================================================================
    00002 // Trigger.h: interface for the Trigger class.
    00003 //
    00004 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00005 // All Rights Reserved          Massachusetts Institute of Technology
    00006 //
    00007 // This software is provided as is. Model-based Embedded and Robotic Systems
    00008 // (MERS) group does not assume any responsibility.
    00009 //
    00010 // Author:                      Oliver B. Martin
    00011 // Organization:        Model-based Embedded and Robotic Systems Group
    00012 //                                      Massachusetts Institute of Technology
    00013 //
    00014 // The Trigger class is responsible for determining which dissents and compiled
    00015 //  transitions are enabled and disabled based on the current trajectories
    00016 //  (mode assignments), observations, and commands. The trigger
    00017 //  returns a set of conflicts from the enabled dissents as well as a set of
    00018 //  mode assignments with the probability of transitioning into that mode.
    00019 //  Probabilities are determined by summing all the enabled incomming transition
    00020 //  probabilities as defined by most likely trajectories
    00021 //
    00022 //=============================================================================
    00023
    00024 #if !defined(_TRIGGER_H_)
    00025 #define _TRIGGER_H_
    00026
    00027 #if _MSC_VER > 1000
    00028 #pragma once
    00029 #endif // _MSC_VER > 1000
    00030
    00031 #include <vector>
    00032 #include <iostream>
    00033 #include <Mers/Utils/Containers/IntegerArray.h>
    00034
    00035
    00036 namespace Mers {
    00037         namespace Models {
    00038                 namespace Base {
    00039                         class BaseModelVariable;
    00040                         class BaseModelVariableArray;
    00041                         class BaseModelAssignment;
    00042                         class BaseModelAssignmentArray;
    00043                 }
    00044         }
    00045         namespace Estimation {
    00046                 namespace Discrete {
    00047
    00048                         class Dissent;
    00049                         class CompiledTransition;
    00050                         class CompiledObject;
    00051                         class Trajectories;
    00052
    00054                         static const unsigned int       MAX_NUM_VARIABLES = 1000;
    00055                         static const unsigned int       MAX_DOMAIN_SIZE = 25;
    00056
    00066                         class Trigger
    00067                         {
    00068                                 friend std::ostream &  operator<<(std::ostream &, Trigger const &);
    00069
    00070                         public:
    00071                                 //-----------------------------------------
    00072                                 // Constructors
    00073                                 //-----------------------------------------
    00074
    00086                                 Trigger(const Mers::Models::Base::BaseModelVariableArray * stateVarArray,
    00087                                         const Mers::Utils::Containers::IntegerArray * pMap, const unsigned int totalNumVars,
    00088                                         std::vector<const Dissent *> diss, std::vector<const CompiledTransition *> compT,
    00089                                         const Trajectories * trajs, unsigned short db = 0);
    00090
    00091
    00092                                 //-----------------------------------------
    00093                                 // Destructors
    00094                                 //-----------------------------------------
    00095
    00099                                 virtual ~Trigger();
    00100
    00101
    00102                                 //-----------------------------------------
    00103                                 // Functions
    00104                                 //-----------------------------------------
    00105
    00106
    00115                                 bool insertAssignment(const Mers::Models::Base::BaseModelAssignment * assign);
    00116
    00123                                 bool insertAssignment(const Mers::Models::Base::BaseModelAssignment * assign, unsigned int estNum);
    00124
    00132                                 bool changeTrajectories(const Trajectories * trajs);
    00133
    00143                                 std::vector<double> getNormalizedEnabledTransitionProbabilities(void);
    00144
    00150                                 std::vector<const Mers::Models::Base::BaseModelAssignmentArray *> getConflicts(void);
    00151
    00157                                 int getCurrentCommandObservationValueUID(unsigned int varUID) const;
    00158
    00163                                 void showDissents(std::ostream &out) const;
    00164
    00169                                 void showCompiledTransitions(std::ostream &out) const;
    00170
    00175                                 void showEnabled(std::ostream &out) const;
    00176
    00182                                 void setDebug(const unsigned short debugVal);
    00183
    00185                                 static const int                                        UNDEFINED;
    00186
    00187                         private:
    00188
    00194                                 bool findConflictsAndModeAssignments(void);
    00195
    00201                                 void clearCompiledObjects(void);
    00202
    00211                                 bool initCompiledObjectList(const unsigned int numEstimates);
    00212
    00213
    00223                                 bool processCompiledObjects(const Mers::Utils::Containers::IntegerArray * compObjIndices,
    00224                                         const bool add = true, const unsigned int estNum = 0);
    00225
    00226
    00227                                 // Still need to add something that normalizes all the enabled outgoing
    00228                                 //  componenent transitions
    00229
    00230                                 //-----------------------------------------
    00231                                 // Data Members
    00232                                 //-----------------------------------------
    00233
    00235                                 std::vector<const Dissent *>                                    dissents;
    00236
    00238                                 std::vector<const CompiledTransition *>                 compiledTransitions;
    00239
    00245                                 std::vector<CompiledObject *>                                   allCompiledObjects;
    00246
    00251                                 Mers::Utils::Containers::IntegerArray *                 lookUpTable[MAX_NUM_VARIABLES][MAX_DOMAIN_SIZE];
    00252
    00258                                 std::vector<Mers::Utils::Containers::IntegerArray>                                      currentAssignmentsVector;
    00259
    00261                                 std::vector<double>                                     modeAssignmentProbabilities;
    00262
    00264                                 std::vector<const Mers::Models::Base::BaseModelAssignmentArray *>       conflicts;
    00265
    00268                                 bool                                                            assignmentsHaveChanged;
    00269
    00272                                 const Mers::Models::Base::BaseModelVariableArray *              allStateVars;
    00274                                 const unsigned int                                      numVariablesInModel;
    00276                                 const unsigned int                                      numComponentsInModel;
    00278                                 const Trajectories *                            currentTrajectories;
    00280                                 const Mers::Utils::Containers::IntegerArray *                   probabilityMap;
    00281
    00283                                 unsigned short                                          debug;
    00284
    00285                         };
    00286                 }
    00287         }
    00288 }
    00289
    00290 #endif // !defined(_DISSENT_H_)