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.9.0
/* @license-end */
TNlopt.h
Go to the documentation of this file.
1
2// 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
50struct grad_work {
51 vector<URANIE::DataServer::UEntry *> *grad;
52 vector<vector<URANIE::DataServer::UEntry *>> *in, *out;
53 int count;
54};
55
56
57namespace URANIE
58{
59namespace Reoptimizer
60{
61
62class TNlopt: public TNloptShare
63{
64protected:
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
85public:
87 {
88 public:
89 NotASingleEval(){std::cout<<"␛[91m <ERROR>"<<std::endl<<" <ERROR> This eval is not working (either not properly defined, or might have crashed)"<<std::endl<<" <ERROR> ␛[0m"<<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
114double nlopt_crit(unsigned, const double*, double*, void *);
115void nlopt_inequal(unsigned, double *, unsigned, const double*, double*, void*);
116void nlopt_equal(unsigned, double *, unsigned, const double*, double*, void*);
117void nlopt_run(void*);
118
119}
120} //namespace
121#endif
122
recuperation de sortie transformées
objectifs et contraintes standards
Definition TNloptShare.h:71
Definition TNloptShare.h:62
Definition TNlopt.h:63
void put(long, std::vector< URANIE::DataServer::UEntry * > *, std::vector< URANIE::DataServer::UEntry * > *, int=0)
void cleanSolver(struct nlopt_work *)
Definition TNlopt.cxx:368
std::map< int, struct grad_work > _job
Definition TNlopt.h:65
void buildSolver(int siz, struct nlopt_work *)
Definition TNlopt.cxx:348
virtual Bool_t readyToGet()
Definition TNlopt.cxx:275
int _coef
Definition TNlopt.h:66
void run(struct nlopt_work *)
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codg
Definition TNlopt.h:67
virtual void addObjective(URANIE::DataServer::TAttribute *, TOptimFit *f=NULL)
Definition TNlopt.cxx:92
void addEquality(URANIE::DataServer::TAttribute *, TOptimFit *f=NULL)
Definition TNlopt.cxx:100
virtual void build()
Definition TNlopt.cxx:85
void gradFromCode(double *code, double *solv)
Definition TNlopt.cxx:106
int equality(struct nlopt_work *, const double *in, double *out, double *grad)
Definition TNlopt.cxx:166
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codi
Definition TNlopt.h:67
virtual int get(long &)
Definition TNlopt.cxx:294
void put(long, std::vector< URANIE::DataServer::UEntry * > *, std::vector< URANIE::DataServer::UEntry * > *, std::vector< URANIE::DataServer::UEntry * > *, int=0)
int inequality(struct nlopt_work *, const double *in, double *out, double *grad)
Definition TNlopt.cxx:138
int critere(struct nlopt_work *, const double *ini, double *out, double *grad)
Definition TNlopt.cxx:119
virtual ~TNlopt()
Definition TNlopt.cxx:80
std::vector< std::vector< URANIE::DataServer::UEntry * > > _codo
Definition TNlopt.h:67
Definition TOptimFit.h:48
void nlopt_inequal(unsigned, double *, unsigned, const double *, double *, void *)
Definition TNloptShare.cxx:169
double nlopt_crit(unsigned, const double *, double *, void *)
Definition TNloptShare.cxx:159
void nlopt_run(void *)
void nlopt_equal(unsigned, double *, unsigned, const double *, double *, void *)
Definition TNloptShare.cxx:178
Definition TCMAES.h:70
Definition TNlopt.h:50
vector< vector< URANIE::DataServer::UEntry * > > * in
Definition TNlopt.h:52
vector< vector< URANIE::DataServer::UEntry * > > * out
Definition TNlopt.h:52
vector< URANIE::DataServer::UEntry * > * grad
Definition TNlopt.h:51
int count
Definition TNlopt.h:53