plexsim.models package

Submodules

plexsim.models.ab module

class plexsim.models.ab.AB(graph, zealots=dict(), **kwargs)

Bases: plexsim.models.base.Model

Voter AB model

Parameters

graph

param zealots

dict of zealots to include (people that cannot be convinced), defaults to 0

param **kwargs

plexsim.models.ab module

class plexsim.models.ab.AB(graph, zealots=dict(), **kwargs)

Bases: plexsim.models.base.Model

Voter AB model

Parameters

graph

param zealots

dict of zealots to include (people that cannot be convinced), defaults to 0

param **kwargs

plexsim.models.adjacency module

class plexsim.models.adjacency.Adjacency(graph)

Bases: object

Constructs adj matrix using structs intput:

nx.Graph or nx.DiGraph

graph

add_edge(self, node_id_t x, node_id_t y, double weight=1)
adj

Returns the adjacency structure. FIXME: further abstract this

graph

Wrapper around retrieving the graph. Some models edit the adjacency structure as such we have to reconstruct the graph from the lower level mapping.

plexsim.models.adjacency module

class plexsim.models.adjacency.Adjacency(graph)

Bases: object

Constructs adj matrix using structs intput:

nx.Graph or nx.DiGraph

graph

add_edge(self, node_id_t x, node_id_t y, double weight=1)
adj

Returns the adjacency structure. FIXME: further abstract this

graph

Wrapper around retrieving the graph. Some models edit the adjacency structure as such we have to reconstruct the graph from the lower level mapping.

plexsim.models.base module

class plexsim.models.base.Model(graph=nx.path_graph(1), agentStates=np.array([0], dtype=np.int), nudgeType='constant', updateType='async', nudges={}, seed=None, memorySize=0, kNudges=1, memento=0, p_recomb=None, rules=nx.Graph(), **kwargs)

Bases: object

Base class for all modeling classes

Parameters
  • graph (nx.Graph or nx.DiGraph) – Network structure indicating relationship among elements of the complex system

  • agentStates (np.ndarray) – Discrete states that the agents can take

  • nudgeType (str) – Type of nudging being used. Can be “constant” or “single”.

  • updateType (str) – Update type of elements of the complex system. Either “sync” or “async” (default). The “sync” options has two independent buffers in which the results are written. The “async” options will have no independent buffers.

  • nudges (dict) – Nudge applied to a certain variable

  • seed (int) – Seed for random number generator.

  • memorySize (int) – Size of the memory of the system. Defaults to 0.

  • kNudges (int) – Deprecated.

  • memento (int) – Deprecated

  • p_recomb (float) – Recombination rate of the genetic algorithm. Values are within 0, 1 (defaults to zero). Non-zero values will activate the genetic algorithm.

  • rules (nx.Graph or nx.DiGraph) – Network structure for rules. Only used for Value networks. Defaults to empty (not used).

add_edge(self, node_id_t x, node_id_t y, double weight=1)
adj
agentStates
get_settings(self)dict

Warning this function may cause bugs The model properties have to be copied without being overly verbose The seed needs to be updated otherwise you will get the model

graph

Returns network interaction structure

kNudges

Deprecated

last_written

noindex:

mcmc

Returns metropolis sampler

memento
memory

Returns memory buffer

memorySize

Returns memory size

nNodes

Returns number of nodes in the system

nStates

Returns size of alphabet of each agent

newstates

nodindex:

nodeids

Returns node ids Note these are not sorted!

nudgeType

Returns nudgeType

nudges

Return dict of nudges

p_recomb

Returns the recombination probability

removeAllNudges(self)

Sets all nudges to zero

reset(self, p=None)void
rng

Returns random number generator. See Sampler.

rules

Returns the rule graph as a networkx object

sampleNodes(self, size_t nSamples)node_id_t[:, ::1]
sampleSize

Returns sampleSize

simulate(self, size_t samples)ndarray

Wrapper for simulating the system

Parameters

samples (size_t) – int

Returns

np.ndarray of size (time_steps, nodes)

Return type

np.ndarray

Examples

FIXME: Add docs.

simulate_mean(self, size_t samples)ndarray
spawn(self, size_t n_jobs=openmp.omp_get_num_threads())list

