Biogeme: Python Library  2.5
biogeme.py
1 """
2 File name : biogeme.py
3 Author : Michel Bierlaire and Mamy Fetiarison
4 Date : Fri May 15 14:23:51 2009
5 """
6 from bio_expression import *
7 from bio_iterator import *
8 from bioMatrix import *
9 
10 
12 class STAN:
13  CATEGORICAL = {}
14  NORMAL = {}
15  GAMMA = {}
16 
17 ## This class gathers the components needed by biogeme to perform the
18 ## estimation or the simulation.
20  ## Expression of the likelihood function to be maximized. Example: @code BIOGEME_OBJECT.ESTIMATE = Sum(log(prob),'obsIter') @endcode
21  ESTIMATE = None
22  ## Enumerate expression to perform sample enumeration. Example:
23  # @code
24  # simulate = Enumerate('Choice prob.', prob)
25  # BIOGEME_OBJECT.SIMULATE = Enumerate(simulate,'obsIter')
26  # @endcode
27  SIMULATE = None
28  ## Expression identifying the observations to be ignored in the data file.
29  # Example:
30  # @code
31  # BIOGEME_OBJECT.EXCLUDE = (TRAVEL_TIME < 0)
32  # @endcode
33  EXCLUDE = None
34  ## Expression computing the weight of each observation, for
35  ## WESML. Typically, a variable in the data file.
36  # Example: @code BIOGEME_OBJECT.WEIGHT = weight @endcode
37  WEIGHT = None
38  ## Object of type bioMatrix that contains the variance covariance
39  ## matrix of the estimators, in order to perform a sensitivity
40  ## analysis of the simulated quantities
41  VARCOVAR = None
42  ## Expression describing a simulation method for the Bayesian
43  ## estimation of the parameters.
44  BAYESIAN = None
45  ## Boolean indicator for the generation of STAN files
46  STAN = STAN()
47  ## Dictionary of expressions to be reported in the output file
48  FORMULAS = {}
49 
50  ## Dictionary of expressions computing statistics on the data.
51  # The index of each entry is associated with the value in the report. Example calculating the null loglikelihood of a choice model:
52  # @code
53  # total = 0
54  # for i,a in availability.items() :
55  # total += (a != 0)
56  # nl = -Sum(log(total),iterator)
57  # BIOGEME_OBJECT.STATISTICS['Null loglikelihood'] = nl
58  # @endcode
59  STATISTICS = {}
60  ## Dictionary of expressions defining constraints on the parameters
61  # to be estimated. In general, it is preferable not to use these
62  # constraints. There is most of the time a way to write the model
63  # with unconstrained parameters. The two typical examples are:
64  # - Constrain a parameter beta to be nonnegative: replace it by the exponential of another parameter.
65  # - A set of parameters b1, b2, ... bn must sum up to one. Replace
66  # them by their normalized version: bi = ci / (c1 + c2 + ... +
67  # cn), where c1, ... cn are unconstrained parameters to be
68  # estimated.
69  # - A combination of the two gives bi = exp(ci) / (exp(c1) + exp(c2) + ... +
70  # exp(cn))
71  CONSTRAINTS = {}
72  ## Dictionary of the various draws used for Monte-Carlo simulation.
73  DRAWS = {}
74 
75  ## Used to set the value of the parameters. The syntax is
76  # @code BIOGEME_OBJECT.PARAMETERS['parameterName'] = 'value' @endcode
77  PARAMETERS = {}
78 
79  def __init__(self) :
80  # Only one object can be instantiate
81  BIOGEME_OBJECT.__init__ = BIOGEME_OBJECT.__once__
82 
83  def __once__(self):
84  print("No further BIOGEME_OBJECT instance can be created!")
85  return
86 
87 
88 """
89 Numeric constants
90 """
91 one = Numeric(1)
92 zero = Numeric(0)
93 
This class gathers the components needed by biogeme to perform the estimation or the simulation...
Definition: biogeme.py:19
Class wrapping an integer or a float value.
Class used for generating STAN files (see http://mc-stan.org)
Definition: biogeme.py:12
Copyright 2016 Michel Bierlaire