heuristic

package
v0.0.0-...-7ea70c7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	H_REACHED = 0.01 // branch was reached
)
View Source
const (
	// MAX_CHAR_DISTANCE 2^16=65536, max distance for a char
	MAX_CHAR_DISTANCE = 65_536
)

Variables

This section is empty.

Functions

func BothFloat

func BothFloat(lvalue reflect.Value, rvalue reflect.Value) bool

func BothInt

func BothInt(lvalue reflect.Value, rvalue reflect.Value) bool

func BothString

func BothString(lvalue reflect.Value, rvalue reflect.Value) bool

func BothUint

func BothUint(lvalue reflect.Value, rvalue reflect.Value) bool

func EvaluateOrderedCmp

func EvaluateOrderedCmp[T constraints.Ordered](h *HeuristicForBooleans, left T, op string, right T, fileName string, line int, branchId int, tracer Tracer) bool

func GetDistanceToEquality

func GetDistanceToEquality(lvalue reflect.Value, rvalue reflect.Value) float64

GetDistanceToEquality compute distance between left and right ==

func GetDistanceToEqualityFloat64

func GetDistanceToEqualityFloat64(a float64, b float64) float64

func GetDistanceToEqualityInt64

func GetDistanceToEqualityInt64(a int64, b int64) float64

func GetDistanceToEqualityString

func GetDistanceToEqualityString(a string, b string) float64

func GetDistanceToEqualityUint64

func GetDistanceToEqualityUint64(a uint64, b uint64) float64

func GetDistanceToLessThan

func GetDistanceToLessThan(lvalue reflect.Value, rvalue reflect.Value) float64

GetDistanceToLessThan compute distance between left and right <

func GetDistanceToLessThanFloat64

func GetDistanceToLessThanFloat64(a float64, b float64) float64

func GetDistanceToLessThanInt64

func GetDistanceToLessThanInt64(a int64, b int64) float64

func GetDistanceToLessThanString

func GetDistanceToLessThanString(a string, b string) float64

func GetDistanceToLessThanUint64

func GetDistanceToLessThanUint64(a uint64, b uint64) float64

func GetLeftAlignmentDistance

func GetLeftAlignmentDistance(a string, b string) float64

func NormalizeValue

func NormalizeValue(v float64) float64

NormalizeValue scales to a positive double value to the [0,1] range. v is a non-negative float

Types

type HeuristicForBooleans

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

func NewHeuristicForBooleans

func NewHeuristicForBooleans() *HeuristicForBooleans

func (*HeuristicForBooleans) ClearLastEvaluation

func (h *HeuristicForBooleans) ClearLastEvaluation()

func (*HeuristicForBooleans) EvaluateAnd

func (h *HeuristicForBooleans) EvaluateAnd(left func() bool, right func() bool, fileName string, line int, branchId int, tracer Tracer) bool

func (*HeuristicForBooleans) EvaluateOr

func (h *HeuristicForBooleans) EvaluateOr(left func() bool, right func() bool, fileName string, line int, branchId int, tracer Tracer) bool

func (*HeuristicForBooleans) EvaluateUnorderedCmp

func (h *HeuristicForBooleans) EvaluateUnorderedCmp(left any, op string, right any, fileName string, line int, branchId int, tracer Tracer) bool

func (*HeuristicForBooleans) HandleNot

func (h *HeuristicForBooleans) HandleNot(value bool) bool

type Tracer

type Tracer interface {
	UpdateBranch(fileName string, line int, branch int, truthness *Truthness)
}

type Truthness

type Truthness struct {
	OfTrue  float64
	OfFalse float64
}

func GetEqualityTruthness

func GetEqualityTruthness(left any, right any) *Truthness

func GetLessThanTruthness

func GetLessThanTruthness[T constraints.Ordered](left T, right T) *Truthness

func NewTruthness

func NewTruthness(ofTrue float64, ofFalse float64) *Truthness

func (*Truthness) Invert

func (t *Truthness) Invert() *Truthness

func (*Truthness) IsFalse

func (t *Truthness) IsFalse() bool

func (*Truthness) IsTrue

func (t *Truthness) IsTrue() bool

func (*Truthness) RescaleFromMin

func (t *Truthness) RescaleFromMin(min float64) *Truthness

Jump to

Keyboard shortcuts

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