action

package
v0.0.0-...-c864ae1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: BSD-2-Clause, BSD-3-Clause, MIT Imports: 5 Imported by: 0

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

View Source
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 (*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) IsActive

func (a *Null) IsActive() bool

func (*Null) ModelVariableValue

func (a *Null) ModelVariableValue(variableName ModelVariableName) float64

func (*Null) PlanningUnit

func (a *Null) PlanningUnit() planningunit.Id

func (*Null) SetActivation

func (a *Null) SetActivation(value bool)

func (*Null) SetActivationUnobserved

func (a *Null) SetActivationUnobserved(value bool)

func (*Null) Subscribe

func (a *Null) Subscribe(observers ...Observer)

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 (*SimpleManagementAction) WithPlanningUnit

func (sma *SimpleManagementAction) WithPlanningUnit(planningUnit planningunit.Id) *SimpleManagementAction

func (*SimpleManagementAction) WithType

func (*SimpleManagementAction) WithVariable

func (sma *SimpleManagementAction) WithVariable(variableName ModelVariableName, value float64) *SimpleManagementAction

Jump to

Keyboard shortcuts

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