fn

package
v0.0.0-...-551a68b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const InvalidSolution string = "Invalid solution"

Variables

This section is empty.

Functions

func AsGraphPath

func AsGraphPath(solution *discrete.Solution, cfg *data.GraphPath) []int

AsGraphPath returns path formed by solution values (with start, end)

func AsPartition

func AsPartition(solution *discrete.Solution, values []discrete.Value) [][]discrete.Variable

AsPartition returns the partition from the solution

func AsPathOrder

func AsPathOrder(solution *discrete.Solution) []discrete.Variable

AsPathOrder returns path index order formed by solution values

func AsSequence

func AsSequence(solution *discrete.Solution) []discrete.Variable

AsSequence returns list of variables sequenced by solution values

func AsSubset

func AsSubset(solution *discrete.Solution) []discrete.Variable

AsSubset assumes BooleanDomain {0,1} and returns list of variables with value=1 in solution

func ConnectedComponents

func ConnectedComponents(graph *ds.Graph, activeEdges ds.EdgeSet) [][]ds.Vertex

ConnectedComponents performs BFS traversal multiple times to discover the connected components of the graph, considering the active edge set, and returns the list of components

func ConstraintAllUnique

func ConstraintAllUnique(solution *discrete.Solution) bool

ConstraintAllUnique makes sure all solution values are unique

func ConstraintAllVerticesCovered

func ConstraintAllVerticesCovered(graph *ds.Graph, vertices []ds.Vertex) discrete.ConstraintFn

ConstraintAllVerticesCovered makes sure all vertices are covered at least once

func ConstraintIncreasingSubsequence

func ConstraintIncreasingSubsequence(cfg *data.Numbers) discrete.ConstraintFn

ConstraintIncreasingSubsequence makes sure that the subsequence is increasing

func ConstraintNoMachineOverlap

func ConstraintNoMachineOverlap(cfg *data.ShopSchedule, tasks []data.Task) discrete.ConstraintFn

ConstraintNoMachineOverlap checks that the schedule has no machine overlap

func ConstraintProperVertexColoring

func ConstraintProperVertexColoring(graph *ds.Graph) discrete.ConstraintFn

ConstraintProperVertexColoring makes sure all adjacent vertices in the graph have a different color

func ConstraintRainbowColoring

func ConstraintRainbowColoring(colors []string) discrete.ConstraintFn

ConstraintRainbowColoring makes sure all chosen items have different colors

func ConstraintSimplePath

func ConstraintSimplePath(cfg *data.GraphPath) discrete.ConstraintFn

ConstraintSimplePath makes sure solution forms a valid simple path (no repeated vertices)

func ConstraintSpanningTree

func ConstraintSpanningTree(graph *ds.Graph, vertices []ds.Vertex) discrete.ConstraintFn

ConstraintSpanningTree checks if the solution forms a tree, and all vertices are reachable from tree traversal

func CoreLookupValueOrder

func CoreLookupValueOrder(problem *discrete.Problem) discrete.SolutionCoreFn

CoreLookupValueOrder groups solutions based on the relative order of the solution values

func CoreMirroredSequence

func CoreMirroredSequence[T any](items []T) discrete.SolutionCoreFn

CoreMirroredSequence groups the normal and the reversed sequence as one

func CoreMirroredValues

func CoreMirroredValues[T any](p *discrete.Problem, items []T) discrete.SolutionCoreFn

CoreMirroredValues groups the normal and reversed list of values as one

func CoreSortedCycle

func CoreSortedCycle[T any](items []T) discrete.SolutionCoreFn

CoreSortedCycle groups the normal and sorted cycles as one

func CoreSortedPartition

func CoreSortedPartition[T any](values []discrete.Value, items []T) discrete.SolutionCoreFn

CoreSortedPartition groups similar partitions by using their sorted versions

func CountColorChanges

func CountColorChanges[T comparable](colorSequence []T) int

CountColorChanges counts the number of color changes in the sequence

func IsClique

func IsClique(graph *ds.Graph, vertices []ds.Vertex) bool

IsClique checks if a list of vertices forms a clique in the graph

func IsEulerianPath

func IsEulerianPath(graph *ds.Graph, edges []ds.Edge) (bool, [2]ds.Vertex)

IsEulerianPath checks if edge sequence is a valid Eulerian path (visit each edge exactly once) Also returns the head/tail of the sequence

