Biogeme: Python Library  2.5
Public Member Functions | Public Attributes | List of all members
bio_expression.Elem Class Reference

Class extracting an expression from a dictionary. More...

Inheritance diagram for bio_expression.Elem:
bio_expression.Expression

Public Member Functions

def __init__ (self, dictionary, key, default=Numeric(0))
 
def getExpression (self)
 
def getID (self)
 
- Public Member Functions inherited from bio_expression.Expression
def __init__ (self)
 Constructor.
 
def getExpression (self)
 
def getID (self)
 
def __str__ (self)
 
def __neg__ (self)
 
def __add__ (self, expression)
 
def __radd__ (self, expression)
 
def __sub__ (self, expression)
 
def __rsub__ (self, expression)
 
def __mul__ (self, expression)
 
def __rmul__ (self, expression)
 
def __div__ (self, expression)
 
def __rdiv__ (self, expression)
 
def __truediv__ (self, expression)
 Support for Python version 3.x. More...
 
def __rtruediv__ (self, expression)
 Support for Python version 3.x. More...
 
def __mod__ (self, expression)
 
def __pow__ (self, expression)
 
def __rpow__ (self, expression)
 
def __and__ (self, expression)
 
def __or__ (self, expression)
 
def __eq__ (self, expression)
 
def __ne__ (self, expression)
 
def __le__ (self, expression)
 
def __ge__ (self, expression)
 
def __lt__ (self, expression)
 
def __gt__ (self, expression)
 

Public Attributes

 prob
 
 choice
 
 default
 
 operatorIndex
 
- Public Attributes inherited from bio_expression.Expression
 operatorIndex
 

Detailed Description

Class extracting an expression from a dictionary.

A typical example consists in returning the probability of a chosen alternative in a choice model. Consider the following dictionary:

1 P = { 1: exp(V1) / (exp(V1)+exp(V2)+exp(V3)),
2 2: exp(V2) / (exp(V1)+exp(V2)+exp(V3)),
3 3: exp(V3) / (exp(V1)+exp(V2)+exp(V3))}

and assume that the variable Choice in the data file contains the identifier of the chosen alternative of the corresponding observation, that is 1, 2 or 3. Then, the probability of the chosen alternative is given by

1 chosenProba = Elem(P,Choice)

If the result of "Choice" does not correspond to any valid entry in the dictionary, a warning is issued and the value of the default expression is returned. The warning is issued because this situation is usually not wanted by the user. To turn off the warning, set the parameter warnsForIllegalElements to 0.

Definition at line 871 of file bio_expression.py.

Constructor & Destructor Documentation

def bio_expression.Elem.__init__ (   self,
  dictionary,
  key,
  default = Numeric(0) 
)
Parameters
dictionaryA dictionary (see Python documentation) such that the indices are numerical values that can match the result of an expression
keyexpression identifying the entry in the dictionary If the result of key does not correspond to any valid entry in the dictionary, the value of the default expression is returned. This argument is optional. If omitted, the default value is 0.

Definition at line 880 of file bio_expression.py.


The documentation for this class was generated from the following file:
Copyright 2016 Michel Bierlaire