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 FB_H
20 #define FB_H
21 
22 /*!\file FischerBurmeister.h
23 
24   \brief Fischer Burmeister functions.
25 
26   A set of routines to compute the Fischer-Burmeister function and its jacobian.
27 
28   The Fischer-Burmeister function is defined as :
29   \f[
30   \phi(z,w) = \sqrt( z^2 + w^2) - z - w
31   \f]
32 
33   This function is used to solve MLCP, MCP and NCP. The inequalities are rewritten using Fischer function with \f$ w = F(z) \f$ and solved with a semi-smooth Newton algorithm.
34 
35   For "mixed" problems (i.e. including equality constraints), the Fischer function is defined as :
36 
37   \f[ \phi_{mixed}(z,F(z)) =
38   \left\lbrace \begin{array}{c}
39   F_e(z) \\
40   \sqrt( z^2 + F_i(z)^2) - z - F_i(z) \end{array}\right. \f]
41 
42   where index "e" stands for equalities part in F and "i" for inequalities.
43 
44   For details see the paper of Kanzow and Kleinmichel, "A New Class of Semismooth Newton-type Methods for Nonlinear
45   Complementarity Problems", Computational Optimization and Applications 11, 227-251 (1998).
46 
47   The notations below are more or less those of this paper.
48 
49 */
50 
51 #include "NumericsFwd.h"  // for NumericsMatrix
52 #include "SiconosConfig.h" // for BUILD_AS_CPP // IWYU pragma: keep
53 
54 #ifdef __cplusplus
55 #define restrict __restrict
56 #endif
57 
58 #if defined(__cplusplus) && !defined(BUILD_AS_CPP)
59 extern "C"
60 {
61 #endif
62 
63   /** Fischer Burmeister function, \f$ \phi(z,F(z)) \f$
64       \param[in] size of vector z
65       \param[in] z vector \f$ z \f$
66       \param[in] F vector \f$ F(z) \f$
67       \param[in,out]  phi vector \f$ \phi(z,F(z)) \f$
68   */
69   void phi_FB(int size, double* restrict z, double* restrict F, double* restrict phi);
70 
71   /** Jacobian of the Fischer Burmeister function, \f$ \nabla_z \phi(z,F(z)) \f$
72       \param[in] size of vector \f$ z \f$
73       \param[in] z vector \f$ z \f$
74       \param[in] F vector \f$ F(z) \f$
75       \param[in] jacobianF \f$ \nabla_z F(z) \f$
76       \param[in,out]  jacobianPhi \f$ \nabla_z \phi(z,F(z)) \f$.
77       \warning this function looks broken !
78   */
79   void jacobianPhi_FB(int size, double* z, double* F, double* jacobianF, double* jacobianPhi);
80 
81   /** Mixed Fischer Burmeister function,
82       \f[ \phi(z,F(z)) = \left\lbrace \begin{array}{c} F(z) \\ \sqrt( z^2 + F(z)^2) - z - F(z) \end{array}\right. \f], the upper for equalities and the rest for inequalities.
83       \param[in] sizeEq number of equality constraints.
84       \param[in] sizeIneq number of complementarity constraints.
85       \param[in] z vector z (size = sizeEq + sizeIneq)
86       \param[in] F vector F(z)
87       \param[in,out] phi \f$ \phi(z,F(z)) \f$.
88   */
89   void phi_Mixed_FB(int sizeEq, int sizeIneq, double* restrict z, double* restrict F, double* restrict phi);
90 
91   /** Jacobian of the mixed Fischer Burmeister function, \f$ \nabla_z \phi(z,F(z)) \f$
92       \param[in] sizeEq number of equality constraints.
93       \param[in] sizeIneq number of complementarity constraints.
94       \param[in] z vector \f$z\f$
95       \param[in] F vector \f$F(z)\f$
96       \param[in] jacobianF \f$ \nabla_z F(z) \f$
97       \param[in,out] jacobianPhi \f$ \nabla_z \phi(z,F(z)) \f$ .
98       \warning this function looks broken !
99   */
100   void jacobianPhi_Mixed_FB(int sizeEq, int sizeIneq, double* z, double* F, double* jacobianF, double* jacobianPhi);
101 
102   /** Computes an element of \f$Jac \mathbf{F}_{\mathrm{FB}}\f$ (possibly mixed) Fischer-Burmeister function, see Facchinei--Pang (2003) p. 808
103       \param[in] n1 number of equality constraints.
104       \param[in] n2 number of complementarity constraints.
105       \param[in] z vector \f$z\f$
106       \param[in] F vector \f$F(z)\f$
107       \param[in] workV1 work vector (value gets overwritten)
108       \param[in] workV2 work vector (value gets overwritten)
109       \param[in] nabla_F \f$ \nabla_z F(z) \f$
110       \param[in,out] H element of Jac_F_merit
111   */
112 void Jac_F_FB(int n1, int n2, double* restrict z, double* restrict F, double* restrict workV1, double* restrict workV2, NumericsMatrix* restrict nabla_F, NumericsMatrix* restrict H);
113 
114 #if defined(__cplusplus) && !defined(BUILD_AS_CPP)
115 }
116 #endif
117 
118 #endif
119