
de.citec.tcs.alignment.CooptimalModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algorithms Show documentation
Show all versions of algorithms Show documentation
This module defines the interface for AlignmentAlgorithms as well as some helper classes. An
AlignmentAlgorithm computes an Alignment of two given input sequences, given a Comparator that
works in these sequences.
More details on the AlignmentAlgorithm can be found in the respective interface. More information
on Comparators can be found in the comparators module.
The resulting 'Alignment' may be just a real-valued dissimilarity between the input sequence or
may incorporate additional information, such as a full Alignment, a PathList, a PathMap or a
CooptimalModel. If those results support the calculation of a Gradient, they implement the
DerivableAlignmentDistance interface.
In more detail, the Alignment class represents the result of a backtracing scheme, listing all
Operations that have been applied in one co-optimal Alignment.
A classic AlignmentAlgorithm does not result in a differentiable dissimilarity, because the
minimum function is not differentiable. Therefore, this package also contains utility functions
for a soft approximation of the minimum function, namely Softmin.
For faster (parallel) computation of many different alignments or gradients we also provide the
ParallelProcessingEngine, the SquareParallelProcessingEngine and the ParallelGradientEngine.
The newest version!
/*
* TCS Alignment Toolbox Version 3
*
* Copyright (C) 2016
* Benjamin Paaßen
* AG Theoretical Computer Science
* Centre of Excellence Cognitive Interaction Technology (CITEC)
* University of Bielefeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package de.citec.tcs.alignment;
import de.citec.tcs.alignment.comparators.Comparator;
import de.citec.tcs.alignment.comparators.DerivableComparator;
import de.citec.tcs.alignment.comparators.OperationType;
import de.citec.tcs.alignment.parallel.MatrixEngine;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import lombok.Getter;
import lombok.NonNull;
/**
* This is a sparse model of all co-optimal paths in an alignment matrix. It essentially stores for
* every partial sequences of both input sequences the co-optimal operations that could have been
* applied.
*
* @author Benjamin Paassen - bpaassen(at)techfak.uni-bielefeld.de
* @param the class of the elements in the left input sequence.
* @param the class of the elements in the right input sequence.
*/
public class CooptimalModel implements DerivableAlignmentDistance {
/**
* The Comparator that was used to compute this CooptimalModel.
*
* @return The Comparator that was used to compute this CooptimalModel.
*/
@Getter
@NonNull
private final Comparator comparator;
@NonNull
private final List left;
@NonNull
private final List right;
private final double distance;
@NonNull
private final TreeMap cooptimals = new TreeMap<>();
public CooptimalModel(@NonNull final Comparator comparator,
@NonNull final List left, @NonNull final List right,
final double distance) {
this.comparator = comparator;
this.left = left;
this.right = right;
this.distance = distance;
}
/**
* A Map of matrix coordinates to an array of sequences of operations that can be co-optimally
* applied at the given position of the dynamic programming matrix.
*
* @return A Map of matrix coordinates to an array of sequences of operations that can be
* co-optimally applied at the given position of the dynamic programming matrix.
*/
public Map getCooptimals() {
return cooptimals;
}
@Override
public List getLeft() {
return left;
}
@Override
public List getRight() {
return right;
}
@Override
public double getDistance() {
return distance;
}
@Override
public double[] computeGradient(@NonNull DerivableComparator comp) {
//TODO: This should be implemented at some point.
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy