34 #ifndef SHARK_OBJECTIVEFUNCTIONS_REGULARIZER_H 35 #define SHARK_OBJECTIVEFUNCTIONS_REGULARIZER_H 64 {
return "OneNormRegularizer"; }
67 return m_numberOfVariables;
81 const RealVector&
mask()
const{
85 double eval( RealVector
const& input )
const{
91 return norm_1(input * m_mask);
98 std::size_t ic = input.size();
99 derivative.resize(ic);
101 for (std::size_t i = 0; i != ic; i++){
102 derivative(i) = boost::math::sign(input(i));
108 for (std::size_t i=0; i != ic; i++){
109 derivative(i) = m_mask(i)*boost::math::sign(input(i));
114 double evalDerivative( RealVector
const& input, SecondOrderDerivative & derivative )
const {
115 std::size_t ic = input.size();
116 derivative.gradient.resize(ic);
117 derivative.hessian.resize(ic,ic);
118 derivative.hessian.clear();
120 for (std::size_t i=0; i != ic; i++){
121 derivative.gradient(i) = boost::math::sign(input(i));
127 for (std::size_t i=0; i != ic; i++){
128 derivative.gradient(i) = m_mask(i)*boost::math::sign(input(i));
135 std::size_t m_numberOfVariables;
164 {
return "TwoNormRegularizer"; }
167 return m_numberOfVariables;
186 virtual double eval( RealVector
const& input )
const 189 return 0.5*norm_sqr(input);
192 return 0.5 * sum(m_mask*
sqr(input));
203 derivative = m_mask*input;
211 virtual ResultType
evalDerivative(
const SearchPointType & input, SecondOrderDerivative & derivative )
const {
212 derivative.gradient = input;
213 derivative.hessian = blas::identity_matrix<double>(input.size());
214 return 0.5 * norm_sqr(input);
217 std::size_t m_numberOfVariables;
223 #endif // SHARK_CORE_REGULARIZER_H