ToggleMoleculeRandomly

open class ToggleMoleculeRandomly<T>(reaction: NodeReaction<T>, randomGenerator: RandomGenerator, molecule: Molecule, concentration: T, odds: Double) : ToggleMolecule<T>

Treats molecule as a probabilistic switch:

  • if it is present, then with probability odds it's removed from targetNode;

  • otherwise, with probability odds it is inserted in targetNode with the provided concentration.

Parameters

reaction

the reaction owning this action, whose node contains the molecule to toggle

molecule

the molecule to toggle

concentration

the concentration to use for the "on" state

Type Parameters

T

the concentration type

Constructors

Link copied to clipboard
constructor(reaction: NodeReaction<T>, randomGenerator: RandomGenerator, molecule: Molecule, concentration: T, odds: Double)

Properties

Link copied to clipboard
override val reaction: NodeReaction<T>

The NodeReaction owning this action, hosted by targetNode.

Link copied to clipboard

Functions

Link copied to clipboard
override fun cloneAction(newReaction: Reaction<T>): Action<T>

Creates an equivalent action owned by newReaction, such as a reaction cloned onto a new node. An action targeting the host of its reaction targets the host of newReaction, which must then be a Node; an action targeting any other node keeps its target.

Link copied to clipboard
open override fun execute()

Rolls the dice and toggles the molecule.

Link copied to clipboard
infix fun Action<*>.shouldEqual(other: Action<*>)
Link copied to clipboard
open override fun toString(): String