How do I minimizie cost of charging an electric car? I want to find a charging schedule that minimize cost of charging an EV.
The main objective is to have a fully charged car for the next morning, but the sub objective is to minimize cost based these two things combined:

*

*Charge when electricity is cheapest - I know the hourly electricity price for the next 24 hours

*Minimize hourly peak demand charges for the household - I pay a small additional fee each month if my hourly demand exceed different steps.

I know the power size of the charger (W), the capacity of the car battery (Wh), how many hours I have to charge (h), I know what my household peak is right now (W), and all prices for both consumption (Money/Wh) and peak demands (xx Money, if hourly demand > xxxx Wh).

*

*What would one call this type of minimization problem?

*How would one go forward to solve this?

*Is there a python package that can help me solve this? (I have seen similar problems been solved with Gurobi)

 A: Let me give you a starting point. The decision variables will be $SoC(t)$ (the state-of-charge of EV battery at time $t$, in %) and $P(t)$ (charging power set-point at time $t$, in kW), where $t \in T$, and $T=\{1,2.,, t_{end}\}$ is the charging horizon.
Perhaps the most important constraints are the state-of-charge dynamics, which are given by:
$SoC(t) = SoC(t-1)+\frac{\Delta T}{Cap}\eta P(t), \forall t \in T-\{1\}$
where $\Delta T$ is the discrete time step size (usually taken as 5 min... 1 hour), $Cap$ is the battery capacity in kWh, $\eta$ is the grid-to-battery efficiency (usually between 90%-98%, and can be assumed constant for simplicity). Note that $SoC(1)$ is the initial state-of-charge, and must be given as a data.
Other constraints can be upper/lower bounds on $SoC(t)$ and $P(t)$, depending on the charging needs and EV/battery/supply equipment technical limits.
The objective function is the total cost of electricity, which consists of two parts: energy charges (charged per kWh) and demand charges (charged per kW according to the monthly peak). The former is easy to formulate:
$\text{Energy charges} = \sum_{t \in T} c(t)P(t)\Delta T$
where $c(t)$ is the (known) energy charge at time $t$, given in $\$/kWh$. I will leave the formulation of demand charges to you.
As you can see, if you are only concerned with the energy charges, the problem can be cast as an LP (of course, with some assumptions).
I strongly suggest you to have a look at https://ev.caltech.edu/ , where you will find tons of interesting data, papers, and a Python-based simulation platform for EV charging scheduling.
