This paper considers the optimal design of input signals for the purpose of discriminating among a finite number of affine models with uncontrolled inputs and noise. Each affine model represents a different system operating mode, corresponding to unobserved intents of other drivers or robots, or to fault types or attack strategies, etc. The input design problem aims to find optimal separating/discriminating (controlled) inputs such that the output trajectories of all the affine models are guaranteed to be distinguishable from each other, despite uncertainty in the initial condition and uncontrolled inputs as well as the presence of process and measurement noise. We propose a novel formulation to solve this problem, with an emphasis on guarantees for model discrimination and optimality, in contrast to a previously proposed conservative formulation using robust optimization. This new formulation can be recast as a bilevel optimization problem and further reformulated as a mixed-integer linear program (MILP). Moreover, our fairly general problem setting allows the incorporation of objectives and/or responsibilities among rational agents. For instance, each driver has to obey traffic rules, while simultaneously optimizing for safety, comfort and energy efficiency. Finally, we demonstrate the effectiveness of our approach for identifying the intention of other vehicles in several driving scenarios.