runtime

package
v0.0.0-...-890eb65 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(m Model)

Init initializes the boosd runtime.

Types

type BaseModel

type BaseModel struct {
	MName    string
	Vars     VarMap
	Defaults DefaultMap
	Tables   map[string]Table
}

func (*BaseModel) Attr

func (m *BaseModel) Attr(name string) interface{}

func (*BaseModel) Default

func (m *BaseModel) Default(name string) (v float64, ok bool)

func (*BaseModel) Name

func (m *BaseModel) Name() string

func (*BaseModel) Var

func (m *BaseModel) Var(name string) (Var, bool)

func (*BaseModel) VarInfo

func (m *BaseModel) VarInfo(name string) map[string]interface{}

func (*BaseModel) VarNames

func (m *BaseModel) VarNames() []string

type BaseSim

type BaseSim struct {
	Parent Model
	Time   Timespec

	Coord Coordinator

	InstanceName string
	VarNames     map[string]string
	SubSims      map[string]BaseSim

	Series []Data

	Tables map[string]Table
	Curr   Data
	Next   Data

	// Calc{Flows,Stocks} are used by the RunTo* functions
	CalcInitial func(dt float64)
	CalcFlows   func(dt float64)
	CalcStocks  func(dt float64)
	// contains filtered or unexported fields
}

func (*BaseSim) Init

func (s *BaseSim) Init(m Model, ts Timespec, tables map[string]Table)

func (*BaseSim) Model

func (s *BaseSim) Model() Model

func (*BaseSim) RunTo

func (s *BaseSim) RunTo(t float64) error

RunTo currently implements the Euler method

func (*BaseSim) RunToEnd

func (s *BaseSim) RunToEnd() error

func (*BaseSim) SetValue

func (s *BaseSim) SetValue(name string, val float64) error

func (*BaseSim) Value

func (s *BaseSim) Value(name string) (v float64, err error)

func (*BaseSim) ValueSeries

func (s *BaseSim) ValueSeries(name string) (r [2][]float64, err error)

type Coordinator

type Coordinator interface {
	Data(s Sim, name string) float64
	Close() error
}

a coordinator is the syncronization point between model instances and provider of gaming variables.

func NewCoordinator

func NewCoordinator() Coordinator

type Data

type Data map[string]float64

type DefaultMap

type DefaultMap map[string]float64

type Model

type Model interface {
	Name() string
	NewSim(iName string, c Coordinator) Sim
	Attr(name string) interface{}
	VarNames() []string
	Var(name string) (Var, bool)
	VarInfo(name string) map[string]interface{}
	Default(name string) (float64, bool)
}

type ModelMap

type ModelMap map[string]map[string]string

type Sim

type Sim interface {
	Model() Model

	RunTo(t float64) error
	RunToEnd() error

	Value(name string) (float64, error)
	ValueSeries(name string) ([2][]float64, error)

	SetValue(name string, val float64) error
}

type Table

type Table [2][]float64

TODO: define useful methods on table

func (Table) Lookup

func (t Table) Lookup(index float64) float64

type Timespec

type Timespec struct {
	Start    float64
	End      float64
	DT       float64
	SaveStep float64
}

type Var

type Var struct {
	Name string
	Type VarType
}

type VarMap

type VarMap map[string]Var

func (VarMap) InstanceMap

func (vm VarMap) InstanceMap(iName string) map[string]string

type VarType

type VarType int
const (
	TyAux     VarType = iota
	TyStock   VarType = iota
	TyFlow    VarType = iota
	TyTable   VarType = iota
	TyConst   VarType = iota
	TyUnknown VarType = iota
)

func TypeForName

func TypeForName(n string) VarType

func (VarType) String

func (vt VarType) String() string

Jump to

Keyboard shortcuts

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