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.

This commit is contained in:
John M. Penn 2015-07-29 16:56:23 -05:00
parent f4e0ce32b0
commit f2ca099baf
3 changed files with 14 additions and 13 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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(")") ;
}
}