planner

package
v0.0.0-...-3371691 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AverageCost

func AverageCost(plan api.Rates) float64

AverageCost returns the time-weighted average cost

func Duration

func Duration(plan api.Rates) time.Duration

Duration returns the sum of all slot's durations

func IsFirst

func IsFirst(r api.Rate, plan api.Rates) bool

IsFirst returns if the slot is the first slot in the plan. Does not require the plan to be sorted by start time.

func SlotAt

func SlotAt(time time.Time, plan api.Rates) api.Rate

SlotAt returns the slot for the given time or an empty slot

func SlotHasSuccessor

func SlotHasSuccessor(r api.Rate, plan api.Rates) bool

SlotHasSuccessor returns if the slot has an immediate successor. Does not require the plan to be sorted by start time.

func Start

func Start(plan api.Rates) time.Time

Start returns the earliest slot's start time

Types

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner plans a series of charging slots for a given (variable) tariff

func New

func New(log *util.Logger, tariff api.Tariff) *Planner

New creates a price planner

func (*Planner) Plan

func (t *Planner) Plan(requiredDuration time.Duration, targetTime time.Time) (api.Rates, error)

Plan creates a lowest-cost charging plan, considering edge conditions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL