beliefspread

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package beliefspread describes the various primitives and behaviours that are used to model the spread of beliefs. This corresponds to the paper directly. It may be used as a library for further analysis of the spread of beliefs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

func Max(a, b float64) float64

Max returns the largest of a or b.

func Min

func Min(a, b float64) float64

Min returns the smallest of a or b.

Types

type Agent

type Agent struct {
	// The UUID of the agent.
	Uuid uuid.UUID
	// The activation of the agent's beliefs at a given time.
	//
	// This should always be between -1 and +1.
	Activations map[SimTime]map[*Belief]float64
	// The relationship of the agent to other agents.
	//
	// This should be in the range [0, 1]
	Friends map[*Agent]float64
	// The actions of the agent at a given time.
	Actions map[SimTime]*Behaviour
	// The deltas of the agent's beliefs.
	//
	// This should be in the range [-1, +1] and is applied multiplicatively to
	// the activation of the belief at the next time step.
	Deltas map[*Belief]float64
}

An Agent in the simulation.

func NewAgent

func NewAgent() (a *Agent)

NewAgent creates a new agent with a randomly generated UUID.

func (*Agent) ActivationChange

func (a *Agent) ActivationChange(
	time SimTime,
	belief *Belief,
	beliefs []*Belief,
	actionsOfFriends map[*Behaviour]float64,
) float64

ActivationChange gets the change in activation for the Agent as a result of observed Behaviour.

This does take into account the context of the Belief.

func (*Agent) Contextualise

func (a *Agent) Contextualise(t SimTime, b *Belief, beliefs []*Belief) (context float64)

Contextualise gets the context for holding the Belief b

This is the compatibility for holding b, given that the Agent all the beliefs the agent holds.

This is an average of the weighted relationships for every Belief in beliefs.

func (*Agent) GetActionsOfFriends

func (a *Agent) GetActionsOfFriends(t SimTime) (actions map[*Behaviour]float64)

GetActionsOfFriends gets the actions of the agent's friends at a given time.

The key is the behaviour, the value is the total weight of friends who performed that behaviour.

func (*Agent) Pressure

func (a *Agent) Pressure(
	belief *Belief,
	actionsOfFriends map[*Behaviour]float64,
) (pressure float64)

Pressure gets the pressure the Agent feels to adopt a Belief given the actions of their friends.

This does not take into account the context of the Belief.

func (*Agent) UpdateActivation

func (a *Agent) UpdateActivation(
	time SimTime,
	belief *Belief,
	beliefs []*Belief,
	actionsOfFriends map[*Behaviour]float64,
) error

UpdateActivation updates the activation for a given belief and time, given the actions of the agents friends.

func (*Agent) UpdateActivationForAllBeliefs

func (a *Agent) UpdateActivationForAllBeliefs(
	time SimTime,
	beliefs []*Belief,
) error

UpdateActivationForAllBeliefs updates the activation for all beliefs at a given time.

func (*Agent) WeightedRelationship

func (a *Agent) WeightedRelationship(t SimTime, b1 *Belief, b2 *Belief) *float64

WeightedRelationship gets the weighted relationship between two beliefs.

This is the compatibility for holding b2, given that the Agent already holds b1.

This is equal to the activation of b1 multiplied by the relationship between b1 and b2.

Returns nil if the agent has no activation for b1, or if b1 and b2 have no relationship.

type Behaviour

type Behaviour struct {
	// The name of the behaviour.
	Name string
	// The UUID of the behaviour.
	Uuid uuid.UUID
}

A Behaviour in the simulation.

func NewBehaviour

func NewBehaviour(name string) (b *Behaviour)

NewBehaviour creates a new behaviour. Name is the name of the behaviour.

This behaviour will have a randomly generated UUID.

type Belief

type Belief struct {
	// The name of the belief.
	Name string
	// The UUID of the belief.
	Uuid uuid.UUID
	// The perception of the belief to a behaviour.
	//
	// The perception is the amount an agent performing the behaviour can be
	// assumed to be driven by the belief.
	//
	// This should be a value between -1 and +1.
	Perception map[*Behaviour]float64

	// The relationship of the belief to another belief.
	//
	// The relationship is the amount the belief can be deemed to be compatible
	// with holding this belief, given that you already hold the other belief.
	Relationship map[*Belief]float64
}

A Belief in the simulation.

func NewBelief

func NewBelief(name string) (b *Belief)

NewBelief creates a new belief.

This belief will have the supplied name, and a randomly generated UUID.

type SimTime

type SimTime uint32

SimTime is how time is represented in the simulation.

Jump to

Keyboard shortcuts

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