00001 #ifndef HELPERS_H
00002 #define HELPERS_H
00003
00004 #include "state.h"
00005 #include "variable.h"
00006 #include "successor_generator.h"
00007 #include "causal_graph.h"
00008 #include "module.h"
00009 #include "variable.h"
00010
00011 #include <string>
00012 #include <vector>
00013 #include <iostream>
00014
00015 using namespace std;
00016
00017 class State;
00018 class Operator;
00019 class Axiom_relational;
00020 class Axiom_functional;
00021 class DomainTransitionGraph;
00022
00023
00024 void read_preprocessed_problem_description(istream &in,
00025 vector<Variable> &internal_variables, vector<Variable *> &variables,
00026 State &initial_state, vector<pair<Variable*, int> > &goals,
00027 vector<Operator> &operators, vector<Axiom_relational> &axioms_rel,
00028 vector<Axiom_functional> &axioms_func,
00029 vector<string> &moduleInits,
00030 vector<string> &subplanGenerators,
00031 vector<ConditionModule> &condModules,
00032 vector<EffectModule> &effectModules,
00033 vector<ConditionModule> & costModules,
00034 vector<TranslatePredicate> &predicate_translations, vector<
00035 TranslateFunction> &function_translations,
00036 vector<string> & pred_constants, vector<string> & num_constants,
00037 vector<string>& objects, vector<string>& oplinits);
00038
00039
00040 void dump_preprocessed_problem_description(const vector<Variable *> &variables,
00041 const State &initial_state, const vector<pair<Variable*, int> > &goals,
00042 const vector<Operator> &operators,
00043 const vector<Axiom_relational> &axioms_rel,
00044 const vector<Axiom_functional> &axioms_func);
00045
00046 void dump_DTGs(const vector<Variable *> &ordering,
00047 vector<DomainTransitionGraph*> &transition_graphs);
00048
00049 void generate_cpp_input(bool causal_graph_acyclic,
00050 const vector<Variable *> & ordered_var,
00051 const vector<string> & moduleInits,
00052 const vector<string> & subplanGenerators,
00053 const vector<ConditionModule> &cond_modules,
00054 const vector<EffectModule> &eff_modules,
00055 const vector<ConditionModule> &cost_modules, const vector<
00056 TranslatePredicate> &pred_translations, const vector<
00057 TranslateFunction> &func_translations,
00058 const vector<string> & predConstants,
00059 const vector<string> & numConstants,
00060 const State &initial_state,
00061 const vector<pair<Variable*, int> > &goals,
00062 const vector<Operator> & operators,
00063 const vector<Axiom_relational> &axioms_rel,
00064 const vector<Axiom_functional> &axioms_func,
00065 const SuccessorGenerator &sg,
00066 const vector<DomainTransitionGraph*> transition_graphs,
00067 const CausalGraph &cg,
00068 const vector<string>& objects,
00069 const vector<string>& oplinits, ostream& outfile);
00070
00071 void check_magic(istream &in, string magic);
00072
00073 enum foperator
00074 {
00075 assign = 0, scale_up = 1, scale_down = 2, increase = 3, decrease = 4
00076 };
00077 enum compoperator
00078 {
00079 lt = 0, le = 1, eq = 2, ge = 3, gt = 4, ue = 5
00080 };
00081
00082 istream& operator>>(istream &is, foperator &fop);
00083
00084 ostream& operator<<(ostream &os, const foperator &fop);
00085
00086 istream& operator>>(istream &is, compoperator &fop);
00087
00088 ostream& operator<<(ostream &os, const compoperator &fop);
00089
00090 enum condition_type
00091 {
00092 start_cond = 0, overall_cond = 1, end_cond = 2, ax_cond
00093 };
00094
00095 istream& operator>>(istream &is, condition_type &fop);
00096
00097 ostream& operator<<(ostream &os, const condition_type &fop);
00098
00099 enum trans_type
00100 {
00101 start = 0, end = 1, compressed = 2, ax_rel = 3
00102 };
00103
00104 istream& operator>>(istream &is, trans_type &fop);
00105
00106 ostream& operator<<(ostream &os, const trans_type &fop);
00107
00108 compoperator get_inverse_op(compoperator op);
00109
00110 struct DurationCond {
00111 compoperator op;
00112 Variable *var;
00113 DurationCond(compoperator o, Variable *v) :
00114 op(o), var(v) {
00115 }
00116 DurationCond() {}
00117 };
00118
00119 template<typename T> vector<T> append(vector<T> &first, vector<T> &sec) {
00120 for(int i = 0; i< sec.size(); i++) {
00121 first.push_back(sec[i]);
00122 }
00123 return first;
00124 }
00125
00126 #endif