X
- the class of input values for this comparator.public class SquareReplacementMatrixComparator<X> extends Object implements DerivableComparator<X,X>
Constructor and Description |
---|
SquareReplacementMatrixComparator(IndexingFunction<X> index) |
SquareReplacementMatrixComparator(IndexingFunction<X> index,
double[][] replacementMatrix) |
Modifier and Type | Method and Description |
---|---|
double |
compare(OperationType type,
X a,
X b)
This method returns a dissimilarity between x and y using the alignment operation op with the
following restrictions:
compare(op,x,y) ≥ 0 (non-negativity)
compare(op,x,y) ≤ 1 (normalization)
x = y ⇒ compare(op,x,y) = 0 (equality)
Further, this function guarantees consistency with respect to null inputs, that is, for any
operation op ∈ {REPLACEMENT, DELETIONREPLACEMENT, INSERTIONREPLACEMENT} it holds:
d(op, x, null) = d(DELETION, x, null)
d(op, null, y) = d(INSERTION, null, y)
and for any operation it holds:
d(op, null, null) = 0
Please note that a and b might be null if this alignment uses gaps or
skips.
|
Gradient |
computeGradient(OperationType type,
X a,
X b)
Computes the gradient of this comparator function w.r.t.
|
static double[] |
costMatrixToVector(double[][] costMatrix)
Turns a cost matrix Lambda into vector form, where all rows are concatenated.
|
boolean |
equals(Object obj) |
static double[][] |
getDefaultReplacementMatrix(int N)
Creates a default Lambda replacement matrix for an alphabet of size N.
|
int |
getNumberOfParameters()
This shall return the number of parameters of this comparator.
|
double[] |
getParameters()
Return the current value of all parameters of this comparator.
|
boolean |
hasCoherentReplacementCost()
This method should return true if and only if this Comparator guarantees that
compare(OperationType.REPLACEMENT, x, y) =
compare(OperationType.DELETIONREPLACEMENT, x, y) =
compare(OperationType.INSERTIONREPLACEMENT, x, y)
for all possible inputs x, y.
|
int |
hashCode() |
void |
setParameters(double[] params)
Sets the current value of all parameters of this comparator.
|
void |
setReplacementMatrix(double[][] replacementMatrix) |
boolean |
supports(OperationType type)
This method should return true if and only if this Comparator supports the given alignment
operation.
|
static double[][] |
vectorToCostMatrix(double[] paramVector)
Turns a parameter vector into a cost matrix Lambda.
|
public SquareReplacementMatrixComparator(@NonNull IndexingFunction<X> index)
public SquareReplacementMatrixComparator(@NonNull IndexingFunction<X> index, @NonNull double[][] replacementMatrix)
public void setReplacementMatrix(@NonNull double[][] replacementMatrix)
replacementMatrix
- The matrix Lambda of parameters containing the explicit distance
values for each pairwise combination of input values, including gaps and skips.public static double[][] getDefaultReplacementMatrix(int N)
N
- the size of the alphabet.public double compare(@NonNull OperationType type, X a, X b)
Comparator
compare
in interface Comparator<X,X>
type
- the type of alignment operation to be used.a
- the left input.b
- the right input.public boolean hasCoherentReplacementCost()
Comparator
hasCoherentReplacementCost
in interface Comparator<X,X>
public boolean supports(OperationType type)
Comparator
supports
in interface Comparator<X,X>
type
- an alignment OperationType.public Gradient computeGradient(OperationType type, X a, X b)
DerivableComparator
computeGradient
in interface DerivableComparator<X,X>
type
- the type of alignment operation to be useda
- the left input.b
- the right input.public int getNumberOfParameters()
DerivableComparator
getNumberOfParameters
in interface DerivableComparator<X,X>
public double[] getParameters()
DerivableComparator
getParameters
in interface DerivableComparator<X,X>
public static double[] costMatrixToVector(@NonNull double[][] costMatrix)
costMatrix
- a cost matrix Lambda.public void setParameters(@NonNull double[] params)
DerivableComparator
setParameters
in interface DerivableComparator<X,X>
params
- the new value of all parameters of this comparator.public static double[][] vectorToCostMatrix(@NonNull double[] paramVector)
paramVector
- a parameter vector, where all rows are concatenated.Copyright (C) 2016 Benjamin Paaßen, AG Theoretical Computer Science, Centre of Excellence Cognitive Interaction Technology (CITEC), University of Bielefeld, licensed under the AGPL v. 3: http://openresearch.cit-ec.de/projects/tcs . This documentation is licensed under the conditions of CC-BY-SA 4.0: https://creativecommons.org/licenses/by-sa/4.0/