1 /* Siconos is a program dedicated to modeling, simulation and control 2 * of non smooth dynamical systems. 3 * 4 * Copyright 2021 INRIA. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef ARMIJOSEARCH_H 20 #define ARMIJOSEARCH_H 21 22 /*!\file ArmijoSearch.h 23 * \brief Armijo type search (linesearch and arcsearch), possibly non-monotone 24 * 25 * Implementation of the Armijo type search. The linesearch version is the most 26 * classical one. The arcsearch assumes that the direction of descent is the 27 * gradient of the merit function. 28 * 29 */ 30 31 #include "SiconosConfig.h" // for BUILD_AS_CPP // IWYU pragma: keep 32 #include "line_search.h" 33 34 /** \struct armijo_extra_params ArmijoSearch.h 35 * Struct to hold together the extra parameters needed by the Armijo line search 36 */ 37 typedef struct { 38 double gamma; /**< Value of the slope coefficient*/ 39 } armijo_extra_params; 40 41 #if defined(__cplusplus) && !defined(BUILD_AS_CPP) 42 extern "C" 43 { 44 #endif 45 46 /** Armijo (non-monotone) search, standalone version: it does not compute 47 * the reference value, it is expected as argument (theta) 48 * \param n size of the problem 49 * \param theta reference value for the acceptance test 50 * \param preRHS pre-computed value for the acceptance test 51 * \param ls_data necessary data for the search algorithm 52 * \return the coefficient alpha 53 */ 54 double search_Armijo_standalone(int n, double* theta, double preRHS, search_data* ls_data); 55 56 /** Armijo linesearch; this version compute and update the reference value 57 * and calls search_Armijo_standalone() 58 * \param n size of the problem 59 * \param theta current value of the merit function 60 * \param preRHS pre-computed value for the acceptance test 61 * \param ls_data necessary data for the search algorithm 62 * \return the coefficient alpha 63 */ linesearch_Armijo2(int n,double theta,double preRHS,search_data * ls_data)64 static inline double linesearch_Armijo2(int n, double theta, double preRHS, search_data* ls_data) 65 { 66 return line_search_generic(n, theta, preRHS, ls_data, LINESEARCH, &search_Armijo_standalone); 67 } 68 69 /** Armijo arcsearch; this version compute and update the reference value 70 * and calls search_Armijo_standalone(). 71 * \warning this function can be used only if the descent direction is the 72 * gradient of the merit function. 73 * \param n size of the problem 74 * \param theta current value of the merit function 75 * \param preRHS pre-computed value for the acceptance test 76 * \param ls_data necessary data for the search algorithm 77 * \return the coefficient alpha 78 */ 79 arcsearch_Armijo2(int n,double theta,double preRHS,search_data * ls_data)80 static inline double arcsearch_Armijo2(int n, double theta, double preRHS, search_data* ls_data) 81 { 82 return line_search_generic(n, theta, preRHS, ls_data, ARCSEARCH, &search_Armijo_standalone); 83 } 84 85 /** Initialize parameters to a default value 86 * \param p parameters to set 87 */ 88 void search_Armijo_params_init(armijo_extra_params* p); 89 90 #if defined(__cplusplus) && !defined(BUILD_AS_CPP) 91 } 92 #endif 93 94 #endif 95