Creates vector of copies of the model Wraps _spawn method. :param n_jobs: Number of copies to make :type n_jobs: int,

Returns

  • list of copies of the model. Note that each thread will generate a different seed;

  • the seed will be increased by the thread id.

states
updateState(self, node_id_t[::1] nodesToUpdate)state_t[::1]

General state updater wrapper

updateType

Returns updateType

class plexsim.models.base.ModelMC(p_recomb=1, *args, **kwargs)

Bases: plexsim.models.base.Model

plexsim.models.base.rebuild(cls, kwargs)

plexsim.models.base module

class plexsim.models.base.Model(graph=nx.path_graph(1), agentStates=np.array([0], dtype=np.int), nudgeType='constant', updateType='async', nudges={}, seed=None, memorySize=0, kNudges=1, memento=0, p_recomb=None, rules=nx.Graph(), **kwargs)

Bases: object

Base class for all modeling classes

Parameters
  • graph (nx.Graph or nx.DiGraph) – Network structure indicating relationship among elements of the complex system

  • agentStates (np.ndarray) – Discrete states that the agents can take

  • nudgeType (str) – Type of nudging being used. Can be “constant” or “single”.

  • updateType (str) – Update type of elements of the complex system. Either “sync” or “async” (default). The “sync” options has two independent buffers in which the results are written. The “async” options will have no independent buffers.

  • nudges (dict) – Nudge applied to a certain variable

  • seed (int) – Seed for random number generator.

  • memorySize (int) – Size of the memory of the system. Defaults to 0.

  • kNudges (int) – Deprecated.

  • memento (int) – Deprecated

  • p_recomb (float) – Recombination rate of the genetic algorithm. Values are within 0, 1 (defaults to zero). Non-zero values will activate the genetic algorithm.

  • rules (nx.Graph or nx.DiGraph) – Network structure for rules. Only used for Value networks. Defaults to empty (not used).

add_edge(self, node_id_t x, node_id_t y, double weight=1)
adj
agentStates
get_settings(self)dict

Warning this function may cause bugs The model properties have to be copied without being overly verbose The seed needs to be updated otherwise you will get the model

graph

Returns network interaction structure

kNudges

Deprecated

last_written

noindex:

mcmc

Returns metropolis sampler

memento
memory

Returns memory buffer

memorySize

Returns memory size

nNodes

Returns number of nodes in the system

nStates

Returns size of alphabet of each agent

newstates

nodindex:

nodeids

Returns node ids Note these are not sorted!

nudgeType

Returns nudgeType

nudges

Return dict of nudges

p_recomb

Returns the recombination probability

removeAllNudges(self)

Sets all nudges to zero

reset(self, p=None)void
rng

Returns random number generator. See Sampler.

rules

Returns the rule graph as a networkx object

sampleNodes(self, size_t nSamples)node_id_t[:, ::1]
sampleSize

Returns sampleSize

simulate(self, size_t samples)ndarray

Wrapper for simulating the system

Parameters

samples (size_t) – int

Returns

np.ndarray of size (time_steps, nodes)

Return type

np.ndarray

Examples

FIXME: Add docs.

simulate_mean(self, size_t samples)ndarray
spawn(self, size_t n_jobs=openmp.omp_get_num_threads())list

Creates vector of copies of the model Wraps _spawn method. :param n_jobs: Number of copies to make :type n_jobs: int,

Returns

  • list of copies of the model. Note that each thread will generate a different seed;

  • the seed will be increased by the thread id.

states
updateState(self, node_id_t[::1] nodesToUpdate)state_t[::1]

General state updater wrapper

updateType

Returns updateType

class plexsim.models.base.ModelMC(p_recomb=1, *args, **kwargs)

Bases: plexsim.models.base.Model

plexsim.models.base.rebuild(cls, kwargs)

plexsim.models.bonabeau module

class plexsim.models.bonabeau.Bonabeau(graph, agentStates=np.array([0, 1]), eta=1, **kwargs)

Bases: plexsim.models.base.Model

Bonabeau model in hierarchy formation updated using heat bath equation based on Bonabeau et al. 1995

eta

coefficient for sigmoid curve

