void RpropMinus::init( ObjectiveFunctionType & objectiveFunction, SearchPointType const& startingPoint, double initDelta ) { checkFeatures(objectiveFunction); objectiveFunction.init(); m_parameterSize = startingPoint.size(); m_delta.resize(m_parameterSize); m_oldDerivative.resize(m_parameterSize); std::fill(m_delta.begin(),m_delta.end(),initDelta); m_oldDerivative.clear(); m_best.point = startingPoint; //evaluate initial point m_best.value = objectiveFunction.evalDerivative(m_best.point,m_derivative); }
void AbstractLineSearchOptimizer::init(ObjectiveFunctionType& objectiveFunction, SearchPointType const& startingPoint) { checkFeatures(objectiveFunction); objectiveFunction.init(); m_linesearch.init(objectiveFunction); m_dimension = startingPoint.size(); m_best.point = startingPoint; m_best.value = objectiveFunction.evalDerivative(m_best.point,m_derivative); // Get space for the different vectors we store. m_lastPoint.resize(m_dimension); m_searchDirection = -m_derivative; m_initialStepLength = 0.0;//1.0 as step length might be very wrong. for (size_t i = 0; i < m_derivative.size(); ++i) m_initialStepLength += std::abs(m_derivative(i)); m_initialStepLength = std::min(1.0, 1.0 / m_initialStepLength); initModel(); }