|
Unfit
3.1.1
Data fitting and optimization software
|
Access to the private member functions in the neldermead class. More...
Public Member Functions | |
| int | AccessGeneratePopulation (GenericCostFunction &CostFunction, std::vector< double > &initial_point) |
| void | AccessComputeCentroid () |
| bool | AccessContractInside (GenericCostFunction &CostFunction) |
| bool | AccessContractOutside (GenericCostFunction &CostFunction) |
| bool | AccessReflect (GenericCostFunction &CostFunction) |
| bool | AccessExpand (GenericCostFunction &CostFunction) |
| bool | AccessShrink (GenericCostFunction &CostFunction) |
| void | AccessInitialiseVectors () |
| void | AccessPrintIterationOutput (double best_cost) |
| int | AccessRegeneratePopulation (GenericCostFunction &CostFunction) |
| void | SetCentroid (std::vector< double > ¢roid_values) |
| void | SetReflect (std::vector< double > &reflect_values) |
| void | SetContract (std::vector< double > &contract_values) |
| void | SetNumberOfDimensions_ (std::size_t number_of_dimensions) |
| std::size_t | GetNumberOfDimensions_ () |
| unsigned | GetExpand (std::vector< double > &store_expand) const |
| unsigned | GetCentroid (std::vector< double > &store_centroid) const |
| unsigned | GetReflect (std::vector< double > &store_reflect) const |
| unsigned | GetContract (std::vector< double > &store_contract) const |
| bool | AccessIsDegenerate () |
| void | SetVertices (std::vector< std::vector< double > > &vertex) |
| std::size_t | GetCurrentFunctionEvaluation () |
| std::size_t | GetCurrentIterations () |
| void | SetProcess (int process) |
| void | SetWorstVertex (unsigned vertex_number) |
Public Member Functions inherited from Unfit::NelderMead | |
| NelderMead () | |
| virtual | ~NelderMead () |
| int | FindMin (GenericCostFunction &CostFunction, std::vector< double > &coordinates) override |
| Implements the Nelder-Mead optimization method. More... | |
| void | Reset () override |
Public Member Functions inherited from Unfit::GenericOptimizer | |
| GenericOptimizer () | |
| virtual | ~GenericOptimizer () |
| void | ResetGenericOptimizer () |
| virtual double | GetCost (std::size_t index=0) const noexcept |
| virtual bool | GetIsPopulationBased () const noexcept |
| virtual std::size_t | GetNumberOfIterations () const noexcept |
| virtual std::size_t | GetNumberOfFunctionEvaluations () const noexcept |
| virtual std::vector< std::vector< double > > | GetPopulation () const |
| virtual std::vector< double > | GetSolution (std::size_t index=0) const |
| virtual void | SetPopulation (const std::vector< std::vector< double >> &population) |
Additional Inherited Members | |
Public Attributes inherited from Unfit::GenericOptimizer | |
| Unfit::Bounds | bounds |
| Unfit::Options | options |
Protected Member Functions inherited from Unfit::GenericOptimizer | |
| virtual bool | CalculateCost (GenericCostFunction &CostFunction, std::vector< double > &x) |
| void | GeneratePopulation (GenericCostFunction &CostFunction, std::size_t dimensions) |
| void | GenerateRandomEngines () |
| virtual bool | IsConverged (const std::vector< double > &best_member, std::size_t truncated_index=0) const |
| Checks to see if the population has converged. More... | |
| virtual void | PrintFinalOutput () const |
| virtual void | SortPopulation () noexcept |
Protected Attributes inherited from Unfit::GenericOptimizer | |
| std::vector< std::vector< double > > | population_ |
| std::vector< std::mt19937 > | random_engines_ |
| std::atomic< std::size_t > | function_evaluations_ |
| std::atomic< std::size_t > | iterations_ |
| bool | is_population_based_ |
Access to the private member functions in the neldermead class.
The main goal of this class is to access the private member functions in the neldermead class in tests. See the documentation of each function for more details.
|
inline |
create a function to access the private method(ComputeCentroid) in class NelderMead.
Intended use: rc = AccessComputeCentroid()
|
inline |
create a function to access the private method (ContractInside) in class NelderMead.
Intended use: bool rc = AccessContractInside(CostFunction);
Parameters:
| CostFunction | (input) the function to be implemented |
Return Codes:
|
inline |
create a function to access the private method (ContractOutside) in class NelderMead.
Intended use: bool rc = AccessContractOutside(CostFunction);
Parameters:
| CostFunction | (input) the function to be implemented |
Return Codes:
|
inline |
create a function to access the private method(Expand) in class NelderMead.
Intended use: bool rc = AccessExpand(CostFunction);
Parameters:
| CostFunction | (input) the function specified by the user |
Return Codes:
|
inline |
create a function to access the private method(GeneratePopulation) in class NelderMead.
Intended use: AccessGeneratePopulation(CostFunction, min_point)
Parameters:
| CostFunction | (input) the function to be implemented |
| initial_point | (input) vector which contain the initial guess |
Return Codes
|
inline |
Initialise the working vectors population_, contract_, centroid_, reflect_, expand_ to size depending on the dimension of the problem. Elements are assigned 0 value.
Behaviour: For population_: population_[number_of_dimensions+1][number_of_dimensions+1] For the rest: workingvector_[number_of_dimensions+1]
Intended use: AccessInitialiseVectors();
|
inline |
Check if the termination criteria are met and stops the NelderMead iteration. Two termination criteria are checked against a user-defined tolerance, and both have to be met. Criteria 1: Check how different the minima calculated are - difference in costs comparing the best vertex to the other vertices Criteria 2: Check how different the coordinates are relative to one another, comparing the best vertex to the other vertices
Intended use: AccessIsDegenerate()
Return Codes:
|
inline |
Calls the PrintIterationOutput method of NelderMead. Requires that the number of iterations, number of function evaluations, cost of the best vertex, and the process be set.
| best_cost | The best cost at the current iteration |
|
inline |
create a function to access the private method(Reflect) in class NelderMead.
Intended use: bool rc = AccessReflect(CostFunction);
Parameters:
| CostFunction | (input) the function to be implemented |
Return Codes:
|
inline |
create a function to access the private method(RegeneratePopulation) in class NelderMead.
Intended use: int rc = AccessRegeneratePopulation(CostFunction);
Parameters:
| CostFunction | (input) the function specified by the user |
Return Codes: 0 = Success 1 = invalid simplex
|
inline |
create a function to access the private method(Shrink) in class NelderMead. Intended use: bool rc = AccessShrink(CostFunction);
Parameters:
| CostFunction | (input) the function to be implemented |
Return Codes:
|
inline |
Gets the centroid coordinates and f(x, y) of the mid point. The mid point vector is stored in a temporary vector store_centroid_. Returns 0 when it is successful.
Intended use: unsigned rc = GetCentroid(store_mid_point);
Parameters:
| store_centroid | (input) a vector of values to be put inside the centroid_ vector |
Return Codes:
|
inline |
Gets the expanded coordinates and f(x, y) after the contract function. The vector is stored in a temporary vector store_contract. It returns 0 when it is successful.
Intended use: unsigned rc = GetContract(store_contract);
Parameters:
| store_contract | (input) vector to be filled in with contract_ values obtained from the Contract function |
Return Codes:
|
inline |
Get the value of the parameter current_function_evaluations
Intended use: unsigned rc = GetCurrentFunctionEvaluation();
Return Code:
|
inline |
Get the value of the parameter current_iterations_
Intended use: unsigned rc = GetCurrentIterations();
Return Code:
|
inline |
Gets the expanded coordinates and f(x, y) after the expand function. The vector is stored in a temporary vector store_expand. It returns 0 when it is successful.
Intended use: unsigned rc = GetExpand(store_expand);
Parameters:
| store_expand | (input) an empty vector to store the expand_ vector that contains the expand point |
Return Codes:
|
inline |
Get the number of dimensions stored in the variable dimensions_. NOTE: the size of the variable must be 2 and above.
Intended use: unsigned rc = GetNumberOfDimensions_();
Return Codes:
|
inline |
Gets the reflect point coordinates and f(x, y) of the reflect point. The reflect vector is stored in a temporary vector store_reflect_
Intended use: unsigned rc = GetCentroid(store_reflect);
Parameters:
| store_reflect | (input) a vector of values to be put inside the reflect_ vector |
Return Codes:
|
inline |
Set the values stored in the vector centroid_. NOTE: the size of the vector that is passed in must be 3.
Intended use: SetCentroid(centroid_values);
Parameters:
| centroid_values | (input) a vector of values to be put inside the centroid_ vector |
|
inline |
Set the values stored in the vector contract_. NOTE: the size of the vector that is passed in must be 3.
Intended use: SetContract(Contract_values);
Parameters:
| contract_values | (input) a vector of values to be put inside the contract_ vector |
|
inline |
Set the number of dimensions stored in the variable dimensions_. NOTE: the size of the variable must be 2 and above.
Intended use: SetNumberOfDimensions_(number of dimensions);
Parameters:
| number_of_dimensions | (input) an integer to be the number of dimensions |
|
inline |
Set the value of the Operation enum (process_ variable). See the documentation for NelderMead.hpp to see what entries are valid.
Parameters:
| process | Must be selected from the Operation enum |
|
inline |
Set the values stored in the vector reflect_. NOTE: the size of the vector that is passed in must be 3.
Intended use: SetReflect(Reflect_values);
Parameters:
| reflect_values | (input) a vector of values to be put inside the reflect_ vector |
|
inline |
Set the values stored in the simplex as a vector of vectors NOTE: the size of the vector that is passed in must be at least 2 and include the cost of the vertex. Size of the vector vector should be a matrix of (n+1) x (n+1) where n is the number of dimensions. This function also helps to set the number of dimension based on the size of the vectors given.
Intended use: SetVertices(vertex);
Parameters:
| vertex | (input) a vector of vectors to be put inside the population_ vector |
|
inline |
Set the vertex that has the worst cost. If it is not clear which one it should be, just call AccessSortPopulation, and then the index of the vertex with the worst cost will be the same as the number of dimensions.
Parameters:
| vertex_number | The index of the vertex with the worst cost (index starts from zero and ends at dimensions_) |
1.8.13