Documentation ¶
Overview ¶
Variable package supplies generalised model variables that allow watchers of models to make decisions on those models by reacting the changes in model decision variables. Decision variables for a model are considered part of that model's public interface.
Index ¶
- Constants
- Variables
- type Bounded
- type Bounds
- type ChangeCommand
- type ChangePerPlanningUnitDecisionVariableCommand
- func (c *ChangePerPlanningUnitDecisionVariableCommand) Change() float64
- func (c *ChangePerPlanningUnitDecisionVariableCommand) Do() command.CommandStatus
- func (c *ChangePerPlanningUnitDecisionVariableCommand) DoUnguarded()
- func (c *ChangePerPlanningUnitDecisionVariableCommand) ForVariable(variable PlanningUnitDecisionVariable) *ChangePerPlanningUnitDecisionVariableCommand
- func (c *ChangePerPlanningUnitDecisionVariableCommand) InPlanningUnit(planningUnit planningunit.Id) *ChangePerPlanningUnitDecisionVariableCommand
- func (c *ChangePerPlanningUnitDecisionVariableCommand) PlanningUnit() planningunit.Id
- func (c *ChangePerPlanningUnitDecisionVariableCommand) SetChange(changeValue float64)
- func (c *ChangePerPlanningUnitDecisionVariableCommand) Undo() command.CommandStatus
- func (c *ChangePerPlanningUnitDecisionVariableCommand) UndoUnguarded()
- func (c *ChangePerPlanningUnitDecisionVariableCommand) UndoneValue() float64
- func (c *ChangePerPlanningUnitDecisionVariableCommand) Value() float64
- func (c *ChangePerPlanningUnitDecisionVariableCommand) Variable() PlanningUnitDecisionVariable
- func (c *ChangePerPlanningUnitDecisionVariableCommand) WithChange(changeValue float64) *ChangePerPlanningUnitDecisionVariableCommand
- type ContainedDecisionVariableObservers
- type ContainedDecisionVariables
- func (c *ContainedDecisionVariables) CreationOrderedVariables() UndoableDecisionVariables
- func (c *ContainedDecisionVariables) DecisionVariable(name string) DecisionVariable
- func (c *ContainedDecisionVariables) DecisionVariableChange(variableName string) float64
- func (c *ContainedDecisionVariables) DecisionVariableNames() []string
- func (c *ContainedDecisionVariables) Initialise()
- func (c *ContainedDecisionVariables) NameMappedVariables() *DecisionVariableMap
- func (c *ContainedDecisionVariables) OffersDecisionVariable(name string) bool
- type DecisionVariable
- type DecisionVariableMap
- type EncodeableDecisionVariable
- type EncodeableDecisionVariables
- type NullChangeCommand
- type Observable
- type Observer
- type PerPlanningUnitDecisionVariable
- func (v *PerPlanningUnitDecisionVariable) Initialise() *PerPlanningUnitDecisionVariable
- func (v *PerPlanningUnitDecisionVariable) NotifyObservers()
- func (v *PerPlanningUnitDecisionVariable) PlanningUnitValue(planningUnit planningunit.Id) float64
- func (v *PerPlanningUnitDecisionVariable) SetPlanningUnitValue(planningUnit planningunit.Id, newPlanningUnitValue float64)
- func (v *PerPlanningUnitDecisionVariable) ValuesPerPlanningUnit() PlanningUnitValueMap
- type PlanningUnitDecisionVariable
- type PlanningUnitValue
- type PlanningUnitValueMap
- type PlanningUnitValues
- type Precision
- type SimpleDecisionVariable
- func (v *SimpleDecisionVariable) Name() string
- func (v *SimpleDecisionVariable) Precision() Precision
- func (v *SimpleDecisionVariable) SetName(name string)
- func (v *SimpleDecisionVariable) SetPrecision(precision Precision)
- func (v *SimpleDecisionVariable) SetUnitOfMeasure(measure UnitOfMeasure)
- func (v *SimpleDecisionVariable) SetValue(value float64)
- func (v *SimpleDecisionVariable) UnitOfMeasure() UnitOfMeasure
- func (v *SimpleDecisionVariable) Value() float64
- type SimpleUndoableDecisionVariable
- func (v *SimpleUndoableDecisionVariable) ApplyDoneValue()
- func (v *SimpleUndoableDecisionVariable) ApplyUndoneValue()
- func (v *SimpleUndoableDecisionVariable) DifferenceInValues() float64
- func (v *SimpleUndoableDecisionVariable) SetUndoableChange(change float64)
- func (v *SimpleUndoableDecisionVariable) SetUndoableValue(value float64)
- func (v *SimpleUndoableDecisionVariable) UndoableValue() float64
- type UndoableDecisionVariable
- type UndoableDecisionVariables
- func (vs *UndoableDecisionVariables) AcceptAll()
- func (vs *UndoableDecisionVariables) Add(newVariables ...UndoableDecisionVariable)
- func (vs *UndoableDecisionVariables) DifferenceInValues(variableName string) float64
- func (vs *UndoableDecisionVariables) NewForName(name string)
- func (vs *UndoableDecisionVariables) RejectAll()
- func (vs *UndoableDecisionVariables) SetValue(name string, value float64)
- func (vs *UndoableDecisionVariables) Value(name string) float64
- func (vs *UndoableDecisionVariables) Variable(name string) UndoableDecisionVariable
- type UndoableValueCommand
- func (c *UndoableValueCommand) Change() float64
- func (c *UndoableValueCommand) Do() command.CommandStatus
- func (c *UndoableValueCommand) DoUnguarded()
- func (c *UndoableValueCommand) ForVariable(variable *SimpleUndoableDecisionVariable) *UndoableValueCommand
- func (c *UndoableValueCommand) SetChange(changeValue float64)
- func (c *UndoableValueCommand) SetValue(value float64)
- func (c *UndoableValueCommand) Undo() command.CommandStatus
- func (c *UndoableValueCommand) UndoUnguarded()
- func (c *UndoableValueCommand) Value() float64
- func (c *UndoableValueCommand) Variable() *SimpleUndoableDecisionVariable
- func (c *UndoableValueCommand) WithChange(changeValue float64) *UndoableValueCommand
- func (c *UndoableValueCommand) WithValue(value float64) *UndoableValueCommand
- type UnitOfMeasure
Constants ¶
const KeyNotFound = -1
const NullDecisionVariableName = "NullDecisionVariable"
Variables ¶
var NullDecisionVariable = new(nullDecisionVariable)
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds struct {
// contains filtered or unexported fields
}
func (*Bounds) BoundErrorAsText ¶
func (*Bounds) SetMaximum ¶
func (*Bounds) WithinBounds ¶
type ChangeCommand ¶
type ChangePerPlanningUnitDecisionVariableCommand ¶
type ChangePerPlanningUnitDecisionVariableCommand struct { command.BaseCommand // contains filtered or unexported fields }
func (*ChangePerPlanningUnitDecisionVariableCommand) Change ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) Change() float64
func (*ChangePerPlanningUnitDecisionVariableCommand) Do ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) Do() command.CommandStatus
func (*ChangePerPlanningUnitDecisionVariableCommand) DoUnguarded ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) DoUnguarded()
func (*ChangePerPlanningUnitDecisionVariableCommand) ForVariable ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) ForVariable(variable PlanningUnitDecisionVariable) *ChangePerPlanningUnitDecisionVariableCommand
func (*ChangePerPlanningUnitDecisionVariableCommand) InPlanningUnit ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) InPlanningUnit(planningUnit planningunit.Id) *ChangePerPlanningUnitDecisionVariableCommand
func (*ChangePerPlanningUnitDecisionVariableCommand) PlanningUnit ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) PlanningUnit() planningunit.Id
func (*ChangePerPlanningUnitDecisionVariableCommand) SetChange ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) SetChange(changeValue float64)
func (*ChangePerPlanningUnitDecisionVariableCommand) Undo ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) Undo() command.CommandStatus
func (*ChangePerPlanningUnitDecisionVariableCommand) UndoUnguarded ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) UndoUnguarded()
func (*ChangePerPlanningUnitDecisionVariableCommand) UndoneValue ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) UndoneValue() float64
func (*ChangePerPlanningUnitDecisionVariableCommand) Value ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) Value() float64
func (*ChangePerPlanningUnitDecisionVariableCommand) Variable ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) Variable() PlanningUnitDecisionVariable
func (*ChangePerPlanningUnitDecisionVariableCommand) WithChange ¶
func (c *ChangePerPlanningUnitDecisionVariableCommand) WithChange(changeValue float64) *ChangePerPlanningUnitDecisionVariableCommand
type ContainedDecisionVariableObservers ¶
type ContainedDecisionVariableObservers struct {
// contains filtered or unexported fields
}
func (*ContainedDecisionVariableObservers) Observers ¶
func (c *ContainedDecisionVariableObservers) Observers() []Observer
func (*ContainedDecisionVariableObservers) Subscribe ¶
func (c *ContainedDecisionVariableObservers) Subscribe(observers ...Observer)
type ContainedDecisionVariables ¶
type ContainedDecisionVariables struct {
UndoableDecisionVariables
}
func (*ContainedDecisionVariables) CreationOrderedVariables ¶
func (c *ContainedDecisionVariables) CreationOrderedVariables() UndoableDecisionVariables
func (*ContainedDecisionVariables) DecisionVariable ¶
func (c *ContainedDecisionVariables) DecisionVariable(name string) DecisionVariable
func (*ContainedDecisionVariables) DecisionVariableChange ¶
func (c *ContainedDecisionVariables) DecisionVariableChange(variableName string) float64
func (*ContainedDecisionVariables) DecisionVariableNames ¶
func (c *ContainedDecisionVariables) DecisionVariableNames() []string
func (*ContainedDecisionVariables) Initialise ¶
func (c *ContainedDecisionVariables) Initialise()
func (*ContainedDecisionVariables) NameMappedVariables ¶
func (c *ContainedDecisionVariables) NameMappedVariables() *DecisionVariableMap
func (*ContainedDecisionVariables) OffersDecisionVariable ¶
func (c *ContainedDecisionVariables) OffersDecisionVariable(name string) bool
type DecisionVariable ¶
type DecisionVariable interface { // Name returns the model-centric name of the DecisionVariable. // Decision variables are expected to have unique names within a model. name.Nameable Value() float64 SetValue(value float64) UnitOfMeasure() UnitOfMeasure Precision() Precision }
DecisionVariable describes an interface between a Model and any decision making logic observing the model via its decision variables. This Value of a decision Variable should be a fine-grained indicator of how well a model is doing against some objective we have for that model. There should be one decision Variable representing each objective being evaluated for a model.
type DecisionVariableMap ¶
type DecisionVariableMap map[string]DecisionVariable
func (DecisionVariableMap) SortedKeyIndex ¶
func (m DecisionVariableMap) SortedKeyIndex(key string) int
func (DecisionVariableMap) SortedKeys ¶
func (m DecisionVariableMap) SortedKeys() (keys []string)
type EncodeableDecisionVariable ¶
type EncodeableDecisionVariable struct { Name string Value float64 Measure UnitOfMeasure `json:"UnitOfMeasure"` ValuePerPlanningUnit PlanningUnitValues `json:",omitempty"` }
func MakeEncodeable ¶
func MakeEncodeable(variable DecisionVariable) EncodeableDecisionVariable
func (*EncodeableDecisionVariable) MarshalJSON ¶
func (v *EncodeableDecisionVariable) MarshalJSON() ([]byte, error)
type EncodeableDecisionVariables ¶
type EncodeableDecisionVariables []EncodeableDecisionVariable
func (EncodeableDecisionVariables) Len ¶
func (v EncodeableDecisionVariables) Len() int
func (EncodeableDecisionVariables) Less ¶
func (v EncodeableDecisionVariables) Less(i, j int) bool
func (EncodeableDecisionVariables) Swap ¶
func (v EncodeableDecisionVariables) Swap(i, j int)
type NullChangeCommand ¶
type NullChangeCommand struct{}
func (*NullChangeCommand) Change ¶
func (c *NullChangeCommand) Change() float64
func (*NullChangeCommand) Do ¶
func (c *NullChangeCommand) Do() command.CommandStatus
func (*NullChangeCommand) Reset ¶
func (c *NullChangeCommand) Reset()
func (*NullChangeCommand) SetChange ¶
func (c *NullChangeCommand) SetChange(change float64)
func (*NullChangeCommand) Undo ¶
func (c *NullChangeCommand) Undo() command.CommandStatus
func (*NullChangeCommand) Value ¶
func (c *NullChangeCommand) Value() float64
type Observable ¶
type Observable interface {
Subscribe(observers ...Observer)
}
type Observer ¶
type Observer interface {
ObserveDecisionVariable(variable DecisionVariable)
}
type PerPlanningUnitDecisionVariable ¶
type PerPlanningUnitDecisionVariable struct { SimpleDecisionVariable ContainedDecisionVariableObservers // contains filtered or unexported fields }
func NewPerPlanningUnitDecisionVariable ¶
func NewPerPlanningUnitDecisionVariable() *PerPlanningUnitDecisionVariable
func (*PerPlanningUnitDecisionVariable) Initialise ¶
func (v *PerPlanningUnitDecisionVariable) Initialise() *PerPlanningUnitDecisionVariable
func (*PerPlanningUnitDecisionVariable) NotifyObservers ¶
func (v *PerPlanningUnitDecisionVariable) NotifyObservers()
func (*PerPlanningUnitDecisionVariable) PlanningUnitValue ¶
func (v *PerPlanningUnitDecisionVariable) PlanningUnitValue(planningUnit planningunit.Id) float64
func (*PerPlanningUnitDecisionVariable) SetPlanningUnitValue ¶
func (v *PerPlanningUnitDecisionVariable) SetPlanningUnitValue(planningUnit planningunit.Id, newPlanningUnitValue float64)
func (*PerPlanningUnitDecisionVariable) ValuesPerPlanningUnit ¶
func (v *PerPlanningUnitDecisionVariable) ValuesPerPlanningUnit() PlanningUnitValueMap
type PlanningUnitDecisionVariable ¶
type PlanningUnitDecisionVariable interface { DecisionVariable ValuesPerPlanningUnit() PlanningUnitValueMap SetPlanningUnitValue(planningUnit planningunit.Id, newValue float64) PlanningUnitValue(planningUnit planningunit.Id) float64 }
type PlanningUnitValue ¶
type PlanningUnitValue struct { PlanningUnit planningunit.Id Value float64 }
type PlanningUnitValueMap ¶
type PlanningUnitValueMap map[planningunit.Id]float64
type PlanningUnitValues ¶
type PlanningUnitValues []PlanningUnitValue
func (PlanningUnitValues) Len ¶
func (v PlanningUnitValues) Len() int
func (PlanningUnitValues) Less ¶
func (v PlanningUnitValues) Less(i, j int) bool
func (PlanningUnitValues) Swap ¶
func (v PlanningUnitValues) Swap(i, j int)
type SimpleDecisionVariable ¶
type SimpleDecisionVariable struct {
// contains filtered or unexported fields
}
func NewSimpleDecisionVariable ¶
func NewSimpleDecisionVariable(name string) *SimpleDecisionVariable
func (*SimpleDecisionVariable) Name ¶
func (v *SimpleDecisionVariable) Name() string
func (*SimpleDecisionVariable) Precision ¶
func (v *SimpleDecisionVariable) Precision() Precision
func (*SimpleDecisionVariable) SetName ¶
func (v *SimpleDecisionVariable) SetName(name string)
func (*SimpleDecisionVariable) SetPrecision ¶
func (v *SimpleDecisionVariable) SetPrecision(precision Precision)
func (*SimpleDecisionVariable) SetUnitOfMeasure ¶
func (v *SimpleDecisionVariable) SetUnitOfMeasure(measure UnitOfMeasure)
func (*SimpleDecisionVariable) SetValue ¶
func (v *SimpleDecisionVariable) SetValue(value float64)
func (*SimpleDecisionVariable) UnitOfMeasure ¶
func (v *SimpleDecisionVariable) UnitOfMeasure() UnitOfMeasure
func (*SimpleDecisionVariable) Value ¶
func (v *SimpleDecisionVariable) Value() float64
type SimpleUndoableDecisionVariable ¶
type SimpleUndoableDecisionVariable struct { SimpleDecisionVariable ContainedDecisionVariableObservers // contains filtered or unexported fields }
func NewUndoableDecisionVariable ¶
func NewUndoableDecisionVariable(name string) *SimpleUndoableDecisionVariable
func (*SimpleUndoableDecisionVariable) ApplyDoneValue ¶
func (v *SimpleUndoableDecisionVariable) ApplyDoneValue()
func (*SimpleUndoableDecisionVariable) ApplyUndoneValue ¶
func (v *SimpleUndoableDecisionVariable) ApplyUndoneValue()
func (*SimpleUndoableDecisionVariable) DifferenceInValues ¶
func (v *SimpleUndoableDecisionVariable) DifferenceInValues() float64
func (*SimpleUndoableDecisionVariable) SetUndoableChange ¶
func (v *SimpleUndoableDecisionVariable) SetUndoableChange(change float64)
func (*SimpleUndoableDecisionVariable) SetUndoableValue ¶
func (v *SimpleUndoableDecisionVariable) SetUndoableValue(value float64)
func (*SimpleUndoableDecisionVariable) UndoableValue ¶
func (v *SimpleUndoableDecisionVariable) UndoableValue() float64
type UndoableDecisionVariable ¶
type UndoableDecisionVariable interface { DecisionVariable // UndoableValue returns an "inductive" Value for the variableOld. This Value cannot become the // actual (induced) Value for the variableOld without a call to ApplyDoneValue. UndoableValue() float64 // SetUndoableValue allows an "undoable"vValue for the variable to be set. This undoable Value is not the // variable's actual value. It is a Value that would result (or be induced) from, some management action change. // This Value is expected to be a temporary, lasting only as long as it takes for decision-making logic to decide // whether to accept the variable value, or reject/undo it. SetUndoableValue(value float64) // DifferenceInValues report the difference in taking the variableOld's actual Value for its inductive Value. // This difference is often used in decision making around whether to accept the inductive Value. DifferenceInValues() float64 // Accepts the inductive Value of the variableOld as the variableOld's actual Value. ApplyDoneValue() // Rejects the inductive Value of the variableOld, resetting the inductive Value to the variableOld's actual Value. ApplyUndoneValue() }
UndoableDecisionVariable is a DecisionVariable that allows an 'inductive' Value to be temporarily stored and retrieved for the decision variableOld (typically based based on some management action change). The induced Value does not become the actual Value for the decision variableOld without being explicitly accepted. The induced Value can also be rejected, which sees it revert to the actual Value of the variableOld.
type UndoableDecisionVariables ¶
type UndoableDecisionVariables []UndoableDecisionVariable
UndoableDecisionVariables offers up a name-indexed collection of UndoableDecisionVariable instances, along with convenience methods for the collection's management. It is typically expected that a model would contain only a single instance of UndoableDecisionVariables to house all of its decision variables.
func NewUndoableDecisionVariables ¶
func NewUndoableDecisionVariables() UndoableDecisionVariables
func (*UndoableDecisionVariables) AcceptAll ¶
func (vs *UndoableDecisionVariables) AcceptAll()
AcceptAll accepts the inductive Value of all the BaseInductiveDecisionVariable instances in its collection.
func (*UndoableDecisionVariables) Add ¶
func (vs *UndoableDecisionVariables) Add(newVariables ...UndoableDecisionVariable)
Adds a number of UndoableDecisionVariables to the collection
func (*UndoableDecisionVariables) DifferenceInValues ¶
func (vs *UndoableDecisionVariables) DifferenceInValues(variableName string) float64
DifferenceInValues reports the difference in values of the variableOld in its collection with the supplied name.
func (*UndoableDecisionVariables) NewForName ¶
func (vs *UndoableDecisionVariables) NewForName(name string)
NewForName creates and adds to its collection, a new BaseInductiveDecisionVariable with the supplied name.
func (*UndoableDecisionVariables) RejectAll ¶
func (vs *UndoableDecisionVariables) RejectAll()
RejectAll rejects the inductive Value of all the BaseInductiveDecisionVariable instances in its collection.
func (*UndoableDecisionVariables) SetValue ¶
func (vs *UndoableDecisionVariables) SetValue(name string, value float64)
SetValue finds the variableOld with supplied name in its collection, and sets its Value appropriately. If the collection has no variableOld for the supplied name, it panics.
func (*UndoableDecisionVariables) Value ¶
func (vs *UndoableDecisionVariables) Value(name string) float64
Value returns the Value of the variableOld in its collection with the supplied name. If the collection has no variableOld for the supplied name, it panics.
func (*UndoableDecisionVariables) Variable ¶
func (vs *UndoableDecisionVariables) Variable(name string) UndoableDecisionVariable
Variable returns a pointer to the variableOld in its collection with the supplied name. If the collection has no variableOld for the supplied name, it panics.
type UndoableValueCommand ¶
type UndoableValueCommand struct { command.BaseCommand // contains filtered or unexported fields }
func (*UndoableValueCommand) Change ¶
func (c *UndoableValueCommand) Change() float64
func (*UndoableValueCommand) Do ¶
func (c *UndoableValueCommand) Do() command.CommandStatus
func (*UndoableValueCommand) DoUnguarded ¶
func (c *UndoableValueCommand) DoUnguarded()
func (*UndoableValueCommand) ForVariable ¶
func (c *UndoableValueCommand) ForVariable(variable *SimpleUndoableDecisionVariable) *UndoableValueCommand
func (*UndoableValueCommand) SetChange ¶
func (c *UndoableValueCommand) SetChange(changeValue float64)
func (*UndoableValueCommand) SetValue ¶
func (c *UndoableValueCommand) SetValue(value float64)
func (*UndoableValueCommand) Undo ¶
func (c *UndoableValueCommand) Undo() command.CommandStatus
func (*UndoableValueCommand) UndoUnguarded ¶
func (c *UndoableValueCommand) UndoUnguarded()
func (*UndoableValueCommand) Value ¶
func (c *UndoableValueCommand) Value() float64
func (*UndoableValueCommand) Variable ¶
func (c *UndoableValueCommand) Variable() *SimpleUndoableDecisionVariable
func (*UndoableValueCommand) WithChange ¶
func (c *UndoableValueCommand) WithChange(changeValue float64) *UndoableValueCommand
func (*UndoableValueCommand) WithValue ¶
func (c *UndoableValueCommand) WithValue(value float64) *UndoableValueCommand
type UnitOfMeasure ¶
type UnitOfMeasure string
const ( NotApplicable UnitOfMeasure = "Not Applicable (NA)" TonnesPerYear UnitOfMeasure = "Tonnes per Year (t/y)" Dollars UnitOfMeasure = "Dollars ($)" )
func (UnitOfMeasure) String ¶
func (uom UnitOfMeasure) String() string
Source Files ¶
- Bounds.go
- ChangePerPlanningUnitDecisionVariableCommand.go
- ContainedDecisionVariables.go
- DecisionVariable.go
- DecisionVariableMap.go
- EncodableDecisionVariable.go
- NullDecisionVariable.go
- Observer.go
- PlanningUnitDecisionVariable.go
- SimpleUndoableDecisionVariable.go
- UndoableDecisionVariable.go
- UndoableDecisionVariables.go