func IsHamiltonianPath

func IsHamiltonianPath(graph *ds.Graph, vertices []ds.Vertex) bool

IsHamiltonianPath checks if vertex path is a valid Hamiltonian path (visit each vertex exactly once)

func MaxConsecutive

func MaxConsecutive(slots []int, limit int) bool

MaxConsecutive checks that consecutive slot lengths do not exceed the given limit

func MirroredList

func MirroredList(sequence []string, separator string) string

MirroredList checks the first and last items if in order; if not, mirrors the list

func MirroredSequence

func MirroredSequence(sequence []string) string

MirroredSequence checks the first and last items if in order; if not, mirrors the sequence

func NoOverlap

func NoOverlap(tasks []data.Task, keys []string, keyFn func(data.Task) string) discrete.ConstraintFn

NoOverlap checks that the schedule has no overlaps

func PartitionStrings

func PartitionStrings[T any](solution *discrete.Solution, values []discrete.Value, items []T) [][]string

PartitionStrings returns the partition as a list of strings

func PartitionSums

func PartitionSums[T number.Number](solution *discrete.Solution, values []discrete.Value, items []T) []T

PartitionSums returns the sums of each partition group

func PathDistances

func PathDistances(solution *discrete.Solution, cfg *data.GraphPath) []float64

PathDistances returns the distance values of the edges in the path

func ScoreCountUniqueValues

func ScoreCountUniqueValues(solution *discrete.Solution) discrete.Score

ScoreCountUniqueValues counts the number of unique values

func ScorePathCost

func ScorePathCost(cfg *data.GraphPath) discrete.ObjectiveFn

ScorePathCost sums up the path cost

func ScoreScheduleMakespan

func ScoreScheduleMakespan(tasks []data.Task) discrete.ObjectiveFn

ScoreScheduleMakespan computes the makespan (total length) of the schedule

func ScoreSubsetSize

func ScoreSubsetSize(solution *discrete.Solution) discrete.Score

ScoreSubsetSize counts the size of solution as subset

func ScoreSumWeightedSubset

func ScoreSumWeightedSubset(keys []string, weight map[string]float64) discrete.ObjectiveFn

ScoreSumWeightedSubset sums up the weight of the solution subset

func ScoreSumWeightedValues

func ScoreSumWeightedValues(variables []discrete.Variable, weight []float64) discrete.ObjectiveFn

ScoreSumWeightedValues sums up the weighted count of each variable

func SortedCycle

func SortedCycle(sequence []string, removeTail bool) string

SortedCycle finds the first element in sorted order, Rearrange the sequence so it becomes the first element

func SpannedVertices

func SpannedVertices(solution *discrete.Solution, graph *ds.Graph) *ds.Set[ds.Vertex]

SpannedVertices returns the vertices spanned by the tree formed by the given edges

func StringAssignment

func StringAssignment(p *discrete.Problem, cfg *data.AssignmentCfg) func(*discrete.Solution) string

StringAssignment displays assignment of {worker = task} Note: didn't explicitly return as SolutionStringFn so it can be reused as SolutionCoreFn

func StringEulerianPath

func StringEulerianPath(graph *ds.Graph) discrete.SolutionStringFn

StringEulerianPath displays the Eulerian path sequence of vertices

func StringGraphPath

func StringGraphPath(cfg *data.GraphPath) discrete.SolutionStringFn

StringGraphPath displays the path sequence of vertices

func StringMap

func StringMap[T any, V any](p *discrete.Problem, variables []T, values []V) discrete.SolutionStringFn

StringMap displays solution as {variable = value}

func StringPartition

func StringPartition[T any](values []discrete.Value, items []T) discrete.SolutionStringFn

StringPartition displays the solution as a partition

func StringSequence

func StringSequence[T any](items []T) discrete.SolutionStringFn

StringSequence displays the solution as sequence of variables

func StringShopSchedule

func StringShopSchedule(tasks []data.Task, machines []string) discrete.SolutionStringFn

StringShopSchedule displays solution as shop schedule (task and machine schedules)

func StringSubset

func StringSubset[T cmp.Ordered](items []T) discrete.SolutionStringFn

StringSubset displays the solution as subset

func StringValues

func StringValues[T any](p *discrete.Problem, items []T) discrete.SolutionStringFn

StringValues displays the solution mapped to given values

Types

This section is empty.

Jump to

Keyboard shortcuts

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