I would like to charge a car under the condition that in the end it is charged at least 75% and if prices are positive I would like it to continue charging, but not surpass the maximum of 100%
So here is what I have so far:
maxF = 100
minF = 75
SoC = 55
i = 0
chargeRate = 10
price = [2,-2,3,4]
while SoC < minF:
if price[i] > 0:
SoC += chargeRate
i += 1
elif (minF - SoC)/chargeRate <= (len(price) - i):
SoC += chargeRate
i += 1
else:
i += 1
print(SoC)
In this piece of code the car charges prices 2 and 3, but not 4. I don't know how to include for the car to continue charging, after having passed the 75%.
I am greatful for any suggestions.
Many thanks, Elena
Aucun commentaire:
Enregistrer un commentaire