Active Power Control of Photovoltaic Systems and Electric Vehicle Optimization Including the Costs of Battery Degradation