Skip to content

Setting Up the Optimization Environment for Traffic Assignment Problem

ASU Trans+AI Lab edited this page Nov 6, 2024 · 3 revisions

Installation Guide

This guide provides step-by-step instructions for setting up the required environment for running optimization codes using taplite.

Step 1: Install Anaconda

  1. Visit Anaconda's official website and register to receive the installation link via email.
  2. Download and install Anaconda on your system. If you have an earlier version of Anaconda, pls reinstall the environment and install the latest version to ensure we have a clean base for the following packages.

Step 2: Install Required Packages

To set up the necessary Python libraries, follow these steps:

  1. Install Ipopt
    Go to the Ipopt package page and run:

    conda install conda-forge/label/cf201901::ipopt
  2. Install Pyomo
    Go to the Pyomo package page and run:

    conda install conda-forge::pyomo
  3. Install CVXPY
    Go to the CVXPY package page and run:

    conda install conda-forge::cvxpy

Step 3: Access Optimization Codes

  1. Locate the Python codes for the optimization model at ASU Trans-AI Lab’s GitHub repository.
  2. Review the following code files:
    • traffic_assignment_cvxpy.py
    • traffic_assignment_ipopt.py

Step 4: Run the Code in Spyder

  1. Open Anaconda Navigator.
  2. Launch the Spyder Python environment.
  3. In Spyder, open and run the selected code files (traffic_assignment_cvxpy.py or traffic_assignment_ipopt.py) to execute the traffic assignment models.

Example Output (CVXPY)

(CVXPY) Nov 03 10:05:30 AM: Problem status: optimal_inaccurate
(CVXPY) Nov 03 10:05:30 AM: Optimal value: 2.040e+04
(CVXPY) Nov 03 10:05:30 AM: Compilation took 1.689e-02 seconds
(CVXPY) Nov 03 10:05:30 AM: Solver (including time spent in interface) took 9.023e-02 seconds

Optimal Flows on Links:

  • Flow on link (1, 3): 944.1528 vehicles
  • Flow on link (3, 2): 944.1593 vehicles
  • Flow on link (1, 4): 48.7980 vehicles
  • Flow on link (4, 2): 48.7957 vehicles

Objective value (Total Cost): 20399.6443

Alternative Result on a slightly different problem (IpOPT):

  • Flow on link (1, 3): 5569.5249 vehicles
  • Flow on link (3, 2): 5569.5249 vehicles
  • Flow on link (1, 4): 2430.4751 vehicles
  • Flow on link (4, 2): 2430.4751 vehicles

Objective value (Total Cost): 197485.3688


Path Flows:

  • Flow on Path 1 (1->3->2): 5569.5249 vehicles
  • Flow on Path 2 (1->4->2): 2430.4751 vehicles

Path Travel Times:

  • Travel Time on Path 1 (1->3->2): 31.2760 minutes
  • Travel Time on Path 2 (1->4->2): 31.2760 minutes

Minimum Travel Time: 31.2760 minutes

User Equilibrium Gaps:

  • Gap for Path 1 (1->3->2): 0.0000 minutes
  • Gap for Path 2 (1->4->2): 0.0000 minutes

Weighted Gaps (by Flow):

  • Weighted Gap for Path 1 (1->3->2): 0.0000 vehicle-minutes
  • Weighted Gap for Path 2 (1->4->2): 0.0836 vehicle-minutes
  • Total Weighted Gap: 0.0836 vehicle-minutes

Objective value (Total Cost): 197485.3688