From 8cfbc6cf20322719c31759cbbaf76587b4fa0125 Mon Sep 17 00:00:00 2001 From: balanche Date: Fri, 13 Apr 2018 15:19:12 +0200 Subject: [PATCH 1/8] =?UTF-8?q?D=C3=A9but=20progress=20bar=20classify=20(P?= =?UTF-8?q?rogressable=20impl=C3=A9ment=C3=A9=20dans=20Classification=20et?= =?UTF-8?q?=20learningResult)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jcl/Classification.java | 86 ++++++++++++++++++- src/jcl/learning/LearningResult.java | 84 +++++++++++++++++- .../monostrategy/SingleClassification.java | 12 +-- .../kmeans/LearningResultKmeans.java | 8 +- 4 files changed, 178 insertions(+), 12 deletions(-) diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index 453241b..cb4ba46 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -19,6 +19,7 @@ import jcl.jcld.RmiServer; import jcl.jcld.database.SSHParameters; import jcl.learning.LearningMethod; import jcl.learning.methods.ClassifierUtils; +import jcl.utils.Progressable; import jcl.utils.exceptions.JCLFormatException; import jcl.utils.exceptions.MethodNotImplementedException; @@ -35,7 +36,7 @@ import jcl.utils.exceptions.MethodNotImplementedException; */ public abstract class Classification extends Observable implements - Serializable, Cloneable { + Progressable, Serializable, Cloneable { /** */ private static final long serialVersionUID = 1L; @@ -49,7 +50,7 @@ public abstract class Classification extends Observable implements /** paramtre de la connection ssh si besoin */ public SSHParameters sshParameters = null; - /** panel ou il faut afficher la non disponibiliter du server rmi */ + /** panel ou il faut afficher la non disponibilite du server rmi */ transient public JPanel container_; /** titre de la classid pour le tabedpane en hybridclassification */ @@ -68,7 +69,21 @@ public abstract class Classification extends Observable implements /** Le nom de la classification */ private String name = ""; + /** + * Parametre de progression pour l'affichage eventuel d'une barre de + * progression + */ + protected int progress = 0; + + /** Valeur maximale de la progression */ + protected int progressM = 100; + + /** Name of the current step of learning */ + private String statusName = "Classifying"; + + + /** *

* Methode utilisee pour le debuggage. Affiche le contenu de la memoire. @@ -767,5 +782,72 @@ public abstract class Classification extends Observable implements * @return the Classification generated */ public abstract Classification ImportResult(String model, int classifIndex) throws MethodNotImplementedException, JCLFormatException; + + /** + *

+ * Fin de la progression. + *

+ */ + @Override + public void endProgress() { + this.progress = this.progressM; + } + + /** + *

+ * Accesseur au niveau de progression des calculs. + *

+ * + * @return le compteur de progression + */ + @Override + public int getProgress() { + return (int) (((double) this.progress / (double) this.progressM) * 100.0); + } + /** + *

+ * Incrementation du niveau de progression. + *

+ */ + @Override + public void incProgress() { + this.progress++; + } + + /** + *

+ * Remise e zero du niveau de progression. + *

+ */ + @Override + public void resetProgress() { + this.progress = 0; + } + + /** + *

+ * Modification du niveau de progression des calculs. + *

+ * + * @param value + * la nouvelle valeur du compteur de progression + */ + @Override + public void setProgress(final int value) { + this.progressM = value; + } + + @Override + public void setStatus(String status) + { + statusName = status; + + } + + @Override + public String getStatus() + { + return statusName; + } } diff --git a/src/jcl/learning/LearningResult.java b/src/jcl/learning/LearningResult.java index 543cf67..61d73aa 100644 --- a/src/jcl/learning/LearningResult.java +++ b/src/jcl/learning/LearningResult.java @@ -7,6 +7,7 @@ import java.util.List; import jcl.Classification; import jcl.clustering.ClusteringResult; import jcl.data.Data; +import jcl.utils.Progressable; import jcl.utils.exceptions.JCLFormatException; import jcl.utils.exceptions.MethodNotImplementedException; import jcl.weights.ClassificationWeights; @@ -21,7 +22,7 @@ import jcl.weights.ClassificationWeights; * @author WEMMERT Cedric */ -public abstract class LearningResult extends Object implements Serializable { +public abstract class LearningResult extends Object implements Progressable,Serializable { /** */ private static final long serialVersionUID = 1L; @@ -46,7 +47,20 @@ public abstract class LearningResult extends Object implements Serializable { /** allow to specify a specific set of colors to all clustering result generated by this model */ protected List colors = null; + + /** + * Parametre de progression pour l'affichage eventuel d'une barre de + * progression + */ + protected int progress = 0; + /** Valeur maximale de la progression */ + protected int progressM = 100; + + /** Name of the current step of learning */ + private String statusName = "Classifying"; + + /** *

* Constructeur a partir d'un ensemble de parametres et de ponderations. @@ -204,4 +218,72 @@ public abstract class LearningResult extends Object implements Serializable { * @return the LearningResult generated */ protected abstract LearningResult ImportResult(String model) throws MethodNotImplementedException, JCLFormatException; + + /** + *

+ * Fin de la progression. + *

+ */ + @Override + public void endProgress() { + this.progress = this.progressM; + } + + /** + *

+ * Accesseur au niveau de progression des calculs. + *

+ * + * @return le compteur de progression + */ + @Override + public int getProgress() { + return (int) (((double) this.progress / (double) this.progressM) * 100.0); + } + + /** + *

+ * Incrementation du niveau de progression. + *

+ */ + @Override + public void incProgress() { + this.progress++; + } + + /** + *

+ * Remise e zero du niveau de progression. + *

+ */ + @Override + public void resetProgress() { + this.progress = 0; + } + + /** + *

+ * Modification du niveau de progression des calculs. + *

+ * + * @param value + * la nouvelle valeur du compteur de progression + */ + @Override + public void setProgress(final int value) { + this.progressM = value; + } + + @Override + public void setStatus(String status) + { + statusName = status; + + } + + @Override + public String getStatus() + { + return statusName; + } } diff --git a/src/jcl/learning/methods/monostrategy/SingleClassification.java b/src/jcl/learning/methods/monostrategy/SingleClassification.java index 06d901d..bc44d38 100644 --- a/src/jcl/learning/methods/monostrategy/SingleClassification.java +++ b/src/jcl/learning/methods/monostrategy/SingleClassification.java @@ -7,6 +7,7 @@ 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; @@ -330,16 +331,17 @@ public class SingleClassification extends Classification { } } else { if (this.learningResult == null) { - // System.out.println("debut learn"); + System.out.println("debut learn"+new Date().toString()); this.learn(); - // System.out.println("fin learn"); + System.out.println("fin learn"+new Date().toString()); } - + //SEPARATION ICI ? + System.out.println("debut classify"+new Date().toString()); this.clusteringResult = this.learningResult .classify(this.classificationData, false); - + System.out.println("fin classify"+new Date().toString()); + this.clusteringResult.setMethode(this.learningMethod.getType()); - /* * si l'utilisateur souhaite une classification hierarchique, il * faut encore appliquer l'algorithme de classification hierarchique diff --git a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java index 356e26b..19bf0be 100644 --- a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java +++ b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java @@ -145,11 +145,11 @@ public class LearningResultKmeans extends LearningResult { ((LightHardSeed) this.seeds.get(i)).setId(i); } } -// long startT = System.nanoTime(); -// System.out.println("start at "+startT); + long startT = System.nanoTime(); + System.out.println("start at "+startT); int clusterMap[] = this.clusterAffectation(data,fromSample); -// long endT = System.nanoTime(); -// System.out.println("endat "+ endT + " total of "+ (endT - startT)/1000000000l); + long endT = System.nanoTime(); + System.out.println("endat "+ endT + " total of "+ (endT - startT)/1000000000l); ClusteringResult result = null; -- GitLab From 30427990144c8c8c8ccbdd03521e284605bc8bfa Mon Sep 17 00:00:00 2001 From: balanche Date: Tue, 17 Apr 2018 09:28:22 +0200 Subject: [PATCH 2/8] =?UTF-8?q?Progress=20bars=20de=20classification=20ter?= =?UTF-8?q?min=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jcl/Classification.java | 47 +++--------- src/jcl/learning/LearningMethod.java | 2 +- src/jcl/learning/LearningResult.java | 2 +- .../monostrategy/SingleClassification.java | 67 +++++++++++++++-- .../monostrategy/kmeans/ClassifierKmeans.java | 1 + .../kmeans/LearningResultKmeans.java | 13 ++-- src/jcl/utils/ProgressMonitor.java | 75 +++++++++++++++++++ 7 files changed, 159 insertions(+), 48 deletions(-) create mode 100644 src/jcl/utils/ProgressMonitor.java diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index cb4ba46..c1ca4bf 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.io.IOException; import java.io.Serializable; import java.text.NumberFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Observable; import java.util.Vector; @@ -19,6 +20,7 @@ import jcl.jcld.RmiServer; import jcl.jcld.database.SSHParameters; import jcl.learning.LearningMethod; import jcl.learning.methods.ClassifierUtils; +import jcl.utils.ProgressMonitor; import jcl.utils.Progressable; import jcl.utils.exceptions.JCLFormatException; import jcl.utils.exceptions.MethodNotImplementedException; @@ -79,9 +81,12 @@ public abstract class Classification extends Observable implements protected int progressM = 100; /** Name of the current step of learning */ - private String statusName = "Classifying"; - + protected String statusName = "Loading"; + /** + * The list of all the progressable to monitor + */ + protected ArrayList progressableList = new ArrayList(); /** @@ -792,18 +797,6 @@ public abstract class Classification extends Observable implements public void endProgress() { this.progress = this.progressM; } - - /** - *

- * Accesseur au niveau de progression des calculs. - *

- * - * @return le compteur de progression - */ - @Override - public int getProgress() { - return (int) (((double) this.progress / (double) this.progressM) * 100.0); - } /** *

@@ -824,30 +817,14 @@ public abstract class Classification extends Observable implements public void resetProgress() { this.progress = 0; } - /** - *

- * Modification du niveau de progression des calculs. - *

- * - * @param value - * la nouvelle valeur du compteur de progression + * Add a progressable to monitor + * @param p the progressable to add */ - @Override - public void setProgress(final int value) { - this.progressM = value; + public void addProgressable(Progressable p) { + this.progressableList.add(p); } - @Override - public void setStatus(String status) - { - statusName = status; - - } - @Override - public String getStatus() - { - return statusName; - } + } diff --git a/src/jcl/learning/LearningMethod.java b/src/jcl/learning/LearningMethod.java index 0581af8..6a5f990 100644 --- a/src/jcl/learning/LearningMethod.java +++ b/src/jcl/learning/LearningMethod.java @@ -365,7 +365,7 @@ public abstract class LearningMethod implements Progressable, Cloneable, */ @Override public void setProgress(final int value) { - this.progressM = value; + this.progress = value; } @Override diff --git a/src/jcl/learning/LearningResult.java b/src/jcl/learning/LearningResult.java index 61d73aa..9685797 100644 --- a/src/jcl/learning/LearningResult.java +++ b/src/jcl/learning/LearningResult.java @@ -271,7 +271,7 @@ public abstract class LearningResult extends Object implements Progressable,Seri */ @Override public void setProgress(final int value) { - this.progressM = value; + this.progress = value; } @Override diff --git a/src/jcl/learning/methods/monostrategy/SingleClassification.java b/src/jcl/learning/methods/monostrategy/SingleClassification.java index bc44d38..77b132b 100644 --- a/src/jcl/learning/methods/monostrategy/SingleClassification.java +++ b/src/jcl/learning/methods/monostrategy/SingleClassification.java @@ -27,6 +27,7 @@ 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.utils.exceptions.MethodNotImplementedException; import jcl.weights.ClassificationWeights; @@ -323,6 +324,10 @@ public class SingleClassification extends Classification { @Override public void classify() { + /* Add all the process to monitor in the list (they have to implement progressable) */ + this.addProgressable(this.learningMethod); + this.addProgressable(this.learningResult); + if (this.useRmi() && !this.isMaclaw()) { if (this.sshParameters == null) { this.rmiClassify(); @@ -331,15 +336,18 @@ public class SingleClassification extends Classification { } } else { if (this.learningResult == null) { - System.out.println("debut learn"+new Date().toString()); + System.out.println("debut learn "+new Date().toString()); this.learn(); - System.out.println("fin learn"+new Date().toString()); + System.out.println("fin learn "+new Date().toString()); } + + this.progressableList.set(1, this.learningResult);// ne se met pas à jour ?? //SEPARATION ICI ? - System.out.println("debut classify"+new Date().toString()); + + System.out.println("debut classify "+new Date().toString()); this.clusteringResult = this.learningResult .classify(this.classificationData, false); - System.out.println("fin classify"+new Date().toString()); + System.out.println("fin classify "+new Date().toString()); this.clusteringResult.setMethode(this.learningMethod.getType()); /* @@ -461,7 +469,7 @@ public class SingleClassification extends Classification { this.learningMethod.sshparameters = this.sshParameters; this.learningMethod.container_ = this.container_; } - // System.out.println(this.learningMethod.getName()+" starts to learn"); + System.out.println(this.learningMethod.getName()+" starts to learn"); this.learningResult = this.learningMethod .learn(this.classificationData); } @@ -612,4 +620,53 @@ public class SingleClassification extends Classification { return result; } + @Override + public void setProgress(final int value) { + this.progress = value; + } + + @Override + public void setStatus(String status) + { + this.statusName = status; + + } + + @Override + public String getStatus() + { + String status = "Preparing ... "; + if(!this.progressableList.isEmpty()) { + for (int i = 0 ; i < this.progressableList.size(); i++) { + if (this.progressableList.get(i) != null) { + if (this.progressableList.get(i).getProgress() != 100) + status = "Step "+ (i+1) + "/" + this.progressableList.size() + " : " + this.progressableList.get(i).getStatus(); + } + } + } + return status; + } + + + @Override + public int getProgress() { + int progress = 0; + boolean allEnded = true; //boolean for the stop condition + if(!this.progressableList.isEmpty()) { + for (Progressable p : this.progressableList) { + if(p!=null) { + if (p.getProgress() != 100) { + progress=p.getProgress(); + allEnded=false; + } + } + } + } + if(allEnded) {//returns 100 to stop the ProgressThread if all progressables are at 100% + progress = 100; + System.out.println("allEnded"); + } + return progress; + } + } diff --git a/src/jcl/learning/methods/monostrategy/kmeans/ClassifierKmeans.java b/src/jcl/learning/methods/monostrategy/kmeans/ClassifierKmeans.java index 97da418..6a38a2b 100644 --- a/src/jcl/learning/methods/monostrategy/kmeans/ClassifierKmeans.java +++ b/src/jcl/learning/methods/monostrategy/kmeans/ClassifierKmeans.java @@ -281,6 +281,7 @@ public class ClassifierKmeans extends LearningMethod { @Override public LearningResult learn(Data data) { this.progressM = this.getNbIters(); + LearningResultKmeans result = new LearningResultKmeans(data, (ParametersKmeans) this.parameters, this.samples); this.initViewers(result); diff --git a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java index 19bf0be..f41c9a1 100644 --- a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java +++ b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java @@ -139,7 +139,6 @@ public class LearningResultKmeans extends LearningResult { @Override public ClusteringResult classify(Data data, boolean fromSample) { - for (int i = 0 ; i < this.seeds.size() ; i++) { if (this.seeds.get(i) instanceof LightHardSeed) { ((LightHardSeed) this.seeds.get(i)).setId(i); @@ -147,10 +146,9 @@ public class LearningResultKmeans extends LearningResult { } long startT = System.nanoTime(); System.out.println("start at "+startT); - int clusterMap[] = this.clusterAffectation(data,fromSample); + int clusterMap[] = this.clusterAffectation(data,fromSample);// !!! long endT = System.nanoTime(); System.out.println("endat "+ endT + " total of "+ (endT - startT)/1000000000l); - ClusteringResult result = null; if (((ParametersKmeans) this.params).fuzzy) { @@ -163,7 +161,6 @@ public class LearningResultKmeans extends LearningResult { result = ClusteringResult.gerenerateDefaultClusteringResult(this, clusterMap, null, this.weights, this.seeds.size(), null, data, this.qualityIndices, getColors()); } - return result; } @@ -257,8 +254,11 @@ public class LearningResultKmeans extends LearningResult { } else { nbObjects = data.getWholeDataNbObjects(); } - int clusterMap[] = new int[nbObjects]; + + this.progressM=nbObjects; + this.resetProgress(); + int clusterMap[] = new int[nbObjects]; int nbThreads = ((ParametersKmeans) this.params).nbThreads; nbThreads = 1; if (((ParametersKmeans) this.params).fuzzy) { @@ -347,7 +347,7 @@ public class LearningResultKmeans extends LearningResult { this.weights, this.seeds); } tabThreads[nbThreads - 1].start(); - + for (int th = 0; th < nbThreads; th++) { try { tabThreads[th].join(); @@ -899,6 +899,7 @@ public class LearningResultKmeans extends LearningResult { threadGlobalDistance += distMin; //((HardSeed) seeds.get(clusterMap[i])).addObject(obj); + incProgress(); i++; } // writer.close(); diff --git a/src/jcl/utils/ProgressMonitor.java b/src/jcl/utils/ProgressMonitor.java new file mode 100644 index 0000000..9d17cd6 --- /dev/null +++ b/src/jcl/utils/ProgressMonitor.java @@ -0,0 +1,75 @@ +package jcl.utils; + +/** + * ?? + * @author Jean-Noël Balanche + * + */ + + +public interface ProgressMonitor { + /** + * ?? + * @param id ?? + */ + public void incProgress(int id); + + /** + *

+ * Methode de decrementation de l'indice de progression. + *

+ * + */ + public void endMonitorProgress(); + + /** + *

+ * Methode d'acces au pourcentage en cours de la progression. + *

+ * + * @return le pourcentage (entre 0 et 100) de la progression + */ + public int getMonitorProgress(); + + /** + *

+ * Methode d'incrementation de l'indice de progression. + *

+ */ + public void incMonitorProgress(); + + /** + *

+ * Methode de remise a zero de l'indice de progression. + *

+ */ + public void resetMonitorProgress(); + + /** + *

+ * Methode de modification du pourcentage de progression. + *

+ * + * @param value + * la nouvelle valeur + */ + public void setMonitorProgress(int value); + + /** + *

+ * Methode de modification du status. + *

+ * + * @param status + */ + public void setMonitorStatus(String status); + + /** + *

+ * Methode d'acces au status. + *

+ * + * @param status + */ + public String getMonitorStatus(); +} \ No newline at end of file -- GitLab From 180e6605845c3367da6cad086614dc64a3353898 Mon Sep 17 00:00:00 2001 From: balanche Date: Wed, 18 Apr 2018 13:58:46 +0200 Subject: [PATCH 3/8] =?UTF-8?q?Ajout=20d'une=20derni=C3=A8re=20=C3=A9tape?= =?UTF-8?q?=20de=20progress=20bar=20lors=20de=20la=20classification=20+=20?= =?UTF-8?q?D=C3=A9placement=20des=20imp=C3=A9mentations=20de=20progtressab?= =?UTF-8?q?le=20dans=20classification.java=20+=20Suppression=20des=20scrol?= =?UTF-8?q?lbars=20sur=20le=20panel=20Dataset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jcl/Classification.java | 69 +++++++++++++++++++ .../monostrategy/SingleClassification.java | 68 ++++-------------- .../kmeans/LearningResultKmeans.java | 8 +-- 3 files changed, 85 insertions(+), 60 deletions(-) diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index c1ca4bf..5f641e2 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -817,6 +817,65 @@ public abstract class Classification extends Observable implements public void resetProgress() { this.progress = 0; } + + @Override + public void setProgress(final int value) { + this.progress = value; + } + + @Override + public void setStatus(String status) + { + this.statusName = status; + + } + + @Override + public String getStatus() + { + String status = "Preparing ... "; + boolean allEnded = true; //boolean for the stop condition + + if(!this.progressableList.isEmpty()) { + for (int i = 0 ; i < this.progressableList.size(); i++) { + if (this.progressableList.get(i) != null) { + if (this.progressableList.get(i).getProgress() != 100) { + status = "Step "+ (i+1) + "/" + (this.progressableList.size()+1) + " : " + this.progressableList.get(i).getStatus(); + allEnded = false; + } + } + } + } + if(allEnded) {//return the usual value (this.status) when all progressables are done (to monitor the final step which is displaying the result) + status = this.statusName; + } + return status; + } + + + @Override + public int getProgress() + { + int progress = 0; + boolean allEnded = true; //boolean for the stop condition + + if(!this.progressableList.isEmpty()) { + for (Progressable p : this.progressableList) { + if(p!=null) { + if (p.getProgress() != 100) { + progress=p.getProgress(); + allEnded=false; + } + } + } + } + if(allEnded) {//return the usual value (this.progress) when all progressables are done (to monitor the final step which is displaying the result) + progress = this.progress; + //System.out.println("all progressable ended"); + } + return progress; + } + /** * Add a progressable to monitor * @param p the progressable to add @@ -825,6 +884,16 @@ public abstract class Classification extends Observable implements this.progressableList.add(p); } + /** + * Get the list of all the progressables to monitor in this classification + * @return the progressable list + */ + public ArrayList getProgressableList(){ + return this.progressableList; + } + + + } diff --git a/src/jcl/learning/methods/monostrategy/SingleClassification.java b/src/jcl/learning/methods/monostrategy/SingleClassification.java index 77b132b..0f0aca8 100644 --- a/src/jcl/learning/methods/monostrategy/SingleClassification.java +++ b/src/jcl/learning/methods/monostrategy/SingleClassification.java @@ -324,9 +324,11 @@ public class SingleClassification extends Classification { @Override public void classify() { - /* Add all the process to monitor in the list (they have to implement progressable) */ + /* + * Add all the processes to monitor in the list (they have to implement progressable) + */ this.addProgressable(this.learningMethod); - this.addProgressable(this.learningResult); + this.addProgressable(null);// had null because this.learningResult is not defined yet if (this.useRmi() && !this.isMaclaw()) { if (this.sshParameters == null) { @@ -336,18 +338,17 @@ public class SingleClassification extends Classification { } } else { if (this.learningResult == null) { - System.out.println("debut learn "+new Date().toString()); +// System.out.println("debut learn "+new Date().toString()); this.learn(); - System.out.println("fin learn "+new Date().toString()); +// System.out.println("fin learn "+new Date().toString()); } - this.progressableList.set(1, this.learningResult);// ne se met pas à jour ?? - //SEPARATION ICI ? + this.progressableList.set(1, this.learningResult);// now this.learningResult isn't null anymore so we can add him - System.out.println("debut classify "+new Date().toString()); +// System.out.println("debut classify "+new Date().toString()); this.clusteringResult = this.learningResult .classify(this.classificationData, false); - System.out.println("fin classify "+new Date().toString()); +// System.out.println("fin classify "+new Date().toString()); this.clusteringResult.setMethode(this.learningMethod.getType()); /* @@ -469,7 +470,7 @@ public class SingleClassification extends Classification { this.learningMethod.sshparameters = this.sshParameters; this.learningMethod.container_ = this.container_; } - System.out.println(this.learningMethod.getName()+" starts to learn"); +// System.out.println(this.learningMethod.getName()+" starts to learn"); this.learningResult = this.learningMethod .learn(this.classificationData); } @@ -620,53 +621,8 @@ public class SingleClassification extends Classification { return result; } - @Override - public void setProgress(final int value) { - this.progress = value; - } - @Override - public void setStatus(String status) - { - this.statusName = status; - - } - - @Override - public String getStatus() - { - String status = "Preparing ... "; - if(!this.progressableList.isEmpty()) { - for (int i = 0 ; i < this.progressableList.size(); i++) { - if (this.progressableList.get(i) != null) { - if (this.progressableList.get(i).getProgress() != 100) - status = "Step "+ (i+1) + "/" + this.progressableList.size() + " : " + this.progressableList.get(i).getStatus(); - } - } - } - return status; - } - - - @Override - public int getProgress() { - int progress = 0; - boolean allEnded = true; //boolean for the stop condition - if(!this.progressableList.isEmpty()) { - for (Progressable p : this.progressableList) { - if(p!=null) { - if (p.getProgress() != 100) { - progress=p.getProgress(); - allEnded=false; - } - } - } - } - if(allEnded) {//returns 100 to stop the ProgressThread if all progressables are at 100% - progress = 100; - System.out.println("allEnded"); - } - return progress; - } + + } diff --git a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java index f41c9a1..dbe2499 100644 --- a/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java +++ b/src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java @@ -144,11 +144,11 @@ public class LearningResultKmeans extends LearningResult { ((LightHardSeed) this.seeds.get(i)).setId(i); } } - long startT = System.nanoTime(); - System.out.println("start at "+startT); +// long startT = System.nanoTime(); +// System.out.println("start at "+startT); int clusterMap[] = this.clusterAffectation(data,fromSample);// !!! - long endT = System.nanoTime(); - System.out.println("endat "+ endT + " total of "+ (endT - startT)/1000000000l); +// long endT = System.nanoTime(); +// System.out.println("endat "+ endT + " total of "+ (endT - startT)/1000000000l); ClusteringResult result = null; if (((ParametersKmeans) this.params).fuzzy) { -- GitLab From 14880188a82bf36b6de523dd865dd51c3700ab86 Mon Sep 17 00:00:00 2001 From: balanche Date: Thu, 19 Apr 2018 09:30:53 +0200 Subject: [PATCH 4/8] Correction d'un bug sur la progress bar Sampling et d'un autre bug sur la progress bar Displaying --- src/jcl/Classification.java | 2 ++ .../clustering/ClusteringEvaluation.java | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index 5f641e2..72b8cd9 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -35,6 +35,8 @@ import jcl.utils.exceptions.MethodNotImplementedException; *

* * @author WEMMERT Cedric + * + * Implementation progressable par jean-Noël Balanche */ public abstract class Classification extends Observable implements diff --git a/src/jcl/evaluation/clustering/ClusteringEvaluation.java b/src/jcl/evaluation/clustering/ClusteringEvaluation.java index eaebccb..bcd871b 100644 --- a/src/jcl/evaluation/clustering/ClusteringEvaluation.java +++ b/src/jcl/evaluation/clustering/ClusteringEvaluation.java @@ -1170,7 +1170,6 @@ public class ClusteringEvaluation { int CPindex = 2; ClusteringResult clusteringResult = classification.getClusteringResult(); - Iterator iter = clusteringResult.getData().getWholeSourceDataObjects(); // initialization for WG @@ -1184,11 +1183,13 @@ public class ClusteringEvaluation { for (int k = 0; k < clusteringResult.getNbClusters(); k++) { clustersSE[k] = 0; } + + double step = 100./clusteringResult.getNbObjects(); + double progress = classification.getProgress()+step; for(int n = 0 ; iter.hasNext() ; n++) { DataObject object = iter.next(); - int currentCluster = clusteringResult.getClusterMap(false)[n]; - + int currentCluster = clusteringResult.getClusterMap(false)[n]; // compute for WG double distMinWG = Double.MAX_VALUE; @@ -1212,7 +1213,12 @@ public class ClusteringEvaluation { // compute for Square Error final double distanceSE = clusteringResult.getCluster(currentCluster).distance(currentCluster); qualities[SEindex] += (distanceSE * distanceSE); - + /* + * increments classification's progressable (for the "Displaying" step) + */ + progress+=step; + classification.setProgress((int)progress); + } // merge result for WG -- GitLab From cdf1f2c4a8df4f02024db84f16372c138f352485 Mon Sep 17 00:00:00 2001 From: balanche Date: Thu, 19 Apr 2018 15:16:08 +0200 Subject: [PATCH 5/8] add a comment in Classification.java --- src/jcl/Classification.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index 72b8cd9..d09a437 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -36,7 +36,7 @@ import jcl.utils.exceptions.MethodNotImplementedException; * * @author WEMMERT Cedric * - * Implementation progressable par jean-Noël Balanche + * Implementation progressable avec liste de sous-processus progressable à suivre par Jean-Noël Balanche */ public abstract class Classification extends Observable implements -- GitLab From fe65da922335f163549b02d253340fe245a6cda1 Mon Sep 17 00:00:00 2001 From: lafabregue Date: Thu, 19 Apr 2018 15:17:41 +0200 Subject: [PATCH 6/8] Update Classification.java --- src/jcl/Classification.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jcl/Classification.java b/src/jcl/Classification.java index d09a437..26612a8 100644 --- a/src/jcl/Classification.java +++ b/src/jcl/Classification.java @@ -20,7 +20,6 @@ import jcl.jcld.RmiServer; import jcl.jcld.database.SSHParameters; import jcl.learning.LearningMethod; import jcl.learning.methods.ClassifierUtils; -import jcl.utils.ProgressMonitor; import jcl.utils.Progressable; import jcl.utils.exceptions.JCLFormatException; import jcl.utils.exceptions.MethodNotImplementedException; -- GitLab From 6cbec2d79fd645879eb940939cd99dcdf47a0cb5 Mon Sep 17 00:00:00 2001 From: lafabregue Date: Thu, 19 Apr 2018 15:19:19 +0200 Subject: [PATCH 7/8] Update SingleClassification.java --- .../learning/methods/monostrategy/SingleClassification.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/jcl/learning/methods/monostrategy/SingleClassification.java b/src/jcl/learning/methods/monostrategy/SingleClassification.java index 0f0aca8..d24ee8c 100644 --- a/src/jcl/learning/methods/monostrategy/SingleClassification.java +++ b/src/jcl/learning/methods/monostrategy/SingleClassification.java @@ -338,17 +338,13 @@ public class SingleClassification extends Classification { } } else { if (this.learningResult == null) { -// System.out.println("debut learn "+new Date().toString()); this.learn(); -// System.out.println("fin learn "+new Date().toString()); } this.progressableList.set(1, this.learningResult);// now this.learningResult isn't null anymore so we can add him -// System.out.println("debut classify "+new Date().toString()); this.clusteringResult = this.learningResult .classify(this.classificationData, false); -// System.out.println("fin classify "+new Date().toString()); this.clusteringResult.setMethode(this.learningMethod.getType()); /* -- GitLab From 304004c58fcba5a5bdf4f877ea56a12aaab51b25 Mon Sep 17 00:00:00 2001 From: lafabregue Date: Thu, 19 Apr 2018 15:20:59 +0200 Subject: [PATCH 8/8] Delete ProgressMonitor.java --- src/jcl/utils/ProgressMonitor.java | 75 ------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 src/jcl/utils/ProgressMonitor.java diff --git a/src/jcl/utils/ProgressMonitor.java b/src/jcl/utils/ProgressMonitor.java deleted file mode 100644 index 9d17cd6..0000000 --- a/src/jcl/utils/ProgressMonitor.java +++ /dev/null @@ -1,75 +0,0 @@ -package jcl.utils; - -/** - * ?? - * @author Jean-Noël Balanche - * - */ - - -public interface ProgressMonitor { - /** - * ?? - * @param id ?? - */ - public void incProgress(int id); - - /** - *

- * Methode de decrementation de l'indice de progression. - *

- * - */ - public void endMonitorProgress(); - - /** - *

- * Methode d'acces au pourcentage en cours de la progression. - *

- * - * @return le pourcentage (entre 0 et 100) de la progression - */ - public int getMonitorProgress(); - - /** - *

- * Methode d'incrementation de l'indice de progression. - *

- */ - public void incMonitorProgress(); - - /** - *

- * Methode de remise a zero de l'indice de progression. - *

- */ - public void resetMonitorProgress(); - - /** - *

- * Methode de modification du pourcentage de progression. - *

- * - * @param value - * la nouvelle valeur - */ - public void setMonitorProgress(int value); - - /** - *

- * Methode de modification du status. - *

- * - * @param status - */ - public void setMonitorStatus(String status); - - /** - *

- * Methode d'acces au status. - *

- * - * @param status - */ - public String getMonitorStatus(); -} \ No newline at end of file -- GitLab