Version: v0.0.0-...-fcde085 Latest Latest

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

Go to latest
Published: Oct 19, 2020 License: LGPL-2.1 Imports: 9 Imported by: 0



Package lincircles provides method for packing circles on a straight line using a packing cost



This section is empty.


This section is empty.


This section is empty.


type Animator

type Animator struct {
	// contains filtered or unexported fields

Animator works with psokit to generate an HTML file that gives an animation of used circles of global best during the run.

func NewAnimator

func NewAnimator(skipLen, dispSize int) *Animator

NewAnimator creates an animation of the personal best used circles

func (*Animator) DataUpdate

func (ac *Animator) DataUpdate(man *psokit.ManPso)

DataUpdate stores used circles of personal best

func (*Animator) Result

func (ac *Animator) Result(man *psokit.ManPso)

Result outputs the stored used circles as an animation

func (*Animator) RunInit

func (ac *Animator) RunInit(man *psokit.ManPso)

RunInit initializes it for a run

type Circle

type Circle struct {
	// contains filtered or unexported fields

Circle is the type used to represent a packing

type FloatFunStub

type FloatFunStub = futil.FloatFunStub

FloatFunStub gives interface to setpso

func New

func New(radius float64, innerFuzz, outerFuzz float64, valueNbits int, birthBonus float64) *FloatFunStub

New generates a circle packing cost function suitable for SPSO. 'radius' is the radius of the circles to be packed; 'innerFuzz' is reducing factor on 'radius' to get rejection radius 'outerFuzz' is increasing factor on 'radius' to get maximum influence radius // 'value. Nbits' is the number of bits used to locate a coordinate of a packed circle. 'birthBonus' is the reduction of cost due to including a circle

type Fun

type Fun struct {
	// contains filtered or unexported fields

Fun is the circles packaging cost function

func (*Fun) About

func (f *Fun) About() string

About returns a string description of the contents of Fun

func (*Fun) Constraint

func (f *Fun) Constraint(pre TryData, hint *big.Int) (valid bool)

Constraint attempts to constrain hint possibly using a copy of pre to do this

func (*Fun) CopyData

func (f *Fun) CopyData(dest, src TryData)

CopyData copies src to dest

func (*Fun) Cost

func (f *Fun) Cost(data TryData) (cost float64)

Cost returns the remainder after dividing p in to the prime product

func (*Fun) CreateData

func (f *Fun) CreateData() TryData

CreateData creates a empty structure for decoded try

func (*Fun) DefaultParam

func (f *Fun) DefaultParam() *big.Int

DefaultParam gives a default that satisfies constraints

func (*Fun) Delete

func (f *Fun) Delete(i int) bool

Delete hints to the function to remove/replace the ith item

func (*Fun) IDecode

func (f *Fun) IDecode(data TryData, z *big.Int)

IDecode decodes z into d

func (*Fun) Len

func (f *Fun) Len() int

Len gives the maximum number of circles in each try

func (*Fun) MaxLen

func (f *Fun) MaxLen() int

MaxLen returns the number of elements in the subset sum problem

type FunTry

type FunTry = futil.FloatTry

FunTry gives the try structure to use

type FunTryData

type FunTryData struct {
	UsedCircles []Circle
	// contains filtered or unexported fields

FunTryData is the decoded data structure for a try

func (*FunTryData) Circles

func (d *FunTryData) Circles() []Circle

Circles returns the array of used circles

func (*FunTryData) Decode

func (d *FunTryData) Decode() string

Decode requests the function to give a meaningful interpretation of d.

type Store

type Store struct {
	// contains filtered or unexported fields

Store stores circles for plotting

func NewStore

func NewStore(dataLen, skipLen, nCircles, dispSize int) *Store

NewStore creates a circle store assuming dataLen data points but with a skipLen skip interval on this data each snapshot storing at most nCircles; dispSize is the size of animation display in pixels.

func (*Store) Animate

func (cs *Store) Animate() string

Animate generates a data string for animation

func (*Store) Append

func (cs *Store) Append(circles []Circle)

Append appends some circles transformed for display followed by a zero entry as an end marker to the list

func (*Store) Clear

func (cs *Store) Clear()

Clear empties the circle store

type Try

type Try = setpso.Try

Try is the try interface used by setpso

type TryData

type TryData = futil.TryData

TryData is the interface for FunTryData used in package futil

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL