25 #ifndef ARTIFICIALLANDSCAPES_HPP_
26 #define ARTIFICIALLANDSCAPES_HPP_
28 #include <types/MatrixTypes.hpp>
31 namespace neural_nets {
32 namespace optimization {
33 namespace artificial_landscapes {
39 template <
typename eT=
float>
54 virtual mic::types::MatrixPtr<eT>
calculateGradient(mic::types::MatrixPtr<eT> x_) = 0;
79 template <
typename eT=
float>
95 assert((
size_t)x_->size() == this->
dims);
98 for (
size_t i=0; i<this->
dims; i++)
99 val += (*x_)[i] * (*x_)[i];
107 assert((
size_t)x_->size() == this->
dims);
110 mic::types::MatrixPtr<eT> dx = MAKE_MATRIX_PTR(eT, this->
dims, 1);
111 for (
size_t i=0; i<this->
dims; i++)
112 (*dx)[i] = 2 * (*x_)[i];
123 template <
typename eT=
float>
140 assert((
size_t)x_->size() == this->
dims);
146 eT a = (1.5 - x + x*y);
147 eT b = (2.25 - x + x * y * y);
148 eT c = (2.625 - x + x * y * y * y);
149 return a*a + b*b + c*c;
156 assert((
size_t)x_->size() == this->
dims);
158 mic::types::MatrixPtr<double> dx = MAKE_MATRIX_PTR(eT, this->
dims, 1);
164 eT ax = 2*(1.5 - x + x*y) * (-1 + y);
165 eT bx = 2*(2.25 - x + x * y * y) * ( - 1 + y * y);
166 eT cx = 2*(2.625 - x + x * y * y * y) * ( - 1 + y * y * y);
168 eT ay = 2*(1.5 - x + x*y) * (x);
169 eT by = 2*(2.25 - x + x * y * y) * (2*x*y);
170 eT cy = 2*(2.625 - x + x * y * y * y) * (3*x*y*y);
172 (*dx)[0] = ax + bx +cx;
173 (*dx)[1] = ay + by +cy;
186 template <
typename eT=
float>
203 assert((
size_t)x_->size() == this->
dims);
209 eT p1 = (
a - x) * (
a - x);
210 eT p2 =
b * (y - x * x) * (y - x * x);
219 assert((
size_t)x_->size() == this->
dims);
221 mic::types::MatrixPtr<eT> dx = MAKE_MATRIX_PTR(eT, this->
dims, 1);
227 eT p1x = -2 * (
a - x);
228 eT p2x = 2 *
b * (y - x * x) * (-2 * x) ;
232 eT p2y = 2 *
b * (y - x * x) ;
235 (*dx)[0] = p1x + p2x;
236 (*dx)[1] = p1y + p2y;
mic::types::MatrixPtr< eT > min_arguments
vector of arguments for which the function has a minimum.
eT calculateValue(mic::types::MatrixPtr< eT > x_)
Rosenbrock2DFunction(eT a_=1, eT b_=100)
Constructor.
mic::types::MatrixPtr< eT > calculateGradient(mic::types::MatrixPtr< eT > x_)
eT minValue()
Returns min value of the function.
virtual ~DifferentiableFunction()
Virtual destructor - empty.
A sphere function - square function generalized to n dimensions.
eT calculateValue(mic::types::MatrixPtr< eT > x_)
mic::types::MatrixPtr< eT > calculateGradient(mic::types::MatrixPtr< eT > x_)
SphereFunction(size_t dims_)
Constructor.
mic::types::MatrixPtr< eT > calculateGradient(mic::types::MatrixPtr< eT > x_)
DifferentiableFunction(size_t dims_)
Constructor. Asserts whether dimensions must be > 0.
size_t dims
Number of function dimensions (input variables).
Beale2DFunction()
Constructor.
Abstract class representing interface to a differentiable function.
eT min_value
Minimal value.
virtual mic::types::MatrixPtr< eT > calculateGradient(mic::types::MatrixPtr< eT > x_)=0
mic::types::MatrixPtr< eT > minArguments()
Returns the vector of arguments being the function minimum.
virtual eT calculateValue(mic::types::MatrixPtr< eT > x_)=0
eT calculateValue(mic::types::MatrixPtr< eT > x_)