00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "helper_functions.h"
00010 #include "successor_generator.h"
00011 #include "causal_graph.h"
00012 #include "domain_transition_graph.h"
00013 #include "state.h"
00014 #include "operator.h"
00015 #include "axiom.h"
00016 #include "variable.h"
00017 #include "module.h"
00018 #include <iostream>
00019 #include <cstring>
00020 using namespace std;
00021
00022 int main(int argc, const char **argv) {
00023
00024 ifstream file("../../benchmarks/modules-test/output-modules.sas");
00025 if(argc == 2 && strcmp(argv[1], "-eclipserun") == 0) {
00026 cin.rdbuf(file.rdbuf());
00027 argc = 1;
00028 }
00029
00030 streambuf* old_cout = cout.rdbuf();
00031 cout.rdbuf(cerr.rdbuf());
00032
00033 vector<Variable *> variables;
00034 vector<Variable> internal_variables;
00035 State initial_state;
00036 vector<pair<Variable *, int> > goals;
00037 vector<Operator> operators;
00038 vector<Axiom_relational> axioms_rel;
00039 vector<Axiom_functional> axioms_func;
00040 vector<DomainTransitionGraph*> transition_graphs;
00041 vector<string> moduleInits;
00042 vector<string> subplanGenerators;
00043 vector<ConditionModule> condModules;
00044 vector<EffectModule> effectModules;
00045 vector<ConditionModule> costModules;
00046 vector<TranslatePredicate> predicateTranslations;
00047 vector<TranslateFunction> functionTranslations;
00048 vector<string> predConstants;
00049 vector<string> numConstants;
00050 vector<string> objects;
00051 vector<string> oplinits;
00052
00053 if(argc != 1) {
00054 cout << "*** do not perform relevance analysis ***" << endl;
00055 g_do_not_prune_variables = true;
00056 }
00057
00058 read_preprocessed_problem_description(cin, internal_variables, variables,
00059 initial_state, goals, operators, axioms_rel, axioms_func,
00060 moduleInits, subplanGenerators, condModules, effectModules,
00061 costModules, predicateTranslations, functionTranslations,
00062 predConstants, numConstants, objects, oplinits);
00063
00064
00065
00066
00067
00068 cout << "Building causal graph..." << endl;
00069 CausalGraph
00070 causal_graph(variables, operators, axioms_rel, axioms_func, goals);
00071 const vector<Variable *> &ordering = causal_graph.get_variable_ordering();
00072
00073
00074
00075
00076 bool cg_acyclic = causal_graph.is_acyclic();
00077
00078
00079
00080 strip_operators(operators);
00081 strip_Axiom_relationals(axioms_rel);
00082 strip_Axiom_functionals(axioms_func);
00083
00084
00085
00086
00087 cout << "Building domain transition graphs..." << endl;
00088 build_DTGs(ordering, operators, axioms_rel, axioms_func, transition_graphs);
00089
00090 bool solveable_in_poly_time = false;
00091 if(cg_acyclic)
00092 solveable_in_poly_time = are_DTGs_strongly_connected(transition_graphs);
00093
00094
00095 cout << "solveable in poly time " << solveable_in_poly_time << endl;
00096 cout << "Building successor generator..." << endl;
00097 SuccessorGenerator successor_generator(ordering, operators);
00098
00099
00100
00101
00102
00103 cout << "Writing output..." << endl;
00104 ostream out(old_cout);
00105 generate_cpp_input(solveable_in_poly_time, ordering,
00106 moduleInits,
00107 subplanGenerators, condModules, effectModules, costModules,
00108 predicateTranslations, functionTranslations, predConstants,
00109 numConstants,
00110 initial_state, goals,
00111 operators, axioms_rel, axioms_func, successor_generator,
00112 transition_graphs, causal_graph,
00113 objects, oplinits, out);
00114 cout << "done" << endl << endl;
00115 }