base

package
Version: v0.0.0-...-e3ff730 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

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

City : coordinates of city

func GenerateCity

func GenerateCity(x int, y int) City

GenerateCity : Generate city with user defined coordinates

func GenerateRandomCity

func GenerateRandomCity() City

GenerateRandomCity : Generate city with random coordinates

func ShuffleCities

func ShuffleCities(in []City) []City

ShuffleCities : return a shuffled []City given input []City

func (*City) DistanceTo

func (a *City) DistanceTo(c City) float64

DistanceTo : distance of current city to target city

func (*City) SetLocation

func (a *City) SetLocation(x int, y int)

SetLocation : User defined coordinates for a city

func (City) String

func (a City) String() string

func (*City) X

func (a *City) X() int

func (*City) Y

func (a *City) Y() int

type Population

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

func (*Population) GetFittest

func (a *Population) GetFittest() *Tour

func (*Population) GetTour

func (a *Population) GetTour(i int) *Tour

func (*Population) InitEmpty

func (a *Population) InitEmpty(pSize int)

func (*Population) InitPopulation

func (a *Population) InitPopulation(pSize int, tm TourManager)

func (*Population) PopulationSize

func (a *Population) PopulationSize() int

func (*Population) SaveTour

func (a *Population) SaveTour(i int, t Tour)

type Tour

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

func (*Tour) ContainCity

func (a *Tour) ContainCity(c City) bool

func (*Tour) Fitness

func (a *Tour) Fitness() float64

func (*Tour) GetCity

func (a *Tour) GetCity(tourPosition int) City

GetCity : Get city based on position in slice

func (*Tour) InitTour

func (a *Tour) InitTour(numberOfCities int)

InitTour : Initialize tour with cities arranged randomly

func (*Tour) InitTourCities

func (a *Tour) InitTourCities(tm TourManager)

InitTourCities

func (*Tour) ResetFitnessDistance

func (a *Tour) ResetFitnessDistance()

func (*Tour) SetCity

func (a *Tour) SetCity(tourPosition int, c City)

SetCity : Set position of city in tour slice

func (Tour) String

func (a Tour) String() string

func (*Tour) TourDistance

func (a *Tour) TourDistance() float64

TourDistance : Calculates total distance traveled for this tour

func (*Tour) TourSize

func (a *Tour) TourSize() int

type TourManager

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

ToueManager : Contains list of of cities to be visited

func (*TourManager) AddCity

func (a *TourManager) AddCity(c City)

func (*TourManager) GetCity

func (a *TourManager) GetCity(i int) City

func (*TourManager) NewTourManager

func (a *TourManager) NewTourManager()

NewTourManager : Initialize TourManager

func (*TourManager) NumberOfCities

func (a *TourManager) NumberOfCities() int

Jump to

Keyboard shortcuts

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