ual / ual_model_workspace

Repo for building a clean UrbanSim model for the Bay Area
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Large MNL can't fit the model with multiple alternatives table #11

Closed Arezoo-bz closed 6 years ago

Arezoo-bz commented 6 years ago

LargeMNL works with single table of alternatives but not multiple.

smmaurer commented 6 years ago

This might be fixed in the PR i just merged, https://github.com/UDST/urbansim_templates/pull/14?

I've successfully estimated a model with two data tables for the alternatives in the updated Large-MNL-work.ipynb (prices pulled from the buildings table and auto-merged onto the units table so that households can choose a unit_id).

I'll try estimating some more complicated models and see if i run into problems..

Arezoo-bz commented 6 years ago

I still get an error for some table combinations in alternatives. Is it because of unnamed columns in tables? or index issues? https://github.com/ual/urbansim_parcel_bayarea/blob/master/notebooks/HLCM.ipynb

smmaurer commented 6 years ago

I figured some things out, but it's a little complicated.

One issue is that the 'choice_column' in the choosers table needs to match the index of the primary alternatives table. So if the choices are in terms of a unit_id, the units table needs to be the first one in the list of data sources for the alternatives.

But the deeper problem is that it seems like for Orca to automatically merge two tables, we need to have specified an explicit relationship between the two of them, not just an overall relationship structure. In the data setup, I had only linked each table to its nearest neighbor (units -> buildings -> parcels -> nodes).

It seems like this will run: m.alternatives = ['units', 'buildings', 'parcels']

But this will not: m.alternatives = ['units', 'parcels']

I'm setting up some more merge relationships in datasources.py so that we can merge node aggregations directly onto any of the other tables.. fix ready soon!

Arezoo-bz commented 6 years ago

I see, good diagnosis. :) Thank you

smmaurer commented 6 years ago

Ok, I merged a few new lines of data setup code into the master branch (https://github.com/ual/urbansim_parcel_bayarea/pull/15), and here's a notebook showing some working use cases: HLCM-temp.ipynb.

I ran into a problem where if you have too many merge relationships, it also doesn't work, though..

For example, these combinations run:

But this combination crashes:

This seems like a bug; i'll write up an orca issue when i have a chance.