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 #include <stdio.h> // for printf
20 #include <stdlib.h> // for free
21 #include "NumericsFwd.h" // for Varia...
22 #include "SOCLCP_Solvers.h" // for soclc...
23 #include "SecondOrderConeLinearComplementarityProblem.h" // for Secon...
24 #include "SecondOrderConeLinearComplementarityProblem_as_VI.h" // for Secon...
25 #include "SiconosBlas.h" // for cblas...
26 #include "SolverOptions.h" // for Solve...
27 #include "VariationalInequality.h" // for Varia...
28 #include "VariationalInequality_Solvers.h" // for varia...
29 #include "numerics_verbose.h" // for verbose
30 #include "soclcp_compute_error.h" // for soclc...
31
soclcp_VI_FixedPointProjection(SecondOrderConeLinearComplementarityProblem * problem,double * reaction,double * velocity,int * info,SolverOptions * options)32 void soclcp_VI_FixedPointProjection(SecondOrderConeLinearComplementarityProblem* problem, double *reaction, double *velocity, int* info, SolverOptions* options)
33 {
34 /* Dimension of the problem */
35 int n = problem->n;
36
37 VariationalInequality *vi = (VariationalInequality *)malloc(sizeof(VariationalInequality));
38
39 //vi.self = &vi;
40 vi->F = &Function_VI_SOCLCP;
41 vi->ProjectionOnX = &Projection_VI_SOCLCP;
42
43 double error=1e24;
44
45 SecondOrderConeLinearComplementarityProblem_as_VI *soclcp_as_vi= (SecondOrderConeLinearComplementarityProblem_as_VI*)malloc(sizeof(SecondOrderConeLinearComplementarityProblem_as_VI));
46 vi->env =soclcp_as_vi ;
47 vi->size = n;
48
49 /*set the norm of the VI to the norm of problem->q */
50 vi->normVI= cblas_dnrm2(n, problem->q, 1);
51 vi->istheNormVIset=1;
52
53 soclcp_as_vi->vi = vi;
54 soclcp_as_vi->soclcp = problem;
55 /* frictionContact_display(fc3d_as_vi->fc3d); */
56
57 variationalInequality_FixedPointProjection(vi, reaction, velocity, info, options);
58
59 /* **** Criterium convergence **** */
60 soclcp_compute_error(problem, reaction, velocity, options->dparam[0], options, &error);
61
62 /* for (i =0; i< n ; i++) */
63 /* { */
64 /* printf("reaction[%i]=%f\t",i,reaction[i]); printf("velocity[%i]=F[%i]=%f\n",i,i,velocity[i]); */
65 /* } */
66
67 if(verbose > 0)
68 {
69 printf("---------------SOCLCP - VI Fixed Point Projection (VI_FPP) - #Iteration %i Final Residual = %14.7e\n",
70 options->iparam[SICONOS_IPARAM_MAX_ITER], options->dparam[SICONOS_DPARAM_RESIDU]);
71
72 }
73 free(vi);
74 free(soclcp_as_vi);
75 }
76