Class StructuralCausalModel
java.lang.Object
org.tweetyproject.causal.syntax.StructuralCausalModel
- All Implemented Interfaces:
Iterable<PlFormula>,Collection<PlFormula>,BeliefBase
This class describes a structural causal model in the sense of Pearl.
- Author:
- Julian Sander, Lars Bengel
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThrown to indicate that the structural equations of a causal model contain a cyclic dependency -
Constructor Summary
ConstructorsConstructorDescriptionInitializes an empty causal modelStructuralCausalModel(Collection<PlFormula> equations) Initializes a causal model based on the given structural equations. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends PlFormula> c) booleanaddBackgroundAtom(Proposition atom) Adds a background atom to the modelbooleanaddBackgroundAtoms(Collection<Proposition> atoms) Add new background atoms to the modelbooleanaddExplainableAtom(PlFormula atom, PlFormula cause) Adds a new explainable atom together with its cause to the causal modelvoidclear()clone()booleanbooleancontainsAll(Collection<?> c) getAtoms()Returns the set of all atoms of the causal modelReturns the set of background atoms of the causal modelgetCause(Proposition atom) Get the cause of the given atomgetCounterfactualCopy(Proposition proposition) Converts the given causal atom to a counterfactual copyReturns the set of explainable atoms of the causal modelReturns the signature of the language of this knowledge base.Returns the structural equations of the causal modelConstructs the twin model for this causal model, i.e., it creates for each structural equation a copy where all explainable atoms X are replaced by a twin version X*intervene(Proposition v, boolean x) Performs an intervention on the explainable atom 'v' by setting it to a given truth value.booleanisEmpty()iterator()Returns a human-readable string representation of this causal model.booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
StructuralCausalModel
public StructuralCausalModel()Initializes an empty causal model -
StructuralCausalModel
public StructuralCausalModel(Collection<PlFormula> equations) throws StructuralCausalModel.CyclicDependencyException Initializes a causal model based on the given structural equations. Every structural equation must be a logical equivalence of the form:e <=> f(...)where 'e' is a literal and f(...) is some logical formula representing the 'cause' of 'e'. The equations must be non-cyclic.- Parameters:
equations- the set of structural equations- Throws:
StructuralCausalModel.CyclicDependencyException- iff the equations are cyclic
-
-
Method Details
-
getBackgroundAtoms
Returns the set of background atoms of the causal model- Returns:
- the set of background atoms
-
getExplainableAtoms
Returns the set of explainable atoms of the causal model- Returns:
- the set of background atoms
-
getAtoms
Returns the set of all atoms of the causal model- Returns:
- the set of all atoms
-
getStructuralEquations
Returns the structural equations of the causal model- Returns:
- the structural equations
-
getCause
Get the cause of the given atom- Parameters:
atom- some atom of the causal model- Returns:
- the cause of the atom
-
addBackgroundAtom
Adds a background atom to the model- Parameters:
atom- some new background atom- Returns:
- true iff added successfully
-
addBackgroundAtoms
Add new background atoms to the model- Parameters:
atoms- a set of new background atoms- Returns:
- true iff added successfully
-
addExplainableAtom
public boolean addExplainableAtom(PlFormula atom, PlFormula cause) throws StructuralCausalModel.CyclicDependencyException Adds a new explainable atom together with its cause to the causal model- Parameters:
atom- some new explainable atomcause- the cause of the new atom- Returns:
- true iff added successfully
- Throws:
StructuralCausalModel.CyclicDependencyException- iff the new equation introduces a cyclic dependency
-
getCounterfactualCopy
Converts the given causal atom to a counterfactual copy- Parameters:
proposition- some causal atom- Returns:
- the counterfactual copy of the given causal atom
-
getTwinModel
Constructs the twin model for this causal model, i.e., it creates for each structural equation a copy where all explainable atoms X are replaced by a twin version X*- Returns:
- the twin model
-
intervene
Performs an intervention on the explainable atom 'v' by setting it to a given truth value. Removes the original cause of the atom and thus permanently changes the causal model- Parameters:
v- some explainable atomx- Truth value of the intervention- Returns:
- newModel TODO should this be in-place instead?
-
prettyPrint
Returns a human-readable string representation of this causal model.- Returns:
- a pretty-printed representation
-
toString
- Specified by:
toStringin interfaceBeliefBase- Overrides:
toStringin classObject
-
clone
-
getMinimalSignature
Description copied from interface:BeliefBaseReturns the signature of the language of this knowledge base.- Specified by:
getMinimalSignaturein interfaceBeliefBase- Returns:
- the signature of the language of this knowledge base.
-
size
public int size()- Specified by:
sizein interfaceCollection<PlFormula>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<PlFormula>
-
contains
- Specified by:
containsin interfaceCollection<PlFormula>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<PlFormula>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<PlFormula>
-
add
- Specified by:
addin interfaceCollection<PlFormula>
-
remove
- Specified by:
removein interfaceCollection<PlFormula>
-
containsAll
- Specified by:
containsAllin interfaceCollection<PlFormula>
-
addAll
- Specified by:
addAllin interfaceCollection<PlFormula>
-
removeAll
- Specified by:
removeAllin interfaceCollection<PlFormula>
-
retainAll
- Specified by:
retainAllin interfaceCollection<PlFormula>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<PlFormula>
-