示例#1
0
        beta_domestic_work_%s * domestic + beta_otherworker_work_%s * otherworker +\
        beta_student16_work_%s * student16 + beta_student515_work_%s * student515 +\
        beta_child4_work_%s * child4 + beta_age2025_work_%s * age2025 +\
        beta_age2635_work_%s * age2635 + beta_age5165_work_%s * age5165 +\
        beta_maleage4_work_%s * maleage4 + beta_maleage515_work_%s * maleage515 +\
        beta_femalenone_work_%s * femalenone + beta_femaleage4_work_%s * femaleage4 +\
        beta_femaleage515_work_%s * femaleage515 + beta_onlyadults_work_%s * onlyadults +\
        beta_onlyworkers_work_%s * onlyworkers + beta_income_work_%s * income +\
        beta_workathome_work_%s * workathome +\
        beta_caravail_work_%s * caravail +\
        beta_motoravail_work_%s * motoravail + beta_logsum_work_%s*worklogsum"
        % ((counter, ) * 30))
V = dict(zip(range(1, 4), [eval('V_%s' % i) for i in choiceset]))
av = {1: 1, 2: 1, 3: 1}

one = MU1, [1]
twoplus = MU2plus, [2, 3]
nests = one, twoplus

#prob = bioLogit(V,av,work_tour)
prob = nested(V, av, nests, work_tour)

rowIterator('obsIter')
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob), 'obsIter')
exclude = ((oldpattern == 0) + (work_tour <= 0))
BIOGEME_OBJECT.EXCLUDE = exclude
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = '4'
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = 'CFSQP'
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = '0'
BIOGEME_OBJECT.PARAMETERS['moreRobustToNumericalIssues'] = '0'
示例#2
0
        beta_child4_work_%s * child4 + beta_age2025_work_%s * age2025 +\
        beta_age2635_work_%s * age2635 + beta_age5165_work_%s * age5165 +\
        beta_maleage4_work_%s * maleage4 + beta_maleage515_work_%s * maleage515 +\
        beta_femalenone_work_%s * femalenone + beta_femaleage4_work_%s * femaleage4 +\
        beta_femaleage515_work_%s * femaleage515 + beta_onlyadults_work_%s * onlyadults +\
        beta_onlyworkers_work_%s * onlyworkers + beta_income_work_%s * income +\
        beta_workathome_work_%s * workathome +\
        beta_caravail_work_%s * caravail +\
        beta_motoravail_work_%s * motoravail + beta_logsum_work_%s*worklogsum" % ((counter,)*30))
V =dict(zip(range(1,4),[eval('V_%s' %i) for i in choiceset]))
av={1:1,2:1,3:1}

one=MU1,[1]
twoplus=MU2plus, [2,3]
nests=one,twoplus

#prob = bioLogit(V,av,work_tour)
prob = nested(V,av,nests,work_tour)

rowIterator('obsIter')
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob),'obsIter')
exclude = ((oldpattern == 0) + (work_tour<=0))
BIOGEME_OBJECT.EXCLUDE = exclude
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = '4'
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = 'CFSQP'
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = '0'
BIOGEME_OBJECT.PARAMETERS['moreRobustToNumericalIssues'] = '0'



示例#3
0
        beta_domestic_other_%s * domestic + beta_otherworker_other_%s * otherworker +\
        beta_student16_other_%s * student16 + beta_student515_other_%s * student515 +\
        beta_child4_other_%s * child4 + beta_age2025_other_%s * age2025 +\
        beta_age2635_other_%s * age2635 + beta_age5165_other_%s * age5165 +\
        beta_maleage4_other_%s * maleage4 + beta_maleage515_other_%s * maleage515 +\
        beta_femalenone_other_%s * femalenone + beta_femaleage4_other_%s * femaleage4 +\
        beta_femaleage515_other_%s * femaleage515 + beta_onlyadults_other_%s * onlyadults +\
        beta_onlyworkers_other_%s * onlyworkers + beta_income_other_%s * income +\
        beta_workathome_other_%s * workathome +\
        beta_caravail_other_%s * caravail +\
        beta_motoravail_other_%s * motoravail + beta_logsum_other_%s*otherlogsum"
        % ((counter, ) * 30))
