English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / ReOptimizer: TNloptShare.h Source File
Uranie / ReOptimizer  v4.11.0
/* @license-end */
TNloptShare.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 __NLOPTSHARE__
33 #define __NLOPTSHARE__
34 
35 #include <vector>
36 #include <map>
37 
38 //ROOT
39 #include "Rtypes.h"
40 #include "TObject.h"
41 
42 //Uranie
43 #include "Reoptimizer.h"
44 #include "TOptimShare.h"
45 
46 #include "DataServer.h"
47 #include "TEval.h"
48 #include "TOptimFit.h"
49 #include "TFitGetter.h"
50 //#include "TNlopt.h"
51 
52 struct nlopt_opt_s;
53 /* opaque structure, defined internally */
54 typedef struct nlopt_opt_s *nlopt_opt;
55 struct nlopt_work;
56 
57 
58 namespace URANIE
59 {
60 namespace Reoptimizer
61 {
62 
63 class TNloptSolver : public TOptimSolver
64 {
65 public:
66  virtual ~TNloptSolver() {}
67  virtual nlopt_opt build(int, int, int, double, nlopt_opt*) = 0;
68  virtual TOptimShare *getMaster(URANIE::DataServer::TDataServer *tds,
69  URANIE::Relauncher::TRun *run);
70 
71  ClassDef(URANIE::Reoptimizer::TNloptSolver, ID_REOPTIMIZER)
72 };
73 
74 class TNloptShare: public TOptimShare
75 {
76 private:
77  void create();
78 
79 protected:
81  TObjArray _equal;
83  std::vector<double *> _guess;
84  int _id, _max; //, _coef;
85  std::vector<std::vector<URANIE::DataServer::UEntry *>> _codi, _codo, _codg;
86 
87  virtual void build();
88  // abstrack methods
89  virtual void buildSolver(int siz, struct nlopt_work *) = 0;
90  virtual void cleanSolver(struct nlopt_work *) = 0;
91  virtual void put(struct nlopt_work *, Bool_t, const double *) = 0;
92  virtual int get(long &) = 0;
93  //void gradFromCode(double *code, double *solv);
94  // solver
95  void solver(struct nlopt_work *, int, double*,
96  vector<URANIE::DataServer::UEntry*>&,
97  vector<URANIE::DataServer::UEntry*>&,
98  vector<URANIE::DataServer::UEntry*>&
99  );
100  void calcul(struct nlopt_work *, Bool_t, const double *);
101  void fillOptimum(struct nlopt_work *);
102  void fill(struct nlopt_work *, URANIE::DataServer::TDataServer *tds, int id);
103 
104 public:
106  {
107  };
108 
109  TNloptShare(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TRun *run,
110  TNloptSolver *algo);
111  TNloptShare(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TEval *fun,
112  TNloptSolver *algo);
113  virtual ~TNloptShare();
114 
115  // initialisation
116  virtual void setStartingPoint(double *pt);
117  virtual void setStartingPoint(int nb, double *pt);
118  virtual void setMaximumEval(int max)
119  {
120  _max = max;
121  }
122 
123  // callback methode
124  virtual int critere(struct nlopt_work*, const double *ini, double *out,
125  double *grad) = 0;
126  virtual int inequality(struct nlopt_work*, const double *in, double *out,
127  double *grad) = 0;
128  virtual int equality(struct nlopt_work*, const double *in, double *out,
129  double *grad) = 0;
130  void run(struct nlopt_work *);
131 
134  {
135  return _retOptim;
136  }
137 
139  {
140  return _guess.size();
141  }
142 
143 
144  virtual void solverLoop();
145 
146  ClassDef(URANIE::Reoptimizer::TNloptShare, ID_REOPTIMIZER)
147 };
148 
149 #ifdef HIDE
150 double nlopt_crit(unsigned, const double*, double*, void *);
151 void nlopt_inequal(unsigned, double *, unsigned, const double*, double*, void*);
152 void nlopt_equal(unsigned, double *, unsigned, const double*, double*, void*);
153 //void nlopt_run(void*);
154 #endif
155 
156 }
157 } //namespace
158 #endif
159 
Definition: TCMAES.cxx:49
int _max
Definition: TNloptShare.h:84
TObjArray _equal
Definition: TNloptShare.h:81
objectifs et contraintes standards
void solver(struct nlopt_work *, int, double *, vector< URANIE::DataServer::UEntry *> &, vector< URANIE::DataServer::UEntry *> &, vector< URANIE::DataServer::UEntry *> &)
Definition: TNloptShare.cxx:241
double nlopt_crit(unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:159
virtual void put(struct nlopt_work *, Bool_t, const double *)=0
void create()
Definition: TNloptShare.cxx:99
TNloptSolver * _solv
Definition: TNloptShare.h:82
virtual ~TNloptSolver()
Definition: TNloptShare.h:66
virtual void buildSolver(int siz, struct nlopt_work *)=0
std::vector< double * > _guess
Definition: TNloptShare.h:83
Definition: TFitGetter.h:50
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codo
Definition: TNloptShare.h:85
Definition: TOptimShare.h:121
int _retOptim
Definition: TNloptShare.h:132
Definition: TNloptShare.h:74
virtual void solverLoop()
Definition: TNloptShare.cxx:342
virtual int critere(struct nlopt_work *, const double *ini, double *out, double *grad)=0
void nlopt_equal(unsigned, double *, unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:178
int getReturnOptim()
Definition: TNloptShare.h:133
virtual ~TNloptShare()
Definition: TNloptShare.cxx:82
struct nlopt_opt_s * nlopt_opt
Definition: TNloptShare.h:54
void nlopt_inequal(unsigned, double *, unsigned, const double *, double *, void *)
Definition: TNloptShare.cxx:169
Definition: TOptimShare.h:52
Definition: TNloptShare.h:63
virtual void setStartingPoint(double *pt)
Definition: TNloptShare.cxx:119
virtual void cleanSolver(struct nlopt_work *)=0
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codg
Definition: TNloptShare.h:85
TFitGetter * _crit
Definition: TNloptShare.h:80
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codi
Definition: TNloptShare.h:85
virtual nlopt_opt build(int, int, int, double, nlopt_opt *)=0
int getNStartingPoint()
Definition: TNloptShare.h:138
void fillOptimum(struct nlopt_work *)
Definition: TNloptShare.cxx:410
TNloptShare(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TRun *run, TNloptSolver *algo)
Definition: TNloptShare.cxx:68
virtual int equality(struct nlopt_work *, const double *in, double *out, double *grad)=0
void calcul(struct nlopt_work *, Bool_t, const double *)
Definition: TNloptShare.cxx:188
virtual void build()
Definition: TNloptShare.cxx:110
int _id
Definition: TNloptShare.h:84
recuperation de sortie transformées
methodes communes aux algo d optimisation
void run(struct nlopt_work *)
Definition: TNloptShare.cxx:310
void fill(struct nlopt_work *, URANIE::DataServer::TDataServer *tds, int id)
Definition: TNloptShare.cxx:417
virtual int inequality(struct nlopt_work *, const double *in, double *out, double *grad)=0
virtual TOptimShare * getMaster(URANIE::DataServer::TDataServer *tds, URANIE::Relauncher::TRun *run)
Definition: TNloptDirect.cxx:48
virtual void setMaximumEval(int max)
Definition: TNloptShare.h:118