Documentation ¶
Overview ¶
action package contains interfaces and behaviour for general-purpose "management actions" that change a model's decision variables based on their activation status.
Index ¶
- Constants
- type ManagementAction
- type ManagementActionType
- type ManagementActions
- type ModelManagementActions
- func (m *ModelManagementActions) Actions() ManagementActions
- func (m *ModelManagementActions) ActiveActions() ManagementActions
- func (m *ModelManagementActions) Add(newActions ...ManagementAction)
- func (m *ModelManagementActions) DeactivateLastInitialisedAction()
- func (m *ModelManagementActions) Initialise()
- func (m *ModelManagementActions) LastAppliedAction() ManagementAction
- func (m *ModelManagementActions) RandomlyDeInitialiseAction(action ManagementAction)
- func (m *ModelManagementActions) RandomlyDeInitialiseAnyAction() ManagementAction
- func (m *ModelManagementActions) RandomlyInitialise()
- func (m *ModelManagementActions) RandomlyInitialiseAction(action ManagementAction)
- func (m *ModelManagementActions) RandomlyInitialiseAnyAction() ManagementAction
- func (m *ModelManagementActions) RandomlyToggleOneActivation() ManagementAction
- func (m *ModelManagementActions) SetActivation(index int, value bool)
- func (m *ModelManagementActions) SetActivationUnobserved(index int, value bool)
- func (m *ModelManagementActions) Sort()
- func (m *ModelManagementActions) ToggleAction(planningUnit planningunit.Id, actionType ManagementActionType)
- func (m *ModelManagementActions) ToggleActionUnobserved(planningUnit planningunit.Id, actionType ManagementActionType)
- func (m *ModelManagementActions) ToggleLastActivation()
- func (m *ModelManagementActions) ToggleLastActivationUnobserved()
- type ModelVariableName
- type Null
- func (a *Null) InitialisingActivation()
- func (a *Null) InitialisingDeactivation()
- func (a *Null) IsActive() bool
- func (a *Null) ModelVariableValue(variableName ModelVariableName) float64
- func (a *Null) PlanningUnit() planningunit.Id
- func (a *Null) SetActivation(value bool)
- func (a *Null) SetActivationUnobserved(value bool)
- func (a *Null) Subscribe(observers ...Observer)
- func (a *Null) ToggleActivation()
- func (a *Null) ToggleActivationUnobserved()
- func (a *Null) Type() ManagementActionType
- type Observer
- type SimpleManagementAction
- func (sma *SimpleManagementAction) InitialisingActivation()
- func (sma *SimpleManagementAction) InitialisingDeactivation()
- func (sma *SimpleManagementAction) IsActive() bool
- func (sma *SimpleManagementAction) ModelVariableKeys() (keys []ModelVariableName)
- func (sma *SimpleManagementAction) ModelVariableValue(variableName ModelVariableName) float64
- func (sma *SimpleManagementAction) PlanningUnit() planningunit.Id
- func (sma *SimpleManagementAction) SetActivation(value bool)
- func (sma *SimpleManagementAction) SetActivationUnobserved(value bool)
- func (sma *SimpleManagementAction) Subscribe(observers ...Observer)
- func (sma *SimpleManagementAction) ToggleActivation()
- func (sma *SimpleManagementAction) ToggleActivationUnobserved()
- func (sma *SimpleManagementAction) Type() ManagementActionType
- func (sma *SimpleManagementAction) WithPlanningUnit(planningUnit planningunit.Id) *SimpleManagementAction
- func (sma *SimpleManagementAction) WithType(actionType ManagementActionType) *SimpleManagementAction
- func (sma *SimpleManagementAction) WithVariable(variableName ModelVariableName, value float64) *SimpleManagementAction
Constants ¶
const NullPlanningUnitId planningunit.Id = math.MaxUint64
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ManagementAction ¶
type ManagementAction interface { // PlanningUnit returns the identifier of the planning unit in which management action is spatially located. PlanningUnit() planningunit.Id // Type identifies the ManagementActionType of a particular management action Type() ManagementActionType // IsActive reports whether a management action is active (true) or not (false). IsActive() bool // ModelVariableName reports tha value of the model variableName stored with the management action. ModelVariableValue(variableName ModelVariableName) float64 // Subscribe allows a number of implementations of Reporting to subscribe fur updates (changes in activation state). Subscribe(observers ...Observer) // InitialisingActivation activates an inactive management action, triggering Reporting method // ObserveActionInitialising callbacks. InitialisingActivation() InitialisingDeactivation() // ToggleActivation activates an inactive ManagementAction and vice-versa, // triggering Reporting method ObserveAction callbacks. ToggleActivation() // ToggleActivationUnobserved activates an inactive ManagementAction and vice-versa, without triggering any // Reporting method callbacks. Expected to be called when undoing a change that observers shouldn't react to. ToggleActivationUnobserved() // SetActivation activates an the ManagementAction as per the value supplied, SetActivation(value bool) // SetActivation activates an the ManagementAction as per the value supplied, without triggering any // Reporting method callbacks. Expected to be called when undoing a change that observers shouldn't react to. SetActivationUnobserved(value bool) }
ManagementAction defines a general interface for the implementation of management actions.
var NullManagementAction ManagementAction = new(Null)
NullManagementAction is a stateless/neutral implementation of the ManagementAction interface, useful for testing scenarios where action state is irrelevant or within scenarios where a Null Pattern for actions makes sense (https://en.wikipedia.org/wiki/Null_object_pattern).
type ManagementActionType ¶
type ManagementActionType string
ManagementActionType identifies a set of management actions that make the same kind of change to relevant model decision variables.
const NullManagementActionType ManagementActionType = "NullType"
func (ManagementActionType) String ¶
func (t ManagementActionType) String() string
type ManagementActions ¶
type ManagementActions []ManagementAction
func (ManagementActions) Len ¶
func (ma ManagementActions) Len() int
func (ManagementActions) Less ¶
func (ma ManagementActions) Less(i, j int) bool
func (ManagementActions) Swap ¶
func (ma ManagementActions) Swap(i, j int)
type ModelManagementActions ¶
type ModelManagementActions struct { rand.RandContainer // contains filtered or unexported fields }
ModelManagementActions is a container/manager for all management actions that can be applied to a model.
func (*ModelManagementActions) Actions ¶
func (m *ModelManagementActions) Actions() ManagementActions
func (*ModelManagementActions) ActiveActions ¶
func (m *ModelManagementActions) ActiveActions() ManagementActions
func (*ModelManagementActions) Add ¶
func (m *ModelManagementActions) Add(newActions ...ManagementAction)
Add allows onr ore management actions to be added to the set of actions under management.
func (*ModelManagementActions) DeactivateLastInitialisedAction ¶
func (m *ModelManagementActions) DeactivateLastInitialisedAction()
func (*ModelManagementActions) Initialise ¶
func (m *ModelManagementActions) Initialise()
func (*ModelManagementActions) LastAppliedAction ¶
func (m *ModelManagementActions) LastAppliedAction() ManagementAction
func (*ModelManagementActions) RandomlyDeInitialiseAction ¶
func (m *ModelManagementActions) RandomlyDeInitialiseAction(action ManagementAction)
func (*ModelManagementActions) RandomlyDeInitialiseAnyAction ¶
func (m *ModelManagementActions) RandomlyDeInitialiseAnyAction() ManagementAction
func (*ModelManagementActions) RandomlyInitialise ¶
func (m *ModelManagementActions) RandomlyInitialise()
RandomlyInitialise will pass through its stored management actions, applying a 50/50 chance to activate each action. Any action chosen for activation triggers its observers to react to its 'initialising' activation.
func (*ModelManagementActions) RandomlyInitialiseAction ¶
func (m *ModelManagementActions) RandomlyInitialiseAction(action ManagementAction)
func (*ModelManagementActions) RandomlyInitialiseAnyAction ¶
func (m *ModelManagementActions) RandomlyInitialiseAnyAction() ManagementAction
func (*ModelManagementActions) RandomlyToggleOneActivation ¶
func (m *ModelManagementActions) RandomlyToggleOneActivation() ManagementAction
RandomlyToggleOneActivation randomly picks one of its stored management actions and toggles its activation in a way that will trigger any observers of the selected management action to react to its change in activation state.
func (*ModelManagementActions) SetActivation ¶
func (m *ModelManagementActions) SetActivation(index int, value bool)
func (*ModelManagementActions) SetActivationUnobserved ¶
func (m *ModelManagementActions) SetActivationUnobserved(index int, value bool)
func (*ModelManagementActions) Sort ¶
func (m *ModelManagementActions) Sort()
func (*ModelManagementActions) ToggleAction ¶
func (m *ModelManagementActions) ToggleAction(planningUnit planningunit.Id, actionType ManagementActionType)
func (*ModelManagementActions) ToggleActionUnobserved ¶
func (m *ModelManagementActions) ToggleActionUnobserved(planningUnit planningunit.Id, actionType ManagementActionType)
func (*ModelManagementActions) ToggleLastActivation ¶
func (m *ModelManagementActions) ToggleLastActivation()
ToggleLastActivation allows for the last recorded management action change to have its activation state reverted, alerting any observers of the change.
func (*ModelManagementActions) ToggleLastActivationUnobserved ¶
func (m *ModelManagementActions) ToggleLastActivationUnobserved()
ToggleLastActivationUnobserved allows for the last recorded management action change to have its activation state reverted, without triggering any observation of the change.
type ModelVariableName ¶
type ModelVariableName string
ModelVariableName identifies a particular model variableOld value that a management action modifies when its activation status changes.
type Null ¶
type Null struct{}
func (*Null) InitialisingActivation ¶
func (a *Null) InitialisingActivation()
func (*Null) InitialisingDeactivation ¶
func (a *Null) InitialisingDeactivation()
func (*Null) ModelVariableValue ¶
func (a *Null) ModelVariableValue(variableName ModelVariableName) float64
func (*Null) PlanningUnit ¶
func (a *Null) PlanningUnit() planningunit.Id
func (*Null) SetActivation ¶
func (*Null) SetActivationUnobserved ¶
func (*Null) ToggleActivation ¶
func (a *Null) ToggleActivation()
func (*Null) ToggleActivationUnobserved ¶
func (a *Null) ToggleActivationUnobserved()
func (*Null) Type ¶
func (a *Null) Type() ManagementActionType
type Observer ¶
type Observer interface { // ObserveActionInitialising is a callback method, invoked when a management action is activated as part of any // necessary model initialisation. ObserveActionInitialising(action ManagementAction) // ObserverAction is a callback method, invoked when a management action's activation changes as a model runs // (only after the model has been initialised). ObserveAction(action ManagementAction) }
Reporting defines an interface allowing the observation of management actions via callback methods.
type SimpleManagementAction ¶
type SimpleManagementAction struct {
// contains filtered or unexported fields
}
SimpleManagementAction is a basic, generally useful implementation of the ManagementAction interface, using a fluent interface for its action construction.
func (*SimpleManagementAction) InitialisingActivation ¶
func (sma *SimpleManagementAction) InitialisingActivation()
func (*SimpleManagementAction) InitialisingDeactivation ¶
func (sma *SimpleManagementAction) InitialisingDeactivation()
func (*SimpleManagementAction) IsActive ¶
func (sma *SimpleManagementAction) IsActive() bool
func (*SimpleManagementAction) ModelVariableKeys ¶
func (sma *SimpleManagementAction) ModelVariableKeys() (keys []ModelVariableName)
func (*SimpleManagementAction) ModelVariableValue ¶
func (sma *SimpleManagementAction) ModelVariableValue(variableName ModelVariableName) float64
func (*SimpleManagementAction) PlanningUnit ¶
func (sma *SimpleManagementAction) PlanningUnit() planningunit.Id
func (*SimpleManagementAction) SetActivation ¶
func (sma *SimpleManagementAction) SetActivation(value bool)
func (*SimpleManagementAction) SetActivationUnobserved ¶
func (sma *SimpleManagementAction) SetActivationUnobserved(value bool)
func (*SimpleManagementAction) Subscribe ¶
func (sma *SimpleManagementAction) Subscribe(observers ...Observer)
func (*SimpleManagementAction) ToggleActivation ¶
func (sma *SimpleManagementAction) ToggleActivation()
func (*SimpleManagementAction) ToggleActivationUnobserved ¶
func (sma *SimpleManagementAction) ToggleActivationUnobserved()
func (*SimpleManagementAction) Type ¶
func (sma *SimpleManagementAction) Type() ManagementActionType
func (*SimpleManagementAction) WithPlanningUnit ¶
func (sma *SimpleManagementAction) WithPlanningUnit(planningUnit planningunit.Id) *SimpleManagementAction
func (*SimpleManagementAction) WithType ¶
func (sma *SimpleManagementAction) WithType(actionType ManagementActionType) *SimpleManagementAction
func (*SimpleManagementAction) WithVariable ¶
func (sma *SimpleManagementAction) WithVariable(variableName ModelVariableName, value float64) *SimpleManagementAction