Commit b8f42088 authored by lafabregue's avatar lafabregue

Add agent constrained samarah

parent f960b309
No preview for this file type
......@@ -6,6 +6,7 @@ import java.io.Serializable;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.weights.Weights;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -28,7 +29,7 @@ abstract public class Cluster implements Serializable {
protected Color color = new Color(0);
/** The cluster's father node color*/
protected Color couleur_pere = new Color(0);
protected Color couleur_pere = null;
/** L'index qui correspond a la place du cluster dans result */
protected int id = -1;
......@@ -204,17 +205,21 @@ abstract public class Cluster implements Serializable {
*
* @param o
* l'index de l'objet
* @return le degre d'appartenance du o-ieme objet e la classe
* @return le degre d'appartenance du o-ieme objet e la classe *
* @throws MethodNotImplementedException
* si la methode n'implante pas cet operateur
*/
abstract public double getMembership(final int o);
abstract public double getMembership(final int o) throws MethodNotImplementedException;
/**
* <p>
* Probabilite de la classe.
* </p>
*
* @return la probabilite de la classe
* @return la probabilite de la classe *
* @throws MethodNotImplementedException
* si la methode n'implante pas cet operateur
*/
abstract public double getMembershipProbabilityEM();
abstract public double getMembershipProbabilityEM() throws MethodNotImplementedException;
/**
* <p>
......
......@@ -7,6 +7,7 @@ import jcl.data.mask.IntArrayMask.IntMaskIterator;
import jcl.data.mask.Mask;
import jcl.weights.Weights;
import jj2000.j2k.NotImplementedError;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
public class LightCluster extends Cluster {
......@@ -147,13 +148,13 @@ public class LightCluster extends Cluster {
@Override
public double getMembership(int o) {
throw new NotImplementedError("method not Implemented for LighCluster class");
public double getMembership(int o) throws MethodNotImplementedException{
throw new MethodNotImplementedException("method not Implemented for LighCluster class");
}
@Override
public double getMembershipProbabilityEM() {
throw new NotImplementedError("method not Implemented for LighCluster class");
public double getMembershipProbabilityEM() throws MethodNotImplementedException{
throw new MethodNotImplementedException("method not Implemented for LighCluster class");
}
@Override
......
......@@ -6,6 +6,7 @@ import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.weights.Weights;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -44,7 +45,11 @@ public class SimpleCluster extends Cluster {
}
this.membershipDegree = new double[cluster.membershipDegree.length];
for (int i = 0; i < this.membershipDegree.length; i++) {
try {
this.membershipDegree[i] = cluster.getMembership(i);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
}
this.membershipProbabilityEM = cluster.membershipProbabilityEM;
}
......@@ -230,6 +235,7 @@ public class SimpleCluster extends Cluster {
this.data = (Data) cluster.getData(fromSample).clone();
}
try {
if(cluster instanceof SimpleCluster) {
this.membershipDegree = new double[((SimpleCluster)cluster).membershipDegree.length];
for (int i = 0; i < this.membershipDegree.length; i++) {
......@@ -243,6 +249,9 @@ public class SimpleCluster extends Cluster {
this.membershipDegree[i] = cluster.getMembership(i);
}
}
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
if (this.clusterCenter == null)
this.clusterCenter = this.computeCenter();
......@@ -322,7 +331,7 @@ public class SimpleCluster extends Cluster {
* l'index de l'objet
* @return le degre d'appartenance du o-ieme objet e la classe
*/
public double getMembership(final int o) {
public double getMembership(final int o) throws MethodNotImplementedException {
double degree = 0;
if ((o >= 0) && (o < this.membershipDegree.length)) {
degree = this.membershipDegree[o];
......@@ -337,7 +346,7 @@ public class SimpleCluster extends Cluster {
*
* @return la probabilite de la classe
*/
public double getMembershipProbabilityEM() {
public double getMembershipProbabilityEM() throws MethodNotImplementedException {
return this.membershipProbabilityEM;
}
......
......@@ -853,7 +853,7 @@ public class AttributeMultiDimSequence extends Attribute {
}
public static int ArgMin3(final double a, final double b, final double c) {
return (a < b) ? ((a < c) ? 0 : 2) : (b < c) ? 1 : 2;
return (a <= b) ? ((a <= c) ? 0 : 2) : (b <= c) ? 1 : 2;
}
public static int getMode() {
......@@ -3351,8 +3351,11 @@ public class AttributeMultiDimSequence extends Attribute {
// AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 1.0 }, { 10.0 }, { 10.0 }, { 10.0 }, { 1.0 }, { 1.0 }, {
// 1.0 } });
// AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 1.0 }, { 1.0 }, { 1.0 }, { 10.0 }, { 1.0 } });
AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 1.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 1.0 }, { 0.0 }, { 0.0 } });
AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 3.0 }, { 1.0 } });
AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 3.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq3 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 3.0 }, { 3.0 }, { 1.0 } });
AttributeMultiDimSequence seq4 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 1.0 }, { 1.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq5 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 3.0 }, { 0.0 } });
// System.out.println(DTWPageRank(seq1, seq2));
// System.out.println(DTWDistanceToDiagonal(seq1, seq2));
// System.out.println(DTWDistanceToDiagonal(seq2, seq1));
......@@ -3365,7 +3368,12 @@ public class AttributeMultiDimSequence extends Attribute {
// System.out.println(DTWDatedTimeToGo(seq1, new short[] { 0, 2, 3, 4 }, seq2, new short[] { 0, 1, 2, 3, 4 }));
// System.out.println(DTWDatedMeanSpeed(seq1, new short[] { 0, 2, 3, 4 }, seq2, new short[] { 0, 1, 2, 3, 4 }));
AttributeMultiDimSequence.setMode(DTW_BARYCENTRE);
System.out.println(seq1.distance(seq2));
// System.out.println(seq1.distance(seq2));
AttributeMultiDimSequence[] tabSequence = { seq1, seq2, seq3, seq4, seq5 };
AttributeMultiDimSequence avg = DBAMean(seq2, tabSequence);
System.out.println("DBA mean : " +avg);
}
......
......@@ -13,6 +13,7 @@ import jcl.data.DataObject;
import jcl.evaluation.QualityIndex;
import jcl.utils.MathTools;
import jcl.weights.Weights;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* @author Alexandre BLANSCHE
......@@ -544,7 +545,11 @@ public class ClusteringEvaluation {
int i = 0;
while(iter.hasNext()) {
final double distance = cluster.distance(iter.next());
try {
sum += distance * distance * cluster.getMembership(i);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
i++;
}
......@@ -608,9 +613,13 @@ public class ClusteringEvaluation {
for (int i = 0; i < clusteringResult.getNbObjects(); i++) {
double proba = 0;
for (int k = 0; k < clusteringResult.getNbClusters(); k++) {
try {
proba += clusteringResult.getCluster(k)
.getMembershipProbabilityEM()
* clusteringResult.getCluster(k).getMembership(i);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
}
sum += Math.log(proba);
}
......@@ -757,7 +766,11 @@ public class ClusteringEvaluation {
for (int i = 0; i < clusteringResult.getNbObjects(); i++) {
double sum = 0;
for (int k = 0; k < membership.length; k++) {
try {
membership[k] = clusteringResult.getCluster(k).getMembership(i);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
sum += membership[k];
}
for (int k = 0; k < membership.length; k++) {
......@@ -1016,7 +1029,11 @@ public class ClusteringEvaluation {
for (int i = 0; i < clusteringResult.getNbObjects(); i++) {
double sum = 0;
for (int k = 0; k < membership.length; k++) {
try {
membership[k] = clusteringResult.getCluster(k).getMembership(i);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
sum += membership[k];
}
for (int k = 0; k < membership.length; k++) {
......
......@@ -52,36 +52,35 @@ public class Kmeans {
Random randGenerator = new Random();
for (int i = 0; i < NB_OBJECTS; i++) { //~ Initialization of objects (random)
Attribute[] attributes = new Attribute[2];
Attribute[] attributes = new Attribute[1];
if (randGenerator.nextDouble() < 0.5) { // first cluster
attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() + .5);
// attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() + .5);
double[] sequence = new double[SEQUENCE_LENGTH];
for (int l = 0; l < sequence.length; l++) {
double p = l + randGenerator.nextGaussian();
sequence[l] = cos(p / SEQUENCE_LENGTH * 2 * PI);
}
attributes[1] = new AttributeSequence(sequence);
attributes[0] = new AttributeSequence(sequence);
} else {
attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() - .5);
// attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() - .5);
double[] sequence = new double[SEQUENCE_LENGTH];
for (int l = 0; l < sequence.length; l++) {
double p = l + randGenerator.nextGaussian();
sequence[l] = sin(p / SEQUENCE_LENGTH * 2 * PI);
}
attributes[1] = new AttributeSequence(sequence);
attributes[0] = new AttributeSequence(sequence);
}
objects.add(new DataObject(attributes));
}
//~ In order to create a dataset, a model of comparison has to be set
Distance[] distances = new Distance[2]; // a distance is set for every attribute
distances[0] = NumericalEuclideanDistance.getInstance(); // first attribute compared with an euclidean distance between numericals
distances[1] = jcl.data.distance.sequential.DistanceDTW.getInstance(); // second attribute (sequential) compared with the DTW distance
Distance[] distances = new Distance[1]; // a distance is set for every attribute
// distances[0] = NumericalEuclideanDistance.getInstance(); // first attribute compared with an euclidean distance between numericals
distances[0] = jcl.data.distance.sequential.DistanceDTW.getInstance(); // second attribute (sequential) compared with the DTW distance
MetaDistance metaDistance = MetaDistanceEuclidean.getInstance(); // defines the way the two scores are combined (possibility to weight)
Model model = new Model(distances, metaDistance);
......@@ -94,8 +93,8 @@ public class Kmeans {
DistanceParameter[][] distanceParameters = new DistanceParameter[NB_THREADS][2];
for (int th = 0; th < NB_THREADS; th++) {
distanceParameters[th][0] = EmptyDistanceParameter.getInstance(); //no parameter for a numerical euclidean distance
distanceParameters[th][1] = new ParameterDTW(new double[SEQUENCE_LENGTH][SEQUENCE_LENGTH]); //but yes for DTW (requires a matrix to work in)
// distanceParameters[th][0] = EmptyDistanceParameter.getInstance(); //no parameter for a numerical euclidean distance
distanceParameters[th][0] = new ParameterDTW(new double[SEQUENCE_LENGTH][SEQUENCE_LENGTH]); //but yes for DTW (requires a matrix to work in)
}
param = new ParametersKmeans(NB_CLUSTERS, NB_TURNS, NB_THREADS, new GlobalWeights(dataset), distanceParameters);
......
......@@ -8,6 +8,7 @@ import java.util.Vector;
import javax.swing.JPanel;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.jcld.RmiServer;
import jcl.jcld.database.SSHParameters;
......@@ -277,61 +278,104 @@ public abstract class LearningMethod implements Progressable, Cloneable,
/**
* <p>
* Methode de fusion d'un ensemble de classes.
* Method to merge a set of clusters
* </p>
*
* @param learningResult
* resultat d'apprentissage
*
* the learned model
* @param result
* le resultat e modifier
* the result to modify
* @param data
* les donnees d'apprentrissage
* the data to train the model on
* @param cr
* l'ensemble des classes representatives e fusionner
* @return le resultat modifie
* the set of clusters to merge
* @return the modified result
* @throws MethodNotImplementedException
* si la methode n'implante pas cet operateur
* if the LearningMethod does not implement this method
*/
public abstract ClusteringResult merge(LearningResult learningResult,
ClusteringResult result, Data data, Vector cr)
throws MethodNotImplementedException;
/**
* affichage dans la console, deux cas possible: execution local, algorithme
* effetue par le client, affichage direct. execution deporte, renvoie du
* resultat par RMI
* <p>
* Method to split a cluster
* </p>
*
* @param s
* @param learningResult
* the learned model
* @param result
* the result to modify
* @param data
* the data to train the model on
* @param c
* the cluster to remove id
* @param n
* the number of cluster to split the cluster into
* @return the modified result
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public void print(final String s) {
for (int i = 0; i < this.viewers.size(); i++) {
this.viewers.get(i).print(s);
}
}
public abstract ClusteringResult split(LearningResult learningResult,
ClusteringResult result, Data data, int c, int n)
throws MethodNotImplementedException;
/**
* <p>
* Methode de suppresion d'une classe.
* Method to remove a cluster a classify its element
* in the other ones
* </p>
*
* @param learningResult
* resultat d'apprentissage
*
* the learned model
* @param result
* le resultat a modifier
* the result to modify
* @param data
* les donnees d'apprentrissage
* the data to train the model on
* @param c
* le numero de la classe a supprimer
* @return le resultat modifie
* the cluster to remove id
* @return the modified result
* @throws MethodNotImplementedException
* si la methode d'apprentissage n'implante pas cet operateur
* if the LearningMethod does not implement this method
*/
public abstract ClusteringResult reclass(LearningResult learningResult,
ClusteringResult result, Data data, int c)
throws MethodNotImplementedException;
/**
* <p>
* Method to compute a new clustering from the existing one that respect the constraints
* </p>
*
* @param learningResult
* the learned model
* @param result
* the result to modify
* @param data
* the data to train the model on
* @param constraints
* the set of Constraints to use
* @return the modified result
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public abstract ClusteringResult injectConstraints(LearningResult learningResult,
ClusteringResult result, Data data, Vector<Constraint> constraints)
throws MethodNotImplementedException;
/**
* affichage dans la console, deux cas possible: execution local, algorithme
* effetue par le client, affichage direct. execution deporte, renvoie du
* resultat par RMI
*
* @param s
*/
public void print(final String s) {
for (int i = 0; i < this.viewers.size(); i++) {
this.viewers.get(i).print(s);
}
}
/**
* <p>
* Remise e zero du niveau de progression.
......@@ -381,30 +425,6 @@ public abstract class LearningMethod implements Progressable, Cloneable,
return statusName;
}
/**
* <p>
* Methode de decoupage d'une classe en sous-classes.
* </p>
*
* @param learningResult
* le resultat d'apprentissage
* @param result
* le resultat a modifier
* @param data
* les donnees d'apprentissage
* @param c
* le numero de la classe a scinder
* @param n
* le nombre de sous-classes desire
* @return le resultat modifie
* @throws MethodNotImplementedException
* si la methode d'apprentissage n'implante pas cet operateur
*/
public abstract ClusteringResult split(LearningResult learningResult,
ClusteringResult result, Data data, int c, int n)
throws MethodNotImplementedException;
@Override
public String toString() {
return this.getStringParams();
......
......@@ -3,10 +3,12 @@ package jcl.learning.methods;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.learning.LearningMethod;
import jcl.learning.LearningParameters;
import jcl.learning.LearningResult;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -165,4 +167,10 @@ public class ClassifierUnified extends LearningMethod implements Cloneable {
"Method split() not yet implemented.");
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
}
......@@ -87,6 +87,11 @@ public class ClassifierUtils {
*/
public final static int SAMARAHV4 = 121;
/**
* Identification of the SMARAH algorithm where constraints are handled at agent level
*/
public final static int SAMARAH_CONSTRAINED = 122;
public final static int MACLAW = 125;
/**
* Constante representant un classifieur SAMARAH : Ne pas modifier car correspond à l'indice de
......
......@@ -7,7 +7,6 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import javax.naming.Context;
......@@ -17,6 +16,7 @@ import javax.swing.JOptionPane;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.data.SimpleData;
import jcl.jcld.interJcld;
......@@ -27,7 +27,6 @@ import jcl.learning.methods.ClassifierUtils;
import jcl.learning.methods.monostrategy.ahc.LearningResultAHC;
import jcl.learning.methods.monostrategy.ahc.ParametersAHC;
import jcl.learning.methods.monostrategy.kmeans.LearningResultKmeans;
import jcl.utils.Progressable;
import jcl.utils.exceptions.JCLFormatException;
import jcl.weights.ClassificationWeights;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
......@@ -491,6 +490,22 @@ public class SingleClassification extends Classification {
}
/**
* Compute a new clustering from the existing one that respect the constraints
* @param constraints
* the set of Constraints to use
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public void injectConstraints(Vector<Constraint> constraints) throws MethodNotImplementedException {
if (this.getClusteringResult() != null) {
this.clusteringResult = this.getLearningMethod().injectConstraints(
this.getLearningResult(), this.getClusteringResult(),
this.classificationData, constraints);
}
}
@Override
public void save(final String file) throws IOException {
final FileOutputStream fos = new FileOutputStream(file);
......
......@@ -4,6 +4,7 @@ import java.util.Iterator;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.learning.LearningMethod;
......@@ -94,24 +95,27 @@ public class ClassifierAHC extends LearningMethod {
public ClusteringResult merge(final LearningResult learningResult,
final ClusteringResult result, final Data data, final Vector cr)
throws MethodNotImplementedException {
// TODO Auto-generated method stub
return null;
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult reclass(final LearningResult learningResult,
final ClusteringResult result, final Data data, final int c)
throws MethodNotImplementedException {
// TODO Auto-generated method stub
return null;
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult split(final LearningResult learningResult,
final ClusteringResult result, final Data data, final int c,
final int n) throws MethodNotImplementedException {
// TODO Auto-generated method stub
return null;
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
}
......@@ -5,11 +5,13 @@ import java.util.Iterator;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.learning.LearningMethod;
import jcl.learning.LearningResult;
import jcl.learning.methods.ClassifierUtils;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -569,6 +571,12 @@ public class ClassifierCobweb extends LearningMethod implements Cloneable,
return resultP;
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
/**
* <p>
* determination d'un nouvel identifiant de concept
......
......@@ -3,6 +3,7 @@ package jcl.learning.methods.monostrategy.cure;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.learning.LearningMethod;
import jcl.learning.LearningResult;
......@@ -75,4 +76,10 @@ public class ClassifierCure extends LearningMethod {
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
}
......@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.learning.LearningMethod;
import jcl.learning.LearningResult;
......@@ -105,4 +106,10 @@ public class ClassifierEM extends LearningMethod implements Serializable {
final int n) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
}
......@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.learning.LearningMethod;
import jcl.learning.LearningResult;
......@@ -137,6 +138,12 @@ public class ClassifierEvidence extends LearningMethod implements Serializable {
throw new MethodNotImplementedException();
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
@Override
public String toString() {
String str = "";
......
......@@ -3,6 +3,7 @@ package jcl.learning.methods.monostrategy.gng;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.Constraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.attribute.Attribute;
......@@ -572,6 +573,12 @@ public class ClassifierGNG extends LearningMethod {
return res.classify(data, true);
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
throw new MethodNotImplementedException();
}
/**
* Build a minimum-heap.
*
......
......@@ -7,6 +7,9 @@ import java.util.Map;
import java.util.Vector;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.CannotLinkConstraint;
import jcl.clustering.constraints.Constraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.attribute.AttributeHardConstrainedMultiDimSequence;
......@@ -17,6 +20,7 @@ import jcl.learning.LearningMethod;
import jcl.learning.LearningResult;
import jcl.learning.methods.ClassifierUtils;
import jcl.weights.GlobalWeights;
import multiCube.tools.util.exceptions.MethodNotImplementedException;
/**
* <p>
......@@ -405,6 +409,46 @@ public class ClassifierKmeans extends LearningMethod {
return null;
}
@Override
public ClusteringResult injectConstraints(LearningResult learningResult, ClusteringResult _result, Data data,
Vector<Constraint> constraints) throws MethodNotImplementedException {
for (Constraint c : constraints) {
if (c instanceof CannotLinkConstraint) {
// in the case of CL we create a new seed with the farthest element