def process_args(): opts, args = getopt.getopt(sys.argv[1:], "glnd") for o, a in opts: if o == "-g": interaction.enable_gpu() if o == "-n": RUNCONFIG['update_networks'] = 1 if o == "-d": RUNCONFIG['run_developer'] = 1 if o == "-l": RUNCONFIG['lottery_choices'] = 1 return args
from synthicity.urbansim import interaction, mnl import numpy as np, pandas as pd GPU = 0 if GPU: interaction.enable_gpu() EMTOL = 1e-03 MAXITER = 10000 def lcmnl_estimate(cmdata,numclasses,csdata,numalts,chosen,maxiter=MAXITER,emtol=EMTOL): loglik = -999999 beta = [np.ones(csdata.shape[1]) for i in range(numclasses)] #cmbeta = np.ones((cmdata.shape[1]+1)*(numclasses-1)) # +1 if for asc, -1 is base alt cmbeta = np.ones(cmdata.shape[1]) for i in range(maxiter): print "Running iteration %d" % (i+1) # EXPECTATION print "Running class membership model" print "cmbeta", cmbeta cmprobs = mnl.mnl_simulate(cmdata,cmbeta,numclasses,GPU=GPU,returnprobs=1) print "cmprobs", cmprobs csprobs = [] for cno in range(numclasses): print "Running class specific model for class %d" % (cno+1) print "csbeta", beta[cno] tmp = mnl.mnl_simulate(csdata,beta[cno],numalts,GPU=GPU,returnprobs=1) print "csprobs", tmp