Go to the documentation of this file.00001
00005 #ifndef _PDDL_MODULE_TYPES_H_
00006 #define _PDDL_MODULE_TYPES_H_
00007
00008 #define PDDL_MODULE_VERSION_MAJOR 0
00009 #define PDDL_MODULE_VERSION_MINOR 3
00010 #define PDDL_MODULE_VERSION_STRING "0.3"
00011
00012 #include <math.h>
00013 #include <stdio.h>
00014 #include <string>
00015 #include <vector>
00016 #include <map>
00017 #include <iostream>
00018 #include <algorithm>
00019 #include <utility>
00020 #include <tr1/unordered_map>
00021 using std::string;
00022 using std::vector;
00023 using std::map;
00024
00025
00026 typedef std::pair<int, int> VarVal;
00027 typedef std::tr1::unordered_map<string, VarVal> PredicateMapping;
00028 typedef std::tr1::unordered_map<string, int> FunctionMapping;
00029
00030 typedef std::map<std::string, std::string> ObjectTypeMap;
00031
00032 namespace modules
00033 {
00034
00035 const double INFINITE_COST = HUGE_VAL;
00036
00037 static string toLower(const string & s)
00038 {
00039 string ret;
00040 #ifdef _WIN32
00041 std::transform(s.begin(), s.end(), back_inserter(ret), (int(*)(int)) tolower);
00042 #else
00043 std::transform(s.begin(), s.end(), back_inserter(ret), (int(*)(int)) std::tolower);
00044 #endif
00045 return ret;
00046 }
00047
00049 class Parameter {
00050 public:
00051 Parameter(string n, string t, string v = "") {
00052 if(n.find("?") == 0)
00053 n = n.substr(1);
00054 name = toLower(n);
00055 type = toLower(t);
00056 value = toLower(v);
00057 }
00058
00059 string name;
00060 string type;
00061 string value;
00062 };
00063
00064 typedef vector<Parameter> ParameterList;
00065
00066 class Predicate {
00067 public:
00068 Predicate(string n, ParameterList pl, bool v = true) : parameters(pl), value(v) {
00069 name = toLower(n);
00070 }
00071
00072 string name;
00073 ParameterList parameters;
00074 bool value;
00075 };
00076
00077 typedef vector<Predicate> PredicateList;
00078
00079 class NumericalFluent {
00080 public:
00081 NumericalFluent(string n, ParameterList pl, double v = 0.0) : parameters(pl), value(v) {
00082 name = toLower(n);
00083 }
00084
00085 string name;
00086 ParameterList parameters;
00087 double value;
00088 };
00089
00090 typedef vector<NumericalFluent> NumericalFluentList;
00091
00102 typedef bool (*predicateCallbackType)(PredicateList* & predicateList);
00103
00108 typedef bool (*numericalFluentCallbackType)(NumericalFluentList* & numericalFluentList);
00109
00110
00111
00113 typedef void (*moduleInitType)(int argc, char** argv);
00114
00116
00121 typedef double (*conditionCheckerType)(const ParameterList & parameterList,
00122 predicateCallbackType predicateCallback, numericalFluentCallbackType numericalFluentCallback, int relaxed);
00123
00125
00129 typedef int (*applyEffectType)(const ParameterList & parameterList,
00130 predicateCallbackType predicateCallback, numericalFluentCallbackType numericalFluentCallback,
00131 vector<double> & writtenVars);
00132
00133
00134
00136 typedef void* subplanType;
00137
00139
00143 typedef subplanType (*subplanGeneratorType)(const string & operatorName, const ParameterList & parameterList,
00144 predicateCallbackType predicateCallback, numericalFluentCallbackType numericalFluentCallback, int heuristic);
00145
00146
00148 typedef string (*outputSubplanType)(subplanType subplan);
00149
00151 typedef vector<subplanType> modulePlanType;
00152
00154
00158 typedef void (*executeModulePlanType)(modulePlanType modulePlan);
00159
00160 std::ostream & operator<<(std::ostream & os, const Parameter & p);
00161 std::ostream & operator<<(std::ostream & os, const ParameterList & pl);
00162 std::ostream & operator<<(std::ostream & os, const Predicate & p);
00163 std::ostream & operator<<(std::ostream & os, const PredicateList & pl);
00164 std::ostream & operator<<(std::ostream & os, const NumericalFluent & n);
00165 std::ostream & operator<<(std::ostream & os, const NumericalFluentList & nl);
00166
00167 }
00168
00169 #define VERIFY_CONDITIONCHECKER_DEF(name) conditionCheckerType name##_def_check = name
00170 #define VERIFY_APPLYEFFECT_DEF(name) applyEffectType name##_def_check = name
00171 #define VERIFY_SUBPLANGENERATOR_DEF(name) subplanGeneratorType name##_def_check = name
00172
00173 #endif
00174