Documentation ¶
Index ¶
- Constants
- Variables
- func GetDeltaCount()
- func GetLastState() system.SystemState
- func SetBurner(b *gpio.Pin)
- func SetLastState(s system.SystemState)
- func SetPumpH(p *system.Pump)
- func SetPumpW(p *system.Pump)
- type ADPState
- func (s *ADPState) CompareTo(sPrime system.State) int
- func (a *ADPState) CreateRelation()
- func (a *ADPState) Delete()
- func (s *ADPState) Equals(sPrime system.State) bool
- func (a *ADPState) GetRelationName() string
- func (a *ADPState) Insert(val ...interface{})
- func (s *ADPState) Reward(a *system.Action, sPrime system.State) system.Reward
- func (s *ADPState) String() string
- func (s *ADPState) Successor(a *system.Action) system.State
- func (s *ADPState) Terminal() bool
- func (a *ADPState) Update(val ...interface{})
- type ActionPicker
- type Agent
- type AiState
- type CountTable
- type HashLookupTable
- type HeatingAgent
- type Model
- type Policy
- type QStateTable
- type ReflexAction
- type ReflexAgent
- func (agent *ReflexAgent) CalculateAction(percept *system.Percept, reward system.Reward) (action *system.Action, log bool)
- func (agent *ReflexAgent) GetBurnerState(*system.Action) bool
- func (agent *ReflexAgent) GetCurrentHStartingTemp(percept *system.Percept) int
- func (agent *ReflexAgent) GetCurrentWStartingTemp(percept *system.Percept) int
- func (agent *ReflexAgent) GetHPumpThrottle(*system.Action) float64
- func (r *ReflexAgent) GetStateHash()
- func (agent *ReflexAgent) GetWPumpThrottle(*system.Action) float64
- func (r *ReflexAgent) InitProcessPerceptData(p *system.Percept, vals ...int) (s *ReflexState)
- func (r *ReflexAgent) PassiveAdpLearning(p *system.Percept, rPrime system.Reward) (a *system.Action, log bool)
- func (r *ReflexAgent) PrintData()
- func (r *ReflexAgent) PrintSeq()
- func (r *ReflexAgent) ResetReflexAgent()
- func (r *ReflexAgent) SetLastAction(a *system.Action)
- type ReflexState
- func (s *ReflexState) CompareTo(sPrime system.State) int
- func (s *ReflexState) Equals(sPrime system.State) bool
- func (s *ReflexState) GetIdentifier() (hash string)
- func (s *ReflexState) Reward(a *system.Action, sPrime system.State) system.Reward
- func (s *ReflexState) SetBurnerVal(number int)
- func (s *ReflexState) SetWPumpVal(number int)
- func (s *ReflexState) Successor(a *system.Action) system.State
- func (s *ReflexState) Terminal() bool
- type ReflexStateActionHash
- type ReflexStateHash
- type RewardFunction
- type SimpleHeatingAgent
- type StateGenerator
- type StateID
- type TransitionTable
- type UtilityFunction
Constants ¶
View Source
const ( BOILER_TARGET_FALLBACK = 40000 BOILER_MAX_TOP = 45000 )
Variables ¶
View Source
var ( Potential_Count = [1000][1000]int{} Test = "String" )
Functions ¶
func GetDeltaCount ¶
func GetDeltaCount()
func (r *ReflexAgent) ProcessNewState(s *ReflexState)(){ if r.previousState == nil { r.previousState = s r.previousAction = s.action r.seqBeginningState = s s.wEnergyRequirement = 0 } else { if r.seqBeginningState.action != nil { if s.action.GetBurnerState() != r.previousState.action.GetBurnerState() || s.action.GetWPumpState() != r.previousState.action.GetWPumpState() { r.seqBeginningState = s } else { if !(r.previousAction.GetBurnerState() || r.previousAction.GetWPumpState()) { e := base_delta_transitions[fmt.Sprintf("BT:%d x DE:%d",r.previousState.Percept.BoilerMidTemp.GetValue(),r.previousState.boilerDeltaSince)][s.wEnergyRequirement] var t int for _,count := range base_delta_transitions[fmt.Sprintf("BT:%d x DE:%d",r.previousState.Percept.BoilerMidTemp.GetValue(),r.previousState.boilerDeltaSince)] { t += count } ae := delta_transitions[fmt.Sprintf("BT:%d x DE:%d",r.previousState.Percept.BoilerMidTemp.GetValue(),r.previousState.boilerDeltaSince)][s.wEnergyRequirement] var at int for _,count := range delta_transitions[fmt.Sprintf("BT:%d x DE:%d",r.previousState.Percept.BoilerMidTemp.GetValue(),r.previousState.boilerDeltaSince)] { at += count } if t == 0 { t=1 e=0 } fmt.Printf("%v\t%.2f (night)\t%.2f (all)\t[%d>%d]",r.previousState.Percept.CurrentTime,100.0*float64(e)/float64(t),100.0*float64(ae)/float64(at),r.previousState.wEnergyRequirement,s.wEnergyRequirement) npb := base_potential_transitions[r.previousState.wEnergyPotential][s.wEnergyPotential] var npt int for _,count := range base_potential_transitions[r.previousState.wEnergyPotential] { npt += count } pab := potential_transitions[r.previousState.wEnergyPotential][s.wEnergyPotential] var pat int for _,count := range potential_transitions[r.previousState.wEnergyPotential] { pat += count } if t > 0 { fmt.Printf("\t%.2f (night)\t%.2f (all)\t[%d>%d]\n",100.0*float64(npb)/float64(npt),100.0*float64(pab)/float64(pat),r.previousState.wEnergyPotential,s.wEnergyPotential) } } } } r.previousState = s r.previousAction = s.action } }
func GetLastState ¶
func GetLastState() system.SystemState
func SetLastState ¶
func SetLastState(s system.SystemState)
func SetPumpW ¶
type Percept struct { //logger.Relation CurrentTime time.Time OutsideTemp, BoilerMidTemp, BoilerTopTemp, KettleTemp, HForeRunTemp, HReverseRunTemp, WForeRunTemp, WReverseRunTemp, WIntakeTemp *w1.Temperature Valid bool }
func (p *Percept) String()(string){ var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("\nPercept at:\t%s\n",p.CurrentTime.String())) buffer.WriteString(fmt.Sprintf("Outside Temperature Value:\t%d\t(%v)\n",p.OutsideTemp.GetValue(),p.OutsideTemp.IsValid())) buffer.WriteString(fmt.Sprintf("BoilerTopTemp Temperature Value:\t%d\t(%v)\n",p.BoilerTopTemp.GetValue(),p.BoilerTopTemp.IsValid())) buffer.WriteString(fmt.Sprintf("BoilerMidTemp Temperature Value:\t%d\t(%v)\n",p.BoilerMidTemp.GetValue(),p.BoilerMidTemp.IsValid())) buffer.WriteString(fmt.Sprintf("KettleTemp Temperature Value:\t%d\t(%v)\n",p.KettleTemp.GetValue(),p.KettleTemp.IsValid())) buffer.WriteString(fmt.Sprintf("HForeRun Temperature Value:\t%d\t(%v)\n",p.HForeRunTemp.GetValue(),p.HForeRunTemp.IsValid())) buffer.WriteString(fmt.Sprintf("HReverse Temperature Value:\t%d\t(%v)\n",p.HReverseRunTemp.GetValue(),p.HReverseRunTemp.IsValid())) buffer.WriteString(fmt.Sprintf("WForeRun Temperature Value:\t%d\t(%v)\n",p.WForeRunTemp.GetValue(),p.WForeRunTemp.IsValid())) buffer.WriteString(fmt.Sprintf("WReverse Temperature Value:\t%d\t(%v)\n",p.WReverseRunTemp.GetValue(),p.WReverseRunTemp.IsValid())) buffer.WriteString(fmt.Sprintln()) return buffer.String() }
func (p *Percept) GetRelationName()(string) { return PERCEPT_TABLE }
func (p *Percept) CreateRelation()() { var stmnt_string string stmnt_string = fmt.Sprintf( "CREATE TABLE IF NOT EXISTS %s(" + "p_id INT NOT NULL AUTO_INCREMENT," + "OutsideTemp INT SIGNED NULL DEFAULT 0," + "BoilerMidTemp INT SIGNED NULL DEFAULT 0," + "BoilerTopTemp INT SIGNED NULL DEFAULT 0," + "KettleTemp INT SIGNED NULL DEFAULT 0," + "H1ForeRunTemp INT SIGNED NULL DEFAULT 0," + "H1ReverseRunTemp INT SIGNED NULL DEFAULT 0," + "H2ForeRunTemp INT SIGNED NULL DEFAULT 0," + "WForeRunTemp INT SIGNED NULL DEFAULT 0," + "WReverseRunTemp INT SIGNED NULL DEFAULT 0," + "PRIMARY KEY(p_id)," + "UNIQUE value_key (OutsideTemp,BoilerMidTemp,BoilerTopTemp,KettleTemp,H1ForeRunTemp,H1ReverseRunTemp,H2ForeRunTemp,WForeRunTemp,WReverseRunTemp)" + ")ENGINE=InnoDB DEFAULT CHARSET=latin1", p.GetRelationName()) logger.StatementExecute(stmnt_string) }
func (p *Percept) Insert(val ...interface{})() { var stmnt_string string stmnt_string = fmt.Sprintf( "INSERT IGNORE INTO %s" + "(OutsideTemp,BoilerMidTemp,BoilerTopTemp,KettleTemp,H1ForeRunTemp,H1ReverseRunTemp,H2ForeRunTemp,WForeRunTemp,WReverseRunTemp)" + " VALUES " + "(%d,%d,%d,%d,%d,%d,%d,%d,%d)", p.GetRelationName(),p.OutsideTemp.GetValue(),p.BoilerMidTemp.GetValue(),p.BoilerTopTemp.GetValue(),p.KettleTemp.GetValue(),p.HForeRunTemp.GetValue(),p.HReverseRunTemp.GetValue(),p.WIntakeTemp.GetValue(),p.WForeRunTemp.GetValue(),p.WReverseRunTemp.GetValue()) logger.StatementExecute(stmnt_string) }
func (p *Percept) Delete()() { //@todo }
func (p *Percept) Update(val ...interface{})() { //@todo }
func (p *Percept) getBoilerDelta(successor *Percept)(tempDelta int,recordingDuration time.Duration){ if successor == nil { return } else { tempDelta = p.BoilerMidTemp.GetValue() - successor.BoilerMidTemp.GetValue() recordingDuration = p.CurrentTime.Sub(successor.CurrentTime) } return }
func (p *Percept) getKettleDelta(successor *Percept)(tempDelta int,recordingDuration time.Duration){ if successor == nil { return } else { tempDelta = p.KettleTemp.GetValue() - successor.KettleTemp.GetValue() recordingDuration = p.CurrentTime.Sub(successor.CurrentTime) } return }
func (p *Percept) checkValidity()(bool){ return true }
Types ¶
type ADPState ¶
type ADPState struct { AiState // contains filtered or unexported fields }
func (*ADPState) CreateRelation ¶
func (a *ADPState) CreateRelation()
func (*ADPState) GetRelationName ¶
type ActionPicker ¶
type CountTable ¶
type CountTable map[ReflexStateHash]int
type HashLookupTable ¶
type HashLookupTable map[ReflexStateHash]AiState
type Model ¶
type Model map[ReflexStateActionHash]map[ReflexStateHash]float64
type QStateTable ¶
type QStateTable map[ReflexStateActionHash]int
type ReflexAction ¶
func (*ReflexAction) RollOut ¶
func (a *ReflexAction) RollOut()
type ReflexAgent ¶
type ReflexAgent struct { Agent // contains filtered or unexported fields }
func NewADPAgent ¶
func NewADPAgent(a *system.Action) (r *ReflexAgent)
func NewReflexAgent ¶
func NewReflexAgent(a *system.Action) (r *ReflexAgent)
func (*ReflexAgent) CalculateAction ¶
func (agent *ReflexAgent) CalculateAction(percept *system.Percept, reward system.Reward) (action *system.Action, log bool)
*
- Agent Interface functions
func (*ReflexAgent) GetBurnerState ¶
func (agent *ReflexAgent) GetBurnerState(*system.Action) bool
func (*ReflexAgent) GetCurrentHStartingTemp ¶
func (agent *ReflexAgent) GetCurrentHStartingTemp(percept *system.Percept) int
func (*ReflexAgent) GetCurrentWStartingTemp ¶
func (agent *ReflexAgent) GetCurrentWStartingTemp(percept *system.Percept) int
func (*ReflexAgent) GetHPumpThrottle ¶
func (agent *ReflexAgent) GetHPumpThrottle(*system.Action) float64
func (*ReflexAgent) GetStateHash ¶
func (r *ReflexAgent) GetStateHash()
func (*ReflexAgent) GetWPumpThrottle ¶
func (agent *ReflexAgent) GetWPumpThrottle(*system.Action) float64
func (*ReflexAgent) InitProcessPerceptData ¶
func (r *ReflexAgent) InitProcessPerceptData(p *system.Percept, vals ...int) (s *ReflexState)
func (*ReflexAgent) PassiveAdpLearning ¶
func (*ReflexAgent) PrintData ¶
func (r *ReflexAgent) PrintData()
func (*ReflexAgent) PrintSeq ¶
func (r *ReflexAgent) PrintSeq()
func (*ReflexAgent) ResetReflexAgent ¶
func (r *ReflexAgent) ResetReflexAgent()
func (*ReflexAgent) SetLastAction ¶
func (r *ReflexAgent) SetLastAction(a *system.Action)
type ReflexState ¶
type ReflexState struct { AiState Percept *system.Percept // contains filtered or unexported fields }
func (*ReflexState) GetIdentifier ¶
func (s *ReflexState) GetIdentifier() (hash string)
func (*ReflexState) SetBurnerVal ¶
func (s *ReflexState) SetBurnerVal(number int)
func (*ReflexState) SetWPumpVal ¶
func (s *ReflexState) SetWPumpVal(number int)
func (*ReflexState) Terminal ¶
func (s *ReflexState) Terminal() bool
type ReflexStateActionHash ¶
type ReflexStateActionHash string
type ReflexStateHash ¶
type ReflexStateHash string
type RewardFunction ¶
type RewardFunction map[ReflexStateHash]system.Reward
type SimpleHeatingAgent ¶
type SimpleHeatingAgent struct {
// contains filtered or unexported fields
}
func NewSimpleHeatingAgent ¶
func NewSimpleHeatingAgent(config_oracle_available bool) (a *SimpleHeatingAgent)
type StateGenerator ¶
type TransitionTable ¶
type TransitionTable map[ReflexStateActionHash]map[ReflexStateHash]int
type UtilityFunction ¶
type UtilityFunction map[ReflexStateHash]float64
Click to show internal directories.
Click to hide internal directories.