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

# /Users/fpy/titan-1-5-MBARI/Mers/Solvers/Entailment/GI/GoalInterpreter.h

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #ifndef __GOALINTERPRETER__
    00015 #define __GOALINTERPRETER__
    00016
    00017 #include <cstdlib>
    00018 #include <iostream>
    00019 #include <fstream>
    00020 #include <list>
    00021 #include <vector>
    00022
    00023 #include <Mers/Models/CCA/CCAModel.h>
    00024 #include <Mers/Utils/Lang/String.h>
    00025
    00026 #include <Mers/Utils/Containers/intList.h>
    00027 #include <Mers/Utils/Containers/IntegerArray.h>
    00028
    00029 #include <Mers/Solvers/Entailment/GoalInterpreterInterface.h>
    00030
    00031 class rpCCAutomata;
    00032
    00033 namespace Mers {
    00034         namespace Solvers {
    00035                 namespace SAT {
    00036                         namespace ISAT {
    00037                                 class ISATTester;
    00038                         }
    00039                         namespace GATSAT {
    00040                                 namespace OpSAT {
    00041                                         class Opsat;
    00042                                 }
    00043                         }
    00044                 }
    00045                 namespace Entailment {
    00046                         namespace GI {
    00047
    00048                                 class
    00049                                 GoalInterpreter : public GoalInterpreterInterface
    00050                                 {
    00051                                 public:
    00052                                         //--------------------------------------------
    00053                                         //      CONSTRUCTOR
    00054                                         //--------------------------------------------
    00055
    00056                                         GoalInterpreter(Mers::Models::CCA::CCAModel const * m, bool initialDebug = false);
    00057                                         //GoalInterpreter(rpCCAutomata * new_rpCCAutomata);
    00058                                         virtual ~GoalInterpreter();
    00059
    00060                                         //--------------------------------------------
    00061                                         //      PUBLIC FUNCTION METHODS
    00062                                         //--------------------------------------------
    00063
    00064                                         //void             progress(unsigned int cmd_index, unsigned int value_index);
    00065                                         //void             observe(unsigned int obs_index, unsigned int value_index);
    00066                                         // updates return 'false' if it fails - needs finishing!:
    00067                                         bool               updateGoal(unsigned int var, unsigned int val);
    00068                                         bool               updateGoal(Mers::Utils::Lang::String var, Mers::Utils::Lang::String val);
    00069                                         bool               updateCurrentState(unsigned int variable_id, unsigned int value_id);
    00070                                         bool               updateCurrentState(Mers::Utils::Lang::String var, Mers::Utils::Lang::String val);
    00071                                         bool               updateReachableStates(Mers::Utils::Containers::intList const * rstates);
    00072                                         void               clearGoal();
    00073                                         Mers::Utils::Containers::intList const *    generateGoalState();
    00074
    00075                                         void               setDebug(bool debugState);
    00076                                         bool               getDebug()  const;
    00077                                         //BFIGConstraint *   clauseToConstraint(Mers::Models::Base::BaseModelClause const * cl, bool conjunctive = false)  const;
    00078
    00079                                         //std::list<BFIGVariable *>   getVariablesAll();
    00080                                         //std::list<BFIGVariable *>   getVariablesState();
    00081                                         void               showVariables() const;
    00082
    00083                                         //BFIGAssignment const * findAssignment(Mers::Utils::Lang::String var, Mers::Utils::Lang::String val)  const;
    00084                                         //BFIGAssignment const * findAssignment(unsigned int var, unsigned int val)  const;
    00085
    00095                                         virtual int variableAndValueToUID(Mers::Utils::Lang::String var, Mers::Utils::Lang::String val,
    00096                                                                                                                                                                                 unsigned int &varUID,
    00097                                                                                                                                                                                 unsigned int &valUID) const;
    00098
    00108                                         virtual int variableAndValueToString(unsigned int var,
    00109                                                                                                                                                                                          unsigned int val,
    00110                                                                                                                                                                                          Mers::Utils::Lang::String &varString,
    00111                                                                                                                                                                                          Mers::Utils::Lang::String &valString) const;
    00112
    00113 #ifndef EMBEDDED
    00114
    00120                                         virtual void print(std::ostream &out) const;
    00121 #endif
    00122
    00123                                 private:
    00124                                         //--------------------------------------------
    00125                                         //      PRIVATE CLASS
    00126                                         //--------------------------------------------
    00127                                         /*
    00128                                                 class GIHelper : public ModelConvertorInterface
    00129                                                 {
    00130                                                 public:
    00131                                                 BFIGConstraint * clauseToConstraint(Mers::Models::Base::BaseModelClause const * cl, bool conjunctive = false) const;
    00132                                                 GoalInterpreter const * parent;
    00133                                                 };
    00134                                         */
    00135
    00136                                         // friend class GIHelper;
    00137
    00138                                 private:
    00139                                         //--------------------------------------------
    00140                                         //      PRIVATE DATA MEMBERS
    00141                                         //--------------------------------------------
    00142
    00143                                         // Our Model
    00144                                         Mers::Models::CCA::CCAModel const *       model;
    00145                                         // Opsat for GI.
    00146                                         Mers::Solvers::SAT::GATSAT::OpSAT::Opsat * opsat;
    00147                                         // A tester for checking the consistency of generated goals.
    00148                                         Mers::Solvers::SAT::ISAT::ISATTester * consistencyVsat;
    00149
    00155                                         Mers::Utils::Containers::IntegerArray mValueBaseIndices;
    00156
    00160                                         std::vector<double> mAssignmentCosts;
    00161
    00166                                         double * mVariableCosts;
    00167
    00171                                         double mPruneCost;
    00172
    00174                                         Mers::Utils::Containers::IntegerArray mCurrentValue;
    00175
    00177                                         Mers::Models::CCA::CCAVariables mSearchVariables;
    00178
    00180                                         Mers::Models::Base::BaseModelSentence mAllConstraints;
    00181
    00182                                         //rpCCAutomata *        model;
    00183
    00184                                         //# probably temporary. Shouldn't even be exposed, but C++ sucks:
    00185                                         std::list<int>             progressHistory;
    00186                                         std::list<int>             observationHistory;
    00187
    00188                                         //std::list<BFIGVariable *>              variablesState;
    00189                                         //std::list<BFIGVariable *>              variablesStateAll;
    00190                                         //std::list<BFIGVariable *>              variablesAll;
    00191                                         //std::list<CCATransition const *>      transitionsAll;
    00192                                         //std::list<BFIGVariable *>              variablesOther;
    00193                                         //std::list<BFIGVariable const *>        variablesOpsatState;
    00194                                         //std::list<BFIGVariable const *>        variablesOpsatDesign;
    00195                                         //std::list<BFIGConstraint const *>      constraintsModel;
    00196                                         //std::list<BFIGConstraint const *>      constraintsState;
    00197                                         //Mers::Models::Base::BaseModelClause constraintsGoal;
    00198                                         Mers::Models::Base::BaseModelClause antiGoal;
    00199
    00200                                         //GIHelper giHelper;
    00201
    00202                                         bool                          debug;
    00203
    00204                                         //--------------------------------------------
    00205                                         //      PRIVATE FUNCTION METHODS
    00206                                         //--------------------------------------------
    00207                                         GoalInterpreter();
    00208                                         GoalInterpreter(GoalInterpreter const &);
    00209
    00216                                         unsigned int findUID(unsigned int varUID);
    00217
    00218                                         //BFIGConstraint makeConstraint(unsigned int var, unsigned int val,
    00219                                         //      bool positive = true)  const;
    00220                                         //BFIGConstraintUnit makeConstraintUnit(unsigned int var, unsigned int val,
    00221                                         //      bool positive = true)  const;
    00222                                         //BFIGVariable * variableToVariable(Mers::Models::Base::BaseModelVariable const * varIn)  const;
    00223                                         //Mers::Utils::Containers::intList              implicantTointList(BFIGImplicant const & imp)  const;
    00224                                         Mers::Utils::Containers::intList bmAssignmentArrayToIntList(Mers::Models::Base::BaseModelAssignmentArray const & imp) const;
    00225                                         void                 fetchTheory();
    00226                                         Mers::Solvers::SAT::ISAT::ISATTester *               makeTestSat();
    00227                                         //BFIGVariable *           findVariable(Mers::Utils::Lang::String var)  const;
    00228                                         //BFIGVariable *           findVariable(unsigned int var)  const;
    00229
    00230                                 };
    00231
    00232                         }
    00233                 }
    00234         }
    00235 }
    00236
    00237 #endif //ndef __GOALINTERPRETER__
    00238