Module: hybrid_vector_model.boater_movement_model

Classes:

TrafficFactorModel(originData, …)

Gravity model for a factor proportional to the mean boater flow between jurisdictions and lakes.

Functions:

example()

Shows how an example model can be fitted.

class TrafficFactorModel(originData, destinationData, postalCodeAreaData, distances, postalCodeDistances)[source]

Bases: hybrid_vector_model.hybrid_vector_model.BaseTrafficFactorModel

Gravity model for a factor proportional to the mean boater flow between jurisdictions and lakes.

Attributes:

BOUNDS

((float, float)[]) – Reasonable bounds for the parameters (before conversion).

DESTINATION_COVARIATES

((str, type=double)[]) – The names and types of the covariates for the sinks.

LABELS

(str[]) – The names of the parameters in the implemented model.

ORIGIN_COVARIATES

((str, type)[]) – The names and types of the covariates for the sources.

PERMUTATIONS

(bool[][]) – Parameter combinations to be considered when selecting the optimal model.

SIZE

(int) – Maximal number of parameters in the implemented model.

Methods:

convert_parameters(dynamicParameters, …)

Converts an array of given parameters to an array of standard (maximal) length and in the parameter domain of the model.

get_mean_factor(parameters, parametersConsidered)

Returns a factor proportional to the mean traveller flow between the source-sink pair pair or all sources and sinks (if pair is None)

get_mean_factor_autograd(parameters, …)

Same as get_mean_factor(), but must use autograd’s functions instead of numpy.

process_sink_covariates(covariates)

Process sink covariates before saving them.

BOUNDS = array([[  -2, 2000],        [   0,    3],        [  -2, 2000],        [   0,    3],        [  -5,   20],        [  -7,    7],        [  -5,   20],        [  -7,    7],        [  -5,   20],        [  -7,    7],        [  -5,   20],        [  -7,  500],        [   0,    3],        [  -5,    7],        [ -10,    0],        [   0,    3],        [  -7,  500],        [   0,    5],        [  -7,  500],        [   0,    5],        [  -3,    5],        [  -5,    0]])

((float, float)[]) – Reasonable bounds for the parameters (before conversion).

The length must match the maximal number of parameters of the model (see SIZE).

DESTINATION_COVARIATES = [('area', 'double'), ('perimeter', 'double'), ('campgrounds', 'int'), ('pointsOfInterest', 'int'), ('marinas', 'int'), ('population', 'double')]

((str, type=double)[]) – The names and types of the covariates for the sinks.

LABELS = array(['base area', 'area exponent', 'base perimeter',        'perimeter exponent', 'campground factor', 'campground exponent',        'POI factor', 'POI exponent', 'marina factor', 'marina exponent',        'surrounding population factor', 'base surrounding population',        'surrounding population exponent', 'base PCA distance',        'PCA distance exponent', 'PC population exponent',        'base population', 'population exponent', 'base angler number',        'angler number exponent', 'canadian factor', 'distance exponent'],       dtype='<U31')

(str[]) – The names of the parameters in the implemented model.

The length must match the maximal number of parameters of the model (see SIZE).

ORIGIN_COVARIATES = [('population', 'double'), ('anglers', 'double'), ('canadian', <class 'bool'>)]

((str, type)[]) – The names and types of the covariates for the sources. If the type is not spcified, it will default to float.

PERMUTATIONS = [[True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, True, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, True, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, False, False, False, False, True, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, True, False, False, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, False, False, False, False, True, False, False, False, True, True], [False, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, True, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, False, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, False, False, False, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, True, True, False, False, False, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, False, True, False, False, False, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, False, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, True, True, True, False, False, False, False, False, False, False, True, True], [True, False, False, False, True, False, True, False, True, False, False, True, True, False, False, False, False, False, False, False, True, True], [True, False, False, False, True, False, False, False, True, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, False, False, False, False, True, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, False, False, False, False, True, True, True, False, False, False, False, False, True, False, True, True], [True, False, False, False, True, False, True, False, True, False, False, False, False, False, False, False, False, False, True, False, True, True]]

(bool[][]) – Parameter combinations to be considered when selecting the optimal model.

The number of columns must match the maximal number of parameters of the model (see SIZE).

SIZE = 22

(int) – Maximal number of parameters in the implemented model.

convert_parameters(dynamicParameters, parametersConsidered)[source]

Converts an array of given parameters to an array of standard (maximal) length and in the parameter domain of the model.

Not all parameters may be parametersConsidered in the model (to avoid overfitting) Furthermore, some parameters must be constrained to be positive or within a certain interval. In this method, the parameter vector (containing only the values of the free parameters) is transformed to a vector in the parameter space of the model

Parameters
  • dynamicParameters (float[]) – Free parameters. The parameters that are not held constant.

  • parametersConsidered (bool[]) – Which parameters are free? Is True at the entries corresponding to the parameters that are free. parametersConsidered must have exactly as many True entries as the length of dynamicParameters

get_mean_factor(parameters, parametersConsidered, pair=None)[source]

Returns a factor proportional to the mean traveller flow between the source-sink pair pair or all sources and sinks (if pair is None)

Parameters
  • parameters (double[]) – Contains the free model parameters.

  • parametersConsidered (bool[]) – Which parameters are free? Is True at the entries corresponding to the parameters that are free. parametersConsidered must have exactly as many True entries as the length of dynamicParameters.

  • pair ((int, int)) – Source-sink pair for which the factor shall be determined. This is the source-sink pair of interest (the indices of the source and the sink, NOT their IDs. If None, the factors for all source-sink combinations are computed).

get_mean_factor_autograd(parameters, parametersConsidered)[source]

Same as get_mean_factor(), but must use autograd’s functions instead of numpy.

This function is necessary to compute derivatives with automatic differentiation.

Parameters
  • parameters (double[]) – Contains the free model parameters.

  • parametersConsidered (bool[]) – Which parameters are free? Is True at the entries corresponding to the parameters that are free. parametersConsidered must have exactly as many True entries as the length of dynamicParameters.

static process_sink_covariates(covariates)[source]

Process sink covariates before saving them.

This method is applied to the sink covariates before they are saved. The method can be used to compute derived covariates

Parameters

covariates (float[]) – Covariates describing the attractiveness of sinks

example()[source]

Shows how an example model can be fitted.

The files for the example are provided in the subfolder Example.