import math


def cost_lane_change(vehicle_info, predictions, trajectory):
    """ Computes cost of changing lanes.

    Args:
        vehicle_info: A VehicleInfo tuple.
        predictions: A dict of predictions for vehicles.
        trajectory: A Trajectory tuple.
    Returns:
         A cost in [0, 1].
    """
    # We want to penalize lane changes (i.e., high delta_d).
    delta_d = (2.0 * vehicle_info.goal_lane - trajectory.intended_lane -
               trajectory.final_lane)
    # Ensure that max cost is in [0, 1].
    if abs(vehicle_info.delta_s) < 0.0001:
        # We're very close to the goal.
        return 1
    else:
        return 1 - math.exp(-abs(delta_d) / vehicle_info.delta_s)