OpenCMISS-Zinc C++ API Documentation
|
A description of a non-linear optimisation problem. More...
#include <optimisation.hpp>
Public Types | |
enum | Method { METHOD_INVALID = CMZN_OPTIMISATION_METHOD_INVALID, METHOD_QUASI_NEWTON = CMZN_OPTIMISATION_METHOD_QUASI_NEWTON, METHOD_LEAST_SQUARES_QUASI_NEWTON = CMZN_OPTIMISATION_METHOD_LEAST_SQUARES_QUASI_NEWTON } |
enum | Attribute { ATTRIBUTE_FUNCTION_TOLERANCE = CMZN_OPTIMISATION_ATTRIBUTE_FUNCTION_TOLERANCE, ATTRIBUTE_GRADIENT_TOLERANCE = CMZN_OPTIMISATION_ATTRIBUTE_GRADIENT_TOLERANCE, ATTRIBUTE_STEP_TOLERANCE = CMZN_OPTIMISATION_ATTRIBUTE_STEP_TOLERANCE, ATTRIBUTE_MAXIMUM_ITERATIONS = CMZN_OPTIMISATION_ATTRIBUTE_MAXIMUM_ITERATIONS, ATTRIBUTE_MAXIMUM_FUNCTION_EVALUATIONS = CMZN_OPTIMISATION_ATTRIBUTE_MAXIMUM_FUNCTION_EVALUATIONS, ATTRIBUTE_MAXIMUM_STEP = CMZN_OPTIMISATION_ATTRIBUTE_MAXIMUM_STEP, ATTRIBUTE_MINIMUM_STEP = CMZN_OPTIMISATION_ATTRIBUTE_MINIMUM_STEP, ATTRIBUTE_LINESEARCH_TOLERANCE = CMZN_OPTIMISATION_ATTRIBUTE_LINESEARCH_TOLERANCE, ATTRIBUTE_MAXIMUM_BACKTRACK_ITERATIONS = CMZN_OPTIMISATION_ATTRIBUTE_MAXIMUM_BACKTRACK_ITERATIONS, ATTRIBUTE_TRUST_REGION_SIZE = CMZN_OPTIMISATION_ATTRIBUTE_TRUST_REGION_SIZE } |
Public Member Functions | |
Optimisation (cmzn_optimisation_id in_optimisation_id) | |
Optimisation (const Optimisation &optimisation) | |
Optimisation & | operator= (const Optimisation &optimisation) |
bool | isValid () const |
cmzn_optimisation_id | getId () const |
Method | getMethod () |
int | setMethod (Method method) |
int | getAttributeInteger (Attribute attribute) |
int | setAttributeInteger (Attribute attribute, int value) |
double | getAttributeReal (Attribute attribute) |
int | setAttributeReal (Attribute attribute, double value) |
Field | getFirstIndependentField () |
Field | getNextIndependentField (const Field &refField) |
int | addIndependentField (const Field &field) |
int | removeIndependentField (const Field &field) |
Field | getFirstObjectiveField () |
Field | getNextObjectiveField (const Field &refField) |
int | addObjectiveField (const Field &field) |
int | removeObjectiveField (const Field &field) |
char * | getSolutionReport () |
int | optimise () |
Protected Attributes | |
cmzn_optimisation_id | id |
A description of a non-linear optimisation problem.
A description of a non-linear optimisation problem, consisting of the objective fields (generally spatial sums or sum of squares) to be minimised, independent fields whose parameters are to be modified in the optimisation, the solution method and attributes controlling it.
Labels of optimisation attributes which may be set or obtained using generic get/set_attribute functions.
Enumerator | |
---|---|
ATTRIBUTE_FUNCTION_TOLERANCE |
(Opt++ stopping tolerance) Assigns a stopping tolerance for an optimisation algorithm. Please assign tolerances that make sense given the accuracy of your function. For example, setting TOLERANCE to 1.e-4 in your problem means the optimisation algorithm converges when the function value from one iteration to the next changes by 1.e-4 or less. Default value: 1.49012e-8 |
ATTRIBUTE_GRADIENT_TOLERANCE |
(Opt++ stopping tolerance) Assigns a stopping tolerance for an optimisation algorithm. Please assign tolerances that make sense given your function accuracy. For example, setting GRADIENT_TOLERANCE to 1.e-6 in your problem means the optimisation algorithm converges when the absolute or relative norm of the gradient is 1.e-6 or less. Default value: 6.05545e-6 |
ATTRIBUTE_STEP_TOLERANCE |
(Opt++ stopping tolerance) Assigns a stopping tolerance for the optimisation algorithm. Please set tolerances that make sense, given the accuracy of your function. For example, setting STEP_TOLERANCE to 1.e-2 in your problem means the optimisation algorithm converges when the relative steplength is 1.e-2 or less. Default value: 1.49012e-8 |
ATTRIBUTE_MAXIMUM_ITERATIONS |
(Opt++ stopping tolerance) Places a limit on the number of iterations of the optimisation algorithm. It is useful when your function is computationally expensive or you are debugging the optimisation algorithm. When MAXIMUM_ITERATIONS iterations evaluations have been completed, the optimisation algorithm will stop and report the solution it has reached at that point. It may not be the optimal solution, but it will be the best it could provide given the limit on the number of iterations. Default value: 100. |
ATTRIBUTE_MAXIMUM_FUNCTION_EVALUATIONS |
(Opt++ stopping tolerance) Places an upper bound on the number of function evaluations. The method is useful when your function is computationally expensive and you only have time to perform a limited number of evaluations. When MAXIMUM_NUMBER_FUNCTION_EVALUATIONS function evaluations have been completed, the optimisation algorithm will stop and report the solution it has reached at that point. It may not be the optimal solution, but it will be the best it could provide given the limit on the number of function evaluations. Default value: 1000 |
ATTRIBUTE_MAXIMUM_STEP |
(Opt++ steplength control) Places an upper bound on the length of the step that can be taken at each iteration of the optimisation algorithm. If the scale of your optimisation parameters exceeds the bound, adjust accordingly. If you want to be conservative in your search, you may want to set MAXIMUM_STEP to a smaller value than the default. In our (Opt++) experience, the default value is generally fine. Default value: 1.0e3 |
ATTRIBUTE_MINIMUM_STEP |
(Opt++ steplength control) Places a lower bound on the length of the step that can be taken at each iteration of the optimisation algorithm. If the scale of your optimisation parameters exceeds the bound, adjust accordingly. If you expect the optimisation algorithm to navigate some tricky areas, set MINIMUM_STEP to a smaller value than the default. In our (Opt++) experience, the default value is generally fine. Default value: 1.49012e-8 |
ATTRIBUTE_LINESEARCH_TOLERANCE |
(Opt++ globalisation strategy parameter) In practice, the linesearch tolerance is set to a small value, so that almost any decrease in the function value results in an acceptable step. Suggested values are 1.e-4 for Newton methods and 1.e-1 for more exact line searches. Default value: 1.e-4 |
ATTRIBUTE_MAXIMUM_BACKTRACK_ITERATIONS |
(Opt++ globalisation strategy parameter) Only relevant when you use a algorithm with a linesearch search strategy. The value places a limit on the number of iterations in the linesearch routine of the optimisation algorithm. If the limit is reached before computing a step with acceptable decrease, the algorithm terminates with an error message. The reported solution is not optimal, but the best one given the number of linesearch iterations. Increasing the number of linesearch iterations may lead to an acceptable step, but it also results in more function evaluations and a shorter steplength. Default value: 5 |
ATTRIBUTE_TRUST_REGION_SIZE |
(Opt++ globalisation strategy parameter) Only relevant when you are using an algorithm with a trust-region or a trustpds search strategy. The value initialises the size of the trust region. Default value: 0.1?? (
If your problem is quadratic or close to it, you may want to initialise the size of the trust region to a larger value.
|
The optimisation methods available via the optimisation object.
|
inline |
Add an independent field to the given optimisation problem description. Valid independent fields are limited to constant and finite_element types. The parameters of these fields are modified to minimise the objective fields. NOTE: Beware that many existing cubic Hermite meshes in EX format do not correctly share common value or derivative versions and thus will 'open up' during fitting/optimisation.
field | Real-valued independent field to add to the optimisation object (accessed internally so safe for caller to destroy locally). |
|
inline |
Add an objective field to the optimisation problem description. Valid objective fields must be spatially constant. The least squares solution method treats fields performing a sum of squares (nodeset_sum_squares, nodeset_mean_squares) specially, passing each term to the optimiser. The overall objective function becomes the sum of all components of all objective fields, or for the least-squares method, the sum of the squares of all terms (or components if the objective field is not a sum of squares).
field | Real-valued objective field to add to the optimisation object (accessed internally so safe for caller to destroy locally). |
|
inline |
Get an integer or Boolean attribute of the optimisation object.
attribute | The identifier of the integer attribute to get. |
|
inline |
Get a real attribute of the optimisation object.
attribute | The identifier of the real attribute to get. |
|
inline |
Get the first independent field from the optimisation problem description.
|
inline |
Get the first objective field from the optimisation problem description.
|
inline |
Return the C handle of the Optimisation object.
|
inline |
Get the current optimisation method for the given optimisation object.
Get the next independent field in the optimisation problem description after the supplied ref_field. Use to iterate over the independent fields, taking care to destroy all returned field handles exactly once:
cmzn_field_id field = cmzn_optimisation_get_first_objective_field(optimisation); while (field) { cmzn_field_id next_field = cmzn_optimisation_get_next_objective_field(optimisation, field); cmzn_field_destroy(&field); field = next_field; }
refField | Handle to an independent field from the optimisation. |
Get the next objective field in the optimisation problem description after the supplied ref_field. Use to iterate over the objective fields, taking care to destroy all returned field handles exactly once:
cmzn_field_id field = cmzn_optimisation_get_first_objective_field(optimisation); while (field) { cmzn_field_id next_field = cmzn_optimisation_get_next_objective_field(optimisation, field); cmzn_field_destroy(&field); field = next_field; }
refField | Handle to an objective field from the optimisation. |
|
inline |
Get a textual report on the last solution.
|
inline |
Check if this is a valid Optimisation object.
|
inline |
Perform the optimisation described by the provided optimisation object.
|
inline |
Remove an independent field from the optimisation problem.
field | The independent field to remove. |
|
inline |
Remove an objective field from the optimisation problem.
field | The objective field to remove. |
|
inline |
Set an integer or Boolean attribute of the optimisation object.
attribute | The identifier of the integer attribute to set. |
value | The new value for the attribute. For Boolean values use 1 for true in case more options are added in future. |
|
inline |
Set a real attribute of the optimisation object.
attribute | The identifier of the real attribute to set. |
value | The new value for the attribute. |
|
inline |
Set the optimisation method for the given optimisation object.
method | The optimisation method to use. |