Patterns in static

Apophenia

Functions
apop_linear_constraint.c File Reference

Functions

long double apop_linear_constraint (gsl_vector *beta, apop_data *constraint, double margin)
 

Detailed Description

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.

Function Documentation

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.

Parameters
betaThe proposed vector about to be tested. No default, must not be NULL.
constraintA vector/matrix pair [v | m1 m2 ... mn] where each row is interpreted as a less-than inequality: $v < m1x1+ m2x2 + ... + mnxn$. For example, say your constraints are $3 < 2x + 4y - 7z$ and $y$ is positive, i.e. $0 < y$. Allocate and fill the matrix representing these two constraints via:
1 apop_data *constr = apop_data_falloc((2,2,3), 3, 2, 4, 7,
2  0, 0, 1, 0);
. Default: each elements is greater than zero. E.g., for three parameters:
1 apop_data *constr = apop_data_falloc((3,3,3), 0, 1, 0, 0,
2  0, 0, 1, 0,
3  0, 0, 0, 1);
marginIf 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.

  • This function uses the Designated initializers syntax for inputs. todo The apop_linear_constraint function doesn't check for odd cases like coplanar constraints.

Autogenerated by doxygen on Sun Oct 26 2014 (Debian 0.999b+ds3-2).