From f2ca099baf994154b109d2b45d5a00928c2a6eba Mon Sep 17 00:00:00 2001 From: "John M. Penn" Date: Wed, 29 Jul 2015 16:56:23 -0500 Subject: [PATCH] Fixes #44: Changed the MonteRun values that are used and that are recorded to be the same precision. Also increased the precision from 10 to 15 significant digits. --- .../MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp | 6 ++++++ .../sim_services/MonteCarlo/MonteVarCalculated.cpp | 12 ++++-------- .../sim_services/MonteCarlo/MonteVarRandom.cpp | 9 ++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp index 3fdf6977..d01b6063 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp @@ -33,11 +33,17 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *in_run, MonteSlave *in_s message_publish(MSG_INFO, "Monte [Master] Dispatching run %d to %s:%d.\n", in_run->id, in_slave->machine_name.c_str(), in_slave->id) ; } + int command = htonl(MonteSlave::PROCESS_RUN); tc_write(&connection_device, (char *)&command, (int)sizeof(command)); int num_bytes = htonl(buffer.length()); tc_write(&connection_device, (char*)&num_bytes, (int)sizeof(num_bytes)); tc_write(&connection_device, (char*)buffer.c_str(), (int)buffer.length()); + + if (verbosity >= INFORMATIONAL) { + message_publish(MSG_INFO, "Parameterization of run %d :\n%s\n", in_run->id, buffer.c_str()) ; + } + tc_disconnect(&connection_device); ++in_slave->num_dispatches; diff --git a/trick_source/sim_services/MonteCarlo/MonteVarCalculated.cpp b/trick_source/sim_services/MonteCarlo/MonteVarCalculated.cpp index 6deefc3c..f7a231d4 100644 --- a/trick_source/sim_services/MonteCarlo/MonteVarCalculated.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteVarCalculated.cpp @@ -42,15 +42,12 @@ std::string Trick::MonteVarCalculated::get_next_value() { value = buffer; break; case TRICK_FLOAT: - sprintf(buffer, "%.10g", *(float *)ref2->address); + sprintf(buffer, "%.15g", *(float *)ref2->address); value = buffer; - sprintf(buffer, "trick.unhex_float(0x%lx)", *(long *)ref2->address); break; case TRICK_DOUBLE: - sprintf(buffer, "%.10g", *(double *)ref2->address); + sprintf(buffer, "%.15g", *(double *)ref2->address); value = buffer; - sprintf(buffer, "struct.unpack(\"!d\", binascii.unhexlify(\"%016llx\"))[0]", - *(long long *)ref2->address); break; default: sprintf(buffer, "#Unsupported value type %d", ref2->attr->type) ; @@ -58,10 +55,9 @@ std::string Trick::MonteVarCalculated::get_next_value() { } if (unit.empty()) { - return name + std::string(" = ") + std::string(buffer) + std::string(" # ") + std::string(value); + return name + std::string(" = ") + value; } else { - return name + std::string(" = trick.attach_units(\"") + unit + std::string("\", ") + std::string(buffer) + - std::string(") # ") + std::string(value); + return name + std::string(" = trick.attach_units(\"") + unit + std::string("\", ") + value + std::string(")"); } } return NULL; diff --git a/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp b/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp index 2f49ed49..c29b7e43 100644 --- a/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp @@ -181,17 +181,16 @@ std::string Trick::MonteVarRandom::get_next_value() { case TRICK_GSL_GAUSS: case TRICK_GSL_FLAT: default: - sprintf(buffer, "%.10g", return_value.d); + sprintf(buffer, "%.15g", return_value.d); value = buffer; - sprintf(buffer, "struct.unpack(\"!d\", binascii.unhexlify(\"%llx\"))[0]", return_value.ll); break; } if (unit.empty()) { - return name + std::string(" = ") + std::string(buffer) + std::string(" # ") + std::string(value); + return name + std::string(" = ") + value ; } else { - return name + std::string(" = trick.attach_units(\"") + unit + std::string("\", ") + std::string(buffer) + - std::string(") # ") + std::string(value); + return name + std::string(" = trick.attach_units(\"") + unit + std::string("\", ") + value + + std::string(")") ; } }