algorithms

package
v0.0.0-...-4ac049e Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Algorithms

func Algorithms() []string

Algorithms returns all of the premade algorithm names

Types

type AStar

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

AStar implements the A* search algorithm. See https://en.wikipedia.org/wiki/A*_search_algorithm for a quick overview.

func (AStar) Run

Run runs A* on the environment and returns the result

type Algorithm

type Algorithm interface {
	// Run searches in the environment for the goal node
	Run(ctx search.Context, e environments.Environment) (search.Result, error)
}

Algorithm defines the interface for a search algorithm

func GetAlgorithm

func GetAlgorithm(name string) (Algorithm, error)

GetAlgorithm returns the desired algorithm

type BreadthFirst

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

BreadthFirst implements the breadth first search algorithm

func (BreadthFirst) Run

Run runs A* on the environment and returns the result

type DepthFirst

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

DepthFirst implements the depth first search algorithm

func (DepthFirst) Run

Run runs A* on the environment and returns the result

type DepthLimited

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

DepthLimited implements the depth limited search algorithm. It requires the `depth_limit` custom argument to be passed

func (DepthLimited) Run

Run runs A* on the environment and returns the result

type GreedyBestFirst

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

GreedyBestFirst implements the greedy best first search algorithm

func (GreedyBestFirst) Run

Run runs A* on the environment and returns the result

type IterativeDeepening

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

IterativeDeepening implements the depth limited search algorithm. It can take the `initial_depth` custom argument, but by the default the value will be 0

func (IterativeDeepening) Run

Run runs A* on the environment and returns the result

type PriorityNodeQueue

type PriorityNodeQueue struct {
	PriorityNodeQueueConfig

	// Frontier is the current
	// open set
	Frontier []environments.Node

	// PriorityMap is referenced
	// to get the priority value
	// for a node. Lowest priority
	// nodes are the ones that are
	// popped
	PriorityMap map[string]int

	// NodeIndexes keeps track
	// of the indexes of nodes
	// based upon their name
	NodeIndexes map[string]int
}

PriorityNodeQueue implements heap.Interface to allow for a priority queue based on a custom priority map; see heap.Interface for usage

func NewPriorityNodeQueue

func NewPriorityNodeQueue(start environments.Node, priorityMap map[string]int, config PriorityNodeQueueConfig) *PriorityNodeQueue

NewPriorityNodeQueue initializes a priority queue with the provided start node and priority map to use

func (*PriorityNodeQueue) Len

func (q *PriorityNodeQueue) Len() int

func (*PriorityNodeQueue) Less

func (q *PriorityNodeQueue) Less(i, j int) bool

func (*PriorityNodeQueue) Pop

func (q *PriorityNodeQueue) Pop() interface{}

Pop returns the value with the lowest

func (*PriorityNodeQueue) Push

func (q *PriorityNodeQueue) Push(x interface{})

Push adds a new value

func (*PriorityNodeQueue) Swap

func (q *PriorityNodeQueue) Swap(i, j int)

type PriorityNodeQueueConfig

type PriorityNodeQueueConfig struct {
	HigherIsBetter bool
}

PriorityNodeQueueConfig defines optional arguments when creating a priority node queue

type RecursiveBestFirstSearch

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

RecursiveBestFirstSearch implements the RBFS, a modification and/or optimization of A*

func (RecursiveBestFirstSearch) Run

Run runs A* on the environment and returns the result

type UniformCost

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

UniformCost implements the uniform cost search algorithm

func (UniformCost) Run

Run runs A* on the environment and returns the result

Jump to

Keyboard shortcuts

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