rl

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interpreter

type Interpreter interface {
	RewardFunc(State, *strategies.Action) float64
	Interpret(*types.Event, *strategies.Context) State
	Actions(State, *strategies.Context) []*strategies.Action
}

type Policy

type Policy interface {
	NextAction(*StateActionMap, State, []*strategies.Action) (*strategies.Action, bool)
}

type RLStrategy

type RLStrategy struct {
	*types.BaseService
	// contains filtered or unexported fields
}

func NewRLStrategy

func NewRLStrategy(config *RLStrategyConfig) (*RLStrategy, error)

func (*RLStrategy) ActionsCh

func (r *RLStrategy) ActionsCh() *types.Channel[*strategies.Action]

func (*RLStrategy) EndCurIteration

func (r *RLStrategy) EndCurIteration(ctx *strategies.Context)

func (*RLStrategy) Finalize

func (r *RLStrategy) Finalize(_ *strategies.Context)

func (*RLStrategy) NextIteration

func (r *RLStrategy) NextIteration(_ *strategies.Context)

func (*RLStrategy) Start

func (r *RLStrategy) Start() error

func (*RLStrategy) Step

func (r *RLStrategy) Step(e *types.Event, ctx *strategies.Context)

func (*RLStrategy) Stop

func (r *RLStrategy) Stop() error

type RLStrategyConfig

type RLStrategyConfig struct {
	Alpha       float64
	Gamma       float64
	Interpreter Interpreter
	Policy      Policy
}

type SimpleInterpreter

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

func NewSimpleInterpreter

func NewSimpleInterpreter() *SimpleInterpreter

func (*SimpleInterpreter) Actions

func (s *SimpleInterpreter) Actions(state State, ctx *strategies.Context) []*strategies.Action

func (*SimpleInterpreter) Interpret

func (s *SimpleInterpreter) Interpret(e *types.Event, ctx *strategies.Context) State

func (*SimpleInterpreter) RewardFunc

func (s *SimpleInterpreter) RewardFunc(_ State, _ *strategies.Action) float64

type SimpleInterpreterState

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

func (*SimpleInterpreterState) Hash

func (s *SimpleInterpreterState) Hash() string

type SoftMaxPolicy

type SoftMaxPolicy struct {
}

func NewSoftMaxPolicy

func NewSoftMaxPolicy() *SoftMaxPolicy

func (*SoftMaxPolicy) NextAction

func (p *SoftMaxPolicy) NextAction(saMap *StateActionMap, state State, actions []*strategies.Action) (*strategies.Action, bool)

type State

type State interface {
	Hash() string
}

type StateActionMap

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

func (*StateActionMap) AddState

func (s *StateActionMap) AddState(state State)

func (*StateActionMap) ExistsValue

func (s *StateActionMap) ExistsValue(state, action string) bool

func (*StateActionMap) Get

func (s *StateActionMap) Get(state, action string) (float64, bool)

func (*StateActionMap) GetState

func (s *StateActionMap) GetState(key string) (State, bool)

func (*StateActionMap) MaxQ

func (s *StateActionMap) MaxQ(state string) (float64, bool)

func (*StateActionMap) Update

func (s *StateActionMap) Update(state, action string, val float64)

Jump to

Keyboard shortcuts

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