Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateSwarmSize(dim, max_size int) int
- func EvalGriewank(vec []float64) float64
- func EvalRosenbrock(vec []float64) float64
- func EvalSphere(vec []float64) float64
- func NewJSONDataConverter() converter.DataConverter
- func PSOWorkflow(ctx workflow.Context, functionName string) (string, error)
- type ObjectiveFunction
- type Particle
- type ParticleResult
- type Position
- type Swarm
- type SwarmSettings
- type Vector
- type WorkflowResult
Constants ¶
View Source
const ( InitParticleActivityName = "initParticleActivityName" UpdateParticleActivityName = "updateParticleActivityName" )
*
- Sample activities used by file processing sample workflow.
View Source
const ContinueAsNewStr = "CONTINUEASNEW"
Variables ¶
View Source
var ActivityOptions = workflow.ActivityOptions{ ScheduleToStartTimeout: time.Second * 5, StartToCloseTimeout: time.Minute * 10, HeartbeatTimeout: time.Second * 2, RetryPolicy: &temporal.RetryPolicy{ InitialInterval: time.Second, BackoffCoefficient: 2.0, MaximumInterval: time.Minute, MaximumAttempts: 5, }, }
ActivityOptions can be reused
View Source
var Griewank = ObjectiveFunction{ Goal: 1e-5, Evaluate: EvalGriewank, // contains filtered or unexported fields }
View Source
var Rosenbrock = ObjectiveFunction{ Goal: 1e-5, Evaluate: EvalRosenbrock, // contains filtered or unexported fields }
View Source
var Sphere = ObjectiveFunction{ Goal: 1e-5, Evaluate: EvalSphere, // contains filtered or unexported fields }
Functions ¶
func CalculateSwarmSize ¶
func EvalGriewank ¶
func EvalRosenbrock ¶
func EvalSphere ¶
func NewJSONDataConverter ¶
func NewJSONDataConverter() converter.DataConverter
NewJSONDataConverter creates a json data converter
Types ¶
type ObjectiveFunction ¶
type ObjectiveFunction struct { Goal float64 // optimization goal (error threshold) Evaluate func(vec []float64) float64 // the objective function // contains filtered or unexported fields }
func FunctionFactory ¶
func FunctionFactory(functionName string) ObjectiveFunction
type Particle ¶
func InitParticleActivity ¶
func NewParticle ¶
func UpdateParticleActivity ¶
func (*Particle) UpdateFitness ¶
func (*Particle) UpdateLocation ¶
type ParticleResult ¶
type Position ¶
func NewPosition ¶
func RandomPosition ¶
func RandomPosition(function ObjectiveFunction, rng *rand.Rand) *Position
func (*Position) IsBetterThan ¶
type Swarm ¶
type Swarm struct { Settings *SwarmSettings Gbest *Position Particles []*Particle }
type SwarmSettings ¶
type SwarmSettings struct { FunctionName string // swarm size (number of particles) Size int // ... N steps (set to 0 for no output) PrintEvery int // Steps after issuing a ContinueAsNew, to reduce history size ContinueAsNewEvery int // maximum number of iterations Steps int // cognitive coefficient C1 float64 // social coefficient C2 float64 // max inertia weight value InertiaMax float64 // min inertia weight value InertiaMin float64 // whether to keep particle position within defined bounds (TRUE) // or apply periodic boundary conditions (FALSE) ClampPosition bool Inertia float64 // current inertia weight value // contains filtered or unexported fields }
func PSODefaultSettings ¶
func PSODefaultSettings(functionName string) *SwarmSettings
type WorkflowResult ¶
type WorkflowResult struct { Msg string // Uppercase the members otherwise serialization won't work! Success bool }
func PSOChildWorkflow ¶
PSOChildWorkflow workflow definition Returns true if the optimization has converged
Source Files ¶
Click to show internal directories.
Click to hide internal directories.