RotatedErrorFunction.h
Go to the documentation of this file.
1 /*!
2  *
3  *
4  * \brief Implements a wrapper over an m_objective function which just rotates its inputs
5  *
6  *
7  * \author O.Voss
8  * \date 2010-2014
9  *
10  *
11  * \par Copyright 1995-2015 Shark Development Team
12  *
13  * <BR><HR>
14  * This file is part of Shark.
15  * <http://image.diku.dk/shark/>
16  *
17  * Shark is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU Lesser General Public License as published
19  * by the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * Shark is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
29  *
30  */
31 #ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARKS_ROTATEDOBJECTIVEFUNCTION_H
32 #define SHARK_OBJECTIVEFUNCTIONS_BENCHMARKS_ROTATEDOBJECTIVEFUNCTION_H
33 
35 #include <shark/LinAlg/rotations.h>
36 
37 namespace shark {
38 /// \brief Rotates an objective function using a randomly initialized rotation.
39 ///
40 /// Most benchmark functions are axis aligned because it is assumed that the algorithm
41 /// is rotation invariant. However this does not mean that all its aspects are the same.
42 /// Especially linear algebra routines might take longer when the problem is not
43 /// axis aligned. This function creates a random rotation function and
44 /// applies it to the given input points to make it no longer axis aligned.
47  :m_objective(objective){
48  if(m_objective->canProposeStartingPoint())
50  }
51 
52  /// \brief From INameable: return the class name.
53  std::string name() const
54  { return "RotatedObjectiveFunction<"+m_objective->name()+">"; }
55 
56  std::size_t numberOfVariables()const{
57  return m_objective->numberOfVariables();
58  }
59 
60  void init(){
62  m_objective->init();
63  }
64 
66  return m_objective->hasScalableDimensionality();
67  }
68 
70  m_objective->setNumberOfVariables(numberOfVariables);
71  }
72 
74  RealVector y = m_objective->proposeStartingPoint();
75 
76  return prod(trans(m_rotation),y);
77  }
78 
79  double eval( const SearchPointType & p ) const {
81  RealVector x = prod(m_rotation,p);
82  return m_objective->eval(x);
83  }
84 private:
85  SingleObjectiveFunction* m_objective;
86  RealMatrix m_rotation;
87 };
88 
89 }
90 
91 #endif