V = dict(zip(range(1, 4), [eval('V_%s' % i) for i in choiceset]))
av = {1: 1, 2: 1, 3: 1}

one = MU1, [1]
twoplus = MU2plus, [2, 3]
nests = one, twoplus

#prob = bioLogit(V,av,other_tour)
prob = nested(V, av, nests, other_tour)

rowIterator('obsIter')
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob), 'obsIter')
exclude = ((oldpattern == 0) + (other_tour <= 0) + (other_tour > 3))
BIOGEME_OBJECT.EXCLUDE = exclude
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = '4'
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = 'CFSQP'
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = '0'
BIOGEME_OBJECT.PARAMETERS['moreRobustToNumericalIssues'] = '0'
示例#4
0
    8: walk_avail_dummy,
    9: taxi_avail_dummy
}

#Definition of nests:
# 1: nests parameter
# 2: list of alternatives
car = MU1, [4, 5, 6, 7]
PT = MU2, [1, 2, 3]
other = 1.0, [8, 9]

nests = car, PT, other
#nests=car,PT,private,motor,walk,taxi

# The choice model is a nested logit, with availability conditions
prob = nested(V, av, nests, choice_new)

rowIterator('obsIter')
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob), 'obsIter')

exclude = ((choice == 0) + (PrimaryActivityIndex != 3) +
           (avail_violation == 1) + (student_type_num == 11)) > 0

BIOGEME_OBJECT.EXCLUDE = exclude
nullLoglikelihood(av, 'obsIter')
choiceSet = [1, 2, 3, 4, 5, 6, 7, 8, 9]
cteLoglikelihood(choiceSet, choice_new, 'obsIter')
availabilityStatistics(av, 'obsIter')
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = "CFSQP"
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = "1"
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = "4"
示例#5
0
              0.0235929, -0.00847539, -0.000434418, 0.010273, 0.0218765,
              0.00725802, 0.110753, 0.0555677, -0.0178209
          ],
          [
              0.0224142, -0.00394251, -0.00579638, 0.00438825, 0.0109824,
              0.00507749, 0.0555677, 0.0878987, -0.0248326
          ],
          [
              -0.00807837, 0.0389318, 0.0155749, 0.0106748, -0.0062276,
              0.0131128, -0.0178209, -0.0248326, 0.0934272
          ]]
vc = bioMatrix(9, names, values)
BIOGEME_OBJECT.VARCOVAR = vc

# The choice model is a nested logit
prob_pt = nested(V, av, nests, 0)
prob_car = nested(V, av, nests, 1)
prob_sm = nested(V, av, nests, 2)

# Defines an itertor on the data
rowIterator('obsIter')

#Statistics
nullLoglikelihood(av, 'obsIter')
choiceSet = [0, 1, 2]
cteLoglikelihood(choiceSet, Choice, 'obsIter')
availabilityStatistics(av, 'obsIter')

# Each weight is normalized so that the sum of weights is equal to the
# number of entries (1906).
# The normalization factor has been calculated during estimation
示例#6
0
        beta_child4_other_%s * child4 + beta_age2025_other_%s * age2025 +\
        beta_age2635_other_%s * age2635 + beta_age5165_other_%s * age5165 +\
        beta_maleage4_other_%s * maleage4 + beta_maleage515_other_%s * maleage515 +\
        beta_femalenone_other_%s * femalenone + beta_femaleage4_other_%s * femaleage4 +\
        beta_femaleage515_other_%s * femaleage515 + beta_onlyadults_other_%s * onlyadults +\
        beta_onlyworkers_other_%s * onlyworkers + beta_income_other_%s * income +\
        beta_workathome_other_%s * workathome +\
        beta_caravail_other_%s * caravail +\
        beta_motoravail_other_%s * motoravail + beta_logsum_other_%s*otherlogsum" % ((counter,)*30))
V =dict(zip(range(1,4),[eval('V_%s' %i) for i in choiceset]))
av={1:1,2:1,3:1}

one=MU1,[1]
twoplus=MU2plus, [2,3]
nests=one,twoplus

#prob = bioLogit(V,av,other_tour)
prob=nested(V,av,nests,other_tour)

rowIterator('obsIter')
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob),'obsIter')
exclude = ((oldpattern == 0) + (other_tour<=0)+(other_tour>3))
BIOGEME_OBJECT.EXCLUDE = exclude
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = '4'
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = 'CFSQP'
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = '0'
BIOGEME_OBJECT.PARAMETERS['moreRobustToNumericalIssues'] = '0'



