public boolean dominates(ObjectiveArray that) { // get objectives from states. Objective[] objectivesA = this.getObjectives(); Objective[] objectivesB = that.getObjectives(); // check that sizes are equal. if (objectivesA.length != objectivesB.length) { throw new InconsistentObjectiveSizeException(); } int dominationCountForA = 0; int dominationCountForB = 0; int equalityCount = 0; for (int i = 0; i < objectivesA.length; i++) { // get corresponding objectives to determine domination. Objective objectiveA = objectivesA[i]; Objective objectiveB = objectivesB[i]; if (!objectiveA.getBehaviour().equals(objectiveB.getBehaviour())) { throw new InconsistentObjectiveBehaviourException(); } // if this objective is designed to minimize. if (objectiveA.getBehaviour().equals(ObjectiveBehaviour.MINIMIZED)) { if (objectiveA.getValue() < objectiveB.getValue()) { dominationCountForA++; } else if (objectiveB.getValue() < objectiveA.getValue()) { dominationCountForB++; } else { // the equality condition for two objectives. equalityCount++; } } else { if (objectiveA.getValue() > objectiveB.getValue()) { dominationCountForA++; } else if (objectiveB.getValue() > objectiveA.getValue()) { dominationCountForB++; } else { // the equality condition for two objectives. equalityCount++; } } } if (equalityCount != 0) { if (equalityCount < objectivesA.length) { return (dominationCountForA == (objectivesA.length - equalityCount)) ? true : false; } else { // means that all objectives are same. return false; } } else { return (dominationCountForA == objectivesA.length) ? true : false; } }