- java.lang.Object
-
- org.logicng.transformations.Anonymizer
-
- All Implemented Interfaces:
FormulaTransformation
public final class Anonymizer extends Object implements FormulaTransformation
An anonymizer replaces all variables in a formula with new variables generated from a given prefix and a counter.An instance can be used to anonymize multiple formulas. In this case, variables with the same name will be replaced with the same anonymized variable.
After anonymizing one or more formulas, the mapping from original variable to anonymized variable can be accessed via
getSubstitution().- Since:
- 1.4.0
- Version:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description Anonymizer()Constructs a new anonymizer with the standard variable prefix 'v'.Anonymizer(String prefix)Constructs a new anonymizer with a given prefix for the newly introduced variables.Anonymizer(String prefix, int startCounter)Constructs a new anonymizer with a given prefix for the newly introduced variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Formulaapply(Formula formula, boolean cache)Returns the transformed formula.SubstitutiongetSubstitution()Returns the substitution which was used to anonymize the formula(s).
-
-
-
Constructor Detail
-
Anonymizer
public Anonymizer(String prefix, int startCounter)
Constructs a new anonymizer with a given prefix for the newly introduced variables.- Parameters:
prefix- the prefix for the new variablesstartCounter- where should the counter start
-
Anonymizer
public Anonymizer(String prefix)
Constructs a new anonymizer with a given prefix for the newly introduced variables.- Parameters:
prefix- the prefix for the new variables
-
Anonymizer
public Anonymizer()
Constructs a new anonymizer with the standard variable prefix 'v'.
-
-
Method Detail
-
getSubstitution
public Substitution getSubstitution()
Returns the substitution which was used to anonymize the formula(s).Although a substitution maps from variables to formulas, it is guaranteed that the substitution always maps to variables. So the following cast will always be safe:
(Variable) getSubstitution().getSubstitution(x)- Returns:
- the substitution which was used to anonymize the formula(s)
-
apply
public Formula apply(Formula formula, boolean cache)
Description copied from interface:FormulaTransformationReturns the transformed formula.- Specified by:
applyin interfaceFormulaTransformation- Parameters:
formula- the input formulacache- indicated whether the result (and associated predicates) should be cached in the formula's cache.- Returns:
- the transformed formula
-
-