From eb8f1e99a9a951f924e67980bfd4674d49426efc Mon Sep 17 00:00:00 2001 From: verel Date: Sun, 9 Nov 2014 15:17:41 +0100 Subject: [PATCH] Add precision in the output of the eoValueParam.h --- eo/src/utils/eoFileMonitor.cpp | 3 +-- eo/src/utils/eoFileMonitor.h | 2 ++ eo/src/utils/eoParam.h | 15 +++++++++++++++ mo/src/explorer/moFirstImprHCexplorer.h | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/eo/src/utils/eoFileMonitor.cpp b/eo/src/utils/eoFileMonitor.cpp index 3cc96deb1..80b7afaff 100644 --- a/eo/src/utils/eoFileMonitor.cpp +++ b/eo/src/utils/eoFileMonitor.cpp @@ -67,13 +67,12 @@ eoMonitor& eoFileMonitor::operator()(void) printHeader(); firstcall = false; } - + return operator()(os); } eoMonitor& eoFileMonitor::operator()(std::ostream& os) { - iterator it = vec.begin(); os << (*it)->getValue(); diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index 9438d25c3..dcd48e4c4 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -96,6 +96,7 @@ public : virtual void printHeader(std::ostream& os); virtual std::string getFileName() { return filename;} + private : @@ -116,6 +117,7 @@ private : //! erase the entire file prior to writing in it (mode eos_base:: bool overwrite; + }; #endif diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index 948092c93..d6e794ca9 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -167,6 +167,8 @@ public : repValue(_defaultValue) { eoParam::defValue(getValue()); + // default precision + numOfDigits = std::cout.precision(); } /** Get a reference on the parameter value @@ -203,6 +205,7 @@ public : std::string getValue(void) const { std::ostringstream os; + os.precision(numOfDigits); os << repValue; return os.str(); } @@ -227,9 +230,21 @@ public : is >> repValue; } + /** + set the precision of the output + + @param _numOfDigits the precision of the output + */ + void setPrecision(unsigned _numOfDigits) { + numOfDigits = _numOfDigits; + } + protected: ValueType repValue; + + //! precision of the output + unsigned numOfDigits; }; /* diff --git a/mo/src/explorer/moFirstImprHCexplorer.h b/mo/src/explorer/moFirstImprHCexplorer.h index 8edf9f976..e341908d3 100644 --- a/mo/src/explorer/moFirstImprHCexplorer.h +++ b/mo/src/explorer/moFirstImprHCexplorer.h @@ -162,7 +162,7 @@ private: // true if the move is accepted bool isAccept ; - // if true the HC stop when to improving solution is found + // if true : the HC stop when no improving solution is found // if false : never stop, always continue (external continuator) bool stop ; };