Debian Codegraph @

src/Algo/lgalgo.cpp

raw symbols SCIP
1 /****************************************************************************/cxx . . $ `<file>/src/Algo/lgalgo.cpp`/
2 /* This file is part of FreeFEM. */
3 /* */
4 /* FreeFEM is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU Lesser General Public License as */
6 /* published by the Free Software Foundation, either version 3 of */
7 /* the License, or (at your option) any later version. */
8 /* */
9 /* FreeFEM is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU Lesser General Public License for more details. */
13 /* */
14 /* You should have received a copy of the GNU Lesser General Public License */
15 /* along with FreeFEM. If not, see <http://www.gnu.org/licenses/>. */
16 /****************************************************************************/
17 // SUMMARY : ...
18 // LICENSE : LGPLv3
19 // ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
20 // AUTHORS : Frederic Hecht
21 // E-MAIL : [email protected]
22
23 #include <iostream>
24 #include <cfloat>
25 using namespace std;
26 #include "ff++.hpp"cxx . . $ `<file>/src/fflib/ff++.hpp`/
27 #include "NRJ.hpp"cxx . . $ `<file>/src/Algo/NRJ.hpp`/
28 #include "RosenBrock.hpp"cxx . . $ `<file>/src/Algo/RosenBrock.hpp`/
29 #include "LineSearch.hpp"cxx . . $ `<file>/src/Algo/LineSearch.hpp`/
30 #include "CubicLS.hpp"cxx . . $ `<file>/src/Algo/CubicLS.hpp`/
31 #include "BrentLS.hpp"cxx . . $ `<file>/src/Algo/BrentLS.hpp`/
32 #include "Optima.hpp"cxx . . $ `<file>/src/Algo/Optima.hpp`/
33 #include "BFGS.hpp"cxx . . $ `<file>/src/Algo/BFGS.hpp`/
34 //#include "CG.hpp"
35 #include "NewtonRaphson.hpp"cxx . . $ `<file>/src/Algo/NewtonRaphson.hpp`/
36
37 // template<class R>
38 extern Blockcxx . . $ Block# *currentblockcxx . . $ currentblock.;
39
40 typedef double Rcxx . . $ Fem2D/R#;
41
42 class OptimAlgocxx . . $ OptimAlgo# : public OneOperatorcxx . . $ OneOperator# {
43 public:
44 typedef KNcxx . . $ KN#< Rcxx . . $ Fem2D/R# > Kncxx . . $ OptimAlgo#Kn#;
45 typedef KN_cxx . . $ KN_#< Rcxx . . $ Fem2D/R# > Kn_cxx . . $ OptimAlgo#Kn_#;
46 typedef Rcxx . . $ Fem2D/R# REALcxx . . $ OptimAlgo#REAL#;
47 typedef Paramcxx . . $ Param#< REALcxx . . $ OptimAlgo#REAL# > PARAMcxx . . $ OptimAlgo#PARAM#;
48 typedef KNcxx . . $ KN#< REALcxx . . $ OptimAlgo#REAL# > VECTcxx . . $ OptimAlgo#VECT#;
49 typedef KNMcxx . . $ KNM#< REALcxx . . $ OptimAlgo#REAL# > MATcxx . . $ OptimAlgo#MAT#;
50 typedef Matrice_Creusecxx . . $ Matrice_Creuse#< R >::VMatcxx . . $ Matrice_Creuse#VMat# VMATcxx . . $ OptimAlgo#VMAT#;
51
52 const int cascxx . . $ OptimAlgo#cas.;
53
54 class E_LCGcxx . . $ OptimAlgo#E_LCG# : public E_F0mpscxx . . $ E_F0mps# {
55 public:
56 const int cascxx . . $ OptimAlgo#E_LCG#cas.;
57 static basicAC_F0cxx . . $ basicAC_F0#::name_and_typecxx . . $ basicAC_F0#name_and_type# name_paramcxx . . $ OptimAlgo#E_LCG#name_param.[];
58 static const int n_name_paramcxx . . $ OptimAlgo#E_LCG#n_name_param. = 3;
59 Expressioncxx . . $ Expression# nargscxx . . $ OptimAlgo#E_LCG#nargs.[n_name_paramcxx . . $ OptimAlgo#E_LCG#n_name_param.];
60 Expressioncxx . . $ Expression# Xcxx . . $ OptimAlgo#E_LCG#X.;
61 C_F0cxx . . $ C_F0# inittheparamcxx . . $ OptimAlgo#E_LCG#inittheparam., theparamcxx . . $ OptimAlgo#E_LCG#theparam., closetheparamcxx . . $ OptimAlgo#E_LCG#closetheparam.;
62 Expressioncxx . . $ Expression# Jcxx . . $ OptimAlgo#E_LCG#J., dJcxx . . $ OptimAlgo#E_LCG#dJ., hJcxx . . $ OptimAlgo#E_LCG#hJ.;
63 long argcxx . . $ OptimAlgo#E_LCG#arg(37daf6ef7c79b13b).(int i, Stackcxx . . $ Stack# stack, long a) const {
64 return nargscxx . . $ OptimAlgo#E_LCG#nargs.[i] ? GetAnycxx . . $ GetAny(4ae00c582f151d1b).< long >((*nargscxx . . $ OptimAlgo#E_LCG#nargs.[i])(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stack)) : a;
65 }
66 Rcxx . . $ Fem2D/R# argcxx . . $ OptimAlgo#E_LCG#arg(f5865a2e333c217).(int i, Stackcxx . . $ Stack# stack, Rcxx . . $ Fem2D/R# a) const { return nargscxx . . $ OptimAlgo#E_LCG#nargs.[i] ? GetAnycxx . . $ GetAny(4ae00c582f151d1b).< Rcxx . . $ Fem2D/R# >((*nargscxx . . $ OptimAlgo#E_LCG#nargs.[i])(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stack)) : a; }
67
68 class lgNRJcxx . . $ OptimAlgo#E_LCG#lgNRJ# : public tNRJcxx . . $ tNRJ#< PARAMcxx . . $ OptimAlgo#PARAM#, VECTcxx . . $ OptimAlgo#VECT#, VMATcxx . . $ OptimAlgo#VMAT#, REALcxx . . $ OptimAlgo#REAL# > {
69 private:
70 Stackcxx . . $ Stack# stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.;
71 Expressioncxx . . $ Expression# Jcxx . . $ OptimAlgo#E_LCG#lgNRJ#J., dJcxx . . $ OptimAlgo#E_LCG#lgNRJ#dJ., hJcxx . . $ OptimAlgo#E_LCG#lgNRJ#hJ., theparamecxx . . $ OptimAlgo#E_LCG#lgNRJ#theparame.;
72 VECTcxx . . $ OptimAlgo#VECT# *ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg.;
73
74 protected:
75 void setparamcxx . . $ OptimAlgo#E_LCG#lgNRJ#setparam(1c40ee939394e218).(const Paramcxx . . $ Param#< Rcxx . . $ Fem2D/R# > &x) {
76 KNcxx . . $ KN#< double > *p = GetAnycxx . . $ GetAny(4ae00c582f151d1b).< KNcxx . . $ KN#< double > * >((*theparamecxx . . $ OptimAlgo#E_LCG#lgNRJ#theparame.)(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.));
77 ffassertcxx . . $ `src/fflib/throwassert.hpp:49:9`!(p->N( ) == x.N( ));
78 *p =cxx . . $ KN#`operator=`(8077e5efd1e64c38). x;
79 }
80
81 public:
82 lgNRJcxx . . $ OptimAlgo#E_LCG#lgNRJ#lgNRJ(87043c272a443578).(Stackcxx . . $ Stack# s, int n, Expressioncxx . . $ Expression# t, Expressioncxx . . $ Expression# JJ, Expressioncxx . . $ Expression# dJJ, Expressioncxx . . $ Expression# hJJ)
83 : tNRJcxx . . $ tNRJ#< PARAMcxx . . $ OptimAlgo#PARAM#, VECTcxx . . $ OptimAlgo#VECT#, VMATcxx . . $ OptimAlgo#VMAT#, REALcxx . . $ OptimAlgo#REAL# >(n), stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.(s), Jcxx . . $ OptimAlgo#E_LCG#lgNRJ#J.(JJ), dJcxx . . $ OptimAlgo#E_LCG#lgNRJ#dJ.(dJJ), hJcxx . . $ OptimAlgo#E_LCG#lgNRJ#hJ.(hJJ), theparamecxx . . $ OptimAlgo#E_LCG#lgNRJ#theparame.(t),
84 ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg.(0) {
85 if (dJcxx . . $ OptimAlgo#E_LCG#lgNRJ#dJ.) ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg. = new VECTcxx . . $ OptimAlgo#VECT#(n);
86 }
87
88 ~cxx . . $ OptimAlgo#E_LCG#lgNRJ#`~lgNRJ`(49f6e7a06ebc5aa8).lgNRJcxx . . $ OptimAlgo#E_LCG#lgNRJ#( ) {
89 if (ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg.) delete ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg.;
90 }
91
92 REALcxx . . $ OptimAlgo#REAL# Valcxx . . $ OptimAlgo#E_LCG#lgNRJ#Val(566ffb6765c58bfa).(const Paramcxx . . $ Param#< Rcxx . . $ Fem2D/R# > &x) {
93 setparamcxx . . $ OptimAlgo#E_LCG#lgNRJ#setparam(1c40ee939394e218).(x);
94 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(J);
95 Rcxx . . $ Fem2D/R# ret = GetAnycxx . . $ GetAny(4ae00c582f151d1b).< Rcxx . . $ Fem2D/R# >((*Jcxx . . $ OptimAlgo#E_LCG#lgNRJ#J.)(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.));
96 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.)->cleancxx . . $ StackOfPtr2Free#clean(83c267b20bac841a).( );
97 return ret;
98 }
99
100 VECTcxx . . $ OptimAlgo#VECT# *Gradientcxx . . $ OptimAlgo#E_LCG#lgNRJ#Gradient(ed8090b06f9fc41c).(const Paramcxx . . $ Param#< Rcxx . . $ Fem2D/R# > &x) {
101 setparamcxx . . $ OptimAlgo#E_LCG#lgNRJ#setparam(1c40ee939394e218).(x);
102 if (dJcxx . . $ OptimAlgo#E_LCG#lgNRJ#dJ.) {
103 *ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg. =cxx . . $ KN#`operator=`(9633155e257ac6ae). GetAnycxx . . $ GetAny(4ae00c582f151d1b).< Kn_cxx . . $ OptimAlgo#Kn_# >((*dJcxx . . $ OptimAlgo#E_LCG#lgNRJ#dJ.)(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.));
104 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.)->cleancxx . . $ StackOfPtr2Free#clean(83c267b20bac841a).( );
105 }
106 return ggcxx . . $ OptimAlgo#E_LCG#lgNRJ#gg.; // dJ ? GetAny<Kn*>( (*dJ)(stack)) :0;}
107 }
108
109 VMATcxx . . $ OptimAlgo#VMAT# *Hessiancxx . . $ OptimAlgo#E_LCG#lgNRJ#Hessian(42af389ca4419d97).(const Paramcxx . . $ Param#< Rcxx . . $ Fem2D/R# > &x) {
110 setparamcxx . . $ OptimAlgo#E_LCG#lgNRJ#setparam(1c40ee939394e218).(x);
111 if (!hJcxx . . $ OptimAlgo#E_LCG#lgNRJ#hJ.) return 0;
112 Matrice_Creusecxx . . $ Matrice_Creuse#< Rcxx . . $ Fem2D/R# > *M = GetAnycxx . . $ GetAny(4ae00c582f151d1b).< Matrice_Creusecxx . . $ Matrice_Creuse#< Rcxx . . $ Fem2D/R# > * >((*hJcxx . . $ OptimAlgo#E_LCG#lgNRJ#hJ.)(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.));
113 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stackcxx . . $ OptimAlgo#E_LCG#lgNRJ#stack.)->cleancxx . . $ StackOfPtr2Free#clean(83c267b20bac841a).( );
114 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(M && M->A);
115 return (VMATcxx . . $ OptimAlgo#VMAT# *)M->Acxx . . $ Matrice_Creuse#A.;
116 }
117 };
118
119 E_LCGcxx . . $ OptimAlgo#E_LCG#E_LCG(a65e77a1106337ff).(const basicAC_F0cxx . . $ basicAC_F0# &args, int cc) : cascxx . . $ OptimAlgo#E_LCG#cas.(cc) {
120 int nbj = args.sizecxx . . $ basicAC_F0#size(455f465bc33b4cdf).( ) - 1;
121 Blockcxx . . $ Block#::opencxx . . $ Block#open(ef3679fe5caef0f0).(currentblockcxx . . $ currentblock.); // make a new block to
122 Xcxx . . $ OptimAlgo#E_LCG#X. = tocxx . . $ to(7813c32c88d11da9).< Kncxx . . $ OptimAlgo#Kn# * >(args[cxx . . $ basicAC_F0#`operator[]`(4717a974d14df1e6).nbj]);
123 C_F0cxx . . $ C_F0# X_ncxx . . $ C_F0#C_F0(9d73b76b2846d95).(args[cxx . . $ basicAC_F0#`operator[]`(4717a974d14df1e6).nbj], "n");
124 // the expression to init the theparam of all
125 inittheparamcxx . . $ OptimAlgo#E_LCG#inittheparam. =cxx . . $ C_F0#`operator=`(886a782b76281c4e).
126 currentblockcxx . . $ currentblock.->NewVarcxx . . $ Block#NewVar(ab29e1450ec774fc).< LocalVariablecxx . . $ LocalVariable# >("the parameter", atypecxx . . $ atype(f7e2cbc52f11d57).< KNcxx . . $ KN#< Rcxx . . $ Fem2D/R# > * >( ), X_n);
127 theparamcxx . . $ OptimAlgo#E_LCG#theparam. =cxx . . $ C_F0#`operator=`(886a782b76281c4e). currentblockcxx . . $ currentblock.->Findcxx . . $ Block#Find(62488c1fc61c54aa).("the parameter"); // the expression for the parameter
128 args.SetNameParamcxx . . $ basicAC_F0#SetNameParam(2755858438fb170b).(n_name_paramcxx . . $ OptimAlgo#E_LCG#n_name_param., name_paramcxx . . $ OptimAlgo#E_LCG#name_param., nargscxx . . $ OptimAlgo#E_LCG#nargs.);
129 const Polymorphiccxx . . $ Polymorphic# *opJ = 0;
130 const Polymorphiccxx . . $ Polymorphic# *opdJ = 0;
131 const Polymorphiccxx . . $ Polymorphic# *ophJ = 0;
132 if (nbj > 0) {
133 opJ = dynamic_cast< const Polymorphiccxx . . $ Polymorphic# * >(args[cxx . . $ basicAC_F0#`operator[]`(4717a974d14df1e6).0].LeftValuecxx . . $ C_F0#LeftValue(432a84b242fccb01).( ));
134 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(opJ);
135 }
136 if (nbj > 1) {
137 opdJ = dynamic_cast< const Polymorphiccxx . . $ Polymorphic# * >(args[cxx . . $ basicAC_F0#`operator[]`(4717a974d14df1e6).1].LeftValuecxx . . $ C_F0#LeftValue(432a84b242fccb01).( ));
138 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(opdJ);
139 }
140 if (nbj > 2) {
141 ophJ = dynamic_cast< const Polymorphiccxx . . $ Polymorphic# * >(args[cxx . . $ basicAC_F0#`operator[]`(4717a974d14df1e6).2].LeftValuecxx . . $ C_F0#LeftValue(432a84b242fccb01).( ));
142 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(ophJ);
143 }
144 Jcxx . . $ OptimAlgo#E_LCG#J. = dJcxx . . $ OptimAlgo#E_LCG#dJ. = hJcxx . . $ OptimAlgo#E_LCG#hJ. = 0;
145
146 Jcxx . . $ OptimAlgo#E_LCG#J. = tocxx . . $ to(7813c32c88d11da9).< Rcxx . . $ Fem2D/R# >(C_F0cxx . . $ C_F0#C_F0(1ee17b1be33d9eb4).(opJ, "(", theparamcxx . . $ OptimAlgo#E_LCG#theparam.));
147 if (opdJ)
148 dJcxx . . $ OptimAlgo#E_LCG#dJ. = tocxx . . $ to(7813c32c88d11da9).< Kn_cxx . . $ OptimAlgo#Kn_# >(C_F0cxx . . $ C_F0#C_F0(1ee17b1be33d9eb4).(
149 opdJ, "(", theparamcxx . . $ OptimAlgo#E_LCG#theparam.)); // May2019 (bug?) Modif FH 17102005 (to verify) to<Kn*> ->to<Kn>
150 if (ophJ) hJcxx . . $ OptimAlgo#E_LCG#hJ. = tocxx . . $ to(7813c32c88d11da9).< Matrice_Creusecxx . . $ Matrice_Creuse#< Rcxx . . $ Fem2D/R# > * >(C_F0cxx . . $ C_F0#C_F0(1ee17b1be33d9eb4).(ophJ, "(", theparamcxx . . $ OptimAlgo#E_LCG#theparam.));
151
152 closetheparamcxx . . $ OptimAlgo#E_LCG#closetheparam. =cxx . . $ C_F0#`operator=`(886a782b76281c4e). C_F0cxx . . $ C_F0#C_F0(22fb85d958f4256a).((Expressioncxx . . $ Expression#)Blockcxx . . $ Block#::snewclosecxx . . $ Block#snewclose(9bffd9b3be4b71bb).(currentblockcxx . . $ currentblock.),
153 atypecxx . . $ atype(f7e2cbc52f11d57).< void >( )); // The cleanning block expression
154 /*
155 if (nargs[2]) {
156 const Polymorphic *op = dynamic_cast<const Polymorphic *>(nargs[2]);
157 assert(op);
158 C = op->Find("(", ArrayOfaType(atype<Kn* >(), false));
159 } else C = 0;
160 */
161 }
162
163 virtual AnyTypecxx . . $ AnyType# operatorcxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).( )(Stackcxx . . $ Stack# stack) const {
164 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stack) = new StackOfPtr2Freecxx . . $ StackOfPtr2Free#StackOfPtr2Free(5d22bdacc48458e8).(stack);
165 typedef LineSearchcxx . . $ LineSearch#< PARAMcxx . . $ OptimAlgo#PARAM#, VECTcxx . . $ OptimAlgo#VECT#, MATcxx . . $ OptimAlgo#MAT#, VMATcxx . . $ OptimAlgo#VMAT#, REALcxx . . $ OptimAlgo#REAL# > LScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).LS#;
166 typedef CubicLineSearchcxx . . $ CubicLineSearch#< LScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).LS# > CLScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).CLS#;
167 KNcxx . . $ KN#< double > *delta = 0;
168 Rcxx . . $ Fem2D/R# tol = argcxx . . $ OptimAlgo#E_LCG#arg(f5865a2e333c217).(0, stack, 1E-6);
169 int itMax = argcxx . . $ OptimAlgo#E_LCG#arg(37daf6ef7c79b13b).(1, stack, 100L);
170 int itMaxLine = argcxx . . $ OptimAlgo#E_LCG#arg(37daf6ef7c79b13b).(2, stack, 100L);
171 bool verbose = verbositycxx . . $ verbosity. > 3;
172
173 try {
174 Kncxx . . $ OptimAlgo#Kn# &x = *GetAnycxx . . $ GetAny(4ae00c582f151d1b).< Kncxx . . $ OptimAlgo#Kn# * >((*Xcxx . . $ OptimAlgo#E_LCG#X.)(cxx . . $ E_F0#`operator()`(29b3b217a13aa28b).stack));
175
176 const int n = x.Ncxx . . $ KN_#N(57a65ae535d7db84).( );
177 GetAnycxx . . $ GetAny(4ae00c582f151d1b).< KNcxx . . $ KN#< double > * >(inittheparamcxx . . $ OptimAlgo#E_LCG#inittheparam..evalcxx . . $ C_F0#eval(29b3b217a13aa28b).(stack)); // do allocation
178
179 Paramcxx . . $ Param#< Rcxx . . $ Fem2D/R# > paramcxx . . $ Param#Param(13bb219bb9d16f6).(x);
180 lgNRJcxx . . $ OptimAlgo#E_LCG#lgNRJ# nrj1cxx . . $ OptimAlgo#E_LCG#lgNRJ#lgNRJ(87043c272a443578).(stack, n, theparamcxx . . $ OptimAlgo#E_LCG#theparam., Jcxx . . $ OptimAlgo#E_LCG#J., dJcxx . . $ OptimAlgo#E_LCG#dJ., hJcxx . . $ OptimAlgo#E_LCG#hJ.);
181 if (!dJcxx . . $ OptimAlgo#E_LCG#dJ.) delta = new KNcxx . . $ KN#< double >(n);
182 CLScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).CLS# lscxx . . $ CubicLineSearch#CubicLineSearch(5d34a9eae5819e2f).(&nrj1, itMaxLine, delta);
183 REALcxx . . $ OptimAlgo#REAL# initialNrj = nrj1.getValcxx . . $ tNRJ#getVal(f500175d9f5e9e70).(param);
184 Optimacxx . . $ Optima#< LScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).LS# > *opt = 0;
185 if (cascxx . . $ OptimAlgo#E_LCG#cas. == 1)
186 opt = new BFGScxx . . $ BFGS#< LScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).LS# >((CLScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).CLS# *)&ls, itMax, tol, verbose);
187 else if (cascxx . . $ OptimAlgo#E_LCG#cas. == 2)
188 opt = new Newtcxx . . $ Newt#< LScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).LS# >((CLScxx . . $ OptimAlgo#E_LCG#`operator()`(29b3b217a13aa28b).CLS# *)&ls, itMax, tol, verbose);
189 else
190 ErrorExeccxx . . $ ErrorExec#ErrorExec(34d26762b42c433a).("lgalgo: Case no available. Sorry, internal bug", cascxx . . $ OptimAlgo#E_LCG#cas.);
191
192 param =cxx . . $ Param#`operator=`(ddbb4b6f9bf2de56). opt->optimizercxx . . $ Optima#optimizer(e033336ccb1d726c).(param);
193
194 REALcxx . . $ OptimAlgo#REAL# finalNrj = nrj1.getValcxx . . $ tNRJ#getVal(f500175d9f5e9e70).(param);
195
196 if (verbositycxx . . $ verbosity.) coutcxx . . $ cout. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "*** RESULTS SUMMARY ***" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
197
198 if (verbositycxx . . $ verbosity. > 1) {
199 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " The number of call to NRJ : " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). nrj1.Appel_Valcxx . . $ tNRJ#Appel_Val(455f465bc33b4cdf).( ) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
200 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " The number of call to gradient : " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). nrj1.Appel_Gradcxx . . $ tNRJ#Appel_Grad(455f465bc33b4cdf).( ) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
201 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " The number of call to hessian : " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). nrj1.Appel_Hesscxx . . $ tNRJ#Appel_Hess(455f465bc33b4cdf).( ) <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
202 }
203 if (verbositycxx . . $ verbosity. > 2) {
204 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Normalized residue : ";
205 displaycxx . . $ display(98513a4378d5e3ab).(optcxx . . $ std/__cxx11/list#list(dc54fa54483e74db).->allResiduecxx . . $ Optima#allResidue(f8c41ee59a648f14).( ));
206 }
207 if (verbositycxx . . $ verbosity.) {
208 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Initial NRJ value : " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). initialNrj <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
209 coutcxx . . $ cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Final NRJ value : " <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). finalNrj <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
210 }
211 delete opt;
212
213 // cout << "The final optimized parameters : " << param;
214 x =cxx . . $ KN#`operator=`(8077e5efd1e64c38). param;
215 } catch (...) {
216 closetheparamcxx . . $ OptimAlgo#E_LCG#closetheparam..evalcxx . . $ C_F0#eval(29b3b217a13aa28b).(stack); // clean memory
217 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stack)->cleancxx . . $ StackOfPtr2Free#clean(83c267b20bac841a).( ); // FH mars 2005
218 if (delta) delete delta;
219
220 throw;
221 }
222
223 if (delta) delete delta;
224 closetheparamcxx . . $ OptimAlgo#E_LCG#closetheparam..evalcxx . . $ C_F0#eval(29b3b217a13aa28b).(stack); // clean memory
225 WhereStackOfPtr2Freecxx . . $ WhereStackOfPtr2Free(7a08698bfc529990).(stack)->cleancxx . . $ StackOfPtr2Free#clean(83c267b20bac841a).( ); // FH mars 2005
226
227 return 0Lcxx . . $ AnyTypeWithOutCheck#AnyTypeWithOutCheck(1624ee8275b10bda).; // SetAny<long>(0); Modif FH july 2005
228 }
229
230 operatorcxx . . $ OptimAlgo#E_LCG#`operator const basicForEachType *`(473004fba94dfb53). aTypecxx . . $ aType#( ) const { return atypecxx . . $ atype(f7e2cbc52f11d57).< long >( ); }
231 };
232
233 E_F0cxx . . $ E_F0# *codecxx . . $ OptimAlgo#code(f771666770a2e724).(const basicAC_F0cxx . . $ basicAC_F0# &args) const { return new E_LCGcxx . . $ OptimAlgo#E_LCG#(args, cascxx . . $ OptimAlgo#cas.); }
234
235 explicit OptimAlgocxx . . $ OptimAlgo#OptimAlgo(d4f767463ce0a6b3).(int c)
236 : OneOperatorcxx . . $ OneOperator#OneOperator(62eded790a0abda1).(atypecxx . . $ atype(f7e2cbc52f11d57).< long >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< KNcxx . . $ KN#< Rcxx . . $ Fem2D/R# > * >( )), cascxx . . $ OptimAlgo#cas.(c) {}
237
238 OptimAlgocxx . . $ OptimAlgo#OptimAlgo(3e454b8ccf442868).(int c, int cc)
239 : OneOperatorcxx . . $ OneOperator#OneOperator(91bbe39e279bb652).(atypecxx . . $ atype(f7e2cbc52f11d57).< long >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ),
240 atypecxx . . $ atype(f7e2cbc52f11d57).< KNcxx . . $ KN#< Rcxx . . $ Fem2D/R# > * >( )),
241 cascxx . . $ OptimAlgo#cas.(c) {}
242
243 OptimAlgocxx . . $ OptimAlgo#OptimAlgo(b1146eedae1e1d0b).(int c, int cc, int ccc)
244 : OneOperatorcxx . . $ OneOperator#OneOperator(7382af309e79d918).(atypecxx . . $ atype(f7e2cbc52f11d57).< long >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ),
245 atypecxx . . $ atype(f7e2cbc52f11d57).< Polymorphiccxx . . $ Polymorphic# * >( ), atypecxx . . $ atype(f7e2cbc52f11d57).< KNcxx . . $ KN#< Rcxx . . $ Fem2D/R# > * >( )),
246 cascxx . . $ OptimAlgo#cas.(c) {}
247 };
248
249 basicAC_F0cxx . . $ basicAC_F0#::name_and_typecxx . . $ basicAC_F0#name_and_type# OptimAlgocxx . . $ OptimAlgo#::E_LCGcxx . . $ OptimAlgo#E_LCG#::name_paramcxx . . $ OptimAlgo#E_LCG#name_param.[] = {
250 {"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"nbiterline", &typeid(long)}};
251 void init_algocxx . . $ init_algo(49f6e7a06ebc5aa8).( );
252
253 void init_algocxx . . $ init_algo(49f6e7a06ebc5aa8).( ) {
254 Globalcxx . . $ Global..Addcxx . . $ TableOfIdentifier#Add(4c37bf6e5ab65edf).("BFGS", "(", new OptimAlgocxx . . $ OptimAlgo#(1, 1)); // j + dJ
255 Globalcxx . . $ Global..Addcxx . . $ TableOfIdentifier#Add(4c37bf6e5ab65edf).("Newton", "(", new OptimAlgocxx . . $ OptimAlgo#(2, 2, 2)); // j + dJ
256
257 // Start msh3 debug
258 // extern void init_msh3();
259 // init_msh3();
260 // End mesh3 debug
261 }
262
263 //#include "InitFunct.hpp"
264 // static addingInitFunct TheaddingInitFunct(-9, init_algo);