# A Cox Model-Based Workflow for Increased Accuracy in Activity-Travel Patterns Generation
## 3 Methodology
### Activity-Based Model Structure and Integration with Cox-Based Models  
An important tool under the proposed methodology is a pre-existing open-source ABM model that already includes several software routines for the generation of synthetic activity-travel patterns based on an initial real-world OD dataset. As shown in Figure 1, the ABM model takes as input the survey and, in collaboration with the open-source Python framework called Population Activity Modeler (PAM), generates the population and synthesizes their travel movements. For a potential implementation of the ABM, Python 3.12 may be used alongside PAM version 0.3.2.  
This workflow ultimately creates synthetic travel activity patterns that can be used as input to transport planning models. In addition to generating the synthetic population, the PAM framework is able to perform macroscopic traffic analysis based on the generated synthetic data, which can be used as direct input to transport planning processes.  
While the open-source software has the capability to generalize an initial OD dataset to a bigger synthetic one, it does so by employing simplistic statistical rules applied to the source OD data. However, it is often the case that the input survey (e.g., ABM Travel Survey in our case) is incomplete, thus forcing the synthetic data generation software to rely on false data that include:  
* Missing activity durations,
* Invalid activity durations (Negative values occurred when durations were calculated from inconsistent trip start times, requiring correction through estimation),
* Missing the \"return-to-home\" activity.  
Figure 1: ABM workflow before the intervention proposed by the current research.  
More specifically, the proposed method introduces a new workflow, which identifies when some problem exists in the initial travel survey (aforementioned bullet points) and then uses the Cox and Cox-based models to estimate the missing durations of activities and respective travel times.  
For example, in the case when there is a missing return-to-home activity, the workflow identifies it and applies one of the three models, so that the return time, as well as the duration of the previous trip, are estimated. An example of a missing return-to-home trip is given in Figure 2, where one may notice that there is no return trip home, while the last trip appears to be for work purposes and starts at 18:00. After the application of the proposed Cox model-based workflow, the return home trip is added, and the model estimates the duration of the work-related trip, followed by the estimation of the return time. In this way, we provide the initial travel survey is supplemented, filling in missing data, ultimately resulting in a more accurate input dataset to the ABM, which will be used to create synthetic travel-activity patterns.  
It is important to note that the two Cox and Cox-based machine learning models are trained on the source survey data using an 80/20 train-test split and 5-fold cross-validation, prior to their integration into the workflow illustrated in Figure 3. These trained models are used to identify and correct missing or erroneous activity durations, taking into account the individual characteristics of each observation (Table 3). The corrected duration values are then reintegrated into the original survey, which undergoes a preprocessing phase involving minor adjustments. This produces an updated and enriched survey dataset, which is subsequently given as input to PAM, which follows the standard modeling and synthetic data generation processes.