Ensemble Generation#
AbstractEnsembleGenerator#
-
class
rethon.
AbstractEnsembleGenerator
# Bases:
abc.ABC
Abstract base class for all ensemble generators.
This abstract class should be used to implement ensemble generators. It implements basic functionalities to add data items that will be used to generate dictionaries for each model run and that will contain information about each model run according to the specified data items. Data items (key-value pairs in the produced dict) can be defined by specifying a key and a function that returns the desired data (see
add_item()
).Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
Current dialectical structure when iterating through model runs.
Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Saving model runs as csv file.
Iterator through all model runs.
Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(ensemble_states, …)Initiating data objects that rely on the dialectical structure and a set of finished model runs.
init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and an instantied RE.
init_tau_fields
(tau)Initiating data objects that rely on the dialectical structure.
Current initial commitments when iterating through the model runs.
Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
add_item
(key, fun)# Adds a data item.
Adding a key-method pair that will be used to calculate a data item. Data items will be returned for each model run by
ensemble_items_iter()
. A data item represents data that describes a model run in some way. It can be defined by providing a function that can use the internal attributes (e.g. via its gettersstate()
,dialectical_structure()
,reflective_equilibrium()
,initial_commitments()
andensemble_states()
) and deposited objects (viaadd_obj()
). The function should specify anAbstractEnsembleGenerator
as its one argument.A simple example is the following:
# defining the function def data_last_coms(ensemble_generator): return ensemble_generator.state().last_commitments() # adding the data item my_ensemble_generator.add_item('last_coms', data_last_coms) # looping through the ensemble using the item_iter will now # have a key-value pair that stores the final commitments # for each model run for model_run_data_items in my_ensemble_generator.ensemble_items_iter(): print("The model run produced the following data items:") print(f"{model_run_data_items}.")
- Parameters
key (str) – A key for the data item.
fun (Callable[[AbstractEnsembleGenerator], None]) – A function that defines a datum of a model run.
-
add_obj
(key, obj)# Adding a data object.
This method can be used to store data objects that persists through different model runs and can then be accessed via
get_obj()
. Seeinit_tau_fields()
for the rationale of using data objects.- Parameters
key (str) –
-
dialectical_structure
()# Current dialectical structure when iterating through model runs.
- Return type
DialecticalStructure
-
ensemble_items_iter
()# Iterator through data items of model runs.
This methods uses
ensemble_iter()
to return for each model run a dictionary with predefined data items as key-value pairs. The data items can be added withadd_item()
.- Return type
Iterator
[Dict
]
-
ensemble_items_to_csv
(output_file_name, output_dir_name, archive=False, save_preliminary_results=False, preliminary_results_interval=500, append=False)# Saving model runs as csv file.
Using
ensemble_items_iter()
to save the data items of each model run as csv file.- Parameters
output_file_name (str) – Name of the csv file.
output_dir_name (str) – Directory of the csv file.
archive (bool) – If
True
the csv file will be archived as tar.gz. The csv file will not be removed.save_preliminary_results (bool) – If
True
the method will save preliminary results every other model run as defined bypreliminary_results_interval
.append (bool) – If
True
the rows will be added to the file (if it already exists).preliminary_results_interval (int) –
-
abstract
ensemble_iter
()# Iterator through all model runs.
This method should be overriden by subclasses and is responsible to call
init_tau_fields()
,init_re_start_fields()
,init_re_final_fields()
andinit_ensemble_fields()
at appropriate times. Addionally, it should reset the internal attributescurrent_dialectical_structure
,current_state
,current_reflective_equilibrium
,current_initial_commitments
andcurrent_ensemble_states
that can be used to define data item (seeadd_item()
).- Return type
Iterator
[ReflectiveEquilibrium
]
-
ensemble_states
()# Current ensemble states when iterating through the model runs.
- Return type
List
[REState
]
-
get_item
(key)# Returns the return value of the function that is defined by the data item.
-
get_obj
(key)# Returns a data object.
-
init_ensemble_fields
(ensemble_states, dialectical_structure)# Initiating data objects that rely on the dialectical structure and a set of finished model runs.
This method can be called by implementations of
ensemble_iter()
and can be used to store objects byadd_obj()
that in turn can be accessed byget_obj()
in the definition of data items. Implementing classes should ensure that all models that are aggregated in a sub-ensemble finished in fixed points. (For a rationale of why using this method, seeinit_tau_fields()
.)- Parameters
ensemble_states (List[rethon.base.REState]) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_re_final_fields
(reflective_equilibrium, dialectical_structure)# Initiating data objects that rely on the dialectical structure and a finished model run.
This method can be called by implementations of
ensemble_iter()
and can be used to store objects byadd_obj()
that in turn can be accessed byget_obj()
in the definition of data items. Implementing classes should ensure that the model represented byreflective_equilibrium
finished in a fixed point. (For a rationale of why using this method, seeinit_tau_fields()
.)- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_re_start_fields
(reflective_equilibrium, dialectical_structure)# Initiating data objects that rely on the dialectical structure and an instantied RE.
This method can be called by implementations of
ensemble_iter()
and can be used to store objects byadd_obj()
that in turn can be accessed byget_obj()
in the definition of data items. Implementing classes should ensure that at least the initial commitments and model parameters of the RE instance are already set. (For a rationale of why using this method, seeinit_tau_fields()
.)- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_tau_fields
(tau)# Initiating data objects that rely on the dialectical structure.
This method can be called by implementations of
ensemble_iter()
and can be used to store objects byadd_obj()
that in turn can be accessed byget_obj()
in the definition of data items.The idea is to reuse data instead of recalculating it in every model run inasmuch (depending on the implementation of this class) several model runs can be based on the same dialectical structure \(\tau\). Accordingly, implementations of
ensemble_iter()
should call this method once for every model run that is based on a particular dialectical structure. A subclass, sayMyEnsembleGenerator
, can then override this method:def init_tau_fields(self, tau): self.add_obj('inferential_density', tau.inferential_density())
The implementation can then access this object in the definition of data items, for instance:
generator = MyEnsembleGenerator() generator.add_item('calculated_inferential_density', lambda x: x.get_obj('inferential_density'))
-
initial_commitments
()# Current initial commitments when iterating through the model runs.
- Return type
Position
-
reflective_equilibrium
()# Current state when iterating through the model runs.
- Return type
ReflectiveEquilibrium
-
remove_item
(key)# Removing a data item.
- Parameters
key (str) –
-
state
()# Current state when iterating through model runs.
- Return type
REState
-
EnsembleGenerator#
-
class
rethon.
EnsembleGenerator
(arguments_list, n_sentence_pool, initial_commitments_list, model_parameters_list=None, create_branches=False, implementations=None)# Bases:
rethon.ensemble_generation.AbstractEnsembleGenerator
Ensemble generator base class for independent model runs.
A class that provides iterators for model runs based on the given parameters of the constructor. The iterator will be build as a cartesian product of these arguments (see
EnsembleGenerator.ensemble_iter()
). The model runs of the ensemble are all based on the same sentence pool. If you whish to generate ensemble with differing sentence pool, you can concatenate instances of this class.- Parameters
arguments_list – Dialectical structures as list of argument lists.
n_sentence_pool – Number of (unnegated) sentences in the sentence pool.
initial_commitments_list – List of initial commitments. Each commitments is represent as set of integers.
model_parameters_list – A list of dictionaries that represents the model parameters and can be set by
ReflectiveEquilibrium.set_model_parameter()
.create_branches – If
True
all branches are created.implementations – A list of dicts, each representing a specific implementation. Each dict should contain strings for the keys ‘tau_module_name’, ‘rethon_module_name’, ‘position_class_name’, ‘dialectical_structure_class_name’ and ‘reflective_equilibrium_class_name’. (If these classes are located in different modules, you can, alternatively, specify modules for each class by using the keys ‘position_module_name’, ‘dialectical_structure_module_name’ and ‘reflective_equilibrium_module_name’)
Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Saving model runs as csv file.
Iterator through re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(ensemble_states, …)Initiating data objects that rely on the dialectical structure and a set of finished model runs.
init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and an instantied RE.
init_tau_fields
(tau)Initiating data objects that rely on the dialectical structure.
initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
ensemble_iter
()# Iterator through re processes.
An ensemble iterator that produces all ensembles in the cartesian product of the given dialectical structures (
arguments_list
), the initial commitments (initial_commitments_list
), the list of model parameters (model_parameters_list
) and the given implementations (implementations
). Ifcreate_branches
is set toTrue
every branch resulting from an underdetermination of commitments or theory candidates will be returned as well.- Return type
Iterator
[ReflectiveEquilibrium
]
SimpleEnsembleGenerator#
-
class
rethon.
SimpleEnsembleGenerator
(arguments_list, n_sentence_pool, initial_commitments_list, model_parameters_list=None, create_branches=False, implementations=None)# Bases:
rethon.ensemble_generation.EnsembleGenerator
This class extends
EnsembleGenerator
by adding the following data items that are produced byAbstractEnsembleGenerator.ensemble_items_iter()
:FEATURES OF THE DIALECTICAL STRUCTURE
model_name
: A name of the model as string.ds
: The dialectical structure as list of int-lists. The first numbers of each list represent the premises, the last one the conclusion.n_sentence_pool
: Number of unnegated sentences (half the full size).ds_arg_size
: Number of arguments.ds_infer_dens
: The inferential density of the structure.ds_n_consistent_complete_positions
: Number of dialectically complete and consistent positions.ds_mean_prem
: Mean number of premises per argument.ds_variance_prem
: Variance of the number of premises per argument.tau_truths
: Propositions that are true in every complete consistent position.principles
: A list of tuples of the form(principle, multiplicity)
withmultiplicity
indicating the multiplicity of the principle. A sentence counts as a principle iff it occurs in at least one argument as premise and it or its negation does not occur as a conclusion in an argument. The multiplicity counts in how many argument the sentence occurs as premise.
PARAMETERS OF THE RE-PROCESS
account_penalties
:faithfulness_penalties
:weight_account
:weight_systematicity
:weight_faithfulness
:
PROCESS-FEATURES
init_coms
: The initial commitments.init_coms_size
: Number of initial commitments.init_coms_n_tau_truths
: Number of tau-true propositions in the initial commitments.init_coms_n_tau_falsehoods
: Number of tau-false propositions in the initial commitments.init_coms_min_ax_bases
: Minimal-length axiomatic bases ofinit_coms
with sentences frominit_coms
only. (Sentences \(\mathcal{C}_a\) are an axiomatic basis of \(\mathcal{C}_1\) (with sentences from \(\mathcal{C}_2\) only) iff \(\mathcal{C}_a\) dialectically implies \(\mathcal{C}_1\) and there is no proper subset of \(\mathcal{C}_a\) such that it implies \(\mathcal{C}_1\) (and \(\mathcal{C}_a \subset \mathcal{C}_2\)).)n_init_coms_min_ax_base
: The length of the minimal-length axiomatic bases (not the number of such bases).init_coms_n_consistent_complete_positions
: Number of consistent complete positions that extend the initial commitments.init_coms_dia_consistent
: Whether the initial commitments are dialectically consistent.init_coms_closed
: Whether the initial commitments are dialectically closed.init_coms_closure
: Dialectical closure of initial commitments.fixed_point_coms
: Final commitments.fixed_point_coms_size
: The number of propositions infixed_point_coms
.fixed_point_coms_com_n_tau_truths
: Number of tau-true propositions in the final commitments.fixed_point_coms_com_n_tau_falsehoods
: Number of tau-false propositions in the final commitments.fixed_point_coms_closed
: Whether the final commitments is dialectically closed.fixed_point_coms_closure
: Dialectical closure of final commitments.fixed_point_coms_consistent
: Whether the final commitments is dialectically consistent.fixed_point_theory
: The final theory.fixed_point_theory_closure
: Closure of the final theory.achievements_evolution
:fixed_point_dia_consistent
: Whether the union of final theory & commitments is dialectically consistent.init_final_coms_simple_hamming
: Simple hamming distance between initial and final commitments.init_final_coms_hamming
: Hamming distance between initial and final commitments as defined in BBB with d_3 = 1, d_2 = 1, d_1 = 1, d_0 = 0.init_final_coms_contradictions
: Amount of contradictions: number of sentences whose contradictions are in both positions (i.e. hamming distance as defined in BBB with d_3 = 1, d_2 = 0, d_1 = 0, d_0 = 0)init_final_coms_expansions
: Amount of expansions without expansions that lead to contradictions or identities (i.e. hamming distance as defined in BBB with d_3 = 0, d_2 = 0, d_1 = 1, d_0 = 0)init_final_coms_contractions
: Amount of contractions (i.e. hamming distance as defined in BBB with d_3 = 0, d_2 = 1, d_1 = 0, d_0 = 0)init_final_coms_identities
: Amount of identities without identities that are associated with contradictions (i.e. hamming distance as defined in BBB with d_3 = 0, d_2 = 0, d_1 = 0, d_0 = 1) attention: counts also sentences on which both positions are indifferent.random_choices
:n_random_choices
: Number of random choice of the process.comms_evolution
: The dynamic evolution of theories during the process. (Depicting the algorithmic process.)theory_evolution
: The dynamic evolution of commitments during the process. (Depicting the algorithmic process.)process_length
: The length of the process. Defined as the number of steps that will either produce a change in the commitments or a change in the theory, beginning the choosing the first theory. (I.e. this number will generally be smaller than the amount of elements combined incommitments_evolution
andtheory_evolution
.)
PROCESS-INDEPENDENT FEATURES
In the case that the ensemble generator is configured (via its instantiation) to run all branches the following data items are added as well:
n_branches
: Number of branches of the process (i.e. paths to all fixed points w.r.t. the given initial commitments.
Fixed points:
fixed_points
: All fixed points as theory-commitments-tuples.n_fixed_points
: Number of fixed pointsfp_coms_consistent
: A list of bools (List[bool]
) indicating whether commitments of the fixed_points are dialectically consistent. The order of the list represents the order in fixed_points.fp_union_consistent
: A list of bools (List[bool]
) indicating whether the unions of a commitment-theory-tuple of the fixed_points are dialectically consistent.The order of the list represents the order in fixed_points.fp_account
: The account of each fixed point asList[float]
. The order of the list represents the order in fixed_points.fp_faithfulness
: The faithfulness of each fixed asList[float]
. The order of the list represents the order in fixed_points.
Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Saving model runs as csv file.
ensemble_iter
()Iterator through re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(ensemble_states, …)init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)init_tau_fields
(tau)Overrides
AbstractEnsembleGenerator.init_tau_fields
.initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
init_ensemble_fields
(ensemble_states, dialectical_structure)# Overrides
AbstractEnsembleGenerator.init_ensemble_fields
.Adds the following data object that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘n_branches’ and fixed_points’, if the ensemble generator is set up to run every branch.- Parameters
ensemble_states (List[rethon.base.REState]) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_re_start_fields
(reflective_equilibrium, dialectical_structure)# Overrides
AbstractEnsembleGenerator.init_re_start_fields
.Adds the following data object that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘init_com_min_ax_bases’.- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_tau_fields
(tau)# Overrides
AbstractEnsembleGenerator.init_tau_fields
.Adds the following data objects that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘ds_infer_dens’, ‘n_premises’, ‘principles’, ‘tau_truths’ and ‘tau_falsehoods’.- Parameters
tau (tau.base.DialecticalStructure) –
GlobalREEnsembleGenerator#
-
class
rethon.
GlobalREEnsembleGenerator
(arguments_list, n_sentence_pool, initial_commitments_list, model_parameters_list=None, create_branches=False, implementations=None)# Bases:
rethon.ensemble_generation.SimpleEnsembleGenerator
This class extends
SimpleEnsembleGenerator
by adding the following data items that are produced byAbstractEnsembleGenerator.ensemble_items_iter()
:Additional items for the fixed point:
fixed_point_is_global_optimum
: Whether the fixed point is a global optimum.fixed_point_is_re_state
: Whether the fixed point is a RE state.fixed_point_is_full_re_state
: Whether the fixed point is a full RE state.fixed_point_coms_n_consistent_complete_positions
: The number of complete and dialectically consistent positions that extend the final commitments.fixed_point_coms_min_ax_bases
: Minimal-length axiomatic bases offixed_point_coms
with sentences fromfixed_point_coms
only. (Sentences \(\mathcal{C}_a\) are an axiomatic basis of \(\mathcal{C}_1\) (with sentences from \(\mathcal{C}_2\) only) iff \(\mathcal{C}_a\) dialectically implies \(\mathcal{C}_1\) and there is no proper subset of \(\mathcal{C}_a\) such that it implies \(\mathcal{C}_1\) (and \(\mathcal{C}_a \subset \mathcal{C}_2\)).)n_fixed_point_coms_min_ax_base
: The size of minimal-length axiomatic bases offixed_point_coms
with sentences fromfixed_point_coms
only.fixed_point_coms_min_ax_bases_theory
: A minimal-length subset \(\mathcal{C}'\) of the final commitments such that the final commitments are entailed by the theory and \(\mathcal{C}'\). (Or equivalently: A smallest subset \(\mathcal{C}'\) within the commitments such that there is an axiomatic basis \(A\) for the commitments \(\mathcal{C}\) with: \(A= \mathcal{C}' \cup \mathcal{T}'\) and \(\mathcal{T}'\) a subset of the theory)n_fixed_point_coms_min_ax_base_theory
: Number of propositions in each set infixed_point_coms_min_ax_bases_theory
.fixed_point_theory_axioms
: Axiomatic bases of the final theory.
Additional items for all fixed points (these items are only generated if branches are created):
fp_full_re_state
: A list of bools (List[bool]
) indicating whether the fixed_points are full RE-states (i.e. whether the dialectical closure of the theory is identical to the commitments). The order of the list represents the order in fixed_points.fp_global_optimum
: A list of bools (List[bool]
) indicating whether the fixed_points are global_optima.
Additional items for global optima:
global_optima
: All global optima as theory-commitments-tuples.n_global_optima
: Number of global optima.go_coms_consistent
: A list of bools (List[bool]
) indicating whether commitments of the global_optima are dialectically consistent. The order of the list represents the order in global_optima.go_union_consistent
: A list of bools (List[bool]
) indicating whether the unions of acommitment-theory-tuple of the global_optima are dialectically consistent. I.e. whether the global optima are RE states.The order of the list represents the order in global_optima.
go_full_re_state
: A list of bools (List[bool]
) indicating whether the global_optima are full RE-states (i.e. whether the dialectical closure of the theory is identical to the commitments). The order of the list represents the order in global_optima.go_fixed_point
: A list of bools (List[bool]
) indicating which global optima are fixed points (i.e. which global optima are reachable via a re-process). The order of the list represents the order in global_optima.go_account
: The account of each global optimum asList[float]
. The order of the list represents the order in global_optima.go_faithfulness
: The faithfulness of each global optimum asList[float]
. The order of the list represents the order in global_optima.
Additional items for RE states and full RE states:
re_states
:n_re_states
:full_re_states
:n_full_re_states
:
Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Saving model runs as csv file.
ensemble_iter
()Iterator through re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(ensemble_states, …)init_re_final_fields
(reflective_equilibrium, …)init_re_start_fields
(reflective_equilibrium, …)Extends
SimpleEnsembleGenerator.init_re_final_fields
.init_tau_fields
(tau)Overrides
AbstractEnsembleGenerator.init_tau_fields
.initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
init_re_final_fields
(reflective_equilibrium, dialectical_structure)# Overrides
AbstractEnsembleGenerator.init_re_final_fields
.Adds the following data objects that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘fixed_point_coms_min_ax_bases’ and ‘fixed_point_coms_min_ax_bases_theory’.- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_re_start_fields
(reflective_equilibrium, dialectical_structure)# Extends
SimpleEnsembleGenerator.init_re_final_fields
.Adds the following data objects that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘global_optima’, ‘re_states’ and ‘full_re_states’.- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
LocalREEnsembleGenerator#
-
class
rethon.
LocalREEnsembleGenerator
(arguments_list, n_sentence_pool, initial_commitments_list, model_parameters_list=None, create_branches=False, implementations=None)# Bases:
rethon.ensemble_generation.SimpleEnsembleGenerator
This class extends
SimpleEnsembleGenerator
by adding the following data items that are produced byAbstractEnsembleGenerator.ensemble_items_iter()
:neigbourhood_depth
: The neighbourhood depth that is used to search for next commitmentsand theory candidates.
Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Saving model runs as csv file.
ensemble_iter
()Iterator through re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(ensemble_states, …)init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)init_tau_fields
(tau)Overrides
AbstractEnsembleGenerator.init_tau_fields
.initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
SimpleMultiAgentREContainer#
-
class
rethon.
SimpleMultiAgentREContainer
(re_models, initial_commitments_list, max_re_length=100)# Bases:
rethon.base.REContainer
An
REContainer
for multi-agent ensembles.This container manages and executes model runs that are defined as an multi-agent ensemble. The container will execute for each particular point in time the next step of all model and will then proceed accordingly with the time point. Each model will be provided with the current model states of the other models by references to the other models via the argument
other_model_runs
. This argument is accessible by overriding or extending the following methods in each model:Methods
re_processes
-
re_processes
(re_models=None)# - Return type
List
[ReflectiveEquilibrium
]- Parameters
re_models (Optional[List[rethon.base.ReflectiveEquilibrium]]) –
MultiAgentEnsemblesGenerator#
-
class
rethon.
MultiAgentEnsemblesGenerator
(arguments_list, n_sentence_pools, initial_commitments_list, implementations=None, model_parameters_list=None)# Bases:
rethon.ensemble_generation.AbstractEnsembleGenerator
Ensemble generator base class for multi-agent (=interdependent) model runs.
A class that provides iterators for interdependet model runs based on the given parameters of the constructor. One ensemble corresponds to a dialectical structure together with a set of agents (represented by their initial commitments). The generator will run all ensembles successively.
This structure can be used to generate different ensembles. (E.g., you can vary the number of agents for one particular dialectical structure by repeating the dialectical structure in the above list and vary the list of initial positions.) However, this design adheres to the following confinements: All agents in one ensemble share the implementating classes and their model parameters.
The following data items are defined by default: ‘ensemble_id’ and ‘ensemble_size’ for each multi-agent ensemble.
- Parameters
arguments_list – A list of n dialectical structures as list of argument lists. Each dialectical structure corresponds an multi-agent ensemble.
n_sentence_pool – Number of (unnegated) sentences in the sentence pool.
initial_commitments_list – For each dialectical structure a list of initial commitments. (The initial commitments can be thought of as different agents.)
model_parameters_list – For each dialectical structure a specification of model parameters as dictionary that can be set via
ReflectiveEquilibrium.set_model_parameters()
.implementations – A list of dicts, each representing a specific implementation. Each dict should contain strings for the keys ‘module_name’, ‘position_class_name’, ‘dialectical_structure_class_name’ and ‘reflective_equilibrium_class_name’. (If these classes are located in different modules, you can, alternatively, specify modules for each class by using the keys ‘position_module_name’, ‘dialectical_structure_module_name’ and ‘reflective_equilibrium_module_name’)
Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Extends
AbstractEnsembleGenerator.ensemble_items_to_csv.
Iterator through the re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(re_states, …)init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and an instantied RE.
init_tau_fields
(tau)Initiating data objects that rely on the dialectical structure.
initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
ensemble_items_to_csv
(output_file_name, output_dir_name, archive=False, save_preliminary_results=False, preliminary_results_interval=500, append=False)# Extends
AbstractEnsembleGenerator.ensemble_items_to_csv.
If
append
is set toTrue
the method will make sure that different ensembles have different ensemble ids (which are saved via an extra column for each model run).- Parameters
output_file_name (str) –
output_dir_name (str) –
save_preliminary_results (bool) –
preliminary_results_interval (int) –
-
ensemble_iter
()# Iterator through the re processes.
An ensemble iterator through all model rus of all multi-agents ensembles as defined by the class attributes (implements
AbstractEnsembleGenerator.ensemble_iter()
). Model runs that belong to the same multi-agent ensemble can be identified via their ensemble id, which can be accessed viaget_obj('ensemble_id')
.- Return type
Iterator
[ReflectiveEquilibrium
]
-
init_ensemble_fields
(re_states, dialectical_structure)# Overrides
AbstractEnsembleGenerator.init_ensemble_fields()
Adds for every multi-agent ensemble the following data objects: ‘ensemble_id’ and ‘ensemble_size’.
- Parameters
re_states (List[rethon.base.REState]) –
dialectical_structure (tau.base.DialecticalStructure) –
SimpleMultiAgentEnsemblesGenerator#
-
class
rethon.
SimpleMultiAgentEnsemblesGenerator
(arguments_list, n_sentence_pools, initial_commitments_list, implementations=None, model_parameters_list=None)# Bases:
rethon.ensemble_generation.MultiAgentEnsemblesGenerator
A
MultiAgentEnsembleGenerator
with predefined data items.This class extends
MultiAgentEnsembleGenerator
by adding data items that are produced byAbstractEnsembleGenerator.ensemble_items_iter()
. The ensemble generator is initiated with the same data fields as theSimpleEnsembleGenerator
(except data fields that are only created in the case that theSimpleEnsembleGenerator
runs all branches).Methods
add_item
(key, fun)Adds a data item.
add_obj
(key, obj)Adding a data object.
dialectical_structure
()Current dialectical structure when iterating through model runs.
ensemble_items_iter
()Iterator through data items of model runs.
ensemble_items_to_csv
(output_file_name, …)Extends
AbstractEnsembleGenerator.ensemble_items_to_csv.
ensemble_iter
()Iterator through the re processes.
ensemble_states
()Current ensemble states when iterating through the model runs.
get_item
(key)Returns the return value of the function that is defined by the data item.
get_obj
(key)Returns a data object.
init_ensemble_fields
(re_states, …)init_re_final_fields
(reflective_equilibrium, …)Initiating data objects that rely on the dialectical structure and a finished model run.
init_re_start_fields
(reflective_equilibrium, …)init_tau_fields
(tau)Overrides
AbstractEnsembleGenerator.init_tau_fields
.initial_commitments
()Current initial commitments when iterating through the model runs.
reflective_equilibrium
()Current state when iterating through the model runs.
remove_item
(key)Removing a data item.
state
()Current state when iterating through model runs.
-
init_re_start_fields
(reflective_equilibrium, dialectical_structure)# Overrides
AbstractEnsembleGenerator.init_re_start_fields
.Adds the following data object that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘init_com_min_ax_bases’.- Parameters
reflective_equilibrium (rethon.base.ReflectiveEquilibrium) –
dialectical_structure (tau.base.DialecticalStructure) –
-
init_tau_fields
(tau)# Overrides
AbstractEnsembleGenerator.init_tau_fields
.Adds the following data objects that can be accessed via
AbstractEnsembleGenerator.get_obj()
: ‘ds_infer_dens’, ‘n_premises’, ‘principles’, ‘tau_truths’ and ‘tau_falsehoods’.- Parameters
tau (tau.base.DialecticalStructure) –
-