diff --git a/src/main/java/Evaluators/EvaluatorNESW.java b/src/main/java/Evaluators/EvaluatorNESW.java index c168a742cf37b2c40c02eebf6191ad02e627ddd4..35d57634110b49d3322545d90ef14f49c47b2e86 100644 --- a/src/main/java/Evaluators/EvaluatorNESW.java +++ b/src/main/java/Evaluators/EvaluatorNESW.java @@ -30,48 +30,40 @@ public class EvaluatorNESW implements Evaluator { } public int evaluateBonds(Candidate candidate) { - if (candidate.bonds <= -1) { // Not calculated before - int bonds = 0; + int bonds = 0; - for (int i = 0; i < candidate.vertexList.size() - 2; i++) { - Vertex toCompare = candidate.vertexList.get(i); + for (int i = 0; i < candidate.vertexList.size() - 2; i++) { + Vertex toCompare = candidate.vertexList.get(i); - if (toCompare.isHydrophobic) { - for (int j = i + 2; j < candidate.vertexList.size(); j++) { - Vertex vertex = candidate.vertexList.get(j); - if (vertex.isHydrophobic) { - if (toCompare.neighbouringPosition(vertex)) { - bonds++; - } + if (toCompare.isHydrophobic) { + for (int j = i + 2; j < candidate.vertexList.size(); j++) { + Vertex vertex = candidate.vertexList.get(j); + if (vertex.isHydrophobic) { + if (toCompare.neighbouringPosition(vertex)) { + bonds++; } } } } - candidate.bonds = bonds; } - // Return cached value if this is not the first time the value is needed - return candidate.bonds; + return bonds; } public int evaluateOverlaps(Candidate candidate) { - if (candidate.overlaps <= -1) { // Not calculated before - - int overlaps = 0; - for (int i = 0; i < candidate.vertexList.size(); i++) { - Vertex toCompare = candidate.vertexList.get(i); - for (Vertex vertex : candidate.vertexList) { - if (toCompare.equalsPosition(vertex) && toCompare != vertex) { - overlaps++; - } + int overlaps = 0; + for (int i = 0; i < candidate.vertexList.size(); i++) { + Vertex toCompare = candidate.vertexList.get(i); + for (Vertex vertex : candidate.vertexList) { + if (toCompare.equalsPosition(vertex) && toCompare != vertex) { + overlaps++; } } - - overlaps /= 2; - candidate.overlaps = overlaps; } - // Return cached value if this is not the first time the value is needed - return candidate.overlaps; + overlaps /= 2; + overlaps = overlaps; + + return overlaps; } } diff --git a/src/main/java/MainClasses/Candidate.java b/src/main/java/MainClasses/Candidate.java index cce755905dc6c074a880972481be097812a931dc..db5e6ec7f475a476b52043eb77f0722d0d37e1d6 100644 --- a/src/main/java/MainClasses/Candidate.java +++ b/src/main/java/MainClasses/Candidate.java @@ -9,8 +9,6 @@ public class Candidate { int[] outgoingDirection; // 0 = North | 1 = East | 2 = South | 3 = West public ArrayList<Vertex> vertexList; public double fitness; - public int bonds; - public int overlaps; public Candidate(int[] isH, int[] oD) { this.isHydrophobic = isH; @@ -18,8 +16,6 @@ public class Candidate { this.vertexList = constructVertexes(); this.fitness = -1d; // Not calculated yet - this.bonds = -1; - this.overlaps = -1; } private ArrayList<Vertex> constructVertexes() {