![]() |
|
Functions | |
| long double | apop_linear_constraint (gsl_vector *beta, apop_data *constraint, double margin) |
apop_linear_constraint finds a point that meets a set of linear constraints. This takes a lot of machinery, so it gets its own file.
Copyright (c) 2007, 2009 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2.
| long double apop_linear_constraint | ( | gsl_vector * | beta, |
| apop_data * | constraint, | ||
| double | margin | ||
| ) |
This is designed to be called from within the constraint method of your apop_model. Just write the constraint vector+matrix and this will do the rest. See the outline page for detailed discussion on setting contrasts.
| beta | The proposed vector about to be tested. No default, must not be NULL. |
| constraint | A vector/matrix pair [v | m1 m2 ... mn] where each row is interpreted as a less-than inequality: . For example, say your constraints are and is positive, i.e. . Allocate and fill the matrix representing these two constraints via: . Default: each elements is greater than zero. E.g., for three parameters: |
| margin | If zero, then this is a >= constraint, otherwise I will return a point this amount within the borders. You could try GSL_DBL_EPSILON, which is the smallest value a double can hold, or something like 1e-3. Default = 0. |
return The penalty = the distance between beta and the closest point that meets the constraints. If the constraint is not met, this beta is shifted by margin (Euclidean distance) to meet the constraints.