44 inline double minfun(
double x,
double y)
45 {
return x < y ? x : y; }
47 inline double maxfun(
double x,
double y)
48 {
return x > y ? x : y; }
54 "The \"SIMPLEX\" sub-command adjusts parameters according to the "
55 "\"SIMPLEX\" method taken from MINUIT.") {
57 (
"TOLERANCE",
"The desired tolerance", 1.0
e-6);
59 (
"CALLS",
"Maximum number of calls to the matching functions", 1000.);
81 static const char method[] =
"SIMPLEX";
82 static const double alpha = 1.0;
83 static const double beta = 0.5;
84 static const double gamma = 2.0;
85 static const double rhomin = 4.0;
86 static const double rhomax = 8.0;
87 static const double rho1 = 1.0 +
alpha;
88 static const double rho2 = rho1 + alpha * gamma;
134 for(
int i = 0; i <
n; ++i) {
141 for(idir = 1; idir <= 12; ++idir) {
143 if(
Match::block->evaluate(X, F) && (Fmin = F * F) <= Fsave)
break;
144 if(idir % 2 == 0) step *= 0.1;
150 for(
int ns = 1; ns <= 3; ++ns) {
158 if(!
Match::block->evaluate(X, F) || (Fmin = F * F) > Fsave) {
181 bool restart =
false;
191 Xbar = std::accumulate
194 double Fstar = 2.0 *
Fsim(
jh);
198 if((Fstar = F * F) <
Fsim(
jl)) {
208 double F1 = (Fstar -
Fsim(
jh)) * rho2;
209 double F2 = (Fstst -
Fsim(
jh)) * rho1;
210 rho = 0.5 * (rho2 * F1 - rho1 * F2) / (F1 - F2);
223 if(rho > rhomax) rho = rhomax;
230 (Frho = F * F) <
Fsim(
jl) &&
233 }
else if(Fstst <
Fsim(
jl)) {
250 (Fstst = F * F) <
Fsim(
jh)) {
275 if(Fmin >= 2.0 * (tol + DBL_EPSILON)) {
279 for(
int j = 1; j <
n; ++j) {
281 Xmin.
begin(), minfun);
283 Xmax.
begin(), maxfun);
308 for(
int j = 1; j <=
n; ++j) {
double Round(double value)
Round the double argument.
virtual void execute()
Execute the command.
constexpr double e
The value of .
void razzia(double Fnew, Vector< double > &Xnew)
Simplex()
Exemplar constructor.
MatchState
The possible states of a matching process.
The base class for all OPAL actions.
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
iterator end()
Get end of data.
static Match * block
The block of match data.
int countFunctions() const
Return total number of functions.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
void setVariables(const Vector< double > &x)
Set values of matching variables.
constexpr double alpha
The fine structure constant, no dimension.
void print(const char *method, MatchState state)
Print the results of minimisation.
int countVariables() const
Get total number of variables.
iterator begin()
Get beginning of data.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Array1D< Vector< double > > Xsim
virtual Simplex * clone(const std::string &name)
Make clone.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
double getReal(const Attribute &attr)
Return real value.
void getVariables(Vector< double > &x) const
Get values of matching variables.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.