This research proposes a vehicle-to-grid strategy based on dynamic optimization for a fleet of public transportation Electric Vehicles (EVs) whose charging station is jointly powered by the conventional electrical network and photovoltaic renewable sources. Utilizing two neural networks, the proposed algorithm predicted future energy expenditure of Electric Vehicles (EVs) and the power generation potential of the renewable sources. The goal was to optimize dynamically the EVs' decision-making, encompassing their charging-discharging schedules, power exchange with the electrical network, and travel dispatch. The analysis considered the EVs' capacity for selling energy and providing frequency reserve ancillary services. Consequently, this proposal enables the estimation of fleet management plans by considering the daily average congestion level in the analysis zone, the required departure schedules of the vehicles in the fleet, and the past measures of solar radiation at the site. These variables serve as inputs for the prediction algorithms. The mathematical model of dynamic optimization was formulated as a convex Mixed-Integer problem and was solved using the iterative branch and cut method. The findings revealed that the most profitable options for the EVs' owners include selling energy and providing downward regulation ancillary services. Moreover, as the solution's viability relied on the accuracy of the prediction algorithms' outputs, two high precision neural networks, with an error rate lower than 2%, have been employed.