Add precision in the output of the eoValueParam.h

This commit is contained in:
verel 2014-11-09 15:17:41 +01:00
commit eb8f1e99a9
4 changed files with 19 additions and 3 deletions

View file

@ -73,7 +73,6 @@ eoMonitor& eoFileMonitor::operator()(void)
eoMonitor& eoFileMonitor::operator()(std::ostream& os) eoMonitor& eoFileMonitor::operator()(std::ostream& os)
{ {
iterator it = vec.begin(); iterator it = vec.begin();
os << (*it)->getValue(); os << (*it)->getValue();

View file

@ -97,6 +97,7 @@ public :
virtual std::string getFileName() { return filename;} virtual std::string getFileName() { return filename;}
private : private :
//! complete filename to write to //! complete filename to write to
@ -116,6 +117,7 @@ private :
//! erase the entire file prior to writing in it (mode eos_base:: //! erase the entire file prior to writing in it (mode eos_base::
bool overwrite; bool overwrite;
}; };
#endif #endif

View file

@ -167,6 +167,8 @@ public :
repValue(_defaultValue) repValue(_defaultValue)
{ {
eoParam::defValue(getValue()); eoParam::defValue(getValue());
// default precision
numOfDigits = std::cout.precision();
} }
/** Get a reference on the parameter value /** Get a reference on the parameter value
@ -203,6 +205,7 @@ public :
std::string getValue(void) const std::string getValue(void) const
{ {
std::ostringstream os; std::ostringstream os;
os.precision(numOfDigits);
os << repValue; os << repValue;
return os.str(); return os.str();
} }
@ -227,9 +230,21 @@ public :
is >> repValue; is >> repValue;
} }
/**
set the precision of the output
@param _numOfDigits the precision of the output
*/
void setPrecision(unsigned _numOfDigits) {
numOfDigits = _numOfDigits;
}
protected: protected:
ValueType repValue; ValueType repValue;
//! precision of the output
unsigned numOfDigits;
}; };
/* /*

View file

@ -162,7 +162,7 @@ private:
// true if the move is accepted // true if the move is accepted
bool isAccept ; 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) // if false : never stop, always continue (external continuator)
bool stop ; bool stop ;
}; };