optimization - Pyomo add constraint error: Rule failed when generation . . . Sure, I have two lists: Riders and Vehicles Based on a k-nearest logic, I create a dictionary called k_nearest_vehicles which is a subset of Vehicles for a given rider in Riders Hence, k_nearest_vehicles includes a bunch of unique vehicle ids for a given index in Riders