[Fawkes Git] branch/bschaepers/asp-aspect: 4 revs updated. (0.5.0-3390-g0bc2d4f)

Bjoern Schaepers bjoern.schaepers at rwth-aachen.de
Mon Dec 5 20:09:38 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, bschaepers/asp-aspect has been updated
        to  0bc2d4f079241cf59964d32e914a0507c5b1cf24 (commit)
       via  19db51858a49193f016cda7965decafff476d44e (commit)
       via  4ce5e0fad19278618a9999332a2a89953dfe4a89 (commit)
       via  4512d97664d3528a686db9200455a5efc59757b9 (commit)
      from  0d313da6eb1e98340392de6ae0e415807c95290a (commit)

http://git.fawkesrobotics.org/fawkes.git/bschaepers/asp-aspect

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 4512d97664d3528a686db9200455a5efc59757b9
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Sun Dec 4 22:15:12 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sun Dec 4 22:15:12 2016 +0100

    ASP-Aspect: Added multiple debug levels.
    
    Instead of a boolean switch for all debug messages, add multiple
    hirachial levels. This way you can see what Clingo is doing without the
    massive spam a new model is producing.

http://git.fawkesrobotics.org/fawkes.git/commit/4512d97
http://trac.fawkesrobotics.org/changeset/4512d97

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 4ce5e0fad19278618a9999332a2a89953dfe4a89
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Mon Dec 5 20:07:49 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Mon Dec 5 20:07:49 2016 +0100

    ASP-Aspect: Print if we know we have an optimal model.

http://git.fawkesrobotics.org/fawkes.git/commit/4ce5e0f
http://trac.fawkesrobotics.org/changeset/4ce5e0f

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 19db51858a49193f016cda7965decafff476d44e
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Mon Dec 5 20:08:18 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Mon Dec 5 20:08:18 2016 +0100

    ASP-Aspect: Use domain heuristics for solving.
    
    Needed for useful plans.

http://git.fawkesrobotics.org/fawkes.git/commit/19db518
http://trac.fawkesrobotics.org/changeset/19db518

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 0bc2d4f079241cf59964d32e914a0507c5b1cf24
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Mon Dec 5 20:09:20 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Mon Dec 5 20:09:20 2016 +0100

    ASP-Aspect: Print message on resetting clingo.

http://git.fawkesrobotics.org/fawkes.git/commit/0bc2d4f
http://trac.fawkesrobotics.org/changeset/0bc2d4f

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/plugins/asp/aspect/clingo_access.cpp |  152 ++++++++++++++++++------------
 src/plugins/asp/aspect/clingo_access.h   |   13 +++-
 2 files changed, 104 insertions(+), 61 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 4512d97664d3528a686db9200455a5efc59757b9 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Sun Dec 4 22:15:12 2016 +0100
Subject: ASP-Aspect: Added multiple debug levels.

 src/plugins/asp/aspect/clingo_access.cpp |  144 ++++++++++++++++++------------
 src/plugins/asp/aspect/clingo_access.h   |   13 +++-
 2 files changed, 99 insertions(+), 58 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/clingo_access.cpp b/src/plugins/asp/aspect/clingo_access.cpp
