add eoEvalCmd, an eval that call a system command
This commit is contained in:
parent
9056ed8989
commit
ccb4b3787b
4 changed files with 173 additions and 0 deletions
|
|
@ -70,6 +70,7 @@ set (TEST_LIST
|
|||
#t-eoDualFitness
|
||||
t-eoParser
|
||||
t-eoPartiallyMappedXover
|
||||
t-eoEvalCmd
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
29
eo/test/t-eoEvalCmd.cpp
Normal file
29
eo/test/t-eoEvalCmd.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <eo>
|
||||
#include <es.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int /*argc*/, char* /*argv[]*/)
|
||||
{
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
|
||||
// Build something like: ">&1 echo 1.2; # INVALID 2 1 2"
|
||||
eoEvalCmd<EOT> eval("echo 1.2", ">&1", "; #");
|
||||
|
||||
EOT sol = {1,2};
|
||||
std::clog << sol << std::endl;
|
||||
|
||||
try {
|
||||
eval(sol);
|
||||
} catch(eoSystemError& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::clog << eval.last_call() << std::endl;
|
||||
EOT::Fitness f = sol.fitness();
|
||||
std::clog << "fitness: " << f << std::endl;
|
||||
assert(f = 1.2);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue