An optimal transportation principle for interacting paths and congestion