package fastsolver

import "github.com/purpleidea/mgmt/lang/unification/fastsolver"

Package fastsolver implements very fast type unification.

Index

Constants

const (
	// Name is the prefix for our solver log messages.
	Name = "fast"

	// OptimizationNotImplemented is a placeholder magic flag we can use.
	OptimizationNotImplemented = "not-implemented"
)

Types

type FastInvariantSolver

type FastInvariantSolver struct {
	// Strategy is a series of methodologies to heuristically improve the
	// solver.
	Strategy map[string]string

	// UnifiedState stores a common representation of our unification vars.
	UnifiedState *types.UnifiedState

	Debug bool
	Logf  func(format string, v ...interface{})
	// contains filtered or unexported fields
}

FastInvariantSolver is a fast invariant solver based on union find. It is intended to be computationally efficient.

func (*FastInvariantSolver) Init

func (obj *FastInvariantSolver) Init(init *unification.Init) error

Init contains some handles that are used to initialize the solver.

func (*FastInvariantSolver) Solve

Solve runs the invariant solver. It mutates the .Data field in the .Uni unification variables, so that each set contains a single type. If each of the sets contains a complete type that no longer contains any ?1 type fields, then we have succeeded to unify all of our invariants. If not, then our list of invariants must be ambiguous. This is O(N*K) where N is the number of invariants, and K is the size of the maximum type. Eg a list of list of map of int to str would be of size three. (TODO: or is it four?)

Source Files

fastsolver.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
4 days ago

Tools for package owners.