AGA V1
Asexual Genetic Algorithm Version 1.0
Functions/Subroutines
exfunc Module Reference

External functions module. More...

Functions/Subroutines

real tarfunc (x, npar, q)
 Target Function.
real meritfunc (xobs, yobs, ysigma, q, npar, ndata)
 Merit Function.

Detailed Description

External functions module.

Here the user needs to provide a target (tarfunc) and a merit function (meritfunc). We recommend to preserve the names and interface in order to avoid changing code elsewhere.


Function/Subroutine Documentation

real exfunc::meritfunc ( real,dimension(ndata),intent(in)  xobs,
real,dimension(ndata),intent(in)  yobs,
real,dimension(ndata),intent(in)  ysigma,
real,dimension(npar),intent(in)  q,
integer,intent(in)  npar,
integer,intent(in)  ndata 
)

Merit Function.

User provided merit function.
This function computes the fitness level of each individual.
The program assumes that a low value has the highest level of fitness (since its primary application is to fit functions with a merit function that is an error measure, e.g. $\chi^2$). If one needs to find a maximum of a function, one can use its reciprocal as merit function.
The interface of the function is designed to adjust a target function to a set of observational/experimental data, there some arguments become dummy if the merit function does not need to be called.

Parameters:
[in]xobs(ndata): Vector of data abscissae
[in]yobs(ndata): Vector of data ordinates
[in]ysigma(ndata): Vector of uncertainties in the ordinate
[in]q(npar): Vector of parameters to be adjusted
[in]npar: Number of parameters adjusted
[in]ndata: Number of data points
Returns:
Value of the merit function (lowest value=fittest individual)

Definition at line 139 of file extfunc.f90.

Referenced by agav1::Algorithm().

real exfunc::tarfunc ( real,intent(in)  x,
integer,intent(in)  npar,
real,dimension(npar),intent(in)  q 
)

Target Function.

User provided target function.
In case some observational or experimental data is being fit, this is the function adjusted.
For the example implemented here, finding a maxima of a given function, the evaluation of the level of fitness can be made directly inside the merit function, thus the target function returns a zero (and it is actually not called). Three examples of target functions can be found commented below: several Gaussian components, one or two Lorentzians, and a PNe luminosity function.

Parameters:
[in]x: Independent variable (abscissa)
[in]npar: Number of independent parameters
[in]q(npar): Vector of independent parameters
Returns:
Value of the target function

Definition at line 53 of file extfunc.f90.

 All Namespaces Files Functions Variables