org.decisiondeck.xmcda_oo.utils
Class CompareByDominance

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.utils.CompareByDominance
All Implemented Interfaces:
Comparator<Alternative>

public class CompareByDominance
extends Object
implements Comparator<Alternative>

This comparator must be bound to a set of criteria and to evaluations and compares the given alternatives by their dominance relations (the dominated one is inferior to the dominating one). This comparator must be only given alternatives which dominate each other, or which have exactly the same performance.

No thresholds or other subtleties are considered: a better numerical performance on a given criterion is considered to imply that the alternative is better.

This object (beyond its possible usage as a comparator) may also tell if a given set of alternatives is in dominance relation.


Constructor Summary
CompareByDominance(Set<Criterion> criteria, IRdEvaluations evaluations)
           
 
Method Summary
 int compare(Alternative a1, Alternative a2)
           
 int compare(Alternative a1, Alternative a2, Criterion crit)
           
 int compare2(Alternative a1, Alternative a2)
          As compare(Alternative, Alternative), but throws an exception if some required data is missing.
 ComparisonRelation getRelation(Alternative a1, Alternative a2)
          Returns the relation characterizing the comparison between the two given alternatives.
 boolean isDominance(Set<Alternative> alternatives)
          Indicates whether all these alternatives may be ordered according to the dominance relation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

CompareByDominance

public CompareByDominance(Set<Criterion> criteria,
                          IRdEvaluations evaluations)
Parameters:
criteria - the criteria to use in the comparison. The preference directions must be provided.
evaluations - the evaluations. All evaluations for the alternatives that will be compared on all the relevant criteria must be provided.
Method Detail

compare

public int compare(Alternative a1,
                   Alternative a2)
Specified by:
compare in interface Comparator<Alternative>

compare2

public int compare2(Alternative a1,
                    Alternative a2)
             throws InvalidInputException
As compare(Alternative, Alternative), but throws an exception if some required data is missing.

Parameters:
a1 - an alternative.
a2 - an other one.
Returns:
the comparison of the first against the second, supposing they are in dominance relation.
Throws:
InvalidInputException - iff some data is missing (e.g. a required evaluation).

compare

public int compare(Alternative a1,
                   Alternative a2,
                   Criterion crit)
            throws InvalidInputException
Throws:
InvalidInputException

isDominance

public boolean isDominance(Set<Alternative> alternatives)
                    throws InvalidInputException
Indicates whether all these alternatives may be ordered according to the dominance relation.

Parameters:
alternatives - not null. The alternatives to consider.
Returns:
true iff each pair of alternatives in the given set is such that either they are equal (they have exactly the same evaluations on all the criteria to consider), or one dominates the other one.
Throws:
InvalidInputException - if some missing information renders the check impossible (e.g. an evaluation is missing).

getRelation

public ComparisonRelation getRelation(Alternative a1,
                                      Alternative a2)
                               throws InvalidInputException
Returns the relation characterizing the comparison between the two given alternatives. The first one is preferred, indifferent to the second one iff it is preferred, equal (they have identical evaluations on all relevant criteria).

Parameters:
a1 - the first alternative.
a2 - the alternative to compare it to.
Returns:
the result of the comparison.
Throws:
InvalidInputException - iff some information is missing.


Copyright © 2011. All Rights Reserved.