Functions | |
def | getMevForNested |
Implements the MEV generating function for the nested logit model. | |
def | nested |
Implements the nested logit model as a MEV model. | |
def | nestedMevMu |
Implements the nested logit model as a MEV model, where mu is also a parameter, if the user wants to test different normalization schemes. |
def nested::getMevForNested | ( | V, | |
availability, | |||
nests | |||
) |
Implements the MEV generating function for the nested logit model.
V | A dictionary mapping each alternative id with the expression of the utility function. |
availability | A dictionary mapping each alternative id with its availability condition. |
nests | A tuple containing as many items as nests. Each item is also a tuple containing two items:
|
def getMevForNested(V,availability,nests) : y = {} for i,v in V.items() : y[i] = exp(v) Gi = {} for m in nests: sum = 0.0 for i in m[1]: sum += Elem({0:0,1: y[i] ** m[0]},availability[i]!=0) for i in m[1]: Gi[i] = Elem({0:0,1:y[i]**(m[0]-1.0) * sum ** (1.0/m[0] - 1.0)},availability[i]!=0) return Gi
def nested::nested | ( | V, | |
availability, | |||
nests, | |||
choice | |||
) |
Implements the nested logit model as a MEV model.
V | A dictionary mapping each alternative id with the expression of the utility function. |
availability | A dictionary mapping each alternative id with its availability condition. |
nests | A tuple containing as many items as nests. Each item is also a tuple containing two items:
|
choice | expression producing the id of the chosen alternative. |
def nested(V,availability,nests,choice) : Gi = getMevForNested(V,availability,nests) P = mev(V,Gi,availability,choice) return P
def nested::nestedMevMu | ( | V, | |
availability, | |||
nests, | |||
choice, | |||
mu | |||
) |
Implements the nested logit model as a MEV model, where mu is also a parameter, if the user wants to test different normalization schemes.
V | A dictionary mapping each alternative id with the expression of the utility function. |
availability | A dictionary mapping each alternative id with its availability condition. |
nests | A tuple containing as many items as nests. Each item is also a tuple containing two items:
|
choice | expression producing the id of the chosen alternative. |
mu | expression producing the value of the top-level scale parameter. |
def nestedMevMu(V,availability,nests,choice,mu) : y = {} for i,v in V.items() : y[i] = exp(v) Gi = {} for m in nests: sum = 0.0 for i in m[1]: sum += Elem({0:0,1: y[i] ** m[0]},availability[i]!=0) for i in m[1]: Gi[i] = Elem({0:0,1:mu * y[i]**(m[0]-1.0) * sum ** (mu/m[0] - 1.0)},availability[i]!=0) P = mev(V,Gi,availability,choice) return P