weight

return weights between nodes

plexsim.models.bonabeau module

class plexsim.models.bonabeau.Bonabeau(graph, agentStates=np.array([0, 1]), eta=1, **kwargs)

Bases: plexsim.models.base.Model

Bonabeau model in hierarchy formation updated using heat bath equation based on Bonabeau et al. 1995

eta

coefficient for sigmoid curve

weight

return weights between nodes

plexsim.models.bornholdt module

class plexsim.models.bornholdt.Bornholdt(graph, double alpha=1, **kwargs)

Bases: plexsim.models.potts.Potts

Implementation of Bornholdt model (2000) Ising-like dynamics with a global magnetiztion dynamic

alpha

Global coupling constant

system_mag

plexsim.models.bornholdt module

class plexsim.models.bornholdt.Bornholdt(graph, double alpha=1, **kwargs)

Bases: plexsim.models.potts.Potts

Implementation of Bornholdt model (2000) Ising-like dynamics with a global magnetiztion dynamic

alpha

Global coupling constant

system_mag

plexsim.models.cca module

class plexsim.models.cca.CCA(graph, threshold=0., agentStates=np.array([0, 1, 2], dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

Circular cellular automaton

threshold

plexsim.models.cca module

class plexsim.models.cca.CCA(graph, threshold=0., agentStates=np.array([0, 1, 2], dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

Circular cellular automaton

threshold

plexsim.models.cyclic module

class plexsim.models.cyclic.Cycledelic(graph, double predation=2, double competition=1.5, double diffusion=0.05, **kwargs)

Bases: plexsim.models.base.Model

From Dirk Brockmann

colors
simulate(self, size_t samples)ndarray

” :param samples: number of samples to simulate :type: int :returns: np.ndarray containing the system states to simulate

class plexsim.models.cyclic.CycledelicAgent(graph, double predation=2, reproduction=1.5, mobility=.05)

Bases: plexsim.models.base.Model

Agent-based inspired implementation of rock-paper-scissor dynamics

plexsim.models.cyclic module

class plexsim.models.cyclic.Cycledelic(graph, double predation=2, double competition=1.5, double diffusion=0.05, **kwargs)

Bases: plexsim.models.base.Model

From Dirk Brockmann

colors
simulate(self, size_t samples)ndarray

” :param samples: number of samples to simulate :type: int :returns: np.ndarray containing the system states to simulate

class plexsim.models.cyclic.CycledelicAgent(graph, double predation=2, reproduction=1.5, mobility=.05)

Bases: plexsim.models.base.Model

Agent-based inspired implementation of rock-paper-scissor dynamics

plexsim.models.game_of_life module

class plexsim.models.game_of_life.Conway(graph, size_t threshold=3, **kwargs)

Bases: plexsim.models.base.Model

Conway’s game of life

Implements conways game of life on an abitrary network structure.

Parameters
  • graph (object) –

  • threshold (size_t) –

    Threshold indicating when a cell will survive or die. The threshold will be used by comparing

    heta - 1 <= #alive <= theta.

  • **kwargs (dict) – General settings for the base model (see Model).

Examples

FIXME: Add docs.

threshold

plexsim.models.game_of_life module

class plexsim.models.game_of_life.Conway(graph, size_t threshold=3, **kwargs)

Bases: plexsim.models.base.Model

Conway’s game of life

Implements conways game of life on an abitrary network structure.

Parameters
  • graph (object) –

  • threshold (size_t) –

    Threshold indicating when a cell will survive or die. The threshold will be used by comparing

    heta - 1 <= #alive <= theta.

  • **kwargs (dict) – General settings for the base model (see Model).

Examples

FIXME: Add docs.

threshold

plexsim.models.ising module

class plexsim.models.ising.Ising(graph, **kwargs)

Bases: plexsim.models.potts.Potts

Kinetic Ising model

Implements kinetic Ising model on arbitrary graph.

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure for the spins.

  • **kwargs

    General settings (see Model).

Examples

FIXME: Add docs.

plexsim.models.ising module

class plexsim.models.ising.Ising(graph, **kwargs)

Bases: plexsim.models.potts.Potts

Kinetic Ising model

Implements kinetic Ising model on arbitrary graph.

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure for the spins.

  • **kwargs

    General settings (see Model).

Examples

FIXME: Add docs.

plexsim.models.logmap module

class plexsim.models.logmap.Logmap(graph, double r=1, double alpha=0, agentStates=np.arange(2, dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

alpha
r

plexsim.models.logmap module

class plexsim.models.logmap.Logmap(graph, double r=1, double alpha=0, agentStates=np.arange(2, dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

alpha
r

plexsim.models.magnetic_boids module

class plexsim.models.magnetic_boids.MagneticBoids(coordinates, velocities, rules=nx.Graph(), graph=nx.Graph(), agentStates=np.arange(0, 1, dtype=np.double), size_t bounded_rational=1, boid_radius=.1, max_speed=.1, radius=.1, bounds=np.array([0, 20], dtype=np.double), exploration=np.inf, dt=.01, **kwargs)

Bases: plexsim.models.value_network.ValueNetwork

Magnetic boids. Combines the ideas from the value network without requirement of a social network. The model is inspired by the boids model. Each agent/boid/ node has a color state. The colors bind together in a network dubbed the “value network”. In the normal boids simulation, each boid want to fly close to other boids. From this, flocking behavior appears. In this implementation the boids attempt to flock according the coloring network.

Parameters
  • coordinates (np.ndarray, initial position of the boids.) –

  • velocities (np.ndarray, initial velocities of the boids.) –

  • rules (nx.Graph or nx.DiGraph, color networks indicating how colors want to interact) –

  • agentStates (np.ndarray, colors that each boid can take) –

  • bounded_rational

  • int (unsigned) –

  • to consider for measuring the completion (edges) –

  • the value network (of) –

  • boid_radius (unsigned int, radius of the boid.) –

  • max_speed (unsigned int, maximum speed the boids can fly at. Note that negative speeds are compared to this value!) –

  • radius (unsigned int: radius that the boids can see.) –

  • bounds (np.ndarray, bounding box of the area can fly in.) –

  • exploration (float, amount of noise to add to the update position of the boids.) –

  • dt (float, simulation update parameter (extrapolation)) –

  • kwargs (dict, base model values (see base model)) –

boid_radius
bounds
coordinates
dt
explore

The explore parameter controls how much noise is added to the particle’s position

radius
velocities

plexsim.models.magnetic_boids module

class plexsim.models.magnetic_boids.MagneticBoids(coordinates, velocities, rules=nx.Graph(), graph=nx.Graph(), agentStates=np.arange(0, 1, dtype=np.double), size_t bounded_rational=1, boid_radius=.1, max_speed=.1, radius=.1, bounds=np.array([0, 20], dtype=np.double), exploration=np.inf, dt=.01, **kwargs)

Bases: plexsim.models.value_network.ValueNetwork

Magnetic boids. Combines the ideas from the value network without requirement of a social network. The model is inspired by the boids model. Each agent/boid/ node has a color state. The colors bind together in a network dubbed the “value network”. In the normal boids simulation, each boid want to fly close to other boids. From this, flocking behavior appears. In this implementation the boids attempt to flock according the coloring network.

Parameters
  • coordinates (np.ndarray, initial position of the boids.) –

  • velocities (np.ndarray, initial velocities of the boids.) –

  • rules (nx.Graph or nx.DiGraph, color networks indicating how colors want to interact) –

  • agentStates (np.ndarray, colors that each boid can take) –

  • bounded_rational

  • int (unsigned) –

  • to consider for measuring the completion (edges) –

  • the value network (of) –

  • boid_radius (unsigned int, radius of the boid.) –

  • max_speed (unsigned int, maximum speed the boids can fly at. Note that negative speeds are compared to this value!) –

  • radius (unsigned int: radius that the boids can see.) –

  • bounds (np.ndarray, bounding box of the area can fly in.) –

  • exploration (float, amount of noise to add to the update position of the boids.) –

  • dt (float, simulation update parameter (extrapolation)) –

  • kwargs (dict, base model values (see base model)) –

boid_radius
bounds
coordinates
dt
explore

The explore parameter controls how much noise is added to the particle’s position

radius
velocities

plexsim.models.percolation module

class plexsim.models.percolation.Percolation(graph, p=1, agentStates=np.array([0, 1], dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

” Percolation model. Each bond (edge) can percolate with probability p

p: double

probabililty of bond percolation

agentStates: np.ndarray

States of each vertex/node 1 indicates occupied, 0 is empty

p

plexsim.models.percolation module

class plexsim.models.percolation.Percolation(graph, p=1, agentStates=np.array([0, 1], dtype=np.double), **kwargs)

Bases: plexsim.models.base.Model

” Percolation model. Each bond (edge) can percolate with probability p

p: double

probabililty of bond percolation

agentStates: np.ndarray

States of each vertex/node 1 indicates occupied, 0 is empty

p

plexsim.models.potts module

class plexsim.models.potts.Potts(graph, t=1, agentStates=np.array([0, 1], dtype=np.double), delta=0, p_recomb=None, **kwargs)

Bases: plexsim.models.base.Model

Kinetic q-Potts model

Implements kinetic q-Potts model on arbitrary graph. This model implements all the base functionality of the Potts/Ising related models (e.g. Pottsis or Bornholdt).

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure for the spins.

  • gentStates (np.ndarray,) – Array giving q-states

  • delta (int) – A modifier for how much the memory affects the current received energy of

  • node (a) –

  • **kwargs

    General settings (see Model).

Examples

FIXME: Add docs.

H

External magnetic field

beta

Shortcut for 1/T

delta
magnetize(self, ndarray temps=np.logspace(-3, 2, 20), size_t n=int(1e3), size_t burninSamples=0, size_t n_jobs=0)ndarray

Computes the magnetization as a function of temperatures

temps: np.ndarray

a range of temperatures

: int

number of samples to simulate for

urninSamples: int

number of samples to throw away before sampling

Returns 2D matrix (2, number of temperatures). The first index (0) contains the magnetization, the second index (1) contains the magnetic susceptibility

node_energy(self, state_t[::1] states)ndarray

” Computes average by degree of node energy of all nodes given a system state.

Parameters

states (memoryview doubles) – 1D vector of spin states

Returns

Returns node energy of all nodes given

Return type

states:

siteEnergy(self, state_t[::1] states)vector[double]

Computes raw site energy of nodes given a system state

Parameters
  • states (memory view of spin states) – 1D vector of size number of spins indicating the system state

  • which to compute the site energy. (for) –

Returns

Returns the raw site energy per spin in the system given

Return type

states:

t

Temperature

plexsim.models.potts.match_temperature(match, results, temps)

matches temperature

plexsim.models.potts.sigmoid(x, a, b, c, d)
plexsim.models.potts.sigmoidOpt(x, params, match)

plexsim.models.potts module

class plexsim.models.potts.Potts(graph, t=1, agentStates=np.array([0, 1], dtype=np.double), delta=0, p_recomb=None, **kwargs)

Bases: plexsim.models.base.Model

Kinetic q-Potts model

Implements kinetic q-Potts model on arbitrary graph. This model implements all the base functionality of the Potts/Ising related models (e.g. Pottsis or Bornholdt).

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure for the spins.

  • gentStates (np.ndarray,) – Array giving q-states

  • delta (int) – A modifier for how much the memory affects the current received energy of

  • node (a) –

  • **kwargs

    General settings (see Model).

Examples

FIXME: Add docs.

H

External magnetic field

beta

Shortcut for 1/T

delta
magnetize(self, ndarray temps=np.logspace(-3, 2, 20), size_t n=int(1e3), size_t burninSamples=0, size_t n_jobs=0)ndarray

Computes the magnetization as a function of temperatures

temps: np.ndarray

a range of temperatures

: int

number of samples to simulate for

urninSamples: int

number of samples to throw away before sampling

Returns 2D matrix (2, number of temperatures). The first index (0) contains the magnetization, the second index (1) contains the magnetic susceptibility

node_energy(self, state_t[::1] states)ndarray

” Computes average by degree of node energy of all nodes given a system state.

Parameters

states (memoryview doubles) – 1D vector of spin states

Returns

Returns node energy of all nodes given

Return type

states:

siteEnergy(self, state_t[::1] states)vector[double]

Computes raw site energy of nodes given a system state

Parameters
  • states (memory view of spin states) – 1D vector of size number of spins indicating the system state

  • which to compute the site energy. (for) –

Returns

Returns the raw site energy per spin in the system given

Return type

states:

t

Temperature

plexsim.models.potts.match_temperature(match, results, temps)

matches temperature

plexsim.models.potts.sigmoid(x, a, b, c, d)
plexsim.models.potts.sigmoidOpt(x, params, match)

plexsim.models.pottsis module

class plexsim.models.pottsis.Pottsis(graph, beta=1, eta=.2, mu=.1, **kwargs)

Bases: plexsim.models.potts.Potts

Spin-system epidemic model

Implements spin-system dynamics for susceptible infected susceptible dynamics. It is novel and developed by Casper van Elteren (2020).

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure

  • beta (float) – Temperature of the spin system.

  • eta (float) – Infection rate

  • mu (float) – Recovery rate

  • **kwargs

    Base model settings

Examples

FIXME: Add docs.

beta
eta
mu

plexsim.models.pottsis module

class plexsim.models.pottsis.Pottsis(graph, beta=1, eta=.2, mu=.1, **kwargs)

Bases: plexsim.models.potts.Potts

Spin-system epidemic model

Implements spin-system dynamics for susceptible infected susceptible dynamics. It is novel and developed by Casper van Elteren (2020).

Parameters
  • graph (nx.Graph or nx.DiGraph) – Interaction structure

  • beta (float) – Temperature of the spin system.

  • eta (float) – Infection rate

  • mu (float) – Recovery rate

  • **kwargs

    Base model settings

Examples

FIXME: Add docs.

beta
eta
mu

plexsim.models.prisoner module

class plexsim.models.prisoner.Prisoner(graph, agentStates=np.arange(2), t=1.0, T=1, R=1., P=0., S=0., hierarchy=None, p_recomb=None, alpha=0., **kwargs)

Bases: plexsim.models.potts.Potts

Prisoner dilemma model on a graph

Parameters
  • graph – Structure of the graph see Model :param agentStates:

  • t – level of noise in the system (Gibbs distribution)

  • T – level of temptation to defect [0, 1], defaults to 1

  • R – level of reward to defect [0, 1], defaults to 1

  • P – level of punishment to defect [0, 1], defaults to 0

  • S – level of suckers’ payout to defect [0, 1], defaults to 0

  • hierarchy – external magnetic field that would enforce hierarchy

  • p_recomb – see model

  • alpha – discounting factor of how much to listen to a neighbor, default to 0

P

Punishment property (double)

R

Reward property

S

Suckers’ payout property

T

Temptation property

alpha

Coupling coefficient property

probs(self, state_t state, node_id_t node)double

plexsim.models.prisoner module

class plexsim.models.prisoner.Prisoner(graph, agentStates=np.arange(2), t=1.0, T=1, R=1., P=0., S=0., hierarchy=None, p_recomb=None, alpha=0., **kwargs)

Bases: plexsim.models.potts.Potts

Prisoner dilemma model on a graph

Parameters
  • graph – Structure of the graph see Model :param agentStates:

  • t – level of noise in the system (Gibbs distribution)

  • T – level of temptation to defect [0, 1], defaults to 1

  • R – level of reward to defect [0, 1], defaults to 1

  • P – level of punishment to defect [0, 1], defaults to 0

  • S – level of suckers’ payout to defect [0, 1], defaults to 0

  • hierarchy – external magnetic field that would enforce hierarchy

  • p_recomb – see model

  • alpha – discounting factor of how much to listen to a neighbor, default to 0

P

Punishment property (double)

R

Reward property

S

Suckers’ payout property

T

Temptation property

alpha

Coupling coefficient property

probs(self, state_t state, node_id_t node)double

plexsim.models.pyobjectholder module

plexsim.models.pyobjectholder module

plexsim.models.rbn module

class plexsim.models.rbn.RBN(graph, rule=None, updateType='sync', **kwargs)

Bases: plexsim.models.base.Model

Random boolean network

rules

plexsim.models.rbn module

class plexsim.models.rbn.RBN(graph, rule=None, updateType='sync', **kwargs)

Bases: plexsim.models.base.Model

Random boolean network

rules

plexsim.models.rules module

class plexsim.models.rules.Rules(graph)

Bases: object

Constructs adj matrix using structs :param : :type : nx.Graph or nx.DiGraph: graph

adj

plexsim.models.rules module

class plexsim.models.rules.Rules(graph)

Bases: object

Constructs adj matrix using structs :param : :type : nx.Graph or nx.DiGraph: graph

adj

plexsim.models.sampler module

class plexsim.models.sampler.MCMC(RandomGenerator rng, double p_recomb=1)

Bases: object

Random number generator class
param RandomGenerator rng

param double p_recomb

genetic algorithm recombination probability :type: float

p_recomb
rng
class plexsim.models.sampler.RandomGenerator(seed)

Bases: object

rand(self)double
seed

plexsim.models.sampler module

class plexsim.models.sampler.MCMC(RandomGenerator rng, double p_recomb=1)

Bases: object

Random number generator class
param RandomGenerator rng

param double p_recomb

genetic algorithm recombination probability :type: float

p_recomb
rng
class plexsim.models.sampler.RandomGenerator(seed)

Bases: object

rand(self)double
seed

plexsim.models.simple_copy module

class plexsim.models.simple_copy.SimpleCopy(double weight=0, **kwargs)

Bases: plexsim.models.potts.Potts

plexsim.models.simple_copy module

class plexsim.models.simple_copy.SimpleCopy(double weight=0, **kwargs)

Bases: plexsim.models.potts.Potts

plexsim.models.sirs module

class plexsim.models.sirs.SIRS(graph, agentStates=np.array([0, 1, 2], dtype=np.double), beta=1, mu=1, nu=0, kappa=0, **kwargs)

Bases: plexsim.models.base.Model

SIR model inspired by Youssef & Scolio (2011) The article describes an individual approach to SIR modeling which canonically uses a mean-field approximation. In mean-field approximations nodes are assumed to have ‘homogeneous mixing’, i.e. a node is able to receive information from the entire network. The individual approach emphasizes the importance of local connectivity motifs in spreading dynamics of any process.

The dynamics are as follows

S —-> I —-> R
beta mu

The update deself.mapping.find(k) != tmp.end()pends on the state a individual is in.

S_i: beta A_{i}.dot(states[A[i]]) beta | infected neighbors / total neighbors I_i: mu | prop of just getting cured

TODO: no spontaneous infections possible (my addition) S —-> I —-> R —-> S

beta mu kappa
I —-> S

nu

Todo: the sir model currently describes a final end-state. We can model it that we just assume distributions

beta
init_random(self, node=None)void
kappa
mu
nu

plexsim.models.sirs module

class plexsim.models.sirs.SIRS(graph, agentStates=np.array([0, 1, 2], dtype=np.double), beta=1, mu=1, nu=0, kappa=0, **kwargs)

Bases: plexsim.models.base.Model

SIR model inspired by Youssef & Scolio (2011) The article describes an individual approach to SIR modeling which canonically uses a mean-field approximation. In mean-field approximations nodes are assumed to have ‘homogeneous mixing’, i.e. a node is able to receive information from the entire network. The individual approach emphasizes the importance of local connectivity motifs in spreading dynamics of any process.

The dynamics are as follows

S —-> I —-> R
beta mu

The update deself.mapping.find(k) != tmp.end()pends on the state a individual is in.

S_i: beta A_{i}.dot(states[A[i]]) beta | infected neighbors / total neighbors I_i: mu | prop of just getting cured

TODO: no spontaneous infections possible (my addition) S —-> I —-> R —-> S

beta mu kappa
I —-> S

nu

Todo: the sir model currently describes a final end-state. We can model it that we just assume distributions

beta
init_random(self, node=None)void
kappa
mu
nu

plexsim.models.test module

class plexsim.models.test.A

Bases: object

class plexsim.models.test.B

Bases: plexsim.models.test.A

class plexsim.models.test.C

Bases: plexsim.models.test.B

class plexsim.models.test.D

Bases: plexsim.models.test.C

plexsim.models.test module

class plexsim.models.test.A

Bases: object

class plexsim.models.test.B

Bases: plexsim.models.test.A

class plexsim.models.test.C

Bases: plexsim.models.test.B

class plexsim.models.test.D

Bases: plexsim.models.test.C

plexsim.models.value_network module

class plexsim.models.value_network.ValueNetwork(graph, rules, t=1, bounded_rational=- 1, heuristic=0, redundancy=1, agentStates=np.arange(0, 2, dtype=np.double), **kwargs)

Bases: plexsim.models.potts.Potts

bounded_rational
check_df(self, node_id_t start, bool verbose=False)list

Computes completed value networks

Recursively checks for a node in the current system state the number of completed value networks.

Parameters
  • start (node_id_t) – Node label which to check the completed value networks for.

  • verbose (bool (default False)) – For debugging.

Returns

Return type

List of paths from the node that completes the value networks

dump_rules(self)nx.Graph or nx.DiGraph

Takes the possibly “full” graph, i.e. a networkx graph with negative edges weights, and removes all those edges.

Returns

Return type

Networkx graph without any negative or zero edge weight.

heuristic
redundancy
siteEnergy(self, state_t[::1] states)vector[double]

plexsim.models.value_network module

class plexsim.models.value_network.ValueNetwork(graph, rules, t=1, bounded_rational=- 1, heuristic=0, redundancy=1, agentStates=np.arange(0, 2, dtype=np.double), **kwargs)

Bases: plexsim.models.potts.Potts

bounded_rational
check_df(self, node_id_t start, bool verbose=False)list

Computes completed value networks

Recursively checks for a node in the current system state the number of completed value networks.

Parameters
  • start (node_id_t) – Node label which to check the completed value networks for.

  • verbose (bool (default False)) – For debugging.

Returns

Return type

List of paths from the node that completes the value networks

dump_rules(self)nx.Graph or nx.DiGraph

Takes the possibly “full” graph, i.e. a networkx graph with negative edges weights, and removes all those edges.

Returns

Return type

Networkx graph without any negative or zero edge weight.

heuristic
redundancy
siteEnergy(self, state_t[::1] states)vector[double]

plexsim.models.value_network2 module

class plexsim.models.value_network2.ValueNetwork(graph, rules, t=1, bounded_rational=- 1, agentStates=np.arange(0, 2, dtype=np.double), **kwargs)

Bases: plexsim.models.potts.Potts

bounded_rational
check_df(self, node_id_t start, bool verbose=False)list
check_doubles(self, list path, list results, bool verbose=False)bool

Don’t allow for double edges Adds path inplace if it does not occur in results

check_endpoint(self, state_t s, list vp_path)bool

Check if an end point is reached

check_traversal(self, list proposal, list options, bool verbose=False)void
dump_rules(self)nx.Graph or nx.DiGraph

Takes the possibly “full” graph, i.e. a networkx graph with negative edges weights, and removes all those edges.

Returns

Return type

Networkx graph without any negative or zero edge weight.

merge(self, list results, bool verbose=False)void

Merge paths from branches inplace

pat
siteEnergy(self, state_t[::1] states)vector[double]

plexsim.models.value_network2 module

class plexsim.models.value_network2.ValueNetwork(graph, rules, t=1, bounded_rational=- 1, agentStates=np.arange(0, 2, dtype=np.double), **kwargs)

Bases: plexsim.models.potts.Potts

bounded_rational
check_df(self, node_id_t start, bool verbose=False)list
check_doubles(self, list path, list results, bool verbose=False)bool

Don’t allow for double edges Adds path inplace if it does not occur in results

check_endpoint(self, state_t s, list vp_path)bool

Check if an end point is reached

check_traversal(self, list proposal, list options, bool verbose=False)void
dump_rules(self)nx.Graph or nx.DiGraph

Takes the possibly “full” graph, i.e. a networkx graph with negative edges weights, and removes all those edges.

Returns

Return type

Networkx graph without any negative or zero edge weight.

merge(self, list results, bool verbose=False)void

Merge paths from branches inplace

pat
siteEnergy(self, state_t[::1] states)vector[double]

Module contents