示例#7
0
av = {
    0: avail_quit,
    1: avail_workstop,
    2: avail_edustop,
    3: avail_shopstop,
    4: avail_otherstop
}

nest_quit = MU1, [0]

nest_nonquit = MU2, [1, 2, 3, 4]

nests = nest_quit, nest_nonquit

prob = nested(V, av, nests, stop_type)

#prob = bioLogit(V,av,stop_type)

rowIterator('obsIter')

BIOGEME_OBJECT.ESTIMATE = Sum(log(prob), 'obsIter')

exclude = ((avail_violation == 1) + (origin_mtz == 0) +
           (destination_mtz == 0) + (time_window_h >= 10)) > 0

BIOGEME_OBJECT.EXCLUDE = exclude

nullLoglikelihood(av, 'obsIter')

choiceSet = [0, 1, 2, 3, 4]
work_tour_dummy_Q*1*(tour_type==1)+\
edu_tour_dummy_Q*1*(tour_type==2)+\
shopping_tour_dummy_Q*1*(tour_type==3)+\
other_tour_dummy_Q*1*(tour_type==4)+\
first_tour_dummy_Q*first_tour_dummy+\
sub_tour_dummy_Q*has_subtour+zero_tour_remain_Q*1*(tour_remain==0)+\
one_tour_remain_Q*1*(tour_remain==1)+twoplus_tour_remain_Q*1*(tour_remain>=2)

V = {0:V_quit,1: V_work,2:V_edu,3:V_shopping,4:V_other}
av= {0:avail_quit,1:avail_workstop,2:avail_edustop,3:avail_shopstop,4:avail_otherstop}

nest_quit = MU1 , [0]
nest_nonquit = MU2 , [1,2,3,4]
nests=nest_quit,nest_nonquit


prob = nested(V,av,nests,stop_type)
#prob = bioLogit(V,av,stop_type)
rowIterator('obsIter') 
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob),'obsIter')

exclude = ((avail_violation==1)+(origin_mtz==0)+(destination_mtz==0)+(time_window_h>=10)) > 0

BIOGEME_OBJECT.EXCLUDE = exclude
nullLoglikelihood(av,'obsIter')
choiceSet = [0,1,2,3,4]
cteLoglikelihood(choiceSet,stop_type,'obsIter')
availabilityStatistics(av,'obsIter')
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = "CFSQP"
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = "1"
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = "6"
示例#9
0
V_edu = cons_edu + beta_female_edu * Female_dummy
#V for shopping
V_shopping = cons_shopping + beta_female_shopping * Female_dummy + beta_PT_shopping * PT_dummy
#V for other
V_other=cons_other + beta_female_other * Female_dummy
#V for quit
V_quit= cons_Q + beta_first_work * first_work_dummy + beta_2plus_work * sub_work_dummy + beta_not_usual*not_usual_dummy + beta_no_car *no_car_dummy

a=motor_avail_dummy_all
V = {1:V_work,2: V_edu,3:V_shopping,4:V_other,5:V_quit}
av= {1:a,2:a,3:a,4:a,5:a}

nonquit = MU1,[1,2,3,4]
quit =  MU2,[5] 
nests=nonquit,quit
prob = nested(V,av,nests,subtour_choice_4)
#prob = bioLogit(V,av,subtour_choice)
rowIterator('obsIter') 
BIOGEME_OBJECT.ESTIMATE = Sum(log(prob),'obsIter')

exclude = ((choice==0)+(PrimaryActivityIndex not in [1,2])+(IncomeIndex==12)) > 0

BIOGEME_OBJECT.EXCLUDE = exclude
nullLoglikelihood(av,'obsIter')
choiceSet = [1,2,3,4,5]
cteLoglikelihood(choiceSet,subtour_choice_4,'obsIter')
availabilityStatistics(av,'obsIter')
BIOGEME_OBJECT.PARAMETERS['optimizationAlgorithm'] = "CFSQP"
BIOGEME_OBJECT.PARAMETERS['checkDerivatives'] = "1"
BIOGEME_OBJECT.PARAMETERS['numberOfThreads'] = "4"