Explain the principles of traffic flow theory and how it is applied in the design and analysis of transportation systems. What are the key factors considered in optimizing traffic flow and reducing congestion?