optivgi.scm.go_algorithm

Provides a custom heuristic-based SCM algorithm (“GoAlgorithm”).

This algorithm uses a multi-stage approach to allocate power, prioritizing minimum power requirements and then distributing remaining capacity based on fairness factors and optional strategies like front-loading power. It does not rely on external optimization solvers like PuLP.

optivgi.scm.go_algorithm.DEBUG = False

If True, enables verbose logging of allocation decisions.

Type:

DEBUG

optivgi.scm.go_algorithm.FAIRNESS_FACTOR = 1.0

Exponent applied during proportional power sharing. 1.0 = proportional to remaining need. >1.0 favors EVs needing more power. <1.0 favors EVs needing less.

Type:

FAIRNESS_FACTOR

optivgi.scm.go_algorithm.SHIFT_FRONT = True

If True, attempts to shift allocated power towards earlier time slots after the initial allocation, where capacity allows.

Type:

SHIFT_FRONT

optivgi.scm.go_algorithm.ALLOC_REMAINING_EXTRA = True

If True, allocates any remaining peak power capacity (after primary allocation and shifting) to EVs that can accept more power, potentially exceeding their initial energy request if limits allow.

Type:

ALLOC_REMAINING_EXTRA

class optivgi.scm.go_algorithm.GoAlgorithm(evs, peak_power_demand, now)

Bases: Algorithm

A heuristic Smart Charging Management (SCM) algorithm.

This algorithm allocates power in stages:

  1. Minimum Power Allocation: Iterates backward in time, ensuring each EV receives its minimum required power (min_power) during its connected window, respecting energy needs and available peak power.

  2. Fair Allocation: Iterates backward, distributing the remaining available peak power capacity (peak_power_demand minus already allocated power) proportionally among EVs still needing energy. The proportionality can be adjusted using FAIRNESS_FACTOR. Allocation stops when an EV reaches its max_power or its energy requirement for the timestep.

  3. Shift Power Forward (Optional): If SHIFT_FRONT is True, iterates backward and attempts to move allocated power (above min_power) from later time slots to earlier ones, provided the earlier slot has capacity and the EV can accept power there (up to max_power). This aims to charge EVs sooner if possible.

  4. Allocate Extra Capacity (Optional): If ALLOC_REMAINING_EXTRA is True, iterates forward and distributes any leftover peak power capacity among EVs that can still accept power (up to their max_power), even if they have already met their initial energy requirement.

Uses an inner helper class EVPower to track the remaining energy needed for each EV during the calculation process.

Parameters:
class EVPower(ev)

Bases: object

Helper class to track EV power allocation state during calculation.

Manages the remaining energy needed and provides methods to calculate available power headroom and accept/shift power allocations safely.

Note: Attributes documented automatically by autodoc from class definition.

Parameters:

ev (EV)

ev: EV

The underlying EV object.

energy_left: float

The remaining energy (kWh or Ah) this EV still needs. Initialized from ev.energy and decremented as power is allocated.

power(time, max_available=inf, ignore_energy=False)
Parameters:

time (int)

accept_power(time, power, ignore_energy=False)
Parameters:
shift_power(time_from, time_to, power)
Parameters:
calculate()

Executes the GoAlgorithm calculation logic.

Populates the ev.power list for each EV in self.evs according to the heuristic stages described in the class documentation.

Return type:

None