Commit 7c38e5b9 authored by lafabregue's avatar lafabregue

fix in mask ietration and samarah

parent a2c981db
...@@ -18,7 +18,7 @@ public class LightCluster extends Cluster { ...@@ -18,7 +18,7 @@ public class LightCluster extends Cluster {
private int cardinal = -1; private int cardinal = -1;
/** indexes used to read object in the cluster */ /** indexes used to read object in the cluster */
private int clusterIndex = 0; private int clusterIndex = -1;
/** iterator used to read object in the cluster */ /** iterator used to read object in the cluster */
private IntMaskIterator indexIterator = null; private IntMaskIterator indexIterator = null;
...@@ -122,22 +122,25 @@ public class LightCluster extends Cluster { ...@@ -122,22 +122,25 @@ public class LightCluster extends Cluster {
} }
@Override @Override
public DataObject getObject(int objIndex) { public DataObject getObject(int objIndex) {
boolean fromSample = result.getClusterMap().length == result.data.getNbObjects();
if(objIndex > clusterIndex) { if(objIndex > clusterIndex) {
while(clusterIndex != objIndex && getIndexIterator(false).hasNext()) { while(clusterIndex != objIndex && getIndexIterator(fromSample).hasNext()) {
clusterIndex++; clusterIndex++;
getIndexIterator(false).next(); getIndexIterator(fromSample).next();
} }
return result.getData().getWholeDataDataObject(getIndexIterator(false).current());
} else if (objIndex < clusterIndex){ } else if (objIndex < clusterIndex){
while(clusterIndex != objIndex && clusterIndex > 0) { while(clusterIndex != objIndex && clusterIndex > 0) {
clusterIndex--; clusterIndex--;
getIndexIterator(false).previous(); getIndexIterator(fromSample).previous();
} }
return result.getData().getWholeDataDataObject(getIndexIterator(false).current()); }
if (fromSample) {
return result.getData().getDataObject(getIndexIterator(fromSample).current());
} else {
return result.getData().getWholeDataDataObject(getIndexIterator(fromSample).current());
} }
return result.getData().getWholeDataDataObject(getIndexIterator(false).current());
} }
......
...@@ -568,7 +568,7 @@ public class SimpleData extends Data { ...@@ -568,7 +568,7 @@ public class SimpleData extends Data {
return this.currentView.get(i); return this.currentView.get(i);
} }
@Override @Override
public DataObject getDataObject(int[] coordonneDataObject) { public DataObject getDataObject(int[] coordonneDataObject) {
int aux = 1; int aux = 1;
int index = coordonneDataObject[coordonneDataObject.length - 1]; int index = coordonneDataObject[coordonneDataObject.length - 1];
......
...@@ -160,12 +160,13 @@ public class IntArrayMask implements Mask { ...@@ -160,12 +160,13 @@ public class IntArrayMask implements Mask {
private final int[] mask; private final int[] mask;
private final int id; private final int id;
private final boolean ignore; private final boolean ignore;
private boolean first = true;
public IntMaskIterator(final int[] mask, final int id, final boolean ignore) { public IntMaskIterator(final int[] mask, final int id, final boolean ignore) {
this.id = id; this.id = id;
this.mask = mask; this.mask = mask;
this.ignore = ignore; this.ignore = ignore;
this.cursor = 0; this.cursor = -1;
this.end = getLastIndex(0, mask.length-1); this.end = getLastIndex(0, mask.length-1);
} }
...@@ -174,7 +175,7 @@ public class IntArrayMask implements Mask { ...@@ -174,7 +175,7 @@ public class IntArrayMask implements Mask {
this.id = id; this.id = id;
this.mask = mask; this.mask = mask;
this.ignore = ignore; this.ignore = ignore;
this.cursor = start; this.cursor = start-1;
this.end = getLastIndex(start, end); this.end = getLastIndex(start, end);
} }
...@@ -206,16 +207,16 @@ public class IntArrayMask implements Mask { ...@@ -206,16 +207,16 @@ public class IntArrayMask implements Mask {
} }
public boolean hasNext() { public boolean hasNext() {
return this.cursor <= end; return this.cursor < end;
} }
public Integer next() { public Integer next() {
int next = -1; int next = -1;
cursor++;
if (ignore) { if (ignore) {
while(cursor <= end) { while(cursor <= end) {
if(mask[cursor] != id) { if(mask[cursor] != id) {
next = cursor; next = cursor;
cursor++;
break; break;
} else { } else {
cursor++; cursor++;
...@@ -225,7 +226,6 @@ public class IntArrayMask implements Mask { ...@@ -225,7 +226,6 @@ public class IntArrayMask implements Mask {
while(cursor <= end) { while(cursor <= end) {
if(mask[cursor] == id) { if(mask[cursor] == id) {
next = cursor; next = cursor;
cursor++;
break; break;
} else { } else {
cursor++; cursor++;
...@@ -255,6 +255,12 @@ public class IntArrayMask implements Mask { ...@@ -255,6 +255,12 @@ public class IntArrayMask implements Mask {
} }
/**
* Return the last index called by next() method
* Warning : if no next() have been called it returns -1
*
* @return the last index returned by next() method
*/
public Integer current() { public Integer current() {
return new Integer(cursor); return new Integer(cursor);
} }
......
...@@ -944,9 +944,9 @@ public class LearningResultKmeans extends LearningResult { ...@@ -944,9 +944,9 @@ public class LearningResultKmeans extends LearningResult {
} }
// create Weights section // create Weights section
model = JCLModelExchange.addSection(model, // model = JCLModelExchange.addSection(model,
JCLModelExchange.MODEL_WEIGHT_SECTION, // JCLModelExchange.MODEL_WEIGHT_SECTION,
JCLModelExchange.weightsToString(this.weights.getGlobalWeights())); // JCLModelExchange.weightsToString(this.weights.getGlobalWeights()));
// create dataObject section // create dataObject section
List<DataObject> dataObjects = new ArrayList<DataObject>(); List<DataObject> dataObjects = new ArrayList<DataObject>();
......
...@@ -245,6 +245,8 @@ public class HybridClassification extends Classification implements Runnable, It ...@@ -245,6 +245,8 @@ public class HybridClassification extends Classification implements Runnable, It
// Choix des conflits a resoudre // Choix des conflits a resoudre
this.conflicts = this.worthConflicts(); this.conflicts = this.worthConflicts();
int a = 5;
a = 6;
for (int i = 0; i < this.conflicts.size(); i++) { for (int i = 0; i < this.conflicts.size(); i++) {
final SamarahConflict conf = this.conflicts.get(i); final SamarahConflict conf = this.conflicts.get(i);
...@@ -1309,6 +1311,7 @@ public class HybridClassification extends Classification implements Runnable, It ...@@ -1309,6 +1311,7 @@ public class HybridClassification extends Classification implements Runnable, It
final int km = this.evalMax.alpha[i][j].maxColumn(k); final int km = this.evalMax.alpha[i][j].maxColumn(k);
a = this.getAgent(j); a = this.getAgent(j);
final int kj = clustermaps[j][p]; final int kj = clustermaps[j][p];
vote[j][km] += 1; vote[j][km] += 1;
if (kj == km) { if (kj == km) {
stat[p] += 1; stat[p] += 1;
......
...@@ -111,7 +111,7 @@ public class HybridClassificationConstrained extends jcl.learning.methods.multis ...@@ -111,7 +111,7 @@ public class HybridClassificationConstrained extends jcl.learning.methods.multis
lastCstIndex++; lastCstIndex++;
} }
try { try {
c.injectConstraints(constraints); c.injectConstraints(tmpSet);
} catch (MethodNotImplementedException e) { } catch (MethodNotImplementedException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment