Abie Bouwer
06-08-2010, 07:36 AM
I am fitting a surface (function f(x,t)) to some observed points (g(x,t)). Function f is an analytical function and is calibrated with 7 parameters, z=(z0,z1,...,z6). The objective of the fitting is to find z so that the error between f(x,t) and g(x,t) is a minimum (computed by some error function). The function g(x,t) is not known, all we have is a list of obsevations of the form
class Observations
{public:
class AnObservation
{
...
public:
double l_x;
double l_t;
double l_value;
};
...
list<AnObservation> l_observations;
};
The error function takes two arguments:
double ErrorFunction(const VecDoub& z, const Observations& q) {... return ...}
The problem is that Amoeba.minimize requires an error function func(x) where x[0,..ndim-1]. No room for observations. In order to overcome this problem I made a class, called ObservationFitting, which basically has the form
class ObservationFitting
{
public:
ObservationFitting(const Observations& obs);
double InternalizedError(const VecDoub& z);
Observations l_observations;
}
Note the member function InternalizedError. This function now as the correct form, namely it only takes VecDoub z.
So now the plan is to minimize as follows:
int main()
{
Amoeba am(...);
VecDoub point = ...; Doub del = ...;
ObservationFitting obsfit(Observations(...));
pmin = am.minimize(point, del, obsfit.InternalizedError);
return 1;
}
This strategy casts error C3867. The compiler wants me to provide an agument list for obsfit.InternalizedError. The only way it allows me to specify the error function is
pmin = am.minimize(point, del, &ObservationFitting::InternalizedError);
Apart from the fact that this is just plain wrong (the class is not instantiated with observations...), I then get error C2664:
'VecDoub Amoeba::minimize<double(__thiscall ObservationFitting::* )(const VecDoub &)>(VecDoub_I &,const Doub,T &)' : cannot convert parameter 3 from 'double (__thiscall ObservationFitting::* )(const VecDoub &)' to 'double (__thiscall Observationfitting::* &)(const VecDoub &)'
Has anyone encountered something similar before? How do you overcome it without rewriting Amoeba?
class Observations
{public:
class AnObservation
{
...
public:
double l_x;
double l_t;
double l_value;
};
...
list<AnObservation> l_observations;
};
The error function takes two arguments:
double ErrorFunction(const VecDoub& z, const Observations& q) {... return ...}
The problem is that Amoeba.minimize requires an error function func(x) where x[0,..ndim-1]. No room for observations. In order to overcome this problem I made a class, called ObservationFitting, which basically has the form
class ObservationFitting
{
public:
ObservationFitting(const Observations& obs);
double InternalizedError(const VecDoub& z);
Observations l_observations;
}
Note the member function InternalizedError. This function now as the correct form, namely it only takes VecDoub z.
So now the plan is to minimize as follows:
int main()
{
Amoeba am(...);
VecDoub point = ...; Doub del = ...;
ObservationFitting obsfit(Observations(...));
pmin = am.minimize(point, del, obsfit.InternalizedError);
return 1;
}
This strategy casts error C3867. The compiler wants me to provide an agument list for obsfit.InternalizedError. The only way it allows me to specify the error function is
pmin = am.minimize(point, del, &ObservationFitting::InternalizedError);
Apart from the fact that this is just plain wrong (the class is not instantiated with observations...), I then get error C2664:
'VecDoub Amoeba::minimize<double(__thiscall ObservationFitting::* )(const VecDoub &)>(VecDoub_I &,const Doub,T &)' : cannot convert parameter 3 from 'double (__thiscall ObservationFitting::* )(const VecDoub &)' to 'double (__thiscall Observationfitting::* &)(const VecDoub &)'
Has anyone encountered something similar before? How do you overcome it without rewriting Amoeba?