Skip to content

Commit

Permalink
- Delete the logging class, replaced this with #define macros.
Browse files Browse the repository at this point in the history
- Fixed type detection, in domains where a type has multiple supertypes we detect the most specific one (we do assert the super types share a common parent).
Bram
  • Loading branch information
Morloth authored and Morloth committed Apr 11, 2011
1 parent 0175baa commit 13779b9
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 297 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mypop_SOURCES = VALfiles/DebugWriteController.cpp VALfiles/FastEnvironment.cpp \
SAS/dtg_graph.cpp SAS/property_space.cpp SAS/relaxed_reachability_analyst.cpp \
SAS/recursive_function.cpp \
action_manager.cpp bindings_propagator.cpp \
formula.cpp logging.cpp mypop.cpp parser_utils.cpp \
formula.cpp mypop.cpp parser_utils.cpp \
plan.cpp plan_bindings.cpp plan_flaws.cpp plan_orderings.cpp planner.cpp \
predicate_manager.cpp relaxed_planning_graph.cpp simple_flaw_selector.cpp term_manager.cpp \
type_manager.cpp
Expand Down
4 changes: 2 additions & 2 deletions SAS/transition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,11 @@ Transition* Transition::createTransition(const std::vector<BoundedAtom>& enabler
const std::vector<const Object*>* invariable_term = property_space_invariables[&property_space];
if (invariable_term == NULL)
{
#ifdef ENABLE_MYPOP_SAS_TRANSITION_COMMENTS
#ifdef ENABLE_MYPOP_SAS_TRANSITION_COMMENTS
std::cout << "Could not find the invariable term of ";
bounded_atom->print(std::cout, bindings);
std::cout << "[" << from_node.getIndex(*bounded_atom) << "]" << std::endl;
#endif
#endif
continue;
}

Expand Down
21 changes: 10 additions & 11 deletions action_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#include "predicate_manager.h"
#include "formula.h"
#include "parser_utils.h"
#include "logging.h"
#include "plan_bindings.h"
#include "plan.h"

///#define MYPOP_ACTION_MANAGER_COMMENTS

namespace MyPOP {

/*************************
Expand Down Expand Up @@ -134,10 +135,9 @@ ActionManager::ActionManager(const TypeManager& type_manager, TermManager& term_

ActionManager::~ActionManager()
{
if (Logging::verbosity <= Logging::INFO)
{
std::cout << "[Destructor] ActionManager" << std::endl;
}
#ifdef MYPOP_ACTION_MANAGER_COMMENTS
std::cout << "[Destructor] ActionManager" << std::endl;
#endif
}

void ActionManager::processActions(const VAL::operator_list& operators)
Expand Down Expand Up @@ -209,12 +209,11 @@ void ActionManager::processActions(const VAL::operator_list& operators)

void ActionManager::getAchievingActions(std::vector<std::pair<const Action*, const Atom*> >& actions, const Atom& atom) const
{
if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Find all the actions which can achieve ";
atom.print(std::cout);
std::cout << std::endl;
}
#ifdef MYPOP_ACTION_MANAGER_COMMENTS
std::cout << "Find all the actions which can achieve ";
atom.print(std::cout);
std::cout << std::endl;
#endif

// Create a list of all action which have the same predicate.
for (unsigned int i = 0; i < highest_id_; i++)
Expand Down
10 changes: 5 additions & 5 deletions formula.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "formula.h"
#include "term_manager.h"
#include "logging.h"
#include "plan.h"
#include "pointers.h"
#include "plan_flaws.h"
#include "plan_bindings.h"
#include "predicate_manager.h"

///#define MYPOP_FORMULA_COMMENTS

namespace MyPOP {

// Instantiate default formulea for true and false.
Expand Down Expand Up @@ -56,10 +57,9 @@ Atom::Atom(const Predicate& predicate, const std::vector<const Term*>& terms, bo

Atom::~Atom()
{
if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << predicate_ << " is deleted!" << std::endl;
}
#ifdef MYPOP_FORMULA_COMMENTS
std::cout << predicate_ << " is deleted!" << std::endl;
#endif
delete terms_;
}

Expand Down
15 changes: 8 additions & 7 deletions landmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "SAS/transition.h"
//#include "SAS/reachability.h"

///#define MYPOP_LANDMARKS_COMMENTS

namespace MyPOP {

namespace LANDMARKS {
Expand Down Expand Up @@ -53,13 +55,12 @@ bool LandmarkOrderings::addOrdering(const Ordering& ordering)
biggest_step_id_ = max_step_id;
}

if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Highest index " << biggest_step_id_ << std::endl;
std::cout << "Ordering size" << orderings_.size() << std::endl;
std::cout << "before id " << ordering.before_id() << std::endl;
std::cout << "after id " << ordering.after_id() << std::endl;
}
#ifdef MYPOP_LANDMARKS_COMMENTS
std::cout << "Highest index " << biggest_step_id_ << std::endl;
std::cout << "Ordering size" << orderings_.size() << std::endl;
std::cout << "before id " << ordering.before_id() << std::endl;
std::cout << "after id " << ordering.after_id() << std::endl;
#endif

// Having extended the bitset. We continue by imposing the actual ordering constraint.
(*orderings_[ordering.after_id()])[ordering.before_id()] = false;
Expand Down
36 changes: 0 additions & 36 deletions logging.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions logging.h

This file was deleted.

9 changes: 4 additions & 5 deletions manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <vector>

#include "logging.h"
///#define MYPOP_MANAGER_COMMENTS

namespace MyPOP {

Expand Down Expand Up @@ -49,10 +49,9 @@ class Manager {
// Destroy all the stored objects.
virtual ~Manager()
{
if (Logging::verbosity <= Logging::INFO)
{
std::cout << "[Destructor] Manager" << std::endl;
}
#ifdef MYPOP_MANAGER_COMMENTS
std::cout << "[Destructor] Manager" << std::endl;
#endif

for (unsigned int i = 0; i < objects_.size(); i++)
delete objects_[i];
Expand Down
61 changes: 20 additions & 41 deletions mypop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <assert.h>
#include <sys/time.h>

#include "logging.h"

#include "VALfiles/ptree.h"
#include "VALfiles/TIM.h"
#include "VALfiles/ToFunction.h"
Expand All @@ -30,6 +28,8 @@
#include "relaxed_planning_graph.h"
//#include "action_graph.h"

///#define MYPOP_COMMENTS

extern int yyparse();
extern int yydebug;

Expand All @@ -55,33 +55,16 @@ int main(int argc,char * argv[])
{

// The first line is the debug level.
if (argc != 4)
if (argc != 3)
{
std::cout << "Usage: mypop <debug level> <domain file> <problem file>." << std::endl;
exit(0);
std::cout << "Usage: mypop <domain file> <problem file>." << std::endl;
exit(1);
}

struct itimerval timer = { { 1000000, 900000 }, { 1000000, 900000 } };
setitimer ( ITIMER_PROF, &timer, NULL );

int log_level = -1;
std::string log_level_str(argv[1]);
std::stringstream in(log_level_str);
in >> log_level;

// Set the log level:
if (log_level < Logging::DEBUG || log_level > Logging::ERROR)
{
std::cout << "The log level should be between " << Logging::DEBUG << "(DEBUG) and " << Logging::ERROR << "(ERROR)." << std::endl;
exit(0);
}
Logging::setLogLevel(log_level);
if (Logging::verbosity <= Logging::INFO)
{
std::cout << "Logging level set to " << Logging::LogLevelString[Logging::verbosity] << std::endl;
}

TIM::performTIMAnalysis(&argv[2]);
TIM::performTIMAnalysis(&argv[1]);
for_each(TA->pbegin(),TA->pend(), ptrwriter<PropertySpace>(cout,"\n"));
for_each(TA->abegin(),TA->aend(), ptrwriter<PropertySpace>(cout,"\n"));

Expand Down Expand Up @@ -188,34 +171,30 @@ int main(int argc,char * argv[])
// Create the initial step, which is a custom action with the atoms of the initial state as its effects.
Action* initial_action = new Action("Initial action", Formula::TRUE, initial_action_variables, initial_effects);

if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Print initial action" << std::endl;
std::cout << *initial_action << std::endl;
}
#ifdef MYPOP_COMMENTS
std::cout << "Print initial action" << std::endl;
std::cout << *initial_action << std::endl;
#endif

// Create the goal, which is a custom action with the goal atoms as preconditions.
if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Create goal action" << std::endl;
}
#ifdef MYPOP_COMMENTS
std::cout << "Create goal action" << std::endl;
#endif
std::vector<const Variable*>* goal_action_variables = new std::vector<const Variable*>();
std::vector<const Atom*>* goal_action_effects = new std::vector<const Atom*>();
Action* goal_action = new Action("Goal action", *goal, goal_action_variables, goal_action_effects);


if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Print goal action" << std::endl;
std::cout << *goal_action << std::endl;
}
#ifdef MYPOP_COMMENTS
std::cout << "Print goal action" << std::endl;
std::cout << *goal_action << std::endl;
#endif

plan->makeInitialPlan(*initial_action, *goal_action);

if (Logging::verbosity <= Logging::DEBUG)
{
std::cout << "Initial plan" << *plan << std::endl;
}
#ifdef MYPOP_COMMENTS
std::cout << "Initial plan" << *plan << std::endl;
#endif

assert (plan->getSteps().size() == 2);

Expand Down
8 changes: 3 additions & 5 deletions parser_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "term_manager.h"
#include "predicate_manager.h"
#include "formula.h"
#include "logging.h"

///#define MYPOP_PARSER_UTILS_COMMENTS

namespace MyPOP {

Expand Down Expand Up @@ -38,10 +39,7 @@ const Formula* Utility::convertGoal(const TermManager& term_manager, const Predi
return con;
}

if (Logging::verbosity <= Logging::ERROR)
{
std::cout << "Unsupported goal detected, quiting!" << std::endl;
}
std::cout << "Unsupported goal detected, quiting!" << std::endl;
assert (false);
}

Expand Down
Loading

0 comments on commit 13779b9

Please sign in to comment.