Skip to content

Commit

Permalink
Merge branch 'dev' into elitism_103
Browse files Browse the repository at this point in the history
Conflicts:
	tests/test-functions.cc
  • Loading branch information
Emmanuel Benazera committed Feb 5, 2015
2 parents 820daad + 70db212 commit 5127295
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmasolutions.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ namespace libcmaes
inline Candidate best_candidate() const
{
if (_best_candidates_hist.empty()) // iter = 0
return Candidate(std::numeric_limits<double>::quiet_NaN(),_xmean);
{
if (_initial_candidate.get_x_size())
return _initial_candidate;
else return Candidate(std::numeric_limits<double>::quiet_NaN(),_xmean);
}
return _best_candidates_hist.back();
}

Expand Down
6 changes: 4 additions & 2 deletions cmastrategy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,12 @@ namespace libcmaes
//DLOG(INFO) << "optimize()\n";
//debug

if (eostrat<TGenoPheno>::_initial_elitist)
if (eostrat<TGenoPheno>::_initial_elitist
|| eostrat<TGenoPheno>::_parameters._initial_fvalue)
{
eostrat<TGenoPheno>::_solutions._initial_candidate = Candidate(eostrat<TGenoPheno>::_func(eostrat<TGenoPheno>::_solutions._xmean.data(),eostrat<TGenoPheno>::_parameters._dim),
eostrat<TGenoPheno>::_solutions._initial_candidate = Candidate(eostrat<TGenoPheno>::_func(eostrat<TGenoPheno>::_parameters._gp.pheno(eostrat<TGenoPheno>::_solutions._xmean).data(),eostrat<TGenoPheno>::_parameters._dim),
eostrat<TGenoPheno>::_solutions._xmean);
this->update_fevals(1);
}

std::chrono::time_point<std::chrono::system_clock> tstart = std::chrono::system_clock::now();
Expand Down
11 changes: 11 additions & 0 deletions parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,15 @@ namespace libcmaes
return _maximize;
}

/**
* \brief whether to compute initial objective function value (i.e. at x0)
* @param b activates / deactivates
*/
inline void set_initial_fvalue(const bool &b)
{
_initial_fvalue = b;
}

/**
* \brief activates / deactivates uncertainty handling scheme.
* @param b activates / deactivates
Expand Down Expand Up @@ -565,6 +574,8 @@ namespace libcmaes
bool _maximize = false; /**< convenience option of maximizing -f instead of minimizing f. */
static std::map<std::string,int> _algos; /**< of the form { {"cmaes",0}, {"ipop",1}, ...} */;

bool _initial_fvalue = false; /**< whether to compute initial objective function value (not required). */

// uncertainty handling
bool _uh = false; /**< whether to activate uncertainty handling. */
double _rlambda; /**< fraction of solutions to be reevaluated. */
Expand Down

0 comments on commit 5127295

Please sign in to comment.