|
From: <mm...@us...> - 2012-11-29 18:21:28
|
Revision: 3299
http://dmcs.svn.sourceforge.net/dmcs/?rev=3299&view=rev
Author: mmsc
Date: 2012-11-29 18:21:17 +0000 (Thu, 29 Nov 2012)
Log Message:
-----------
Intermediate commit: on fixing a bug with cyclic topology: missing models after encoutering conflict ones.
Modified Paths:
--------------
dmcs/branches/dmcs1.5/examples/test/runTest.sh
dmcs/branches/dmcs1.5/include/parser/Makefile.am
dmcs/branches/dmcs1.5/src/parser/Makefile.am
Added Paths:
-----------
dmcs/branches/dmcs1.5/include/parser/NewDLVResultParser.h
dmcs/branches/dmcs1.5/src/parser/NewDLVResultParser.cpp
Modified: dmcs/branches/dmcs1.5/examples/test/runTest.sh
===================================================================
--- dmcs/branches/dmcs1.5/examples/test/runTest.sh 2012-11-29 12:28:58 UTC (rev 3298)
+++ dmcs/branches/dmcs1.5/examples/test/runTest.sh 2012-11-29 18:21:17 UTC (rev 3299)
@@ -27,15 +27,20 @@
#################################################################################
moveLogFiles()
{
- no_args=$#
+ noargs=$#
optimized=opt_
- if [ $no_args -eq 3 ] ; then
+ loopMode=noloop_
+ mode=
+ if [ $noargs -eq 3 ] ; then
optimized=
+ loopMode=
+ elif [ $noargs -eq 4 ] ; then
+ loopMode=
fi
toponame=$1
testname=$2
- mode=$optimized$3
+ mode=$optimized$loopMode$3
basedir=../../..
createSubDir $basedir/output
@@ -58,6 +63,7 @@
teName=$3
tpack=$4
runOpt=$5
+ noLoop=$6
basedir=../../..
@@ -71,39 +77,45 @@
wantOpt=-opt
fi
- for (( i = 1; i <= $MAXTRY; ++i)) ; do
- if [ $i -eq 1 ] ; then
- echo "Run "$teName $tpack $runOpt
+ wantNoLoop=
+ if [ x$noLoop = xnoloop ] ; then
+ wantNoLoop=-noloop
+ fi
+
+ declare -i j
+ for (( j=1; j <= $MAXTRY; ++j)) ; do
+ if [ $j -eq 1 ] ; then
+ echo "Run "$teName $tpack $runOpt $noLoop
else
- echo "Retry($i) "$teName $tpack $runOpt
+ echo "Retry($j) "$teName $tpack $runOpt $noLoop
fi
- bash $toName-command-line$wantOpt-$tpack$wantlog.sh
+ bash $toName-command-line$wantOpt-$tpack$wantlog$wantNoLoop.sh
RETVAL=$?
echo $RETVAL
if [ $RETVAL -eq 0 ] ; then
- echo "PASSED: $teName $tpack $runOpt" > $toName-status.log
- echo $toName,$teName,$tpack,$runOpt >> $basedir/passedtests.log
- (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "PASSED: dmcs testcase on GLUCK: $teName $tpack $runOpt" $EMAIL
+ echo "PASSED: $teName $tpack $runOpt $noLoop" > $toName-status.log
+ echo $toName,$teName,$tpack,$runOpt,$noLoop >> $basedir/passedtests.log
+ (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "PASSED: dmcs testcase on GLUCK: $teName $tpack $runOpt $noLoop" $EMAIL
break
elif [ $RETVAL -eq 124 ] ; then
- echo "TIMEOUT: $teName $tpack $runOpt" > $toName-status.log
- echo $toName,$teName,$tpack,$runOpt >> $basedir/timeouttests.log
- (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "TIMEOUT: dmcs testcase on GLUCK: $teName $tpack $runOpt" $EMAIL
+ echo "TIMEOUT: $teName $tpack $runOpt $noLoop" > $toName-status.log
+ echo $toName,$teName,$tpack,$runOpt,$noLoop >> $basedir/timeouttests.log
+ (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "TIMEOUT: dmcs testcase on GLUCK: $teName $tpack $runOpt $noLoop" $EMAIL
break
else
- if [ $i -eq $MAXtRY ] ; then
- echo "FAILED: $teName $tpack $runOpt" > $toName-status.log
- echo $toName,$teName,$tpack,$runOpt >> $basedir/$filename
- (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "FAILED: dmcs testcase on GLUCK: $teName $tpack $runOpt" $EMAIL
+ if [ $j -eq $MAXTRY ] ; then
+ echo "FAILED: $teName $tpack $runOpt $noLoop" > $toName-status.log
+ echo $toName,$teName,$tpack,$runOpt,$noLoop >> $basedir/$filename
+ (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "FAILED: dmcs testcase on GLUCK: $teName $tpack $runOpt $noLoop" $EMAIL
else
- (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "FAILED($i): dmcs testcase on GLUCK: $teName $tpack $runOpt" $EMAIL
+ (cat $toName-time.log ; echo ; cat $toName.log ; echo ; cat $toName-err.log) | mail -s "FAILED($j): dmcs testcase on GLUCK: $teName $tpack $runOpt $noLoop" $EMAIL
fi
fi
done
- moveLogFiles $toName $teName $tpack $runOpt
+ moveLogFiles $toName $teName $tpack $runOpt $noLoop
} # end of runOneInstance
#################################################################################
@@ -126,6 +138,9 @@
for ((i = 0; i < $no_test_packs; ++i)) ; do
runOneInstance $filename $toponame $testname ${testpack[$i]}
runOneInstance $filename $toponame $testname ${testpack[$i]} opt
+ if [ $i -gt 0 ] ; then
+ runOneInstance $filename $toponame $testname ${testpack[$i]} opt noloop
+ fi
done
cd ../../.. # get out of data/$toponame/$testname
@@ -145,9 +160,12 @@
# list[0] = toponame
# list[1] = testname
# list[2] = testpack
- # list[3] = (mode)
+ # list[3] = (opt-mode)
+ # list[4] = (loop-mode)
cd data/${list[0]}/${list[1]}
- if [ $noArguments -eq 4 ] ; then
+ if [ $noArguments -eq 5 ] ; then
+ runOneInstance failedtests.tmp ${list[0]} ${list[1]} ${list[2]} ${list[3]} ${list[4]}
+ elif [ $noArguments -eq 4 ] ; then
runOneInstance failedtests.tmp ${list[0]} ${list[1]} ${list[2]} ${list[3]}
else
runOneInstance failedtests.tmp ${list[0]} ${list[1]} ${list[2]}
Modified: dmcs/branches/dmcs1.5/include/parser/Makefile.am
===================================================================
--- dmcs/branches/dmcs1.5/include/parser/Makefile.am 2012-11-29 12:28:58 UTC (rev 3298)
+++ dmcs/branches/dmcs1.5/include/parser/Makefile.am 2012-11-29 18:21:17 UTC (rev 3299)
@@ -5,6 +5,7 @@
BridgeRuleParser.h \
DLVResultGrammar.h \
DLVResultParser.h \
+ NewDLVResultParser.h \
ParserState.h \
QueryPlanParser.h \
ReturnPlanParser.h
Added: dmcs/branches/dmcs1.5/include/parser/NewDLVResultParser.h
===================================================================
--- dmcs/branches/dmcs1.5/include/parser/NewDLVResultParser.h (rev 0)
+++ dmcs/branches/dmcs1.5/include/parser/NewDLVResultParser.h 2012-11-29 18:21:17 UTC (rev 3299)
@@ -0,0 +1,101 @@
+/* DMCS -- Distributed Nonmonotonic Multi-Context Systems.
+ * Copyright (C) 2009, 2010 Minh Dao-Tran, Thomas Krennwallner
+ *
+ * This file is part of DMCS.
+ *
+ * DMCS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DMCS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DMCS. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file NewDLVResultParser.h
+ * @author Minh Dao-Tran <da...@kr...>
+ * @date Thu Nov 29 17:53:40 2012
+ *
+ * @brief
+ *
+ *
+ */
+
+#ifndef ___NEW_DLV_RESULT_PARSER_H___
+#define ___NEW_DLV_RESULT_PARSER_H___
+
+#include "mcs/NewBeliefState.h"
+#include "mcs/BeliefTable.h"
+
+namespace {
+
+using namespace dmcs;
+
+struct SemState
+{
+ SemState(const BeliefTablePtr& btab,
+ const std::size_t ctx_id)
+ : btab(btab),
+ ctx_id(ctx_id)
+ { }
+
+
+ void
+ reset_current()
+ {
+ current = new NewBeliefState(BeliefStateOffset::instance()->NO_BLOCKS(),
+ BeliefStateOffset::instance()->SIZE_BS());
+
+ const std::vector<std::size_t>& starting_offsets = BeliefStateOffset::instance()->getStartingOffsets();
+ current->setEpsilon(ctx_id, starting_offsets);
+
+ std::size_t start_bit = starting_offsets[ctx_id] + 1;
+ std::size_t end_bit;
+ if (ctx_id == starting_offsets.size() - 1)
+ end_bit = current->status_bit.size();
+ else
+ end_bit = starting_offsets[ctx_id+1];
+
+ for (std::size_t i = start_bit; i < end_bit; ++i)
+ current->set(i, NewBeliefState::DMCS_FALSE);
+ }
+
+ BeliefTablePtr btab;
+ const std::size_t ctx_id;
+ NewBeliefState* current;
+};
+
+} // namespace
+
+/*******************************************************************************************/
+
+namespace dmcs {
+
+class NewDLVResultParser
+{
+public:
+ NewDLVResultParser(BeliefTablePtr btab,
+ const std::size_t ctx_id)
+ : state(btab, ctx_id)
+ { }
+
+ NewBeliefState* parseString(const std::string& instr);
+
+private:
+ SemState state;
+};
+
+} // namespace dmcs
+
+#endif // ___NEW_DLV_RESULT_PARSER_H___
+
+
+// Local Variables:
+// mode: C++
+// End:
Modified: dmcs/branches/dmcs1.5/src/parser/Makefile.am
===================================================================
--- dmcs/branches/dmcs1.5/src/parser/Makefile.am 2012-11-29 12:28:58 UTC (rev 3298)
+++ dmcs/branches/dmcs1.5/src/parser/Makefile.am 2012-11-29 18:21:17 UTC (rev 3299)
@@ -31,5 +31,6 @@
BridgeRuleParser.cpp \
DLVResultGrammar.cpp \
DLVResultParser.cpp \
+ NewDLVResultParser.cpp \
QueryPlanParser.cpp \
ReturnPlanParser.cpp
Added: dmcs/branches/dmcs1.5/src/parser/NewDLVResultParser.cpp
===================================================================
--- dmcs/branches/dmcs1.5/src/parser/NewDLVResultParser.cpp (rev 0)
+++ dmcs/branches/dmcs1.5/src/parser/NewDLVResultParser.cpp 2012-11-29 18:21:17 UTC (rev 3299)
@@ -0,0 +1,196 @@
+/* DMCS -- Distributed Nonmonotonic Multi-Context Systems.
+ * Copyright (C) 2009, 2010 Minh Dao-Tran, Thomas Krennwallner
+ *
+ * This file is part of DMCS.
+ *
+ * DMCS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DMCS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DMCS. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file NewDLVResultParser.h
+ * @author Minh Dao-Tran <da...@kr...>
+ * @date Thu Nov 29 18:03:26 2012
+ *
+ * @brief
+ *
+ *
+ */
+
+#undef BOOST_SPIRIT_DEBUG
+#undef BOOST_SPIRIT_DEBUG_WS
+
+#include "mcs/BeliefStateOffset.h"
+#include "parser/NewDLVResultParser.h"
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_fusion.hpp>
+#include <boost/spirit/include/phoenix_stl.hpp>
+#include <boost/fusion/include/adapt_struct.hpp>
+#include <boost/spirit/home/phoenix/statement/if.hpp>
+
+namespace {
+
+namespace qi = boost::spirit::qi;
+namespace ascii = boost::spirit::ascii;
+namespace phoenix = boost::phoenix;
+namespace fusion = boost::fusion;
+
+using namespace dmcs;
+
+template<typename Iterator>
+struct SkipperGrammar: boost::spirit::qi::grammar<Iterator>
+{
+ SkipperGrammar(): SkipperGrammar::base_type(ws)
+ {
+ using namespace boost::spirit;
+ ws = ascii::space
+ | qi::lexeme[ qi::char_('%') > *(qi::char_ - qi::eol) ];
+
+ #ifdef BOOST_SPIRIT_DEBUG_WS
+ BOOST_SPIRIT_DEBUG_NODE(ws);
+ #endif
+ }
+
+ boost::spirit::qi::rule<Iterator> ws;
+};
+
+
+struct HandleLiteral
+{
+ HandleLiteral(SemState& s) : s(s) { }
+
+ template<typename SourceAttributes, typename Context>
+ void
+ operator()(const SourceAttributes& source,
+ Context& ctx,
+ boost::spirit::qi::unused_type) const
+ {
+ const boost::fusion::vector2<boost::optional<char>, std::string>& attr = source;
+
+ bool strong_neg = boost::fusion::at_c<0>(attr);
+ const std::string& belief_text = boost::fusion::at_c<1>(attr);
+ ID belief_id = s.btab->getIDByString(belief_text);
+ assert (belief_id != ID_FAIL);
+
+ if (strong_neg)
+ {
+ s.current->set(s.ctx_id,
+ belief_id.address,
+ BeliefStateOffset::instance()->getStartingOffsets(),
+ NewBeliefState::DMCS_FALSE);
+ }
+ else
+ {
+ s.current->set(s.ctx_id,
+ belief_id.address,
+ BeliefStateOffset::instance()->getStartingOffsets());
+ }
+ }
+
+ SemState& s;
+};
+
+
+
+template<typename Iterator, typename Skipper>
+struct DLVResultGrammar : qi::grammar<Iterator, Skipper>
+{
+ DLVResultGrammar(SemState& state) : DLVResultGrammar::base_type(dlvline)
+ {
+ using qi::int_;
+ using qi::_val;
+ using qi::_1;
+ using qi::lexeme;
+ using qi::raw;
+ using qi::char_;
+ using qi::omit;
+ using qi::lit;
+
+ number =
+ lexeme[ char_('0') ]
+ | lexeme[ char_('1', '9') >> *(char_('0', '9')) ];
+
+ ident =
+ lexeme[char_('"') >> *(char_ - '"') >> char_('"')]
+ | (ascii::lower >> *(ascii::alnum|char_('_')));
+
+ ///TODO: When raw[] is not used, we won't get from 2nd arguments in the facts.
+ ///Something wrong with boost!!! try not to use raw[] with newer version of boost!
+ fact =
+ raw[ident >> -( char_('(') >> (ident | number) >> *(char_(',') >> (ident | number)) >> char_(')') )];
+
+ mlit = ( -char_('-') >> fact >> lit(',') ) [ HandleLiteral(state) ];
+ flit = ( -char_('-') >> fact >> lit('}') ) [ HandleLiteral(state) ];
+
+ answerset
+ = (lit('{') >> '}')
+ | (lit('{') >> *(mlit) >> flit);
+
+ costline
+ = lit("Cost") >> +(ascii::alnum | char_("[]<>():"));
+
+ dlvline
+ = (-lit("Best model:") >> answerset)
+ |
+ costline;
+ }
+
+ qi::rule<Iterator, Skipper> costline, answerset, mlit, flit, dlvline;
+ qi::rule<Iterator, std::string(), Skipper> ident, fact, number;
+
+};
+
+
+} // namespace
+
+/*******************************************************************************************/
+
+namespace dmcs {
+
+NewBeliefState* NewDLVResultParser::parseString(const std::string& instr)
+{
+ state.reset_current();
+
+ std::string::const_iterator begIt = instr.begin();
+ std::string::const_iterator endIt = instr.end();
+
+ typedef SkipperGrammar<std::string::const_iterator> Skipper;
+
+ Skipper skipper;
+
+ DLVResultGrammar<std::string::const_iterator, Skipper> grammar(state);
+
+ bool r = qi::phrase_parse(begIt, endIt, grammar, skipper);
+
+ if (r && begIt == endIt)
+ {
+ return state.current;
+ //std::cerr << "Bridge rules parsing succeeded" << std::endl;
+ }
+ else
+ {
+ //std::cerr << "Bridge rules parsing failed" << std::endl;
+ throw std::runtime_error("Bridge rules parsing failed");
+ }
+}
+
+} // namespace dmcs
+
+// Local Variables:
+// mode: C++
+// End:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|