libcmaes 0.10.2
A C++11 library for stochastic optimization with CMA-ES
Loading...
Searching...
No Matches
pli.h
1
22#ifndef PLI_H
23#define PLI_H
24
25#include <libcmaes/eo_matrix.h>
26#include <vector>
27
28namespace libcmaes
29{
30
34 class pli
35 {
36 friend class CMASolutions;
37 template <class U> friend class errstats;
38
39 public:
40 pli() {}
41
52 pli(const int &k, const int &samplesize, const int &dim,
53 const dVec &xm, const double &fvalue, const double &fup, const double &delta)
54 :_k(k),_samplesize(samplesize),_fvaluem(dVec::Zero(2*samplesize+1)),_xm(dMat::Zero(2*samplesize+1,dim)),_min(0.0),_max(0.0),_err(2*samplesize+1),_fup(fup),_delta(delta)
55 {
56 _fvaluem[samplesize] = fvalue;
57 _xm.row(samplesize) = xm.transpose();
58 _err[samplesize] = 1; // should be current sol status...
59 }
60
61 ~pli() {};
62
70 std::pair<double,double> getMinMax(const double &fvalue,
71 int &minindex, int &maxindex)
72 {
73 (_fvaluem.head(_samplesize) - dVec::Constant(_samplesize,fvalue)).cwiseAbs().minCoeff(&minindex);
74 (_fvaluem.tail(_samplesize) - dVec::Constant(_samplesize,fvalue)).cwiseAbs().minCoeff(&maxindex);
75 double min = _xm(minindex,_k);
76 double max = _xm(_samplesize + 1 + maxindex,_k);
77 if (min > max)
78 std::swap(min,max);
79 return std::pair<double,double>(min,max);
80 }
81
85 void setMinMax()
86 {
87 std::pair<double,double> mm = getMinMax(_fvaluem[_samplesize]+_fup,_minindex,_maxindex);
88 _min = mm.first;
89 _max = mm.second;
90 }
91
96 {
97 setMinMax();
98 _errmin = _min - _xm(_samplesize,_k);
99 _errmax = _max - _xm(_samplesize,_k);
100 }
101
106 inline double get_err_min() const
107 {
108 return _errmin;
109 }
110
115 inline double get_err_max() const
116 {
117 return _errmax;
118 }
119
120 // accessors
121 inline int get_k() const
122 {
123 return _k;
124 }
125
126 inline int get_samplesize() const
127 {
128 return _samplesize;
129 }
130
131 inline dVec get_fvaluem() const
132 {
133 return _fvaluem;
134 }
135
136 inline dMat get_xm() const
137 {
138 return _xm;
139 }
140
141 inline double get_min() const
142 {
143 return this->_min;
144 }
145
146 inline double get_max() const
147 {
148 return _max;
149 }
150
151 private:
152 int _k = -1;
153 int _samplesize = 0;
154 dVec _fvaluem;
155 dMat _xm; // in phenotype
156 double _min = 0.0;
157 double _max = 0.0;
158 double _errmin = 0.0;
159 double _errmax = 0.0;
160 int _minindex = -1;
161 int _maxindex = -1;
162 std::vector<int> _err; // errors from profile likelihood computations as run status codes.
163 double _fup; // the function deviation for which this profile likelihood was computed.
164 double _delta; // the tolerance around fvalue + fup for which this profile likelihood was computed.
165 };
166
167}
168
169#endif
Holder of the set of evolving solutions from running an instance of CMA-ES.
Definition cmasolutions.h:42
an optimizer main class.
Definition esoptimizer.h:72
Definition errstats.h:34
profile likelihood object holder as a set of points and values.
Definition pli.h:35
double get_err_max() const
get upper error bound
Definition pli.h:115
pli(const int &k, const int &samplesize, const int &dim, const dVec &xm, const double &fvalue, const double &fup, const double &delta)
profile likelihood constructor
Definition pli.h:52
void setErrMinMax()
sets the errors bounds for this profile likelihood.
Definition pli.h:95
double get_err_min() const
get lower error bound
Definition pli.h:106
void setMinMax()
Definition pli.h:85
std::pair< double, double > getMinMax(const double &fvalue, int &minindex, int &maxindex)
find bounds around the objective function parameters for a given value of f, base on pre-computed pro...
Definition pli.h:70
linear scaling of the parameter space to achieve similar sensitivity across all components.
Definition acovarianceupdate.h:30