planner.cpp
Go to the documentation of this file.
00001 /* Main file, keeps all important variables.
00002  * Calls functions from "helper_functions" to read in input (variables, operators, 
00003  * goals, initial state),
00004  * then calls functions to build causal graph, domain_transition_graphs and 
00005  * successor generator
00006  * finally prints output to file "output"
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; // dont even bother to interpret these - we dont use them
00042     vector<string> subplanGenerators;
00043     vector<ConditionModule> condModules;
00044     vector<EffectModule> effectModules;
00045     vector<ConditionModule> costModules; //Hacky, reuse ConditionModule here
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     //  for (int i = 0; i< operators.size(); i++)
00066     //      operators[i].dump();
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     //  cout << "ordering:" << endl;
00073     //  for(int i=0; i< ordering.size(); i++) {
00074     //    cout << ordering[i]->get_name() << endl;
00075     //  }
00076     bool cg_acyclic = causal_graph.is_acyclic();
00077 
00078     // Remove unnecessary effects from operators and axioms, then remove
00079     // operators and axioms without effects.
00080     strip_operators(operators);
00081     strip_Axiom_relationals(axioms_rel);
00082     strip_Axiom_functionals(axioms_func);
00083 
00084     // dump_preprocessed_problem_description(variables, initial_state, goals,
00085     //     operators, axioms_rel, axioms_func);
00086 
00087     cout << "Building domain transition graphs..." << endl;
00088     build_DTGs(ordering, operators, axioms_rel, axioms_func, transition_graphs);
00089     //  dump_DTGs(ordering, transition_graphs);
00090     bool solveable_in_poly_time = false;
00091     if(cg_acyclic)
00092         solveable_in_poly_time = are_DTGs_strongly_connected(transition_graphs);
00093     //TODO: genauer machen? (highest level var muss nicht scc sein...gemacht)
00094     //nur Werte, die wichtig sind fuer drunterliegende vars muessen in scc sein
00095     cout << "solveable in poly time " << solveable_in_poly_time << endl;
00096     cout << "Building successor generator..." << endl;
00097     SuccessorGenerator successor_generator(ordering, operators);
00098     //  successor_generator.dump();
00099 
00100     // causal_graph.dump();
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 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


tfd_modules
Author(s): Maintained by Christian Dornhege (see AUTHORS file).
autogenerated on Tue Jan 22 2013 12:25:03