A fleet of electric vehicles returns to a depot during the evening. Each vehicle has a departure deadline, an energy requirement and a range of feasible charging times. The depot has a limited number of charging points and a finite electricity supply.
Even when every vehicle could be charged individually, the depot may not be able to serve every vehicle at its preferred time. The optimization problem is to select a set of compatible charging tasks that maximizes the value of selected charging sessions within the available capacity.
From a depot to a graph
Generate candidates only when a fixed-rate charging session meets the vehicle's energy requirement and departure window. Each candidate specifies a vehicle, charger, start time, power and duration. Assign a binary variable xᵢ to each candidate task and a value wᵢ reflecting the benefit of selecting it.
Two tasks conflict if they serve the same vehicle, or if they use the same charger during overlapping time intervals. Represent each task by a vertex and each conflict by an edge. A collection compatible with these two rules is an independent set of this graph. Maximizing the sum of task values gives a maximum-weight independent set problem.
This representation connects an industrial planning problem to a well-studied class of binary optimization models. It also explains why the number of possible charging schedules can grow rapidly even when the underlying rule is simple.
A QUBO formulation
For a minimization objective, one possible binary quadratic model is
E(x) = -sum_i w[i] * x[i] + P * sum_(i,j in conflicts) x[i] * x[j] When the weights are nonnegative and P exceeds every individual task weight, an infeasible selection containing a conflicting pair can be improved by removing one of its conflicting tasks. Consequently, a global minimizer is conflict-free. The argument is about global optimality; a heuristic solution must still be checked for feasibility.
The same restrictions can be expressed directly as linear constraints. For each vehicle, select at most one task. For each charger and time slot, select at most one of the tasks occupying it. These group constraints define the same feasible selections as the pairwise conflict rules in this discretized model.
A small example
Three candidate tasks use one charger. Tasks A and B overlap; C is compatible with both. Their values are 7, 5 and 4 respectively. The following code enumerates every selection and checks the original conflict rule.
from itertools import product
weights = [7, 5, 4]
conflicts = [(0, 1)]
feasible = [x for x in product((0, 1), repeat=3)
if all(x[i] + x[j] <= 1 for i, j in conflicts)]
best = max(feasible, key=lambda x: sum(w * v for w, v in zip(weights, x)))
assert best == (1, 0, 1)
assert sum(w * v for w, v in zip(weights, best)) == 11
print(best, sum(w * v for w, v in zip(weights, best))) The best selection is A and C, with a total value of 11. Enumeration becomes expensive as the candidate list grows, which is where optimization algorithms become useful.
Adding the electricity supply
Charger occupancy is only one part of the decision. A site-wide electricity limit may restrict several nonconflicting charging tasks from running simultaneously. If the power drawn by a task in a slot is known, its contribution to the site's load can be included in a linear capacity constraint for that slot.
For each time slot t, let pᵢₜ be the power drawn by candidate i when active, and let Lₜ be the available site power. Add the row ∑i pitxi ≤ Lt. A mandatory vehicle needs an exactly-one row rather than an at-most-one row.
Illustration. Two different chargers can each draw four units of power during the same slot. The tasks are compatible in the occupancy graph, but selecting both violates a site limit of six units. A third charger does not solve that electrical capacity restriction.
Explicit capacity rows retain the weighted binary objective and the physical limits of the operation. More detailed charging models may allow interrupted charging, variable rates or energy prices; those require corresponding changes in the model.
The 4colors Optimizer for QUBO supports binary quadratic models with linear constraints. It can provide a classical reference for this class of discrete charging experiments.