Setting up a simulation#

Simulations are instances of a simulation class. There are multiple simulation classes in taupy for different kinds of simulations. The class taupy.Simulation composes arguments at each introduction step. In the class taupy.FixedDebateSimulation, argument maps are pre-compiled and arguments are individually uncovered in each introduction step.

Examples#

A minimal example#

Simulations without agents that follow purposeful introduction or updating strategies can be created with a call to Simulation and leaving the positions to None. Simulations without positions can only contain un-directed, random arguments. Introduced arguments can only follow a purposeful argumentation strategy if there are at least two agents in the population, a “source” and a “target”.

sim1 = Simulation(sentencepool="p:20")
# Create p0, p1,... p19 in a new local namespace. Access them via:
sim1.sentencepool[0], sim1.sentencepool[1], sim1.sentencepool[-1]

A more realistic example#

There are many settings to the simulation classes, listed below, but not all of them need to be configured for every simulation. Here is an example of a simulation that runs largely on the defaults:

# Create 10 positions with strategy attack. These will receive random beliefs
# as none are specified.
my_population = [Position(
        debate=None,
        introduction_strategy=strategies.attack
        ) for _ in range(10)]

# Set up a simulation with a sentence pool of 20, assign the population to it
# and set an argument length to 2 or 3 premises.
sim2 = Simulation(
        positions=my_population,
        sentencepool="p:20",
        argumentlength=[2,3]
)

Simulation types#

Iterative argument introductions#

class taupy.simulation.simulation.Simulation(directed=True, debate_growth='random', events={'introduction': 9, 'new_sentence': 1}, sentencepool='p:10', max_sentencepool=None, key_statements=None, parent_debate=None, argumentlength=2, positions=None, copy_input_positions=True, initial_position_size=None, default_introduction_strategy={'name': 'random', 'pick_premises_from': None, 'source': False, 'source_accepts_conclusion': 'NA', 'target': False, 'target_accepts_conclusion': 'NA'}, default_update_strategy='closest_coherent', partial_neighbour_search_radius=50)[source]#

A simulation in which agents introduce new arguments bit by bit. For historic reasons, this kind of simulation bears the generic name.

