aco

package
v0.0.0-...-198821d Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ant

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

func NewAnt

func NewAnt(c *Colony) *Ant

func (*Ant) Run

func (p *Ant) Run()

func (*Ant) SetWalk

func (p *Ant) SetWalk(data []int)

func (*Ant) Tour

func (p *Ant) Tour(t int)

type Ants

type Ants []*Ant

type Colony

type Colony struct {
	Alpha         float64
	Beta          float64
	Pho           float64
	Q             float64
	BasePheromone float64

	Problem tsp.TSP

	Population Ants

	IsQuick     bool
	IsMakeImage bool
	// contains filtered or unexported fields
}

func NewColony

func NewColony(popSize, maxIterations int, alpha, beta, pho, ip, q float64, p tsp.TSP) *Colony

func (*Colony) CalculateWalkLength

func (p *Colony) CalculateWalkLength(walk []int) int

func (*Colony) GetBest

func (p *Colony) GetBest() []int

func (*Colony) GetBestLength

func (p *Colony) GetBestLength() int

func (*Colony) GetPheromon

func (p *Colony) GetPheromon(i, j int) float64

func (*Colony) Run

func (p *Colony) Run()

func (*Colony) SetPheromon

func (p *Colony) SetPheromon(i, j int, data float64)

type Message

type Message struct {
	// contains filtered or unexported fields
}
func (as Ants)  Len() int{
	return len(as)
}
func (as Ants)  Less(i, j int) bool{
	return as[i].walkLength()<as[j].walkLength
}
func (as Ants)  Swap(i, j int){
	as[i],as[j]=as[j],as[i]
	as[i].idx,as[j].idx=as[j].idx,as[i].idx
}

Jump to

Keyboard shortcuts

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