[..] L'étude de cas [ia] ir5scl

Code
 int ir5_ia(){
   scltracefa(§, ƒ, );
   scltracefc("scl-%s (%s) : %s\n", sclver(), sclsec(), temps_char(0));

   // http://recherche.telecom-bretagne.eu/iono/ir5_publication.php
   scl::string_c datname="ir5.dat", datpath="./don/sul/"+datname;

   int ir5an, ir5mois;
   double cir5, cjj;
   char ir5op; // statut observation/prevision

   std::vector<double> ir5a, ir5o, ir5p, jja, jjo, jjp;

   // Jour Julien 🚀 1er jan 1950 0[h]
   double jj_dis = date_jj(1950, 1, 1, 0, 0, 0, 1);

   FILE *fid = fopen(datpath.c_str(), "rt");
   while(!feof(fid)){
     fscanf(fid, "%d %d %lf %c", &ir5an, &ir5mois, &cir5, &ir5op);
     fgetc(fid); // on passe la fin de ligne
     //scltracefc("%d;%d;%lf;'%c'\n", ir5an, ir5mois, ir5val, ir5op);
     cjj = date_jj(ir5an, ir5mois, 1, 0, 0, 0, 1) - jj_dis;

     if(ir5op=='O'){      ir5o.push_back(cir5); jjo.push_back(cjj); }
     else if(ir5op=='P'){ ir5p.push_back(cir5); jjp.push_back(cjj); }
   }
   fclose(fid); fid=;
   //---------------------------------------------------------------------
   datname.clear(); datname="ir5_archive.dat";
   datpath.clear(); datpath="./don/sul/"+datname;

   fid = fopen(datpath.c_str(), "rt");
   while(!feof(fid)){
     fscanf(fid, "%d %d %lf %c", &ir5an, &ir5mois, &cir5, &ir5op);
     fgetc(fid); // on passe la fin de ligne
     //scltracefc("%d;%d;%lf;'%c'\n", ir5an, ir5mois, ir5val, ir5op);
     cjj = date_jj(ir5an, ir5mois, 1, 0, 0, 0, 1) - jj_dis;

     ir5a.push_back(cir5); jja.push_back(cjj);
   }
   fclose(fid); fid=;

   int o5n=(int)ir5o.size(), o5i, p5n=(int)ir5p.size(),
       a5n=(int)ir5a.size(), a5i;

   double ir5e=-rd;
   cir5=max<double>(o5n, &ir5o[0]); if(ir5e<cir5){ ir5e = cir5; }
   cir5=max<double>(p5n, &ir5p[0]); if(ir5e<cir5){ ir5e = cir5; }
   cir5=max<double>(a5n, &ir5a[0]); if(ir5e<cir5){ ir5e = cir5; }
   double ir5r = (ir5e-0)*10/100/2;

   int xn=o5n+a5n, xi;
   double *x=new double[xn], *t=new double[xn];
   for(a5i=0,xi=a5n-1;a5i<a5n;a5i++,xi--){
     x[xi]=ir5a[a5i]/ir5e;  t[xi]=jja[a5i];
   }
   for(o5i=0,xi=a5n  ;o5i<o5n;o5i++,xi++){
     x[xi]=ir5o[o5i]/ir5e; t[xi]=jjo[o5i];
   }

   int an=40, cn=23, en=6;
   int chn=3;
   int nrn[3], nlt[3];
   nrn[0]=an;               nrn[1]=cn;               nrn[2]=en;
   nlt[0]=SCL_NLTYPE_LINR;  nlt[1]=SCL_NLTYPE_SIGM;  nlt[2]=SCL_NLTYPE_SIGM;
   double η = 0.015;

   int sbln=(xn-an)/en, sbli;
   double **xr=new double*[sbln], *cx;
   double **zr=new double*[sbln], *cz;
   double **yr_0=new double*[sbln], **yr_1=new double*[sbln],
       **yr_4=new double*[sbln], *cy;
   double *y_0=new double[xn], *y_1=new double[xn], *y_4=new double[xn];
   for(sbli=0;sbli<sbln;sbli++){
     cx=&x[sbli*en];      xr[sbli]  =cx;
     cz=&x[an+sbli*en];   zr[sbli]  =cz;
     cy=&y_0[an+sbli*en]; yr_0[sbli]=cy;
     cy=&y_1[an+sbli*en]; yr_1[sbli]=cy;
     cy=&y_4[an+sbli*en]; yr_4[sbli]=cy;
   }
   double **xj=newmat<double>(sbln, an, 0);
   double **zj=newmat<double>(sbln, en, 0);
   double **yj=newmat<double>(sbln, en, 0);

   // Poids synaptiques
   double ***wr = new double**[chn];
   wr[0] = newmat<double>(an, 1);
   wr[1] = newmat<double>(cn, an);
   wr[2] = newmat<double>(en, cn);
   double ***wj = new double**[chn];
   wj[0] = newmat<double>(an, 1);
   wj[1] = newmat<double>(cn, an);
   wj[2] = newmat<double>(en, cn);

   int itrn=1; tic();
   nevronx(chn, &nrn[0], &nlt[0], sbln, xr, xj, zr, zj,
       itrn, εrd, η, 0, yr_0, yj, wr, wj, );
   scltracefc("x%d : %lf [ms]\n", itrn, tac());
   scl::string_c legend = "Itération x"+num_str<int>(itrn);

   itrn=10; tic();
   nevronx(chn, &nrn[0], &nlt[0], sbln, xr, xj, zr, zj,
       itrn, εrd, η, 0, yr_1, yj, wr, wj, );
   scltracefc("x%d : %lf [ms]\n", itrn, tac());
   legend += ";Itération x"+num_str<int>(itrn);

   itrn=10000;
   double *eq = new double[itrn];
   tic();
   nevronx(chn, &nrn[0], &nlt[0], sbln, xr, xj, zr, zj,
       itrn, εrd, η, 0, yr_4, yj, wr, wj, eq);
   scltracefc("x%d : %lf [ms]\n", itrn, tac());
   legend += ";Itération x"+num_str<int>(itrn);

   for(xi=0;xi<xn;xi++){
     y_0[xi]*=ir5e; y_1[xi]*=ir5e; y_4[xi]*=ir5e;
   }

   //---------------------------------------------------------------------
   scl::string_c imgname=scl::string_c(ƒ)+".svg",
       imgpath="./srt/"+imgname;

   graf_dis(imgpath.c_str(), o5n, &jjo[0], &ir5o[0],
       "curve", p5n, &jjp[0], &ir5p[0],
       "curve", a5n, &jja[0], &ir5a[0],
       "curve", 1, &jjo[o5n-1], &ir5o[o5n-1],
       "curve", 1, &jjp[p5n-1], &ir5p[p5n-1],
       "grid", "on",
       "subtitlex",
       "https://recherche.telecom-bretagne.eu/iono/ir5_publication.php",
       "linespec", "-l;-r;-l;h+;h+", "dataxis", "x",
       "legend", "Observation;Prédiction",
       "legcorn", "ula", "title", "Évolution de l'indice IR5",
       "axmax", (jjp[p5n-1]+11*12*30.5),
       "aymin", 0-ir5r, "aymax", ir5e+ir5r,
       "markersize", 20, "linespeca", "-a", );

   //---------------------------------------------------------------------
   imgname.clear(); imgname=scl::string_c(ƒ)+"-drnr-y.svg";
   imgpath.clear(); imgpath="./srt/"+imgname;

   graf_dis(imgpath.c_str(), xn, t, y_0,
       "curve", xn, t, y_1, "curve", xn, t, y_4,
       "grid", "on", "linespec", "-c;-m;-u", "dataxis", "x",
       "legend", legend.c_str(), "legcorn", "ula",
       "title", "Dernières sorties d'apprentissage Sigmoïde",
       "axmax", (jjp[p5n-1]+11*12*30.5),
       "aymin", 0-ir5r, "aymax", ir5e+ir5r,
       "linespeca", "-a", );

   //---------------------------------------------------------------------
   imgname.clear(); imgname=scl::string_c(ƒ)+"-eq.svg";
   imgpath.clear(); imgpath="./srt/"+imgname;

   graf_dis(imgpath.c_str(), itrn, , eq,
       "grid", "on", "linespec", "-u",
       "title", "Erreur quadratique d'apprentissage Sigmoïde",
       "xlabel", "Numéro d'itération", "logaxis", "y",
       "linespeca", "-a", );

   //---------------------------------------------------------------------
   //[>LIBR. MEMOIRE]
   //---------------------------------------------------------------------
   imgpath.clear(); imgname.clear(); legend.clear();
   deletemat<double>(an, &wr[0]); deletemat<double>(cn, &wr[1]);
   deletemat<double>(en, &wr[2]); delete[] wr; wr=;
   deletemat<double>(an, &wj[0]); deletemat<double>(cn, &wj[1]);
   deletemat<double>(en, &wj[2]); delete[] wj; wj=;
   deletemat<double>(sbln, &yj);
   deletemat<double>(sbln, &zj);
   deletemat<double>(sbln, &xj);
   delete[] y_4; y_4=;   delete[] y_1; y_1=;
   delete[] y_0; y_0=;
   delete[] yr_4; yr_4=; delete[] yr_1; yr_1=;
   delete[] yr_0; yr_0=;
   delete[] zr; zr=;     delete[] xr; xr=;
   delete[] t; t=;       delete[] x; x=;
   jjp.clear();  jjo.clear();  jja.clear();
   ir5p.clear(); ir5o.clear(); ir5a.clear();
   datpath.clear(); datname.clear();
   delete[] eq; eq=;
   //---------------------------------------------------------------------
   //[<LIBR. MEMOIRE]
   //---------------------------------------------------------------------

   scltracefe(§, ƒ, );
   return 0;
 }
 /* ƒ décorée par 🔬 le 06-04-2024 13:27:26 */
