English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / ReOptimizer: TNlopt.h Source File
Uranie / ReOptimizer  v4.10.0
/* @license-end */
TNlopt.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2024 CEA/DES
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or any
7 // later version.
8 //
9 // This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 // $Id$
19 // $Author$
20 // $Date$
21 // $Revision 1.5 $
22 // $State$
24 
32 #ifndef __NLOPT__
33 #define __NLOPT__
34 
35 #include <vector>
36 #include <map>
37 
38 //ROOT
39 #include "Rtypes.h"
40 
41 //Uranie
42 #include "Reoptimizer.h"
43 #include "TNloptShare.h"
44 
45 #include "DataServer.h"
46 #include "TEval.h"
47 #include "TOptimFit.h"
48 #include "TFitGetter.h"
49 
50 struct grad_work {
51  vector<URANIE::DataServer::UEntry *> *grad;
52  vector<vector<URANIE::DataServer::UEntry *>> *in, *out;
53  int count;
54 };
55 
56 
57 namespace URANIE
58 {
59 namespace Reoptimizer
60 {
61 
62 class TNlopt: public TNloptShare
63 {
64 protected:
65  std::map<int, struct grad_work> _job;
66  int _coef;
67  std::vector<std::vector<URANIE::DataServer::UEntry *>> _codi, _codo, _codg;
68 
69  virtual void build();
70  // pseudo runner
71  void put(long, std::vector<URANIE::DataServer::UEntry*>*,
72  std::vector<URANIE::DataServer::UEntry*>*, int =0);
73  void put(long, std::vector<URANIE::DataServer::UEntry*>*,
74  std::vector<URANIE::DataServer::UEntry*>*,
75  std::vector<URANIE::DataServer::UEntry*>*, int =0);
76  virtual Bool_t readyToGet();
77  // solver
78  void gradFromCode(double *code, double *solv);
79  // abstract from TNloptShare
80  void buildSolver(int siz, struct nlopt_work *);
81  void cleanSolver(struct nlopt_work *);
82  void put(struct nlopt_work *, Bool_t, const double *);
83  virtual int get(long &);
84 
85 public:
87  {
88  public:
89  NotASingleEval(){std::cout<<" <ERROR>"<<std::endl<<" <ERROR> This eval is not working (either not properly defined, or might have crashed)"<<std::endl<<" <ERROR> "<<std::endl;}
90  };
91 
92  TNlopt(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TRun *run,
93  TNloptSolver *algo);
94  TNlopt(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TEval *fun,
95  TNloptSolver *algo);
96  virtual ~TNlopt();
97 
98  // initialisation
99  virtual void addObjective(URANIE::DataServer::TAttribute *, TOptimFit *f =
100  NULL);
101  void addEquality(URANIE::DataServer::TAttribute *, TOptimFit *f = NULL);
102  // callback methode
103  int critere(struct nlopt_work*, const double *ini, double *out,
104  double *grad);
105  int inequality(struct nlopt_work*, const double *in, double *out,
106  double *grad);
107  int equality(struct nlopt_work*, const double *in, double *out,
108  double *grad);
109  void run(struct nlopt_work *);
110 
111  ClassDef(URANIE::Reoptimizer::TNlopt, ID_REOPTIMIZER)
112 };
113 
114 double nlopt_crit(unsigned, const double*, double*, void *);
115 void nlopt_inequal(unsigned, double *, unsigned, const double*, double*, void*);
116 void nlopt_equal(unsigned, double *, unsigned, const double*, double*, void*);
117 void nlopt_run(void*);
118 
119 }
120 } //namespace
121 #endif
122 
Definition: TCMAES.h:66
objectifs et contraintes standards
void buildSolver(int siz, struct nlopt_work *)
Definition: TNlopt.cxx:348
double nlopt_crit(unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:159
std::map< int, struct grad_work > _job
Definition: TNlopt.h:65
Definition: TNlopt.h:50
int count
Definition: TNlopt.h:53
void put(long, std::vector< URANIE::DataServer::UEntry *> *, std::vector< URANIE::DataServer::UEntry *> *, int=0)
vector< URANIE::DataServer::UEntry * > * grad
Definition: TNlopt.h:51
int _coef
Definition: TNlopt.h:66
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codo
Definition: TNlopt.h:67
int equality(struct nlopt_work *, const double *in, double *out, double *grad)
Definition: TNlopt.cxx:166
Definition: TNloptShare.h:70
Definition: TNlopt.h:62
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codi
Definition: TNlopt.h:67
void nlopt_equal(unsigned, double *, unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:178
virtual Bool_t readyToGet()
Definition: TNlopt.cxx:275
void nlopt_inequal(unsigned, double *, unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:169
Definition: TOptimFit.h:47
void addEquality(URANIE::DataServer::TAttribute *, TOptimFit *f=NULL)
Definition: TNlopt.cxx:100
Definition: TNloptShare.h:61
void nlopt_run(void *)
virtual ~TNlopt()
Definition: TNlopt.cxx:80
void cleanSolver(struct nlopt_work *)
Definition: TNlopt.cxx:368
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codg
Definition: TNlopt.h:67
void run(struct nlopt_work *)
virtual void build()
Definition: TNlopt.cxx:85
virtual void addObjective(URANIE::DataServer::TAttribute *, TOptimFit *f=NULL)
Definition: TNlopt.cxx:92
recuperation de sortie transformées
int critere(struct nlopt_work *, const double *ini, double *out, double *grad)
Definition: TNlopt.cxx:119
vector< vector< URANIE::DataServer::UEntry * > > * in
Definition: TNlopt.h:52
void gradFromCode(double *code, double *solv)
Definition: TNlopt.cxx:106
vector< vector< URANIE::DataServer::UEntry * > > * out
Definition: TNlopt.h:52
int inequality(struct nlopt_work *, const double *in, double *out, double *grad)
Definition: TNlopt.cxx:138
TNlopt(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TRun *run, TNloptSolver *algo)
Definition: TNlopt.cxx:68