helper

package
v0.0.0-...-e2cac0c Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBrokenLinearFunction

func BuildBrokenLinearFunction(shape FunctionShape) func(int64) int64

BuildBrokenLinearFunction creates a function which is built using linear segments. Segments are defined via shape array. Shape[i].Utilization slice represents points on "Utilization" axis where different segments meet. Shape[i].Score represents function values at meeting points.

function f(p) is defined as:

shape[0].Score for p < f[0].Utilization
shape[i].Score for p == shape[i].Utilization
shape[n-1].Score for p > shape[n-1].Utilization

and linear between points (p < shape[i].Utilization)

Types

type FunctionShape

type FunctionShape []FunctionShapePoint

FunctionShape represents a collection of FunctionShapePoint.

type FunctionShapePoint

type FunctionShapePoint struct {
	// Utilization is function argument.
	Utilization int64
	// Score is function value.
	Score int64
}

FunctionShapePoint represents a shape point.

Jump to

Keyboard shortcuts

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