index 23fdd09..64637aa 100644
--- a/src/plugins/asp/aspect/clingo_access.cpp
+++ b/src/plugins/asp/aspect/clingo_access.cpp
@@ -75,8 +75,32 @@ namespace fawkes {
  * @property ClingoAccess::GroundCallback
  * @brief The callback for the grounding.
  *
- * @property ClingoAccess::Debug
- * @brief Whether additional debug output is desired.
+ * @enum ClingoAccess::DebugLevel_t
+ * @brief An enum to define debug levels. The higher levels include the lower values.
+ *
+ * @var ClingoAccess::DebugLevel_t::None
+ * @brief No debug output at all.
+ *
+ * @var ClingoAccess::DebugLevel_t::Time
+ * @brief Print when starting/finishing grounding/solving for analysis.
+ *
+ * @var ClingoAccess::DebugLevel_t::Programs
+ * @brief Print which programs are grounded.
+ *
+ * @var ClingoAccess::DebugLevel_t::Models
+ * @brief Print new models.
+ *
+ * @var ClingoAccess::DebugLevel_t::Externals
+ * @brief Print assignments and releases of externals.
+ *
+ * @var ClingoAccess::DebugLevel_t::AllModelSymbols
+ * @brief Ignore #show statements and print all symbols of a model.
+ *
+ * @var ClingoAccess::DebugLevel_t::All
+ * @brief Print everything.
+ *
+ * @property ClingoAccess::DebugLevel
+ * @brief Which debug outputs should be printed.
  */
 
 
@@ -89,34 +113,37 @@ bool
 ClingoAccess::newModel(const Clingo::Model& model)
 {
 	MutexLocker locker1(&ControlMutex);
-	ModelSymbols = model.symbols();
+	ModelSymbols = model.symbols(DebugLevel >= AllModelSymbols ? Clingo::ShowType::All : Clingo::ShowType::Shown);
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "New model found: #%d", ++ModelCounter);
 
-		/* To save (de-)allocations just move found symbols at the end of the vector and move the end iterator to the
-		 * front. After this everything in [begin, end) is in oldSymbols but not in symbols. */
-		auto begin = OldSymbols.begin(), end = OldSymbols.end();
-
-		for ( const Clingo::Symbol& symbol : ModelSymbols )
+		if ( DebugLevel >= Models )
 		{
-			auto iter = std::find(begin, end, symbol);
-			if ( iter == end )
-			{
-				Log->log_info(LogComponent.c_str(), "New Symbol: %s", symbol.to_string().c_str());
-			} //if ( iter == end )
-			else
+			/* To save (de-)allocations just move found symbols at the end of the vector and move the end iterator to
+			 * the front. After this everything in [begin, end) is in oldSymbols but not in symbols. */
+			auto begin = OldSymbols.begin(), end = OldSymbols.end();
+
+			for ( const Clingo::Symbol& symbol : ModelSymbols )
 			{
-				std::swap(*iter, *--end);
-			} //else -> if ( iter == end )
-		} //for ( const Clingo::Symbol& symbol : ModelSymbols )
+				auto iter = std::find(begin, end, symbol);
+				if ( iter == end )
+				{
+					Log->log_info(LogComponent.c_str(), "New Symbol: %s", symbol.to_string().c_str());
+				} //if ( iter == end )
+				else
+				{
+					std::swap(*iter, *--end);
+				} //else -> if ( iter == end )
+			} //for ( const Clingo::Symbol& symbol : ModelSymbols )
 
-		for ( ; begin != end; ++begin )
-		{
-			Log->log_info(LogComponent.c_str(), "Symbol removed: %s", begin->to_string().c_str());
-		} //for ( ; begin != end; ++begin )
-	} //if ( Debug )
+			for ( ; begin != end; ++begin )
+			{
+				Log->log_info(LogComponent.c_str(), "Symbol removed: %s", begin->to_string().c_str());
+			} //for ( ; begin != end; ++begin )
+		} //if ( DebugLevel >= Models )
+	} //if ( DebugLevel >= Time )
 
 	OldSymbols = ModelSymbols;
 	locker1.unlock();
@@ -139,10 +166,10 @@ ClingoAccess::newModel(const Clingo::Model& model)
 void
 ClingoAccess::solvingFinished(const Clingo::SolveResult result)
 {
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Solving done.");
-	} //if ( Debug )
+	} //if ( DebugLevel >= Time )
 	MutexLocker locker1(&ControlMutex);
 	Solving = false;
 
@@ -188,7 +215,7 @@ ClingoAccess::allocControl()
  * @param[in] controlArgs... The arguments for the clingo control constructor.
  */
 ClingoAccess::ClingoAccess(Logger *log, const std::string& logComponent) : Log(log),
