  We develop optimal control strategies for autonomous vehicles (AVs) that are
required to meet complex specifications imposed as rules of the road (ROTR) and
locally specific cultural expectations of reasonable driving behavior. We
formulate these specifications as rules, and specify their priorities by
constructing a priority structure, called \underline{T}otal \underline{OR}der
over e\underline{Q}uivalence classes (TORQ). We propose a recursive framework,
in which the satisfaction of the rules in the priority structure are
iteratively relaxed in reverse order of priority.
  Central to this framework is an optimal control problem, where convergence to
desired states is achieved using Control Lyapunov Functions (CLFs) and
clearance with other road users is enforced through Control Barrier Functions
(CBFs). We present offline and online approaches to this problem. In the
latter, the AV has limited sensing range that affects the activation of the
rules, and the control is generated using a receding horizon (Model Predictive
Control, MPC) approach. We also show how the offline method can be used for
after-the-fact (offline) pass/fail evaluation of trajectories - a given
trajectory is rejected if we can find a controller producing a trajectory that
leads to less violation of the rule priority structure. We present case studies
with multiple driving scenarios to demonstrate the effectiveness of the
algorithms, and to compare the offline and online versions of our proposed
framework.
