36#if !defined(__GNUC__) || __GNUC__ > 3 || __GNUC_MINOR__ > 4
37#define QL_ARRAY_EXPRESSIONS
44 Real computeSimplexSize (
const std::vector<Array>& vertices) {
45 Array center(vertices.front().size(),0);
46 for (
const auto& vertice : vertices)
48 center *=1/
Real(vertices.size());
50 for (
const auto& vertice : vertices) {
51 Array temp = vertice - center;
52 result +=
Norm2(temp);
54 return result/
Real(vertices.size());
65 Real factor1 = (1.0 - factor)/dimensions;
66 Real factor2 = factor1 - factor;
67 #if defined(QL_ARRAY_EXPRESSIONS)
83 #if defined(QL_ARRAY_EXPRESSIONS)
101 Size maxStationaryStateIterations_
108 QL_FAIL(
"Initial guess " <<
x_ <<
" is not in the feasible region.");
115 for (
Size i=0; i<
n; ++i) {
122 for (
Size i=0; i<=
n; ++i)
133 Size iHighest, iNextHighest;
141 for (i=1;i<=
n; i++) {
143 iNextHighest = iHighest;
164 if (simplexSize < xtol ||
167 maxStationaryStateIterations_, ecType);
178 if ((vTry <=
values_[iLowest]) && (factor == -1.0)) {
182 if (vTry >=
values_[iNextHighest]) {
186 if (vTry >= vSave && std::fabs(factor) >
QL_EPSILON) {
187 for (
Size i=0; i<=
n; i++) {
189 #if defined(QL_ARRAY_EXPRESSIONS)
211 QL_FAIL(
"optimization failed: unexpected behaviour");
1-D array used in linear algebra.
Size size() const
dimension of the array
bool test(const Array &p) const
Real update(Array &p, const Array &direction, Real beta) const
Criteria to end optimization process:
@ StationaryFunctionValue
bool checkStationaryPoint(Real xOld, Real xNew, Size &statStateIterations, EndCriteria::Type &ecType) const
Size maxStationaryStateIterations() const
bool checkMaxIterations(Size iteration, EndCriteria::Type &ecType) const
Constrained optimization problem.
const Array & currentValue() const
current value of the local minimum
Constraint & constraint() const
Constraint.
Real value(const Array &x)
call cost function computation and increment evaluation counter
void setFunctionValue(Real functionValue)
void setCurrentValue(const Array ¤tValue)
std::vector< Array > vertices_
Real extrapolate(Problem &P, Size iHighest, Real &factor) const
EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria) override
minimize the optimization problem P
Abstract constraint class.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
Real Norm2(const Array &v)
Simplex optimization method.