Sortie
        [>..\xpl\src\scl.ia.cpp.ir5_ia]
          scl-24.04 (gwin64) : 06-04-2024 13:27:26
          [<..\src\sclronx.c.nevronx>] Iteration 0/1 Error 0.346211
          x1 : 5.661200 [ms]
          [<..\src\sclronx.c.nevronx>] Iteration 0/10 Error 0.346211
          [<..\src\sclronx.c.nevronx>] Iteration 1/10 Error 0.279188
          [<..\src\sclronx.c.nevronx>] Iteration 2/10 Error 0.275200
          [<..\src\sclronx.c.nevronx>] Iteration 3/10 Error 0.268745
          [<..\src\sclronx.c.nevronx>] Iteration 4/10 Error 0.257574
          [<..\src\sclronx.c.nevronx>] Iteration 5/10 Error 0.237437
          [<..\src\sclronx.c.nevronx>] Iteration 6/10 Error 0.204412
          [<..\src\sclronx.c.nevronx>] Iteration 7/10 Error 0.173927
          [<..\src\sclronx.c.nevronx>] Iteration 8/10 Error 0.168145
          [<..\src\sclronx.c.nevronx>] Iteration 9/10 Error 0.166023
          x10 : 59.917300 [ms]
          x10000 : 50468.191500 [ms]

           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
           <<                END OF DISLIN / VERSION 11.3.2                <<
           <<  Date    : 06.04.2024  Time    : 13:28:17  Pageformat: DA4L  <<
           <<  Vectors : 4174        Warnings: 0         Fileformat:  SVG  <<
           <<  Metafile: ./srt/ir5_ia.svg                                  <<
           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
           <<                END OF DISLIN / VERSION 11.3.2                <<
           <<  Date    : 06.04.2024  Time    : 13:28:17  Pageformat: DA4L  <<
           <<  Vectors : 10647       Warnings: 0         Fileformat:  SVG  <<
           <<  Metafile: ./srt/ir5_ia-drnr-y.svg                           <<
           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
           <<                END OF DISLIN / VERSION 11.3.2                <<
           <<  Date    : 06.04.2024  Time    : 13:28:17  Pageformat: DA4L  <<
           <<  Vectors : 11939       Warnings: 0         Fileformat:  SVG  <<
           <<  Metafile: ./srt/ir5_ia-eq.svg                               <<
           <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        [<..\xpl\src\scl.ia.cpp.ir5_ia]