1 #ifndef TOON_DOWNHILL_SIMPLEX_H
2 #define TOON_DOWNHILL_SIMPLEX_H
100 epsilon = sqrt(numeric_limits<Precision>::epsilon());
112 template<
class Function>
void restart(
const Function& func,
const Vector<N>& c, Precision spread)
114 for(
int i=0; i <
simplex.num_rows(); i++)
117 for(
int i=0; i <
simplex.num_cols(); i++)
120 for(
int i=0; i <
values.size(); i++)
144 template<
class Function>
void restart(
const Function& func, Precision spread)
183 Precision second_worst_val=-HUGE_VAL, bestval = HUGE_VAL, worst_val =
values[worst];
188 for(
int i=0; i <
simplex.num_rows(); i++)
198 if(
values[i] > second_worst_val)
199 second_worst_val =
values[i];
205 x0 *= 1.0 /
simplex.num_cols();
210 Precision fr = func(xr);
216 Precision fe = func(xe);
235 if(fr < second_worst_val)
249 Precision fc = func(xc);
262 for(
int i=0; i <
simplex.num_rows(); i++)
273 template<
class Function>
bool iterate(
const Function& func)
std::pair< Precision, int > min_element(const Vector< Size, Precision, Base > &v)
Vector< Vertices, Precision > Values
const Simplex & get_simplex() const
Return the simplex.
bool iterate(const Function &func)
Precision alpha
Reflected size. Defaults to 1.
Everything lives inside this namespace.
Matrix< Vertices, N, Precision > Simplex
int get_worst() const
Get the index of the worst vertex.
const Values & get_values() const
Return the score at the vertices.
void restart(const Function &func, const Vector< N > &c, Precision spread)
Precision norm(const Vector< Size, Precision, Base > &v)
static const int Vertices
void restart(const Function &func, Precision spread)
Precision rho
Expansion ratio. Defaults to 2.
Precision gamma
Contraction ratio. Defaults to .5.
Precision sigma
Shrink ratio. Defaults to .5.
std::pair< Precision, int > max_element(const Vector< Size, Precision, Base > &v)
int get_best() const
Get the index of the best vertex.
Precision epsilon
Tolerance used to determine if the optimization is complete. Defaults to square root of machine preci...
void find_next_point(const Function &func)
DownhillSimplex(const Function &func, const Vector< N > &c, Precision spread=1)
static Operator< Internal::Zero > Zeros
Precision zero_epsilon
Additive term in tolerance to prevent excessive iterations if . Known as ZEPS in numerical recipies...