models

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TxLikeliness

func TxLikeliness(txMatrices []TxMatrix, history [][]TSState, nextState []TSState) float32

TxLikeliness computes the likeliness that history happens on multivariate txMatrix

Types

type History

type History struct {
	CurrentPhase   int                 `json:"currentPhase"`
	HistoricStates []map[string]string `json:"historicStates"`
	PeriodPath     []int               `json:"periodPath"`
	NextState      map[string]string   `json:"nextState"`
}

History defines the historic path and next step for tspredictor

func ReadHistoryFromFile

func ReadHistoryFromFile(filepath string) History

ReadHistoryFromFile reads History from json file and returns as object

type PeriodTree

type PeriodTree struct {
	Root PeriodTreeNode `json:"root"`
}

PeriodTree contains the root of a PeriodTree

func NewPeriodTree

func NewPeriodTree(size []int) PeriodTree

NewPeriodTree instantiates and returns a new PeriodTree with the `size` child nodes

func (*PeriodTree) GetNode

func (periodTree *PeriodTree) GetNode(path []int) *PeriodTreeNode

GetNode returns the TreeNode which is located at `path`

type PeriodTreeNode

type PeriodTreeNode struct {
	UUID      int
	MaxChilds int              `json:"maxChilds"`
	MaxCounts int              `json:"maxCounts"`
	Children  []PeriodTreeNode `json:"children"`
	TxMatrix  []TxMatrix       `json:"txmatrix"`
}

PeriodTreeNode describes a node holding a TxMatrix and (if not leaf node) children

func NewPeriodTreeNode

func NewPeriodTreeNode(size []int) PeriodTreeNode

NewPeriodTreeNode instantiates and returns a PeriodTreeNode with `size` children (recursively)

func (*PeriodTreeNode) GetNode

func (periodTreeNode *PeriodTreeNode) GetNode(path []int) *PeriodTreeNode

GetNode returns the TreeNode which is located at `path`

type Phases

type Phases struct {
	// A list of detected phases (outer array) for each metric (inner array)
	Phases [][]TxMatrix `json:"phases"`

	// Tx holds the transitions between the phases
	Tx TxMatrix `json:"tx"`
}

Phases holds a list of detected phases and a tx matrix describing the transitioning between these phases

type Settings

type Settings struct {
	// BufferSize defines the amount of TSData items before a new state is transitioned
	BufferSize int `json:"buffersize"`

	// Name allows to identify the profiler, e.g. for human readable differentiation
	Name string `json:"-"`

	// States defines the amount of states to discretize the measurements
	States int `json:"states"`

	// History defines the amount of previous, historic state changes to be considered
	History int `json:"history"`

	// FilterStdDevs defines the amount of stddevs which are max. allowed for data items before skipped as outliers
	FilterStdDevs int `json:"filterstddevs"`

	// FixBound defines if min/max are fixed or dynamic depending on occurred values
	FixBound bool `json:"fixbound"`

	// OutputFreq controls the frequency in which the profiler calls the OutputCallback function (if not set, profile has to be retrieved manually)
	OutputFreq time.Duration `json:"-"`

	// OutputCallback defines the callback function for `TSProfile`s every `OutputFreq`
	OutputCallback func(data TSProfile) `json:"-"`

	// PeriodSize defines the amount and size of periods
	PeriodSize []int `json:"periodsize"`

	// Phase Change Detection settings (likeliness over history)
	PhaseChangeLikeliness float32 `json:"phaseChangeLikeliness"`
	// Phase Change Detection settings (state history length)
	PhaseChangeHistory int64 `json:"phaseChangeHistory"`
	// Phase Change Detection settings (state history fade out)
	PhaseChangeHistoryFadeout bool `json:"phaseChangeHistoryFadeout"`
}

Settings defines settings for TSProfiler

type State

type State struct {
	Value int64
}

State represents a single state value

type TSBuffer

type TSBuffer struct {
	Metric  string
	RawData []float64

	Min      float64
	Max      float64
	FixedMin float64
	FixedMax float64
}

TSBuffer describes one full buffer

func NewTSBuffer

func NewTSBuffer(metric string) TSBuffer

NewTSBuffer instantiates a new TSBuffer with given metric name

func (*TSBuffer) Append

func (tsbuffer *TSBuffer) Append(value float64)

Append adds a single value to the TSBuffer

type TSInput

type TSInput struct {
	Metrics []TSInputMetric `json:"metrics"`
}

TSInput describes a ts data point used as profiler input with a metrics array

type TSInputMetric

type TSInputMetric struct {
	Name     string
	Value    float64
	FixedMin float64
	FixedMax float64
}

TSInputMetric describes profiler input for a single metric

type TSProfile

type TSProfile struct {
	Name       string     `json:"name"`
	RootTx     []TxMatrix `json:"roottx"`
	PeriodTree PeriodTree `json:"periodTree"`
	Phases     Phases     `json:"phases"`
	Settings   Settings   `json:"settings"`
}

TSProfile contains the resulting statistical profile

func (*TSProfile) Likeliness

func (profile *TSProfile) Likeliness(oldstates [][]TSState, newstate []TSState) float32

Likeliness returns how likely [0,1] the current value appears according to the root tx matrix

func (*TSProfile) LikelinessPhase

func (profile *TSProfile) LikelinessPhase(currentPhase int, oldstates [][]TSState, newstate []TSState) float32

LikelinessPhase returns how likely [0,1] the current value appears according to the profile's phase

type TSState

type TSState struct {
	Metric     string
	Statistics TSStats
	State      State
}

TSState describes a single discretized state

type TSStats

type TSStats struct {
	Min       float64 `json:"min"`
	Max       float64 `json:"max"`
	Stddev    float64 `json:"stddev"`
	Avg       float64 `json:"avg"`
	Count     int64   `json:"count"`
	StddevSum float64 `json:"stddevsum"`
}

TSStats contains default statistics

type TXStep

type TXStep struct {
	NextStateProbs []int `json:"nextProbs"`
	StepProb       int   `json:"probability"`
}

TXStep expresses a single state in a markov chain / transition matrix

type TxMatrix

type TxMatrix struct {
	Metric      string            `json:"metric"`
	Transitions map[string]TXStep `json:"transitions"`
	Stats       TSStats           `json:"stats"`
}

TxMatrix describes for one metric a statistical profile

func (*TxMatrix) Diff

func (txMatrix *TxMatrix) Diff(txMatrixRemote TxMatrix) float64

Diff compares two txMatrizes and returns the diff ratio between 0 (not equal) and 1 (fully equal)

func (*TxMatrix) Likeliness

func (txMatrix *TxMatrix) Likeliness(from []TSState, to TSState) float32

Likeliness computes the likeliness for transitioning from the from state to the to state

func (*TxMatrix) Merge

func (txMatrix *TxMatrix) Merge(txMatrixRemote TxMatrix)

Merge merges the given TxMatrix to the current one via average on the probabilities

Jump to

Keyboard shortcuts

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