Documentation ¶
Index ¶
- func AbsInt(x int) int
- func FloorLimit(n int, limit int) int
- func Permutations(plates ...float32) [][]float32
- func RoundUpToNearest(n float32, inc int) int
- type SolutionOpts
- type Tree
- func (t *Tree) Add(plates ...float32) *Tree
- func (t *Tree) Find(plates ...float32) *Tree
- func (t *Tree) Score(preferLessPlates bool) int
- func (t *Tree) String() string
- func (t *Tree) TotalWeight() float32
- func (t *Tree) Walk(fn WalkTreeFn)
- func (t *Tree) WalkNearby(maxDistance int, fn WalkNearbyTreeFn)
- type WalkNearbyTreeFn
- type WalkTreeFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FloorLimit ¶
func Permutations ¶
Permutations returns every possible combination as tuples of length 1 to N. Ex: [1, 2, 3] -> [[1], [1,2], [1,2,3], [1,3,2], [2], [2,1], ...]
func RoundUpToNearest ¶
Types ¶
type SolutionOpts ¶
type Tree ¶
func BestSolution ¶
func BestSolution(tree *Tree, setWeights []float32, maxDistance int, opts *SolutionOpts) []*Tree
BestSolution returns the optimal sequence of plate changes for setWeights by walking the permutation tree and selecting the closest nodes with the lowest combined score.
func SimpleSolution ¶
func SimpleSolution(tree *Tree, setWeights []float32, opts *SolutionOpts) []*Tree
SimpleSolution returns the best plate arrangement for each individual weight in setWeights.
func (*Tree) TotalWeight ¶
func (*Tree) Walk ¶
func (t *Tree) Walk(fn WalkTreeFn)
func (*Tree) WalkNearby ¶
func (t *Tree) WalkNearby(maxDistance int, fn WalkNearbyTreeFn)
type WalkNearbyTreeFn ¶
type WalkTreeFn ¶
type WalkTreeFn func(*Tree)
Click to show internal directories.
Click to hide internal directories.