multimode

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

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

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

Documentation

Overview

Package multimode is a multimode function with noise

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fun

type Fun struct {
	Tc          float64
	SigmaMargin float64
	// contains filtered or unexported fields
}

Fun is the multimode cost function to be minimized.

func (*Fun) About

func (f *Fun) About() (s string)

About gives a description of the cost function

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 evaluates costvalue

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 da

func (*Fun) MaxLen

func (f *Fun) MaxLen() (maxlen int)

MaxLen maximum number of bits in the parameter big integer which is the maximum number of elements in the subset

type FunTry

type FunTry = futil.SFloatTry

FunTry gives the try structure to use

type FunTryData

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

FunTryData is the decoded data structure for a try giving the x coordinate of the function evaluation

func (*FunTryData) Decode

func (d *FunTryData) Decode() string

Decode requests the function to give a meaningful interpretation of d

type SFloatFunStub

type SFloatFunStub = futil.SFloatFunStub

SFloatFunStub gives interface to setpso

func NewFun

func NewFun(nMode, nbits int, margin, sigma float64,
	Tc, SigmaMargin float64, fsd int64) *SFloatFunStub

NewFun creates Fun. Fun is in the range [0,1) to be minimized. it is of the form

y=slope*x + bias -sin(w*x) +noise

w is chosen to give nMode local minima slope is chosen to give a difference of margin between local minima and bias is chosen so that the first minimum has the value 0. The noise has zero mean and standard deviation sigma. nbits is the number of bits used to represent x as a parameter to optimise. margin must be less than 2Pi. For cost values it uses futil.SFloatCostValue so needs: Tc -- time constant of statistics in number of cost value updates

Example
nMode := 2
nbits := 16
margin := 1.0
sigma := 0.0
Tc := 100.0
SigmaMargin := 2.0

f := NewFun(nMode, nbits, margin, sigma,
	Tc, SigmaMargin, 3142)
fmt.Print(f.About())

z := new(big.Int)
z.SetInt64(9811)
t := f.NewTry()
f.SetTry(t, z)
for i := 0; i < 200; i++ {
	f.UpdateCost(t)
}
fmt.Printf(" %s \n", t.Decode())
fmt.Printf("Param= %v\n", t.Parameter())
fmt.Printf(" %s", t.Cost())

/* Output:
 *//
Output:

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