fix new warnings and escape apply namespace
- `std::apply` is part of C++17 and the compiler wants to use it because of ADL. Thus it is now necessary to escape it as `::apply`. - remove some `using namespace std` remaining in the sources. - fix simple warnings.
This commit is contained in:
parent
c95f5607d8
commit
24bc8edd6f
25 changed files with 125 additions and 125 deletions
|
|
@ -84,7 +84,7 @@ int main(int ac, char** av)
|
||||||
eoPop< RealVec >& pop = do_make_pop(parser, state, *init);
|
eoPop< RealVec >& pop = do_make_pop(parser, state, *init);
|
||||||
|
|
||||||
// (2) First evaluation before starting the research algorithm
|
// (2) First evaluation before starting the research algorithm
|
||||||
apply(eval, pop);
|
::apply(eval, pop);
|
||||||
|
|
||||||
// Prepare bounder class to set bounds of sampling.
|
// Prepare bounder class to set bounds of sampling.
|
||||||
// This is used by edoSampler.
|
// This is used by edoSampler.
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ int main(int ac, char** av)
|
||||||
eoPop< EOT >& pop = do_make_pop(parser, state, *init);
|
eoPop< EOT >& pop = do_make_pop(parser, state, *init);
|
||||||
|
|
||||||
// (2) First evaluation before starting the research algorithm
|
// (2) First evaluation before starting the research algorithm
|
||||||
apply(eval, pop);
|
::apply(eval, pop);
|
||||||
|
|
||||||
// Prepare bounder class to set bounds of sampling.
|
// Prepare bounder class to set bounds of sampling.
|
||||||
// This is used by edoSampler.
|
// This is used by edoSampler.
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class edoDistribReset : public eoAlgoReset<typename D::EOType>
|
||||||
_distrib(distrib)
|
_distrib(distrib)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void operator()( eoPop<EOType>& pop )
|
virtual void operator()( eoPop<EOType>& /*pop*/ )
|
||||||
{
|
{
|
||||||
if(_has_dim) {
|
if(_has_dim) {
|
||||||
_distrib.reset(_dim);
|
_distrib.reset(_dim);
|
||||||
|
|
|
||||||
|
|
@ -1339,7 +1339,7 @@ HIDE_UNDOC_RELATIONS = YES
|
||||||
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
||||||
# have no effect if this option is set to NO (the default)
|
# have no effect if this option is set to NO (the default)
|
||||||
|
|
||||||
HAVE_DOT = NO
|
HAVE_DOT = YES
|
||||||
|
|
||||||
# By default doxygen will write a font called FreeSans.ttf to the output
|
# By default doxygen will write a font called FreeSans.ttf to the output
|
||||||
# directory and reference it in all dot files that doxygen generates. This
|
# directory and reference it in all dot files that doxygen generates. This
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,10 @@ public:
|
||||||
virtual void operator() ()
|
virtual void operator() ()
|
||||||
{
|
{
|
||||||
eoPop<POT> empty_pop;
|
eoPop<POT> empty_pop;
|
||||||
apply(proc, pop);
|
::apply(proc, pop);
|
||||||
procPara(empty_pop, pop);
|
procPara(empty_pop, pop);
|
||||||
apply < POT > (initVelo, pop);
|
::apply < POT > (initVelo, pop);
|
||||||
apply < POT > (initBest, pop);
|
::apply < POT > (initBest, pop);
|
||||||
topology.setup(pop);
|
topology.setup(pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Prints the neighborhoods contained in the topology.
|
* Prints the neighborhoods contained in the topology.
|
||||||
*/
|
*/
|
||||||
virtual void printOn() = 0;
|
// virtual void printOn() = 0; // Already defined in eoPop
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "eoParam.h"
|
#include "eoParam.h"
|
||||||
#include "../eoExceptions.h"
|
#include "../eoExceptions.h"
|
||||||
|
|
||||||
using namespace std;
|
// using namespace std;
|
||||||
|
|
||||||
void eoFileMonitor::printHeader(std::ostream& os)
|
void eoFileMonitor::printHeader(std::ostream& os)
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +33,7 @@ void eoFileMonitor::printHeader(std::ostream& os)
|
||||||
void eoFileMonitor::printHeader()
|
void eoFileMonitor::printHeader()
|
||||||
{
|
{
|
||||||
// create file
|
// create file
|
||||||
ofstream os(filename.c_str());
|
std::ofstream os(filename.c_str());
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
|
|
@ -46,11 +46,11 @@ void eoFileMonitor::printHeader()
|
||||||
|
|
||||||
eoMonitor& eoFileMonitor::operator()(void)
|
eoMonitor& eoFileMonitor::operator()(void)
|
||||||
{
|
{
|
||||||
ofstream os(filename.c_str(),
|
std::ofstream os(filename.c_str(),
|
||||||
overwrite ?
|
overwrite ?
|
||||||
ios_base::out|ios_base::trunc // truncate
|
std::ios_base::out|std::ios_base::trunc // truncate
|
||||||
:
|
:
|
||||||
ios_base::out|ios_base::app // append
|
std::ios_base::out|std::ios_base::app // append
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now create the embedded eoIntBounds object
|
// now create the embedded eoIntBounds object
|
||||||
eoIntBounds * locBound;
|
eoIntBounds * locBound = nullptr;
|
||||||
if (minBounded && maxBounded)
|
if (minBounded && maxBounded)
|
||||||
{
|
{
|
||||||
if (maxBound <= minBound)
|
if (maxBound <= minBound)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ Authors:
|
||||||
#include "eoLogger.h"
|
#include "eoLogger.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
// using namespace std;
|
||||||
|
|
||||||
std::ostream& printSectionHeader(std::ostream& os, std::string section)
|
std::ostream& printSectionHeader(std::ostream& os, std::string section)
|
||||||
{
|
{
|
||||||
|
|
@ -76,8 +76,8 @@ eoParameterLoader::~eoParameterLoader()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
eoParser::eoParser ( unsigned _argc, char **_argv , std::string _programDescription,
|
||||||
string /*_lFileParamName*/, char /*_shortHand*/) :
|
std::string /*_lFileParamName*/, char /*_shortHand*/) :
|
||||||
programName(_argv[0]),
|
programName(_argv[0]),
|
||||||
programDescription( _programDescription),
|
programDescription( _programDescription),
|
||||||
needHelpMessage( false ),
|
needHelpMessage( false ),
|
||||||
|
|
@ -92,11 +92,11 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
||||||
if(_argv[i][0] == '@')
|
if(_argv[i][0] == '@')
|
||||||
{ // read response file
|
{ // read response file
|
||||||
char *pts = _argv[i]+1; // yes a char*, sorry :-)
|
char *pts = _argv[i]+1; // yes a char*, sorry :-)
|
||||||
ifstream ifs (pts);
|
std::ifstream ifs (pts);
|
||||||
ifs.peek(); // check if it exists
|
ifs.peek(); // check if it exists
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
{
|
{
|
||||||
// string msg = string("Could not open response file: ") + pts;
|
// std::string msg = std::string("Could not open response file: ") + pts;
|
||||||
throw eoFileError(pts);
|
throw eoFileError(pts);
|
||||||
}
|
}
|
||||||
// read - will be overwritten by command-line
|
// read - will be overwritten by command-line
|
||||||
|
|
@ -105,7 +105,7 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now read arguments on command-line
|
// now read arguments on command-line
|
||||||
stringstream stream;
|
std::stringstream stream;
|
||||||
for (i = 1; i < _argc; ++i)
|
for (i = 1; i < _argc; ++i)
|
||||||
{
|
{
|
||||||
stream << _argv[i] << '\n';
|
stream << _argv[i] << '\n';
|
||||||
|
|
@ -159,24 +159,24 @@ void eoParser::doRegisterParam(eoParam& param)
|
||||||
{
|
{
|
||||||
if (param.required() && !isItThere(param))
|
if (param.required() && !isItThere(param))
|
||||||
{
|
{
|
||||||
string msg = "Required parameter: " + param.longName() + " missing";
|
std::string msg = "Required parameter: " + param.longName() + " missing";
|
||||||
needHelpMessage = true;
|
needHelpMessage = true;
|
||||||
messages.push_back(msg);
|
messages.push_back(msg);
|
||||||
}
|
}
|
||||||
pair<bool, string> value = getValue(param);
|
std::pair<bool, std::string> value = getValue(param);
|
||||||
if (value.first)
|
if (value.first)
|
||||||
{
|
{
|
||||||
param.setValue(value.second);
|
param.setValue(value.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<bool, string> eoParser::getValue(eoParam& _param) const
|
std::pair<bool, std::string> eoParser::getValue(eoParam& _param) const
|
||||||
{
|
{
|
||||||
pair<bool, string> result(false, "");
|
std::pair<bool, std::string> result(false, "");
|
||||||
|
|
||||||
if (_param.shortName() != 0)
|
if (_param.shortName() != 0)
|
||||||
{
|
{
|
||||||
map<char, string>::const_iterator it = shortNameMap.find(_param.shortName());
|
std::map<char, std::string>::const_iterator it = shortNameMap.find(_param.shortName());
|
||||||
if (it != shortNameMap.end())
|
if (it != shortNameMap.end())
|
||||||
{
|
{
|
||||||
result.second = it->second;
|
result.second = it->second;
|
||||||
|
|
@ -184,7 +184,7 @@ pair<bool, string> eoParser::getValue(eoParam& _param) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map<string, string>::const_iterator it = longNameMap.find(_param.longName());
|
std::map<std::string, std::string>::const_iterator it = longNameMap.find(_param.longName());
|
||||||
if (it != longNameMap.end())
|
if (it != longNameMap.end())
|
||||||
{
|
{
|
||||||
result.second = it->second;
|
result.second = it->second;
|
||||||
|
|
@ -205,21 +205,21 @@ void eoParser::updateParameters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoParser::readFrom(istream& is)
|
void eoParser::readFrom(std::istream& is)
|
||||||
{
|
{
|
||||||
string str;
|
std::string str;
|
||||||
// we must avoid processing \section{xxx} if xxx is NOT "Parser"
|
// we must avoid processing \section{xxx} if xxx is NOT "Parser"
|
||||||
bool processing = true;
|
bool processing = true;
|
||||||
while (is >> str)
|
while (is >> str)
|
||||||
{
|
{
|
||||||
if (str.find(string("\\section{"))==0) // found section begin
|
if (str.find(std::string("\\section{"))==0) // found section begin
|
||||||
processing = (str.find(string("Parser"))<str.size());
|
processing = (str.find(std::string("Parser"))<str.size());
|
||||||
|
|
||||||
if (processing) // right \section (or no \section at all)
|
if (processing) // right \section (or no \section at all)
|
||||||
{
|
{
|
||||||
if (str[0] == '#')
|
if (str[0] == '#')
|
||||||
{ // skip the rest of the line
|
{ // skip the rest of the line
|
||||||
string tempStr;
|
std::string tempStr;
|
||||||
getline(is, tempStr);
|
getline(is, tempStr);
|
||||||
}
|
}
|
||||||
if (str[0] == '-')
|
if (str[0] == '-')
|
||||||
|
|
@ -233,35 +233,35 @@ void eoParser::readFrom(istream& is)
|
||||||
|
|
||||||
if (str[1] == '-') // two consecutive dashes
|
if (str[1] == '-') // two consecutive dashes
|
||||||
{
|
{
|
||||||
string::iterator equalLocation = find(str.begin() + 2, str.end(), '=');
|
std::string::iterator equalLocation = find(str.begin() + 2, str.end(), '=');
|
||||||
string value;
|
std::string value;
|
||||||
|
|
||||||
if (equalLocation == str.end())
|
if (equalLocation == str.end())
|
||||||
{ //! @todo it should be the next string
|
{ //! @todo it should be the next std::string
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = string(equalLocation + 1, str.end());
|
value = std::string(equalLocation + 1, str.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
string name(str.begin() + 2, equalLocation);
|
std::string name(str.begin() + 2, equalLocation);
|
||||||
longNameMap[name] = value;
|
longNameMap[name] = value;
|
||||||
}
|
}
|
||||||
else // it should be a char
|
else // it should be a char
|
||||||
{
|
{
|
||||||
string value = "1"; // flags do not need a special
|
std::string value = "1"; // flags do not need a special
|
||||||
|
|
||||||
if (str.size() >= 2)
|
if (str.size() >= 2)
|
||||||
{
|
{
|
||||||
if (str[2] == '=')
|
if (str[2] == '=')
|
||||||
{
|
{
|
||||||
if (str.size() >= 3)
|
if (str.size() >= 3)
|
||||||
value = string(str.begin() + 3, str.end());
|
value = std::string(str.begin() + 3, str.end());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = string(str.begin() + 2, str.end());
|
value = std::string(str.begin() + 2, str.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,7 +274,7 @@ void eoParser::readFrom(istream& is)
|
||||||
updateParameters();
|
updateParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoParser::printOn(ostream& os) const
|
void eoParser::printOn(std::ostream& os) const
|
||||||
{
|
{
|
||||||
typedef MultiMapType::const_iterator It;
|
typedef MultiMapType::const_iterator It;
|
||||||
|
|
||||||
|
|
@ -299,12 +299,12 @@ void eoParser::printOn(ostream& os) const
|
||||||
if (!isItThere(*param)) // comment out the ones not set by the user
|
if (!isItThere(*param)) // comment out the ones not set by the user
|
||||||
os << "# ";
|
os << "# ";
|
||||||
|
|
||||||
string str = "--" + param->longName() + "=" + param->getValue();
|
std::string str = "--" + param->longName() + "=" + param->getValue();
|
||||||
|
|
||||||
os.setf(ios_base::left, ios_base::adjustfield);
|
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||||
os << setfill(' ') << setw(40) << str;
|
os << std::setfill(' ') << std::setw(40) << str;
|
||||||
|
|
||||||
os << setw(0) << " # ";
|
os << std::setw(0) << " # ";
|
||||||
if (param->shortName())
|
if (param->shortName())
|
||||||
os << '-' << param->shortName() << " : ";
|
os << '-' << param->shortName() << " : ";
|
||||||
os << param->description();
|
os << param->description();
|
||||||
|
|
@ -318,11 +318,11 @@ void eoParser::printOn(ostream& os) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoParser::printHelp(ostream& os)
|
void eoParser::printHelp(std::ostream& os)
|
||||||
{
|
{
|
||||||
if (needHelp.value() == false && !messages.empty())
|
if (needHelp.value() == false && !messages.empty())
|
||||||
{
|
{
|
||||||
std::copy(messages.begin(), messages.end(), ostream_iterator<string>(os, "\n"));
|
std::copy(messages.begin(), messages.end(), std::ostream_iterator<std::string>(os, "\n"));
|
||||||
messages.clear();
|
messages.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -333,9 +333,9 @@ void eoParser::printHelp(ostream& os)
|
||||||
// print the usage when calling the program from the command line
|
// print the usage when calling the program from the command line
|
||||||
os << "Usage: "<< programName<<" [Options]\n";
|
os << "Usage: "<< programName<<" [Options]\n";
|
||||||
// only short usage!
|
// only short usage!
|
||||||
os << "Options of the form \"-f[=Value]\" or \"--Name[=value]\"" << endl;
|
os << "Options of the form \"-f[=Value]\" or \"--Name[=value]\"" << std::endl;
|
||||||
|
|
||||||
os << "Where:"<<endl;
|
os << "Where:"<< std::endl;
|
||||||
|
|
||||||
typedef MultiMapType::const_iterator It;
|
typedef MultiMapType::const_iterator It;
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ bool eoParser::userNeedsHelp(void)
|
||||||
// search for unknown long names
|
// search for unknown long names
|
||||||
for (LongNameMapType::const_iterator lIt = longNameMap.begin(); lIt != longNameMap.end(); ++lIt)
|
for (LongNameMapType::const_iterator lIt = longNameMap.begin(); lIt != longNameMap.end(); ++lIt)
|
||||||
{
|
{
|
||||||
string entry = lIt->first;
|
std::string entry = lIt->first;
|
||||||
|
|
||||||
MultiMapType::const_iterator it;
|
MultiMapType::const_iterator it;
|
||||||
|
|
||||||
|
|
@ -397,7 +397,7 @@ bool eoParser::userNeedsHelp(void)
|
||||||
|
|
||||||
if (it == params.end())
|
if (it == params.end())
|
||||||
{
|
{
|
||||||
string msg = "Unknown parameter: --" + entry + " entered";
|
std::string msg = "Unknown parameter: --" + entry + " entered";
|
||||||
needHelpMessage = true;
|
needHelpMessage = true;
|
||||||
messages.push_back(msg);
|
messages.push_back(msg);
|
||||||
}
|
}
|
||||||
|
|
@ -420,15 +420,15 @@ bool eoParser::userNeedsHelp(void)
|
||||||
|
|
||||||
if (it == params.end())
|
if (it == params.end())
|
||||||
{
|
{
|
||||||
string entryString(1, entry);
|
std::string entryString(1, entry);
|
||||||
string msg = "Unknown parameter: -" + entryString + " entered";
|
std::string msg = "Unknown parameter: -" + entryString + " entered";
|
||||||
needHelpMessage = true;
|
needHelpMessage = true;
|
||||||
messages.push_back(msg);
|
messages.push_back(msg);
|
||||||
}
|
}
|
||||||
} // for sIt
|
} // for sIt
|
||||||
|
|
||||||
if( needHelpMessage ) {
|
if( needHelpMessage ) {
|
||||||
string msg = "Use -h or --help to get help about available parameters";
|
std::string msg = "Use -h or --help to get help about available parameters";
|
||||||
messages.push_back( msg );
|
messages.push_back( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,13 +438,13 @@ bool eoParser::userNeedsHelp(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////// I put these here at the moment
|
///////////////// I put these here at the moment
|
||||||
ostream & operator<<(ostream & _os, const eoParamParamType & _rate)
|
std::ostream & operator<<(std::ostream & _os, const eoParamParamType & _rate)
|
||||||
{
|
{
|
||||||
_rate.printOn(_os);
|
_rate.printOn(_os);
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream & operator>>(istream & _is, eoParamParamType & _rate)
|
std::istream & operator>>(std::istream & _is, eoParamParamType & _rate)
|
||||||
{
|
{
|
||||||
_rate.readFrom(_is);
|
_rate.readFrom(_is);
|
||||||
return _is;
|
return _is;
|
||||||
|
|
|
||||||
|
|
@ -14,31 +14,31 @@
|
||||||
#include "../eoObject.h"
|
#include "../eoObject.h"
|
||||||
#include "../eoPersistent.h"
|
#include "../eoPersistent.h"
|
||||||
|
|
||||||
using namespace std;
|
// using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void eoState::removeComment(string& str, string comment)
|
void eoState::removeComment(std::string& str, std::string comment)
|
||||||
{
|
{
|
||||||
string::size_type pos = str.find(comment);
|
std::string::size_type pos = str.find(comment);
|
||||||
|
|
||||||
if (pos != string::npos)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
str.erase(pos, str.size());
|
str.erase(pos, str.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eoState::is_section(const string& str, string& name)
|
bool eoState::is_section(const std::string& str, std::string& name)
|
||||||
{
|
{
|
||||||
string::size_type pos = str.find(_tag_section_so);
|
std::string::size_type pos = str.find(_tag_section_so);
|
||||||
|
|
||||||
if (pos == string::npos)
|
if (pos == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
//else
|
//else
|
||||||
|
|
||||||
string::size_type end = str.find(_tag_section_sc);
|
std::string::size_type end = str.find(_tag_section_sc);
|
||||||
|
|
||||||
if (end == string::npos)
|
if (end == std::string::npos)
|
||||||
return false;
|
return false;
|
||||||
// else
|
// else
|
||||||
|
|
||||||
|
|
@ -59,9 +59,9 @@ eoState::~eoState(void)
|
||||||
|
|
||||||
void eoState::registerObject(eoPersistent& registrant)
|
void eoState::registerObject(eoPersistent& registrant)
|
||||||
{
|
{
|
||||||
string name = createObjectName(dynamic_cast<eoObject*>(®istrant));
|
std::string name = createObjectName(dynamic_cast<eoObject*>(®istrant));
|
||||||
|
|
||||||
pair<ObjectMap::iterator,bool> res = objectMap.insert(make_pair(name, ®istrant));
|
std::pair<ObjectMap::iterator,bool> res = objectMap.insert(make_pair(name, ®istrant));
|
||||||
|
|
||||||
if (res.second == true)
|
if (res.second == true)
|
||||||
{
|
{
|
||||||
|
|
@ -73,13 +73,13 @@ void eoState::registerObject(eoPersistent& registrant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoState::load(const string& _filename)
|
void eoState::load(const std::string& _filename)
|
||||||
{
|
{
|
||||||
ifstream is (_filename.c_str());
|
std::ifstream is (_filename.c_str());
|
||||||
|
|
||||||
if (!is)
|
if (!is)
|
||||||
{
|
{
|
||||||
// string str = "Could not open file " + _filename;
|
// std::string str = "Could not open file " + _filename;
|
||||||
throw eoFileError(_filename);
|
throw eoFileError(_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,14 +89,14 @@ void eoState::load(const string& _filename)
|
||||||
// FIXME implement parsing and loading of other formats
|
// FIXME implement parsing and loading of other formats
|
||||||
void eoState::load(std::istream& is)
|
void eoState::load(std::istream& is)
|
||||||
{
|
{
|
||||||
string str;
|
std::string str;
|
||||||
string name;
|
std::string name;
|
||||||
|
|
||||||
getline(is, str);
|
getline(is, str);
|
||||||
|
|
||||||
if (is.fail())
|
if (is.fail())
|
||||||
{
|
{
|
||||||
// string str = "Error while reading stream";
|
// std::string str = "Error while reading stream";
|
||||||
throw eoFileError("stream");
|
throw eoFileError("stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ void eoState::load(std::istream& is)
|
||||||
{ // parse section header
|
{ // parse section header
|
||||||
if (is_section(str, name))
|
if (is_section(str, name))
|
||||||
{
|
{
|
||||||
string fullString;
|
std::string fullString;
|
||||||
ObjectMap::iterator it = objectMap.find(name);
|
ObjectMap::iterator it = objectMap.find(name);
|
||||||
|
|
||||||
if (it == objectMap.end())
|
if (it == objectMap.end())
|
||||||
|
|
@ -122,7 +122,7 @@ void eoState::load(std::istream& is)
|
||||||
|
|
||||||
// now we have the object, get lines, remove comments etc.
|
// now we have the object, get lines, remove comments etc.
|
||||||
|
|
||||||
string fullstring;
|
std::string fullstring;
|
||||||
|
|
||||||
while (getline(is, str))
|
while (getline(is, str))
|
||||||
{
|
{
|
||||||
|
|
@ -134,7 +134,7 @@ void eoState::load(std::istream& is)
|
||||||
removeComment(str, getCommentString());
|
removeComment(str, getCommentString());
|
||||||
fullstring += str + "\n";
|
fullstring += str + "\n";
|
||||||
}
|
}
|
||||||
istringstream the_stream(fullstring);
|
std::istringstream the_stream(fullstring);
|
||||||
object->readFrom(the_stream);
|
object->readFrom(the_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,13 +148,13 @@ void eoState::load(std::istream& is)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void eoState::save(const string& filename) const
|
void eoState::save(const std::string& filename) const
|
||||||
{ // saves in order of insertion
|
{ // saves in order of insertion
|
||||||
ofstream os(filename.c_str());
|
std::ofstream os(filename.c_str());
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
{
|
{
|
||||||
// string msg = "Could not open file: " + filename + " for writing!";
|
// std::string msg = "Could not open file: " + filename + " for writing!";
|
||||||
throw eoFileError(filename);
|
throw eoFileError(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ void eoState::save(const string& filename) const
|
||||||
|
|
||||||
//void eoState::save(std::ostream& os) const
|
//void eoState::save(std::ostream& os) const
|
||||||
//{ // saves in order of insertion
|
//{ // saves in order of insertion
|
||||||
// for (vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin(); it != creationOrder.end(); ++it)
|
// for (std::vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin(); it != creationOrder.end(); ++it)
|
||||||
// {
|
// {
|
||||||
// os << "\\section{" << (*it)->first << "}\n";
|
// os << "\\section{" << (*it)->first << "}\n";
|
||||||
// (*it)->second->printOn(os);
|
// (*it)->second->printOn(os);
|
||||||
|
|
@ -171,7 +171,7 @@ void eoState::save(const string& filename) const
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void eoState::saveSection( std::ostream& os, vector<ObjectMap::iterator>::const_iterator it) const
|
void eoState::saveSection( std::ostream& os, std::vector<ObjectMap::iterator>::const_iterator it) const
|
||||||
{
|
{
|
||||||
os << _tag_section_so << (*it)->first << _tag_section_sc;
|
os << _tag_section_so << (*it)->first << _tag_section_sc;
|
||||||
|
|
||||||
|
|
@ -190,7 +190,7 @@ void eoState::save(std::ostream& os) const
|
||||||
// save the first section
|
// save the first section
|
||||||
assert( creationOrder.size() > 0 );
|
assert( creationOrder.size() > 0 );
|
||||||
// saves in order of insertion
|
// saves in order of insertion
|
||||||
vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin();
|
std::vector<ObjectMap::iterator>::const_iterator it = creationOrder.begin();
|
||||||
saveSection(os,it);
|
saveSection(os,it);
|
||||||
it++;
|
it++;
|
||||||
|
|
||||||
|
|
@ -204,23 +204,23 @@ void eoState::save(std::ostream& os) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string eoState::createObjectName(eoObject* obj)
|
std::string eoState::createObjectName(eoObject* obj)
|
||||||
{
|
{
|
||||||
if (obj == 0)
|
if (obj == 0)
|
||||||
{
|
{
|
||||||
ostringstream os;
|
std::ostringstream os;
|
||||||
os << objectMap.size();
|
os << objectMap.size();
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
|
|
||||||
string name = obj->className();
|
std::string name = obj->className();
|
||||||
ObjectMap::const_iterator it = objectMap.find(name);
|
ObjectMap::const_iterator it = objectMap.find(name);
|
||||||
|
|
||||||
unsigned count = 1;
|
unsigned count = 1;
|
||||||
while (it != objectMap.end())
|
while (it != objectMap.end())
|
||||||
{
|
{
|
||||||
ostringstream os;
|
std::ostringstream os;
|
||||||
os << obj->className().c_str() << count++;
|
os << obj->className().c_str() << count++;
|
||||||
name = os.str();
|
name = os.str();
|
||||||
it = objectMap.find(name);
|
it = objectMap.find(name);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include "eoParser.h"
|
#include "eoParser.h"
|
||||||
|
|
||||||
using namespace std;
|
// using namespace std;
|
||||||
|
|
||||||
/** Generation of the status file, and output of the help message if needed
|
/** Generation of the status file, and output of the help message if needed
|
||||||
*
|
*
|
||||||
|
|
@ -47,24 +47,24 @@ using namespace std;
|
||||||
void make_help(eoParser & _parser, bool exit_after)
|
void make_help(eoParser & _parser, bool exit_after)
|
||||||
{
|
{
|
||||||
// name of the "status" file where all actual parameter values will be saved
|
// name of the "status" file where all actual parameter values will be saved
|
||||||
string str_status = _parser.ProgramName() + ".status"; // default value
|
std::string str_status = _parser.ProgramName() + ".status"; // default value
|
||||||
eoValueParam<string>& statusParam = _parser.createParam(str_status, "status","Status file",'\0', "Persistence" );
|
eoValueParam<std::string>& statusParam = _parser.createParam(str_status, "status","Status file",'\0', "Persistence" );
|
||||||
|
|
||||||
// dump status file BEFORE help, so the user gets a chance to use it:
|
// dump status file BEFORE help, so the user gets a chance to use it:
|
||||||
// it's probably the case where she/he needs it most!!!
|
// it's probably the case where she/he needs it most!!!
|
||||||
// Only help parameter will not be in status file - but who cares???
|
// Only help parameter will not be in status file - but who cares???
|
||||||
if (statusParam.value() != "")
|
if (statusParam.value() != "")
|
||||||
{
|
{
|
||||||
ofstream os(statusParam.value().c_str());
|
std::ofstream os(statusParam.value().c_str());
|
||||||
os << _parser; // and you can use that file as parameter file
|
os << _parser; // and you can use that file as parameter file
|
||||||
}
|
}
|
||||||
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
|
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
|
||||||
// i.e. in case you need parameters somewhere else, postpone these
|
// i.e. in case you need parameters somewhere else, postpone these
|
||||||
if (_parser.userNeedsHelp())
|
if (_parser.userNeedsHelp())
|
||||||
{
|
{
|
||||||
_parser.printHelp(cout);
|
_parser.printHelp(std::cout);
|
||||||
cout << "You can use an edited copy of file " << statusParam.value()
|
std::cout << "You can use an edited copy of file " << statusParam.value()
|
||||||
<< " as parameter file" << endl;
|
<< " as parameter file" << std::endl;
|
||||||
if(exit_after) {
|
if(exit_after) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ void make_help(eoParser & _parser, bool exit_after)
|
||||||
*/
|
*/
|
||||||
bool testDirRes(std::string _dirName, bool _erase=true)
|
bool testDirRes(std::string _dirName, bool _erase=true)
|
||||||
{
|
{
|
||||||
string s = "test -d " + _dirName;
|
std::string s = "test -d " + _dirName;
|
||||||
int res = system(s.c_str());
|
int res = system(s.c_str());
|
||||||
// test for (unlikely) errors
|
// test for (unlikely) errors
|
||||||
if ( (res==-1) || (res==127) )
|
if ( (res==-1) || (res==127) )
|
||||||
|
|
@ -91,7 +91,7 @@ bool testDirRes(std::string _dirName, bool _erase=true)
|
||||||
// now make sure there is a dir without any file in it - or quit
|
// now make sure there is a dir without any file in it - or quit
|
||||||
if (res) // no dir present
|
if (res) // no dir present
|
||||||
{
|
{
|
||||||
s = string("mkdir ")+ _dirName;
|
s = std::string("mkdir ")+ _dirName;
|
||||||
int res = system(s.c_str());
|
int res = system(s.c_str());
|
||||||
(void)res;
|
(void)res;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -99,7 +99,7 @@ bool testDirRes(std::string _dirName, bool _erase=true)
|
||||||
// else
|
// else
|
||||||
if (_erase) // OK to erase
|
if (_erase) // OK to erase
|
||||||
{
|
{
|
||||||
s = string("/bin/rm ")+ _dirName + "/*";
|
s = std::string("/bin/rm ")+ _dirName + "/*";
|
||||||
int res = system(s.c_str());
|
int res = system(s.c_str());
|
||||||
(void)res;
|
(void)res;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ int main_function(int argc, char **argv)
|
||||||
eoFirstIsBestInit < Indi > localInit;
|
eoFirstIsBestInit < Indi > localInit;
|
||||||
eoPop < Indi > pop;
|
eoPop < Indi > pop;
|
||||||
pop.append (POP_SIZE, random);
|
pop.append (POP_SIZE, random);
|
||||||
apply(eval, pop);
|
::apply(eval, pop);
|
||||||
apply < Indi > (veloRandom, pop);
|
::apply < Indi > (veloRandom, pop);
|
||||||
apply < Indi > (localInit, pop);
|
::apply < Indi > (localInit, pop);
|
||||||
eoRingTopology<Indi> topology(NEIGHBORHOOD_SIZE);
|
eoRingTopology<Indi> topology(NEIGHBORHOOD_SIZE);
|
||||||
topology.setup(pop);
|
topology.setup(pop);
|
||||||
std::cout<<"\n\n\nPopulation :\n\n"<<pop;
|
std::cout<<"\n\n\nPopulation :\n\n"<<pop;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||||
|
|
||||||
eoPop<EOT> pop;
|
eoPop<EOT> pop;
|
||||||
pop.append(pop_size, init);
|
pop.append(pop_size, init);
|
||||||
apply(eval,pop);
|
::apply(eval,pop);
|
||||||
|
|
||||||
algo(pop);
|
algo(pop);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ double binary_value(const Indi & _indi)
|
||||||
}
|
}
|
||||||
// GENERAL
|
// GENERAL
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
// PARAMETRES
|
// PARAMETRES
|
||||||
// all parameters are hard-coded!
|
// all parameters are hard-coded!
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ double real_value(const Indi & _indi)
|
||||||
}
|
}
|
||||||
// GENERAL
|
// GENERAL
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
// PARAMETRES
|
// PARAMETRES
|
||||||
// all parameters are hard-coded!
|
// all parameters are hard-coded!
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ double binary_value(const Indi & _indi)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
const unsigned int SEED = 42; // seed for random number generator
|
const unsigned int SEED = 42; // seed for random number generator
|
||||||
const unsigned int VEC_SIZE = 8; // Number of bits in genotypes
|
const unsigned int VEC_SIZE = 8; // Number of bits in genotypes
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ using namespace std;
|
||||||
// GENERAL
|
// GENERAL
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
// PARAMETRES
|
// PARAMETRES
|
||||||
const unsigned int SEED = 42; // seed for random number generator
|
const unsigned int SEED = 42; // seed for random number generator
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
// PARAMETRES
|
// PARAMETRES
|
||||||
const unsigned int SEED = 42; // seed for random number generator
|
const unsigned int SEED = 42; // seed for random number generator
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public:
|
||||||
* modifies the parent
|
* modifies the parent
|
||||||
* @param _genotype The parent genotype (will be modified)
|
* @param _genotype The parent genotype (will be modified)
|
||||||
*/
|
*/
|
||||||
bool operator()(GenotypeT & _genotype)
|
bool operator()(GenotypeT & /*_genotype*/)
|
||||||
{
|
{
|
||||||
bool isModified(true);
|
bool isModified(true);
|
||||||
// START code for mutation of the _genotype object
|
// START code for mutation of the _genotype object
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public:
|
||||||
* @param _genotype1 The first parent
|
* @param _genotype1 The first parent
|
||||||
* @param _genotype2 The second parent
|
* @param _genotype2 The second parent
|
||||||
*/
|
*/
|
||||||
bool operator()(GenotypeT& _genotype1, GenotypeT & _genotype2)
|
bool operator()(GenotypeT& /*_genotype1*/, GenotypeT & /*_genotype2*/)
|
||||||
{
|
{
|
||||||
bool oneAtLeastIsModified(true);
|
bool oneAtLeastIsModified(true);
|
||||||
// START code for crossover of _genotype1 and _genotype2 objects
|
// START code for crossover of _genotype1 and _genotype2 objects
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EOT>& _init)
|
eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EOT>& /*_init*/)
|
||||||
{
|
{
|
||||||
// this is a temporary version, while Maarten codes the full tree-structured
|
// this is a temporary version, while Maarten codes the full tree-structured
|
||||||
// general operator input
|
// general operator input
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include <eo>
|
#include <eo>
|
||||||
|
|
||||||
// Use functions from namespace std
|
// Use functions from namespace std
|
||||||
using namespace std;
|
// using namespace std; // Do not do this, this shadows EO's `apply` function.
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
typedef eoMinimizingFitness FitT;
|
typedef eoMinimizingFitness FitT;
|
||||||
|
|
@ -33,7 +33,7 @@ FitT real_value (const Particle & _particle)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int /*argc*/, char **/*argv*/)
|
||||||
{
|
{
|
||||||
// PARAMETRES
|
// PARAMETRES
|
||||||
// all parameters are hard-coded!
|
// all parameters are hard-coded!
|
||||||
|
|
@ -114,9 +114,9 @@ void main_function(int argc, char **argv)
|
||||||
pop.sort();
|
pop.sort();
|
||||||
|
|
||||||
// Print (sorted) the initial population (raw printout)
|
// Print (sorted) the initial population (raw printout)
|
||||||
cout << "INITIAL POPULATION:" << endl;
|
std::cout << "INITIAL POPULATION:" << std::endl;
|
||||||
for (unsigned i = 0; i < pop.size(); ++i)
|
for (unsigned i = 0; i < pop.size(); ++i)
|
||||||
cout << "\t best fit=" << pop[i] << endl;
|
std::cout << "\t best fit=" << pop[i] << std::endl;
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
|
@ -158,9 +158,9 @@ void main_function(int argc, char **argv)
|
||||||
// OUTPUT
|
// OUTPUT
|
||||||
// Print (sorted) intial population
|
// Print (sorted) intial population
|
||||||
pop.sort();
|
pop.sort();
|
||||||
cout << "FINAL POPULATION:" << endl;
|
std::clog << "FINAL POPULATION:" << std::endl;
|
||||||
for (unsigned i = 0; i < pop.size(); ++i)
|
for (unsigned i = 0; i < pop.size(); ++i)
|
||||||
cout << "\t best fit=" << pop[i] << endl;
|
std::clog << "\t best fit=" << pop[i] << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,9 +173,9 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
main_function(argc, argv);
|
main_function(argc, argv);
|
||||||
}
|
}
|
||||||
catch(exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
cout << "Exception: " << e.what() << '\n';
|
std::cerr << "Exception: " << e.what() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -45,25 +45,25 @@ FlowShopBenchmarkParser::FlowShopBenchmarkParser(const std::string _benchmarkFil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const unsigned int FlowShopBenchmarkParser::getM()
|
unsigned int FlowShopBenchmarkParser::getM()
|
||||||
{
|
{
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const unsigned int FlowShopBenchmarkParser::getN()
|
unsigned int FlowShopBenchmarkParser::getN()
|
||||||
{
|
{
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector< std::vector<unsigned int> > FlowShopBenchmarkParser::getP()
|
std::vector< std::vector<unsigned int> > FlowShopBenchmarkParser::getP()
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<unsigned int> FlowShopBenchmarkParser::getD()
|
std::vector<unsigned int> FlowShopBenchmarkParser::getD()
|
||||||
{
|
{
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,25 +60,25 @@ class FlowShopBenchmarkParser
|
||||||
/**
|
/**
|
||||||
* the number of machines
|
* the number of machines
|
||||||
*/
|
*/
|
||||||
const unsigned int getM();
|
unsigned int getM();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the number of jobs
|
* the number of jobs
|
||||||
*/
|
*/
|
||||||
const unsigned int getN();
|
unsigned int getN();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the processing times
|
* the processing times
|
||||||
*/
|
*/
|
||||||
const std::vector < std::vector < unsigned int > > getP();
|
std::vector < std::vector < unsigned int > > getP();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the due-dates
|
* the due-dates
|
||||||
*/
|
*/
|
||||||
const std::vector < unsigned int > getD();
|
std::vector < unsigned int > getD();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@
|
||||||
#include <FlowShopObjectiveVectorTraits.h>
|
#include <FlowShopObjectiveVectorTraits.h>
|
||||||
|
|
||||||
|
|
||||||
bool FlowShopObjectiveVectorTraits::minimizing (int _i)
|
bool FlowShopObjectiveVectorTraits::minimizing (int /*_i*/)
|
||||||
{
|
{
|
||||||
// minimizing both
|
// minimizing both
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlowShopObjectiveVectorTraits::maximizing (int _i)
|
bool FlowShopObjectiveVectorTraits::maximizing (int /*_i*/)
|
||||||
{
|
{
|
||||||
// minimizing both
|
// minimizing both
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue