casso

package
v0.0.0-...-45b0304 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateConstraint     = errors.New("duplicate constraint")
	ErrUnsatisfiableConstraint = errors.New("unsatisfiable constraint")
	ErrUnknownConstraint       = errors.New("unknown constraint")
	ErrDuplicateEditVariable   = errors.New("duplicate edit variable")
	ErrBadRequiredStrength     = errors.New("bad required strength")
	ErrUnknownEditVariable     = errors.New("unknown edit variable")
)

Functions

This section is empty.

Types

type Constraint

type Constraint *ConstraintData

func NewConstraint

func NewConstraint(e Expression, op RelationOperator, strength Strength) Constraint

type ConstraintData

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

func (ConstraintData) Expression

func (cd ConstraintData) Expression() Expression

func (ConstraintData) Op

func (ConstraintData) Strength

func (cd ConstraintData) Strength() Strength

type Expression

type Expression struct {
	Terms    []Term
	Constant float64
}

func NewExpression

func NewExpression(constant float64, terms ...Term) Expression

func NewExpressionFromConstant

func NewExpressionFromConstant(v float64) Expression

func NewExpressionFromTerm

func NewExpressionFromTerm(term Term) Expression

func (Expression) DivConstant

func (e Expression) DivConstant(other float64) Expression

func (Expression) MulConstant

func (e Expression) MulConstant(other float64) Expression

func (Expression) Negate

func (e Expression) Negate() Expression

func (Expression) Sub

func (e Expression) Sub(other Expression) Expression

func (Expression) SubConstant

func (e Expression) SubConstant(other float64) Expression

func (Expression) SubVariable

func (e Expression) SubVariable(other Variable) Expression

type InternalSolverError

type InternalSolverError string

func (InternalSolverError) Error

func (e InternalSolverError) Error() string

type PartialConstraint

type PartialConstraint struct {
	Expression Expression
	Relation   WeightedRelation
}

func (PartialConstraint) ConstantRHS

func (p PartialConstraint) ConstantRHS(v float64) Constraint

func (PartialConstraint) ExpressionRHS

func (p PartialConstraint) ExpressionRHS(e Expression) Constraint

func (PartialConstraint) VariableRHS

func (p PartialConstraint) VariableRHS(v Variable) Constraint

type PublicChange

type PublicChange struct {
	Variable Variable
	Constant float64
}

type RelationOperator

type RelationOperator int
const (
	RelationOperatorLessThanEqual RelationOperator = iota + 1
	RelationOperatorEqual
	RelationOperatorGreaterThanEqual
)

type Solver

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

func NewSolver

func NewSolver() Solver

func (*Solver) AddConstraint

func (s *Solver) AddConstraint(constraint Constraint) error

func (*Solver) AddConstraints

func (s *Solver) AddConstraints(constraints ...Constraint) error

func (*Solver) FetchChanges

func (s *Solver) FetchChanges() []PublicChange

FetchChanges fetches all changes to the values of variables since the last call to this function.

The list of changes returned is not in a specific order. Each change comprises the variable changed and the new value of that variable.

func (*Solver) GetValue

func (s *Solver) GetValue(v Variable) float64

func (*Solver) Reset

func (s *Solver) Reset()

type Strength

type Strength float64
const (
	Required Strength = 1_001_001_000
	Strong   Strength = 1_000_000
	Medium   Strength = 1_000
	Weak     Strength = 1
)

type SymbolType

type SymbolType int
const (
	SymbolTypeInvalid SymbolType = iota + 1
	SymbolTypeExternal
	SymbolTypeSlack
	SymbolTypeError
	SymbolTypeDummy
)

type Term

type Term struct {
	Variable    Variable
	Coefficient float64
}

func NewTerm

func NewTerm(variable Variable, coefficient float64) Term

func (Term) Negate

func (t Term) Negate() Term

type Variable

type Variable uint64

func NewVariable

func NewVariable() Variable

func (Variable) Sub

func (v Variable) Sub(other Variable) Expression

type WeightedRelation

type WeightedRelation struct {
	Operator RelationOperator
	Strength Strength
}

func Equal

func Equal(strength Strength) WeightedRelation

func GreaterThanEqual

func GreaterThanEqual(strength Strength) WeightedRelation

func LessThanEqual

func LessThanEqual(strength Strength) WeightedRelation

func (WeightedRelation) ExpressionLHS

func (w WeightedRelation) ExpressionLHS(expression Expression) PartialConstraint

func (WeightedRelation) VariableLHS

func (w WeightedRelation) VariableLHS(variable Variable) PartialConstraint

Jump to

Keyboard shortcuts

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