I have the following questions:
1. How to use CrossVariable Tuple to include travel time from origin to destination for the sample destination alternatives
2. Does number of Jobs also need to be combined variables? if so,
Do I need to put 2 arguments for the combined variable parameters of the SamplingContext: like this
from biogeme.sampling_of_alternatives import SamplingContext
context = SamplingContext(
the_partition = partition_uniform
sample_sizes = segment_sizes,
individuals=work_biogeme_data
choice_column= 'work_pc4'
alternatives= alternatives,
id_column=ID_COLUMN,
biogeme_file_name='Simple Gravity Model MNL intial run'
utility_function= V_work
combined_variables= combined_variables_Jobs, combined_variables_TT
)
I am trying to estimate a destination choice model at PC4 (4 digit postal code) level
But I am not able to figure out how to use CrossVariable Tuple to include travel time from origin to destination for the sample destination alternatives
the information is stored in a dataframe called alternatives which has rows and index as pc4 codes
I followed the restaurant sampling example and created a dataframe called alternatives where the
the rows are the alternatives (pc4 destinations)
and the columns (column names are pc4 codes too) are the travel times to other pc4 codes from that destination,
i have also merged the total number of jobs at each destination in this dataframe, since it is advised in the document to include all the attributes of the alternatives
I have tried this
from biogeme.expressions import Beta, Variable, log
from biogeme.sampling_of_alternatives import CrossVariableTuple
combined_variables_TT = [
CrossVariableTuple(
'log_TT',
log(alternatives[str(home_pc4)])
)]
#KeyError: 'home_pc4'
where home_pc4 is the residential pc4 of the traveler in the observed choice dataframe
(in the document also known as 'individuals' parameter in SamplingContext function)
I have tried to looking at various sources (examples, previous questions, ChatGPT Biogeme assistant etc.) but couldn't find the solution
I have attached a the pdf excerpt from my jupyter file