-		LogComponent(logComponent.empty() ? "Clingo" : logComponent), Control(nullptr), Solving(false), Debug(false)
+		LogComponent(logComponent.empty() ? "Clingo" : logComponent), Control(nullptr), Solving(false), DebugLevel(None)
 {
 	allocControl();
 	return;
@@ -286,10 +313,10 @@ ClingoAccess::startSolving(void)
 		return false;
 	} //if ( Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Start async solving.");
-	} //if ( Debug )
+	} //if ( DebugLevel >= Time )
 	Solving = true;
 	ModelCounter = 0;
 	Control->solve_async([this](const Clingo::Model& model) { return newModel(model); },
@@ -311,10 +338,10 @@ ClingoAccess::startSolvingBlocking(void)
 		return false;
 	} //if ( Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Start sync solving.");
-	} //if ( Debug )
+	} //if ( DebugLevel >= Time )
 	Solving = true;
 	ModelCounter = 0;
 	const auto result(Control->solve([this,&locker](const Clingo::Model& model) {
@@ -341,10 +368,10 @@ ClingoAccess::cancelSolving(void)
 		return false;
 	} //if ( !Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Cancel solving.");
-	} //if ( Debug )
+	} //if ( DebugLevel >= Time )
 	Control->interrupt();
 	return true;
 }
@@ -354,7 +381,7 @@ ClingoAccess::cancelSolving(void)
  * @return If it was an success.
  */
 bool
-ClingoAccess::reset()
+ClingoAccess::reset(void)
 {
 	if ( Solving )
 	{
@@ -412,36 +439,39 @@ ClingoAccess::ground(const Clingo::PartSpan& parts)
 		return false;
 	} //if ( Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Grounding %d parts:", parts.size());
-		auto i = 0;
-		for ( const Clingo::Part& part : parts )
+		if ( DebugLevel >= Programs )
 		{
-			std::string params;
-			bool first = true;
-			for ( const auto& param : part.params() )
+			auto i = 0;
+			for ( const Clingo::Part& part : parts )
 			{
-				if ( first )
-				{
-					first = false;
-				} //if ( first )
-				else
+				std::string params;
+				bool first = true;
+				for ( const auto& param : part.params() )
 				{
-					params += ", ";
-				} //else -> if ( first )
-				params += param.to_string();
-			} //for ( const auto& param : part.params() )
-			Log->log_info(LogComponent.c_str(), "Part #%d: %s [%s]", ++i, part.name(), params.c_str());
-		} //for ( const auto& part : parts )
-	} //if ( Debug )
+					if ( first )
+					{
+						first = false;
+					} //if ( first )
+					else
+					{
+						params += ", ";
+					} //else -> if ( first )
+					params += param.to_string();
+				} //for ( const auto& param : part.params() )
+				Log->log_info(LogComponent.c_str(), "Part #%d: %s [%s]", ++i, part.name(), params.c_str());
+			} //for ( const auto& part : parts )
+		} //if ( DebugLevel >= Programs )
+	} //if ( DebugLevel >= Time )
 
 	Control->ground(parts, GroundCallback);
 
-	if ( Debug )
+	if ( DebugLevel >= Time )
 	{
 		Log->log_info(LogComponent.c_str(), "Grounding done.");
-	} //if ( Debug )
+	} //if ( DebugLevel >= Time )
 	return true;
 }
 
@@ -460,7 +490,7 @@ ClingoAccess::assign_external(const Clingo::Symbol& atom, const Clingo::TruthVal
 		return false;
 	} //if ( Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Externals )
 	{
 		Log->log_info(LogComponent.c_str(), "Assigning %s to %s.", [value](void)
 			{
@@ -473,7 +503,7 @@ ClingoAccess::assign_external(const Clingo::Symbol& atom, const Clingo::TruthVal
 				} //switch ( value )
 				return ret;
 			}(), atom.to_string().c_str());
-	} //if ( Debug )
+	} //if ( DebugLevel >= Externals )
 	Control->assign_external(atom, value);
 	return true;
 }
@@ -492,10 +522,10 @@ ClingoAccess::release_external(const Clingo::Symbol& atom)
 		return false;
 	} //if ( Solving )
 
