Abstract and Core Classes#
ReflectiveEquilibrium#
- class rethon.ReflectiveEquilibrium#
Bases:
ABC
Abstract class representing a process of finding epistemic states that are in a reflective quilibrium.
The process of finding a reflective equilbrium starts with a set of initial commitments \(\mathcal{C}_0\). In the next step a first theory \(\mathcal{T}_0\) is chosen. The process is repeated and represents a step-wise adjusted of theories and commitments until a final state is reached the represents the reflective equilibrium.
\[\mathcal{C_0} \rightarrow \mathcal{T_0} \rightarrow \mathcal{C_1} \rightarrow \mathcal{T_1} \rightarrow \dots \rightarrow \mathcal{T_{final}} \rightarrow \mathcal{C_{final}}\]Each step is triggered by
next_step()
which will, depending on whether the next step is choosing a new theory or a set of new commitments, succeed in the following way:Either
commitment_candidates()
ortheory_candidates()
will be called to determine a set of candidate commitments or theories.pick_commitment_candidate()
orpick_theory_candidate()
will be called to decide on the next commitments/theory according to some additional criterion (which will be non-trivial if the former sets have more than one element).
The function
finished()
is used to determine the final state of the process.Accordingly, subclasses must implement these functions to specify re processes.
Methods
commitment_candidates
([time])Commitment candidates for choosing next commitments.
Implementing classes should use this method to define default model parameters.
Return the dialectical structure on which the model is based.
finished
(**kwargs)Criterion of when the RE process reached a final state.
is_dirty
()Checks whether the model demand an update of internal attributes.
Model name.
model_parameter
(name)Returns model parameters by names.
Returns names (keys) of the model parameters.
Getting all model parameters as dict.
Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
pick_commitment_candidate
(commitments_candidates)Determination of the next commitments given the commitments candidates.
pick_theory_candidate
(theory_candidates[, time])Determination of the next theory given the theory candidates.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.theory_candidates
([time])Theory candidates for choosing the next theory.
update
(**kwargs)Subclasses can extend/override this method to update internal attributes of the model.
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name=None)#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
model_name (str | None) –
- abstract commitment_candidates(time=None, **kwargs)#
Commitment candidates for choosing next commitments.
- Return type:
Set
[Position
]- Parameters:
time (int | None) –
- abstract static default_model_parameters()#
Implementing classes should use this method to define default model parameters.
- Return type:
Dict
- dialectical_structure()#
Return the dialectical structure on which the model is based.
- Return type:
DialecticalStructure
- abstract finished(**kwargs)#
Criterion of when the RE process reached a final state.
- Return type:
bool
- get_id()#
- is_dirty()#
Checks whether the model demand an update of internal attributes.
- model_name()#
Model name.
- Return type:
str
- Returns:
A name of the model implemented by that class.
- model_parameter(name)#
Returns model parameters by names.
- Parameters:
name (str) –
- model_parameter_names()#
Returns names (keys) of the model parameters.
- model_parameters()#
Getting all model parameters as dict.
- Return type:
Dict
- model_parameters_set_to_default()#
Resets the model parameters to their default values.
- next_step(time=None, **kwargs)#
Triggers search for next commitments/theory.
- Parameters:
time (int | None) –
- abstract pick_commitment_candidate(commitments_candidates, time=None, **kwargs)#
Determination of the next commitments given the commitments candidates.
- Return type:
Position
- Parameters:
commitments_candidates (Set[Position]) –
time (int | None) –
- abstract pick_theory_candidate(theory_candidates, time=None, **kwargs)#
Determination of the next theory given the theory candidates.
- Return type:
Position
- Parameters:
theory_candidates (Set[Position]) –
time (int | None) –
- re_process(initial_commitments=None, max_steps=50)#
Process of finding a reflective equilibrium based on given initial commitments.
Starting with the initial commitments \(\mathcal{C}_0\) as the initial epistemic state, the epistemic state is successively revised until the process is finished (as defined by
finished()
).- Parameters:
initial_commitments (
Optional
[Position
]) – A position representing the initial commitments at the outset of an RE process.max_steps (
int
) – The number of steps (i.e. theory or commitments adjustments) before the process is aborted, raising aMaxLoopsWarning
.max_steps
defaults to 50.
- reset_model_parameters(parameters)#
Resetting model parameters.
Replaces the current model parameters with
paramters
.- Parameters:
parameters (Dict) –
- set_dialectical_structure(dialectical_structure)#
Set the dialectical structure on which the model is based.
- Parameters:
dialectical_structure (DialecticalStructure) –
- set_dirty(dirty)#
Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
- Parameters:
dirty (bool) –
- set_id(id)#
- Parameters:
id (int) –
- set_initial_state(initial_commitments)#
Set the initial state of the model.
- Parameters:
initial_commitments (Position) –
- set_model_parameters(parameters=None, **kwargs)#
Setting model parameters either by a dictionary or key-value pairs.
The given parameters will be added to the given parameters or updated respectively.
- Parameters:
parameters (Dict | None) –
- set_state(state)#
Setting the current state of the model.
The instance is set to dirty only when the state is set the first time or the initial state differs.
- Parameters:
state (REState) –
- abstract theory_candidates(time=None, **kwargs)#
Theory candidates for choosing the next theory.
- Return type:
Set
[Position
]- Parameters:
time (int | None) –
- update(**kwargs)#
Subclasses can extend/override this method to update internal attributes of the model.
StandardReflectiveEquilibrium#
- class rethon.StandardReflectiveEquilibrium#
Bases:
ReflectiveEquilibrium
Abstract class that describes RE in terms of optimizing an achievement function.
The class partially implements
ReflectiveEquilibrium
and provides additional functions to calculate an achievement function \(Z\) (achievement()
) for each step that can be used by subclasses to propose theory and commitments candidates.This class already determines the behaviour in the case of an underdetermination of commitments and theory candidates: In this case a set of random commitments/ a random theory is chosen.
Methods
account
(commitments, theory)Account of the theory w.r.t.
achievement
(commitments, theory, ...)The achievement function \(Z\).
commitment_candidates
([time])Commitment candidates for choosing next commitments.
Default model parameters of the standard model.
dialectical_structure
()Return the dialectical structure on which the model is based.
faithfulness
(commitments, initial_commitments)Faithfulness of the commitments w.r.t.
finished
(**kwargs)Implements
ReflectiveEquilibrium.finished()
.hamming_distance
(position1, position2, penalties)The weighted Hamming distance.
is_dirty
()Checks whether the model demand an update of internal attributes.
model_name
()Model name.
model_parameter
(name)Returns model parameters by names.
model_parameter_names
()Returns names (keys) of the model parameters.
model_parameters
()Getting all model parameters as dict.
Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
penalty
(position1, position2, sentence, ...)A penalty function.
Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
pick_theory_candidate
(theory_candidates, ...)Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.systematicity
(theory)Systematicity of the theory.
theory_candidates
([time])Theory candidates for choosing the next theory.
update
(**kwargs)Subclasses can extend/override this method to update internal attributes of the model.
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name='StandardModel')#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
model_name (str) –
- account(commitments, theory)#
Account of the theory w.r.t. the position.
The account \(A\) is a measure of how well the theory \(\mathcal{T}\) accounts for the given commitments \(\mathcal{C}\) and is defined by:
\[A(\mathcal{C}, \mathcal{T}):=\left( 1- \left(\frac{D_{0,0.3,1,1}(\mathcal{C} ,\overline{\mathcal{T}})}{N}\right)^2 \right)\]with \(D\) being the weighted (asymmetric) Hamming Distance (see
hamming_distance()
).- Parameters:
commitments (
Position
) – The commitments \(\mathcal{C}\).theory (
Position
) – The theory \(\mathcal{T}\).
- Return type:
float
- Returns:
- achievement(commitments, theory, initial_commitments)#
The achievement function \(Z\).
The achievement function is a convex combination of account, systematicity and faitfulness:
\[Z(\mathcal{C},\mathcal{T} | \mathcal{C}_0):= \alpha_A A(\mathcal{C}, \mathcal{T}) + \alpha_S S(\mathcal{T}) + \alpha_F F(\mathcal{C}| \mathcal{C}_0)\]The weighing factors \(\alpha_A, \alpha_S, \alpha_F\) are non-negative real numbers that add up to 1.
- Parameters:
commitments (
Position
) – The (current) commitments \(\mathcal{C}\).theory (
Position
) – The (current) theory \(\mathcal{T}\).initial_commitments (
Position
) – The initial commitments \(\mathcal{C}_0\).
- Return type:
float
- Returns:
- static default_model_parameters()#
Default model parameters of the standard model.
Default model parameter for the calculation of achievement and the determination of the vicinity of positions:
{'weights': {'account': 0.35, 'systematicity': 0.55, 'faithfulness': 0.1}, 'account_penalties': list(np.array([0, 0.3, 1, 1], dtype=np.float32)), 'faithfulness_penalties': list(np.array([0, 0, 1, 1], dtype=np.float32)) }
- Return type:
Dict
- faithfulness(commitments, initial_commitments)#
Faithfulness of the commitments w.r.t. the initial commitments.
The faithfulness \(F\) is a measure of how faithfull the commitments \(\mathcal{C}\) are to the initial commitments \(\mathcal{C}_0\) and is defined by:
\[A(\mathcal{C} | \mathcal{C}_0):=\left( 1- \left(\frac{D_{0,0,1,1}(\mathcal{C}_0 ,\mathcal{C})}{N}\right)^2 \right)\]- Parameters:
commitments (
Position
) – The commitments \(\mathcal{C}\).initial_commitments (
Position
) – The initial commitments \(\mathcal{C}_0\).
- Return type:
float
- Returns:
- finished(**kwargs)#
Implements
ReflectiveEquilibrium.finished()
.An re process of the standard model finishes with a state \((\mathcal{C}_i,\mathcal{T}_i)\) iff \((\mathcal{C}_i,\mathcal{T}_i) = (\mathcal{C}_{i-1},\mathcal{T}_{i-1})\)
- Return type:
bool
- hamming_distance(position1, position2, penalties)#
The weighted Hamming distance.
A weighted (asymmetric) Hamming Distance \(D\) between two positions \(\mathcal{A}\) and \(\mathcal{B}\) which is defined by
\[D_{d_0,d_1,d_2,d_3}(\mathcal{A}, \mathcal{B}):= \sum_{\{s,\neg s\} \subset S} d_{{d_0,d_1,d_2,d_3}}(\mathcal{A}, \mathcal{B}, \{s,\neg s\})\]and based on the
penalty()
-function.- Parameters:
position1 (
Position
) –position2 (
Position
) –penalties (
List
[float
]) – A float-list of penalty values for thepenalty()
-function.
- Return type:
float
- Returns:
- model_parameters_set_to_default()#
Resets the model parameters to their default values.
- penalty(position1, position2, sentence, penalties)#
A penalty function.
The penalty function calculates a penalty value for two sentences of two positions given a list of penalty-value and is defined by
\[\begin{split}d_{{d_0,d_1,d_2,d_3}}(\mathcal{A}, \mathcal{B}, \{s,\neg s\}):= \begin{cases} d_3 \text{ if } \{s,\neg s\}\subset(\mathcal{A}\cup \mathcal{B}), \\ d_2 \text{ if } \{s,\neg s\}\cap \mathcal{A} \neq \emptyset \text{ and } \{s,\neg s\}\cap \mathcal{B} = \emptyset, \\ d_3 \text{ if } \{s,\neg s\}\cap \mathcal{A} = \emptyset \text{ and } \{s,\neg s\}\cap \mathcal{B} \neq \emptyset, \\ d_0 \text{ otherwise.}\end{cases}\end{split}\]- Parameters:
position1 (
Position
) –position2 (
Position
) –sentence (
int
) – The index of the sentences with both positions.penalties (
List
[float
]) – A float-list of penalty values.
- Return type:
float
- Returns:
- pick_commitment_candidate(commitments_candidates, **kwargs)#
Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
Chooses randomly a next commitments from the commitment candidates.
- Return type:
Position
- Parameters:
commitments_candidates (Set[Position]) –
- pick_theory_candidate(theory_candidates, **kwargs)#
Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
Chooses randomly a theory from the theory candidates.
- Return type:
Position
- Parameters:
theory_candidates (Set[Position]) –
- systematicity(theory)#
Systematicity of the theory.
The systematicity \(S\) is a measure of the systematising power of a theory \(\mathcal{T}\) and is defined by:
\[S(\mathcal{T}):=\left( 1- \left(\frac{|\mathcal{T}|-1}{|\overline{\mathcal{T}}|}\right)^2 \right)\]- Parameters:
theory (
Position
) – The theory \(\mathcal{T}\).- Return type:
float
- Returns:
LocalReflectiveEquilibrium#
- class rethon.LocalReflectiveEquilibrium#
Bases:
StandardReflectiveEquilibrium
A locally searching RE process.
This (abstract) class implements the following behaviour for choosing commitments/theory candidates by
commitment_candidates()
andtheory_candidates()
:Theory candidates for the next theory are dialectically consistent positions in the vicinity of the last theory (as defined by the model parameter
neighbourhood_depth
, seebasics.Position.neighbours()
) that maximize the achievement function.Commitments candidates for the next commitments are minimally consistent positions in the vicinity of the last commitments (as defined by the model parameter
neighbourhood_depth
, seebasics.Position.neighbours()
) that maximize the achievement function.The first theory is chosen by
first_theory()
.
Remark: Note, that commitment candidates can be dialectically inconsistent.
Note
This class should be used together with dialectical structures that are based on binary decision trees (e.g.
model.BDDDialecticalStructure
).Methods
account
(commitments, theory)Account of the theory w.r.t.
achievement
(commitments, theory, ...)The achievement function \(Z\).
commitment_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.commitment_candidates()
Default model parameters of the standard model.
dialectical_structure
()Return the dialectical structure on which the model is based.
faithfulness
(commitments, initial_commitments)Faithfulness of the commitments w.r.t.
finished
(**kwargs)Implements
ReflectiveEquilibrium.finished()
.Criterion to chose the first theory.
hamming_distance
(position1, position2, penalties)The weighted Hamming distance.
is_dirty
()Checks whether the model demand an update of internal attributes.
model_name
()Model name.
model_parameter
(name)Returns model parameters by names.
model_parameter_names
()Returns names (keys) of the model parameters.
model_parameters
()Getting all model parameters as dict.
Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
penalty
(position1, position2, sentence, ...)A penalty function.
pick_commitment_candidate
(...)Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
pick_theory_candidate
(theory_candidates, ...)Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.systematicity
(theory)Systematicity of the theory.
theory_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.theory_candidates()
update
(**kwargs)Subclasses can extend/override this method to update internal attributes of the model.
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name='LocalReflectiveEquilibrium')#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
- commitment_candidates(**kwargs)#
Implements
basics.ReflectiveEquilibrium.commitment_candidates()
- Return type:
Set
[Position
]
- static default_model_parameters()#
Default model parameters of the standard model.
Default model parameter for the calculation of achievement:
{'weights': {'account': 0.35, 'systematicity': 0.55, 'faithfulness': 0.1}, 'account_penalties': list(np.array([0, 0.3, 1, 1], dtype=np.float32)), 'faithfulness_penalties': list(np.array([0, 0, 1, 1], dtype=np.float32)), 'neighbourhood_depth': 1 }
- Return type:
Dict
- abstract first_theory()#
Criterion to chose the first theory.
- Return type:
Position
- model_parameters_set_to_default()#
Resets the model parameters to their default values.
- theory_candidates(**kwargs)#
Implements
basics.ReflectiveEquilibrium.theory_candidates()
- Return type:
Set
[Position
]
GlobalReflectiveEquilibrium#
- class rethon.GlobalReflectiveEquilibrium#
Bases:
StandardReflectiveEquilibrium
A globally searching RE process.
This class implements the following behaviour for choosing commitments/theory candidates by
commitment_candidates()
andtheory_candidates()
:Theory candidates for the next theory are all dialectically consistent positions that maximize the achievement function.
Commitments candidates for the next commitments are all minimally consistent positions that maximize the achievement function.
Remark: Note, that commitment candidates can be dialectically inconsistent.
Note
This class should be used together with dialectical structures that are based on directed acyclic graph (e.g.
model.DAGDialecticalStructure
). Globally searching RE processes are computationally complex. Hence, you probably won’t be able to compute RE processes with a bigger sentence pool in a reasonable time.Methods
account
(commitments, theory)Account of the theory w.r.t.
achievement
(commitments, theory, ...)The achievement function \(Z\).
commitment_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.commitment_candidates()
default_model_parameters
()Default model parameters of the standard model.
dialectical_structure
()Return the dialectical structure on which the model is based.
faithfulness
(commitments, initial_commitments)Faithfulness of the commitments w.r.t.
finished
(**kwargs)Implements
ReflectiveEquilibrium.finished()
.global_optima
(initial_commitments)Searches for globally optimal theory-commitment pairs (according to the achievement function).
hamming_distance
(position1, position2, penalties)The weighted Hamming distance.
is_dirty
()Checks whether the model demand an update of internal attributes.
model_name
()Model name.
model_parameter
(name)Returns model parameters by names.
model_parameter_names
()Returns names (keys) of the model parameters.
model_parameters
()Getting all model parameters as dict.
model_parameters_set_to_default
()Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
penalty
(position1, position2, sentence, ...)A penalty function.
pick_commitment_candidate
(...)Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
pick_theory_candidate
(theory_candidates, ...)Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.systematicity
(theory)Systematicity of the theory.
theory_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.theory_candidates()
update
(**kwargs)Implements
basics.ReflectiveEquilibrium.update()
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name='GlobalStandardReflectiveEquilibrium')#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
- commitment_candidates(**kwargs)#
Implements
basics.ReflectiveEquilibrium.commitment_candidates()
- Return type:
Set
[Position
]
- global_optima(initial_commitments)#
Searches for globally optimal theory-commitment pairs (according to the achievement function).
- Parameters:
initial_commitments (
Position
) – A Position- Return type:
Set
[Tuple
[Position
,Position
]]- Returns:
A set of globally optimal theory-commitment-pairs as Positions.
- theory_candidates(**kwargs)#
Implements
basics.ReflectiveEquilibrium.theory_candidates()
- Return type:
Set
[Position
]
- update(**kwargs)#
Implements
basics.ReflectiveEquilibrium.update()
REContainer#
- class rethon.REContainer#
Bases:
object
An REContainer responsible for managing the execution of RE processes.
Implementations of this class manage the execution and coordination of RE processes specified by the given list of
re_models
.- re_models#
A list of RE models (
ReflectiveEquilibrium
).
Methods
add_object
(key, object)Helper function to store objects within the container.
get_object
(key)Helper function to retrieve stores objects (see
add_object()
) from the container.get_objects
re_processes
- __init__(re_models=None)#
- Parameters:
re_models (List[ReflectiveEquilibrium] | None) –
- add_object(key, object)#
Helper function to store objects within the container.
- Parameters:
key (Any) –
object (Any) –
- get_object(key)#
Helper function to retrieve stores objects (see
add_object()
) from the container.- Parameters:
key (Any) –
- Return type:
[Any, None]
- get_objects()#
- abstract re_processes(re_models=None)#
- Return type:
Iterator
[ReflectiveEquilibrium
]- Parameters:
re_models (List[ReflectiveEquilibrium] | None) –
REState#
- class rethon.REState#
Bases:
object
Class that represent the internal state of an RE process.
Remark: The attribute
time_line
can be used to externally assign points in time to the steps of the RE process. This feature will be used to coordinate different re processes with each other.- finished#
A boolean indicating whether the process terminated in a fixed point.
- Type:
bool
- evolution#
The evolution of steps beginning with the initial state (i.e., a set of commitments).
- Type:
List[Position]
- alternatives#
For each step a set of possible alternatives the process could have used as step according to
ReflectiveEquilibrium.commitment_candidates()
(orReflectiveEquilibrium.theory_candidates()
respectively).- Type:
List[Set[Position]]
- time_line#
For each step an integer that represents a point in time according to an (external) timeline.
- Type:
List[int]
- error_code#
An integer that represents an error code and which can be set if the process throws an error.
Methods
add_step
(position, alternatives[, time])Adding a new step to the state.
as_dict
()The state as python dictionary.
Evolution of commitments.
from_dict
(state_dict)Instantiation via dict.
Steps in the process with non-empty alternatives.
The initial commitments of the process.
Alternatives of the last step.
The last chosen commitments.
Last step of the evolution.
The last chosen theory.
Checks whether the next step is a theory.
past
(past)A past state as copy.
past_commitments
([past_step, time])Past commitments.
past_step
(time)A past step according to the timeline.
past_theory
([past_step, time])Past theory.
Evolution of theories.
- __init__(finished, evolution, alternatives, time_line, error_code=None)#
- Parameters:
finished (bool) –
evolution (List[Position]) –
alternatives (List[Set[Position]]) –
time_line (List[int]) –
error_code (int | None) –
- add_step(position, alternatives, time=None)#
Adding a new step to the state.
- Parameters:
position (Position) – The added step’s position.
alternatives (Set[Position]) – The alternatives to the added step’s position.
time (int) – A point in time that attributes the next step to an external timeline.
- as_dict()#
The state as python dictionary.
- Return type:
Dict
- Returns:
A dictionary with the state’s attributes as key-value pairs.
- commitments_evolution()#
Evolution of commitments.
- Return type:
List
[Position
]- Returns:
The steps of the process that represents commitments.
- error_codes = {0: 'The process could not finish due to an unexpected error.', 1: 'The process did not converge under a specified maximum number of steps (see process logs for further details).'}#
- static from_dict(state_dict)#
Instantiation via dict.
- indices_of_non_empty_alternatives()#
Steps in the process with non-empty alternatives.
- Return type:
List
[int
]
- initial_commitments()#
The initial commitments of the process.
- Return type:
Position
- last_alternatives()#
Alternatives of the last step.
- last_commitments()#
The last chosen commitments.
- Return type:
Position
- last_step()#
Last step of the evolution.
- Return type:
Position
- last_theory()#
The last chosen theory.
- Return type:
Position
- next_step_is_theory()#
Checks whether the next step is a theory.
- Return type:
bool
- past(past)#
A past state as copy.
- Return type:
- Parameters:
past (int) – Int indicating the past as counted by steps.
-1
represents the last state,-2
represents the next-to-last state and so on.- Returns:
A state representing the past state as a copy.
- past_commitments(past_step=None, time=None)#
Past commitments.
Convenience method to access past commitments either by their timeline or by commitment steps counting backwards. You have to provide exactly one of the arguments.
- Return type:
Position
- Parameters:
past_step (int) – The past counted stepwise beginning from the last commitment (
0
indicating the last commitments,-1
the next-to-last commitments and so on).time (int) – The point in time according to
REState.evolution
.
- past_step(time)#
A past step according to the timeline.
Remark: The time line of the state maps each step to a point in time on an (external) timeline. An re process can, among other things, pause according to this timeline in the case that the states’ timeline looks e.g. like
[0,1,2,5]
. Accordingly, the third step persist through the time points 2,3,4 on the external timeline in this specific example.- Return type:
Position
- Parameters:
time (int) – The point in time attributed to the requested step.
- Returns:
- Returns
None
iftime
falls before the time of the initial state. Otherwise, it will return the requested
Position
.
- Returns
- past_theory(past_step=None, time=None)#
Past theory.
Convenience method to access past theories either by their timeline or by theory steps counting backwards. You have to provide exactly one of the arguments.
- Return type:
Position
- Parameters:
past_step (int) – The past counted stepwise beginning from the last theory (
0
indicating the last theory,-1
the next-to-last theory and so on).time (int) – The point in time according to
REState.evolution
.
- theory_evolution()#
Evolution of theories.
- Return type:
List
[Position
]- Returns:
The steps of the process that represents theories.
StandardGlobalReflectiveEquilibrium#
- class rethon.StandardGlobalReflectiveEquilibrium#
Bases:
GlobalNumpyReflectiveEquilibrium
Class that simply tags
GlobalNumpyReflectiveEquilibrium
as the default implementation ofGlobalReflectiveEquilibrium
.Methods
account
(commitments, theory)Account of the theory w.r.t.
achievement
(commitments, theory, ...)The achievement function \(Z\).
commitment_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.commitment_candidates()
default_model_parameters
()Default model parameters of the standard model.
dialectical_structure
()Return the dialectical structure on which the model is based.
faithfulness
(commitments, initial_commitments)Faithfulness of the commitments w.r.t.
finished
(**kwargs)Implements
ReflectiveEquilibrium.finished()
.global_optima
(initial_commitments)Searches for globally optimal theory-commitment pairs (according to the achievement function).
hamming_distance
(position1, position2, penalties)The weighted Hamming distance.
is_dirty
()Checks whether the model demand an update of internal attributes.
model_name
()Model name.
model_parameter
(name)Returns model parameters by names.
model_parameter_names
()Returns names (keys) of the model parameters.
model_parameters
()Getting all model parameters as dict.
model_parameters_set_to_default
()Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
penalty
(pos1, pos2, sentence, penalties)A penalty function.
pick_commitment_candidate
(...)Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
pick_theory_candidate
(theory_candidates, ...)Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.systematicity
(theory)Systematicity of the theory.
theory_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.theory_candidates()
update
(**kwargs)Implements
basics.ReflectiveEquilibrium.update()
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name='StandardGlobalReflectiveEquilibrium')#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
StandardLocalReflectiveEquilibrium#
- class rethon.StandardLocalReflectiveEquilibrium#
Bases:
LocalNumpyReflectiveEquilibrium
Class that simply tags
LocalNumpyReflectiveEquilibrium
as the default implementation ofLocalReflectiveEquilibrium
Methods
account
(commitments, theory)Account of the theory w.r.t.
achievement
(commitments, theory, ...)The achievement function \(Z\).
commitment_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.commitment_candidates()
default_model_parameters
()Default model parameters of the standard model.
dialectical_structure
()Return the dialectical structure on which the model is based.
faithfulness
(commitments, initial_commitments)Faithfulness of the commitments w.r.t.
finished
(**kwargs)Implements
ReflectiveEquilibrium.finished()
.first_theory
()Choose an initial theory in the neighbourhood of the empty position.
hamming_distance
(position1, position2, penalties)The weighted Hamming distance.
is_dirty
()Checks whether the model demand an update of internal attributes.
model_name
()Model name.
model_parameter
(name)Returns model parameters by names.
model_parameter_names
()Returns names (keys) of the model parameters.
model_parameters
()Getting all model parameters as dict.
model_parameters_set_to_default
()Resets the model parameters to their default values.
next_step
([time])Triggers search for next commitments/theory.
penalty
(pos1, pos2, sentence, penalties)A penalty function.
pick_commitment_candidate
(...)Implements :py:func:ReflectiveEquilibrium.pick_commitment_candidate.
pick_theory_candidate
(theory_candidates, ...)Implements :py:func:ReflectiveEquilibrium.pick_theory_candidate.
re_process
([initial_commitments, max_steps])Process of finding a reflective equilibrium based on given initial commitments.
reset_model_parameters
(parameters)Resetting model parameters.
set_dialectical_structure
(dialectical_structure)Set the dialectical structure on which the model is based.
set_dirty
(dirty)Should be used to indicate whether attributes are reset that demand updating other attributes of the model.
set_initial_state
(initial_commitments)Set the initial state of the model.
set_model_parameters
([parameters])Setting model parameters either by a dictionary or key-value pairs.
set_state
(state)Setting the current state of the model.
state
()Getting the current state of the model as
REState
.systematicity
(theory)Systematicity of the theory.
theory_candidates
(**kwargs)Implements
basics.ReflectiveEquilibrium.theory_candidates()
update
(**kwargs)Subclasses can extend/override this method to update internal attributes of the model.
get_id
set_id
- __init__(dialectical_structure=None, initial_commitments=None, model_name='StandardLocalReflectiveEquilibrium')#
- Parameters:
dialectical_structure (DialecticalStructure | None) –
initial_commitments (Position | None) –
FullBranchREContainer#
- class rethon.FullBranchREContainer#
Bases:
REContainer
An REContainer generating all branches of model runs.
This container will generate all branches of the given model (i.e. branches that occur when the choice of next theories and/or commitments is underdetermined by
ReflectiveEquilibirium.theory_candidates()
and/orReflectiveEquilibirium.commitments_candidates()
).- max_re_length#
The maximum allowed amount of steps for each individual branch (to avoid infinite loops for non-converging processes).
- max_branches#
The maximum allow amount of branches (to avoid indefinite generation of branches).
Methods
add_object
(key, object)Helper function to store objects within the container.
get_object
(key)Helper function to retrieve stores objects (see
add_object()
) from the container.get_objects
re_processes
result_states
- __init__(max_re_length=50, max_branches=50)#
- Parameters:
max_re_length (int) –
max_branches (int) –
- re_processes(re_models=None)#
- Return type:
Iterator
[ReflectiveEquilibrium
]- Parameters:
re_models (List[ReflectiveEquilibrium] | None) –
- result_states(re_model)#
- Return type:
List
[REState
]- Parameters:
re_model (ReflectiveEquilibrium) –