  Traffic on a circular road is described by dynamic programming equations
associated to optimal control problems. By solving the equations analytically,
we derive the relation between the average car density and the average car
flow, known as the fundamental diagram of traffic. First, we present a model
based on min-plus algebra, then we extend it to a stochastic dynamic
programming model, then to a stochastic game model. The average car flow is
derived as the average cost per time unit of optimal control problems, obtained
in terms of the average car density. The models presented in this article can
also be seen as developed versions of the car-following model. The derivations
proposed here can be used to approximate, understand and interprete fundamental
diagrams derived from real measurements.
