|
From: <mm...@us...> - 2012-11-29 12:29:10
|
Revision: 3298
http://dmcs.svn.sourceforge.net/dmcs/?rev=3298&view=rev
Author: mmsc
Date: 2012-11-29 12:28:58 +0000 (Thu, 29 Nov 2012)
Log Message:
-----------
Allow to exit after first loop.
Modified Paths:
--------------
dmcs/branches/dmcs1.5/include/dmcs/ProgramOptions.h
dmcs/branches/dmcs1.5/include/network/NewClient.h
dmcs/branches/dmcs1.5/src/generator/new_staticGen.cpp
dmcs/branches/dmcs1.5/src/network/NewClient.cpp
dmcs/branches/dmcs1.5/src/new_dmcsc.cpp
Modified: dmcs/branches/dmcs1.5/include/dmcs/ProgramOptions.h
===================================================================
--- dmcs/branches/dmcs1.5/include/dmcs/ProgramOptions.h 2012-11-29 12:01:26 UTC (rev 3297)
+++ dmcs/branches/dmcs1.5/include/dmcs/ProgramOptions.h 2012-11-29 12:28:58 UTC (rev 3298)
@@ -77,6 +77,7 @@
#define K2 "k2"
#define STARTUP_TIME "startup-time"
#define TIMEOUT "timeout"
+#define LOOP "loop"
} // namespace dmcs
Modified: dmcs/branches/dmcs1.5/include/network/NewClient.h
===================================================================
--- dmcs/branches/dmcs1.5/include/network/NewClient.h 2012-11-29 12:01:26 UTC (rev 3297)
+++ dmcs/branches/dmcs1.5/include/network/NewClient.h 2012-11-29 12:28:58 UTC (rev 3298)
@@ -42,7 +42,8 @@
NewClient(boost::asio::io_service& io_service,
boost::asio::ip::tcp::resolver::iterator endpoint_iterator,
const std::string& h,
- ForwardMessage& fwd_mess);
+ ForwardMessage& fwd_mess,
+ bool loop);
typedef void (*CallbackFunc)(ReturnedBeliefStateListPtr);
@@ -102,6 +103,7 @@
private:
connection_ptr conn;
CallbackFunc callback;
+ bool loop;
};
} // namespace dmcs
Modified: dmcs/branches/dmcs1.5/src/generator/new_staticGen.cpp
===================================================================
--- dmcs/branches/dmcs1.5/src/generator/new_staticGen.cpp 2012-11-29 12:01:26 UTC (rev 3297)
+++ dmcs/branches/dmcs1.5/src/generator/new_staticGen.cpp 2012-11-29 12:28:58 UTC (rev 3298)
@@ -890,7 +890,8 @@
std::size_t k1,
std::size_t k2,
std::string filename,
- bool want_log = false)
+ bool loop,
+ bool want_log)
{
std::ofstream file;
file.open(filename.c_str());
@@ -943,15 +944,67 @@
<< "--signature=" << testpath << "/client.qp "
<< "--belief-state-size=" << no_atoms << " "
<< "--k1=" << k1 << " "
- << "--k2=" << k2 << " "
- << " > " << prefix << ".log "
- << " 2> " << prefix << "-err.log" << std::endl;
+ << "--k2=" << k2 << " ";
+ if (loop)
+ {
+ file << "--loop=1 ";
+ }
+ else
+ {
+ file << "--loop=0 ";
+ }
+
+ file << "> " << prefix << ".log "
+ << "2> " << prefix << "-err.log" << std::endl;
+
file.close();
}
+std::string
+update_filename(const std::string& filename, const std::string& update_part)
+{
+ std::size_t dot_pos = filename.find(".");
+ assert (dot_pos != std::string::npos);
+
+ std::string new_filename = filename;
+ new_filename.insert(dot_pos, update_part);
+
+ return new_filename;
+}
+
+
void
+print_command_lines(const std::string& filename_text,
+ const std::string& filename_shell,
+ const std::string& filename_log_shell,
+ std::size_t k1,
+ std::size_t k2)
+{
+ // [k1,k2] == [0,0]
+ // or
+ // [k1,k2] == [1,pack_size]
+
+ print_command_lines_file(false, TESTDIR, dmcspath, k1, k2, filename_text, true, false);
+ print_command_lines_file(true, TESTDIR, dmcspath, k1, k2, filename_shell, true, false);
+ print_command_lines_file(true, TESTDIR, dmcspath, k1, k2, filename_log_shell, true, true);
+
+
+ if (k2 > 0)
+ {
+ std::string filename_unique_text = update_filename(filename_text, "-noloop");
+ std::string filename_unique_shell = update_filename(filename_shell, "-noloop");
+ std::string filename_unique_log_shell = update_filename(filename_log_shell, "-noloop");
+
+ print_command_lines_file(false, TESTDIR, dmcspath, k1, k2, filename_unique_text, false, false);
+ print_command_lines_file(true, TESTDIR, dmcspath, k1, k2, filename_unique_shell, false, false);
+ print_command_lines_file(true, TESTDIR, dmcspath, k1, k2, filename_unique_log_shell, false, true);
+ }
+}
+
+
+void
print_command_lines()
{
std::string filename_command_line_all = prefix + "-command-line-all.txt";
@@ -961,9 +1014,10 @@
std::string filename_command_line_opt_all_sh = prefix + "-command-line-opt-all.sh";
std::string filename_command_line_opt_all_log_sh = prefix + "-command-line-opt-all-log.sh";
- print_command_lines_file(false, TESTDIR, dmcspath, 0, 0, filename_command_line_all);
- print_command_lines_file(true, TESTDIR, dmcspath, 0, 0, filename_command_line_all_sh);
- print_command_lines_file(true, TESTDIR, dmcspath, 0, 0, filename_command_line_all_log_sh, true);
+ print_command_lines(filename_command_line_all,
+ filename_command_line_all_sh,
+ filename_command_line_all_log_sh,
+ 0, 0);
if (pack_size > 0)
{
@@ -973,9 +1027,10 @@
std::string filename_command_line_pack = prefix + "-command-line-" + out.str() + ".txt";
std::string filename_command_line_pack_sh = prefix + "-command-line-" + out.str() + ".sh";
std::string filename_command_line_pack_log_sh = prefix + "-command-line-" + out.str() + "-log.sh";
- print_command_lines_file(false, TESTDIR, dmcspath, 1, pack_size, filename_command_line_pack);
- print_command_lines_file(true, TESTDIR, dmcspath, 1, pack_size, filename_command_line_pack_sh);
- print_command_lines_file(true, TESTDIR, dmcspath, 1, pack_size, filename_command_line_pack_log_sh, true);
+ print_command_lines(filename_command_line_pack,
+ filename_command_line_pack_sh,
+ filename_command_line_pack_log_sh,
+ 1, pack_size);
}
OptionValueMap::iterator it = cmdline_options.find("returnplan");
@@ -984,9 +1039,9 @@
cmdline_options.insert(std::pair<std::string, std::string>("optqueryplan", prefix + ".oqp"));
- print_command_lines_file(false, TESTDIR, dmcspath, 0, 0, filename_command_line_opt_all);
- print_command_lines_file(true, TESTDIR, dmcspath, 0, 0, filename_command_line_opt_all_sh);
- print_command_lines_file(true, TESTDIR, dmcspath, 0, 0, filename_command_line_opt_all_log_sh, true);
+ print_command_lines(filename_command_line_opt_all,
+ filename_command_line_opt_all_sh,
+ filename_command_line_opt_all_log_sh, 0, 0);
if (pack_size > 0)
{
@@ -996,9 +1051,10 @@
std::string filename_command_line_opt_pack_sh = prefix + "-command-line-opt-" + out.str() + ".sh";
std::string filename_command_line_opt_pack_log_sh = prefix + "-command-line-opt-" + out.str() + "-log.sh";
- print_command_lines_file(false, TESTDIR, dmcspath, 1, pack_size, filename_command_line_opt_pack);
- print_command_lines_file(true, TESTDIR, dmcspath, 1, pack_size, filename_command_line_opt_pack_sh);
- print_command_lines_file(true, TESTDIR, dmcspath, 1, pack_size, filename_command_line_opt_pack_log_sh, true);
+ print_command_lines(filename_command_line_opt_pack,
+ filename_command_line_opt_pack_sh,
+ filename_command_line_opt_pack_log_sh,
+ 1, pack_size);
}
}
Modified: dmcs/branches/dmcs1.5/src/network/NewClient.cpp
===================================================================
--- dmcs/branches/dmcs1.5/src/network/NewClient.cpp 2012-11-29 12:01:26 UTC (rev 3297)
+++ dmcs/branches/dmcs1.5/src/network/NewClient.cpp 2012-11-29 12:28:58 UTC (rev 3298)
@@ -43,9 +43,11 @@
NewClient::NewClient(boost::asio::io_service& io_service,
boost::asio::ip::tcp::resolver::iterator endpoint_iterator,
const std::string& h,
- ForwardMessage& fwd_mess)
+ ForwardMessage& fwd_mess,
+ bool loop = true)
: conn(new connection(io_service)),
- callback(0)
+ callback(0),
+ loop(loop)
{
boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
@@ -229,8 +231,12 @@
callback(result_list);
}
- if (next_k == 0)
+ if (!loop)
{
+ DBGLOG(DBG, "NewClient::handle_read_answer(): Only once round required. Let's get back.");
+ }
+ else if (next_k == 0)
+ {
DBGLOG(DBG, "NewClient::handle_read_answer(): Done. Let's get back.");
}
else
Modified: dmcs/branches/dmcs1.5/src/new_dmcsc.cpp
===================================================================
--- dmcs/branches/dmcs1.5/src/new_dmcsc.cpp 2012-11-29 12:01:26 UTC (rev 3297)
+++ dmcs/branches/dmcs1.5/src/new_dmcsc.cpp 2012-11-29 12:28:58 UTC (rev 3298)
@@ -205,6 +205,7 @@
std::string port;
std::string filename_signature = "";
std::size_t root_ctx;
+ bool loop;
// range of requested equilibria. [0,0] for requesting all equilibria
std::size_t k1;
std::size_t k2;
@@ -220,6 +221,7 @@
(ROOT_CTX, boost::program_options::value<std::size_t>(&root_ctx)->default_value(0), "set root context id to query")
(SIGNATURE, boost::program_options::value<std::string>(&filename_signature)->default_value(""), "set signature file name")
(BS_SIZE, boost::program_options::value<std::size_t>(&bs_size), "set belief state size")
+ (LOOP, boost::program_options::value<bool>(&loop)->default_value(true), "set belief state size")
(K1, boost::program_options::value<std::size_t>(&k1)->default_value(1), "set starting range of requested equlibria. k1 <= k2")
(K2, boost::program_options::value<std::size_t>(&k2)->default_value(1), "set end range of requested equilibria. [0,0] for requesting all equilibria")
;
@@ -265,7 +267,7 @@
ForwardMessage request(qid, history, k1, k2);
ForwardMessage end_message(end_qid, history);
- NewClient client(*io_service, it, header, request);
+ NewClient client(*io_service, it, header, request, loop);
client.setCallback(&handle_belief_states);
if (!filename_signature.empty())
@@ -313,12 +315,12 @@
diff_count = final_result.size() - diff_count;
next_count++;
- /*if (!unique)
+ if (!loop)
{
- DBGLOG(DBG, "new_dmcsc: Do not need unique answers. Going to terminate the client after 1st round.");
+ DBGLOG(DBG, "new_dmcsc: Do not require looping. Going to terminate the client after 1st round.");
client.terminate(end_message);
break;
- }*/
+ }
if (last_round)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|