Open godrays opened 2 years ago
I found a suggestion in other issues saying we needed to use cmasols.get_best_seen_candidate() instead of cmasols.best_candidate()
auto best_candidate = cmasols.get_best_seen_candidate();
std::cout << "Best solution: f-value: " << best_candidate.get_fvalue()
<< ", x: " << best_candidate.get_x().front() << std::endl;
Unfortunately, I still see incorrect answers in outputs.. Just see below that x should never be lower than 0.
...
Best solution: f-value: -6, x: 8.78817
Best solution: f-value: -6, x: -8.36663
Here is an other incorrect output.. x should never be higher than 21.
...
Best solution: f-value: -6, x: 8.6857
Best solution: f-value: -6, x: 8.69536
Best solution: f-value: -6, x: 37.5472
Best solution: f-value: -6, x: 37.5472
Best solution: f-value: -6, x: 8.07772
...
Please note that the issue happened less frequently than the first test, but still the same issue.
Hi, see https://github.com/CMA-ES/libcmaes/wiki/Defining-and-using-bounds-on-parameters
You are using a genopheno for bounded parameters, thus need to print the solution in pheno space: cmasols.print(std::cout, 0, gp)
?
Also, for you own better understanding, the implementation is here: https://github.com/CMA-ES/libcmaes/blob/master/src/cmasolutions.cc#L257 (see the gp.get_pheno(best_candidate()...
call.
Thank you for the quick clarification.
Transformation solved my issue. However, cmasols.print(...) implementation you mentioned uses the best_candidate() for report
<< " / x=" << gp.pheno(best_candidate().get_x_dvec()).transpose();
The documentation suggests using best_seen_candidate(), which is confusing.
Eigen::VectorXd bestparameters = gp.pheno(cmasols.get_best_seen_candidate().get_x_dvec());
In this case, anyone who uses cmasols.print(...) might not see the best parameters. What is the exact difference between best_candidate() and best_seen_candidate()? Can we document the diff?
best_seen_candidate()
returns the best over the whole run, while best_candidate()
returns the current solution.
You should be able to apply gp.pheno
to best_seen_candidate()
, this is th reason why I pointed to the implementation.
Maybe we should provide a print_best_seen
function as well...
Hello,
I found that the CMASolutions does not report best candidate's x value properly.
Here is an example output from 20 iteration:
I validated that x values in fitness function never gets higher than 21 during simulations, which is expected. You can see some of the x values are over 21. Sometimes I see negative x values too, which is also NOT expected.
Here is the test code I used:
Is this expected behavior? If yes then why?
I compiled the lib with OpenMP=OFF I use v0.10 and built it from the source code.
Thanks