-	if ( Debug )
+	if ( DebugLevel >= Externals )
 	{
 		Log->log_info(LogComponent.c_str(), "Releasing %s.", atom.to_string().c_str());
-	} //if ( Debug )
+	} //if ( DebugLevel >= Externals )
 	Control->release_external(atom);
 	return true;
 }
diff --git a/src/plugins/asp/aspect/clingo_access.h b/src/plugins/asp/aspect/clingo_access.h
index 0651d7b..7bcb844 100644
--- a/src/plugins/asp/aspect/clingo_access.h
+++ b/src/plugins/asp/aspect/clingo_access.h
@@ -61,7 +61,18 @@ class ClingoAccess
 	void allocControl(void);
 
 	public:
-	std::atomic_bool Debug;
+	enum DebugLevel_t
+	{
+		None = 0,
+		Time = 10,
+		Programs = 20,
+		Models = 30,
+		Externals = 40,
+		AllModelSymbols = 50,
+		All
+	};
+
+	std::atomic<DebugLevel_t> DebugLevel;
 
 	ClingoAccess(Logger *log, const std::string& logComponent);
 	~ClingoAccess(void);

- *commit* 4ce5e0fad19278618a9999332a2a89953dfe4a89 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Mon Dec 5 20:07:49 2016 +0100
Subject: ASP-Aspect: Print if we know we have an optimal model.

 src/plugins/asp/aspect/clingo_access.cpp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/clingo_access.cpp b/src/plugins/asp/aspect/clingo_access.cpp
index 64637aa..31dfca7 100644
--- a/src/plugins/asp/aspect/clingo_access.cpp
+++ b/src/plugins/asp/aspect/clingo_access.cpp
@@ -117,7 +117,8 @@ ClingoAccess::newModel(const Clingo::Model& model)
 
 	if ( DebugLevel >= Time )
 	{
-		Log->log_info(LogComponent.c_str(), "New model found: #%d", ++ModelCounter);
+		Log->log_info(LogComponent.c_str(), "New %smodel found: #%d", model.optimality_proven() ? "optimal " : "",
+			++ModelCounter);
 
 		if ( DebugLevel >= Models )
 		{

- *commit* 19db51858a49193f016cda7965decafff476d44e - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Mon Dec 5 20:08:18 2016 +0100
Subject: ASP-Aspect: Use domain heuristics for solving.

 src/plugins/asp/aspect/clingo_access.cpp |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/clingo_access.cpp b/src/plugins/asp/aspect/clingo_access.cpp
index 31dfca7..5daea54 100644
--- a/src/plugins/asp/aspect/clingo_access.cpp
+++ b/src/plugins/asp/aspect/clingo_access.cpp
@@ -186,10 +186,10 @@ ClingoAccess::solvingFinished(const Clingo::SolveResult result)
  * @brief Allocates the control object and initializes the logger.
  */
 void
-ClingoAccess::allocControl()
+ClingoAccess::allocControl(void)
 {
 	assert(!Control);
-	Control = new Clingo::Control({},
+	Control = new Clingo::Control({"--heur=Domain"/*, "--output-debug=translate"*/},
 		[this](const Clingo::WarningCode code, char const *msg)
 		{
 			fawkes::Logger::LogLevel level = fawkes::Logger::LL_NONE;

- *commit* 0bc2d4f079241cf59964d32e914a0507c5b1cf24 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Mon Dec 5 20:09:20 2016 +0100
Subject: ASP-Aspect: Print message on resetting clingo.

 src/plugins/asp/aspect/clingo_access.cpp |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/clingo_access.cpp b/src/plugins/asp/aspect/clingo_access.cpp
index 5daea54..e338632 100644
--- a/src/plugins/asp/aspect/clingo_access.cpp
+++ b/src/plugins/asp/aspect/clingo_access.cpp
@@ -391,6 +391,7 @@ ClingoAccess::reset(void)
 		cancelSolving();
 		return false;
 	} //if ( Solving )
+	Log->log_warn(LogComponent.c_str(), "Clingo will be resetted.");
 	delete Control;
 	Control = nullptr;
 	allocControl();




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list