Parameters:
  • directed (bool) – Boolean indicating whether purposeful argument introductions are requested. If set to False, random arguments that do not take into account agents’ belief systems are introduced.

  • debate_growth – Can be either of "random" or "treelike". Random debate growth leads to argument maps that are like random graphs. Tree-like debate growth leads to maps that are hierarchical, tree-like structures. The latter require specification of key_statements, as the roots of the tree need to be specified.

  • events (dict) – A mapping of events to their chance of occuring. Recognised events are "introduction" and "new_sentence".

  • sentencepool – The initial pool of sentence available for argument introductions. The input needs to be valid input for sympy.symbols(). It is recommded to use sympy’s "p:n" notation, where n refers to the number of sentences.

  • max_sentencepool – When the probability of a “new_sentence” event is non-zero, the sentencepool is enlarged in the course of a simulation run until it reaches its maximum extension. As in sentencepool, the input needs to be understood by sympy.symbols() and should be equal or greater than sentencepool. If None is input, it will default to the extension of sentencepool.

  • key_statements

    When a "treelike" debate_growth is selected, should be an iterable of inputs understood by sympy.symbols(). Has no effect when "random" debate_growth is selected. These key statements will be the roots of constructed tree-like argument map. Needs to be a subset of elements from sentencepool and max_sentencepool.

    Example

    A sentence pool of "p:20" includes the symbols p0, p1, …, p19. The first two items can be selected as roots for the argument map like this:

    >>> s = Simulation(debate_growth="treelike", sentencepool="p:20", key_statements=["p0", "p1"])
    

  • parent_debate – If supplied, the simulation will inherit this debate stage. Otherwise, simulations are initialised with an empty debate stage.

  • argumentlength

    Either an integer or an iterable of integers indicating the number of premises per argument. If an integer \(n\) is provided, all arguments will have \(n\) premises. If an iterable is provided, one of its elements \(e\) is chosen randomly at each argument introduction, and the introduced arguments will receive \(e\) premises.

    Examples

    Arguments with exactly four premises are introduced to a simulation:

    >>> s = Simulation(argumentlength=4)
    

    Arguments with 1–4 premises are introduced to this simulation:

    >>> s = Simulation(argumentlength=[1,2,3,4])
    

  • positions

    An iterable of agents participating in the debate. If not supplied, only random arguments can be introduced in a simulation. Other argumentation strategies require at least two agents in the population.

    Example

    First generate a list of 10 agents with the fortify strategy:

    >>> mypositions = [Position(debate=None, introduction_strategy=strategies.fortify) for _ in range(10)]
    

    And then use it in the Simulation initialisation:

    >>> s = Simulation(positions=mypositions)
    

  • copy_input_positions – Decide whether to make a deep copy of the input positions. If set to False, the input position objects will be mutated by the simulation run.

  • initial_position_size – If given as an integer \(i\), positions will be filled up with random truth-value attributions until they contain \(i\) such judgements. When None is selected, agents will have complete positions, i.e. they will assign a truth-value to each sentence in the sentence pool.

  • default_introduction_strategy – The introduction strategy for positions that have no introduction_strategy assigned to them.

  • default_update_strategy

    Specifies how agents should update their belief system in case of incoherence. Two methods are implemented:

    • "closest_coherent": recommended for complete positions

    • "closest_closed_partial_coherent": recommended for partial positions

  • partial_neighbour_search_radius (int) – A parameter for the "closest_closed_partial_coherent". As the number of partial neighbours rises exponentially when the distance increases, this puts an upper limit on the number of inspected possible positions that an agent with a partial position would move to.

Pre-compiled argument maps#

class taupy.simulation.simulation.FixedDebateSimulation(argument_selection_strategy='any', debate_generation={'max_density': 1.0}, default_update_strategy='closest_coherent', initial_arguments=None, initial_position_size=None, num_key_statements=1, partial_neighbour_search_radius=100, positions=None, sentencepool='p:10')[source]#

A simulation that begins with a pre-defined debate. Agents uncover arguments from the debate in each simulation step. The pre-defined debate follows the argument map generation algorithm Betz, Chekan & Mchedlidze ([Betz2021]).

Parameters:
  • argument_selection_strategy – Can be "any" or "max". When set to "any", a random argument is uncovered at each step as long as it matches the argumentation strategies’ requirements. If "max" is selected, arguments that reach the most agents in the population is selected.

  • debate_generation (dict) – Additional settings to the initial argument map generation which are passed on to generate_hierarchical_argument_map(). Note that the number of key statements and the sentencepool are provided in dedicated attributes num_key_statements and sentencepool.

  • default_update_strategy – Agents who need to update their position do so according to the strategy selected here. Options are "closest_coherent" for complete positions and "closest_closed_partial_coherent" for partial positions.

  • initial_arguments – Start the simulation with these arguments, even if they are not part of the generated argument map. It is advised to use the default None.

  • initial_position_size – The number of belief for the initial positions. If set to None, will default to the length of the sentencepool. If smaller than the sentencepool, positions will be partial and contain a random subset of sentences. Positions that have no initial truth-value attributions will be randomly assigned.

  • num_key_statements (int) – The number of roots for the generated tree-like argument map.

  • partial_neighbour_search_radius (int) – An additional setting for the "closest_closed_partial_coherent" updating strategy, indicating the neighbourhood radius that is scanned for an alternative if a position needs to update.

  • positions – A list of initial positions, as indicated in Setting up a population.

  • sentencepool – A sentencepool, given as an iterable understood by sympy.symbols(), to be forwarded to the tree-like argument map generation.