org.decisiondeck.jmcda.structure.sorting.assignment
Class VersatileOrderedAssignments

java.lang.Object
  extended by org.decisiondeck.jmcda.structure.sorting.assignment.VersatileOrderedAssignments

public class VersatileOrderedAssignments
extends Object

An ordered equivalent to VersatileAssignments.

The orderings returned by this object are always compatible with the order given by the categories. Hence, when the categories are changed, it is possible that the order changes. Read carefully the contract of the relevant methods.


Constructor Summary
VersatileOrderedAssignments()
           
VersatileOrderedAssignments(IOrderedAssignmentsToMultipleRead assignments)
           
VersatileOrderedAssignments(IOrderedAssignmentsWithCredibilitiesRead assignments)
           
VersatileOrderedAssignments(VersatileOrderedAssignments copy)
          Copy constructor by value.
 
Method Summary
 boolean clear()
           
 Set<Alternative> getAlternatives()
           
 Set<Alternative> getAlternatives(Category category)
           
 Set<Category> getCategories()
           
 Set<Category> getCategories(Alternative alternative)
           
 NavigableSet<Category> getCategoriesSorted()
           
 NavigableSet<Category> getCategoriesSorted(Alternative alternative)
           
 Category getCategory(Alternative alternative)
           The alternative must not be assigned to more than one category (otherwise an exception is raised).
 Map<Category,Double> getCredibilities(Alternative alternative)
           
 NavigableMap<Category,Double> getCredibilitiesSorted(Alternative alternative)
           
 boolean isCrisp()
           
 NavigableMap<Category,Double> remove(Alternative alternative)
           
 boolean setCategories(Alternative alternative, Set<Category> categories)
           Sets, replaces, or removes the assignment of an alternative.
 boolean setCategories(SortedSet<Category> categories)
           
 boolean setCategory(Alternative alternative, Category category)
          Sets, replaces, or removes the assignment of an alternative.
 boolean setCredibilities(Alternative alternative, Map<Category,Double> credibilities)
          Sets, replaces, or removes the assignment of an alternative and the associated degrees of credibility.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersatileOrderedAssignments

public VersatileOrderedAssignments()

VersatileOrderedAssignments

public VersatileOrderedAssignments(VersatileOrderedAssignments copy)
Copy constructor by value.

Parameters:
copy - not null. The source data to be copied into this object.

VersatileOrderedAssignments

public VersatileOrderedAssignments(IOrderedAssignmentsWithCredibilitiesRead assignments)

VersatileOrderedAssignments

public VersatileOrderedAssignments(IOrderedAssignmentsToMultipleRead assignments)
Method Detail

setCategories

public boolean setCategories(SortedSet<Category> categories)

isCrisp

public boolean isCrisp()
Returns:
true iff every assigned alternatives are assigned to exactly one category (thus with a credibility degree of one). Returns false iff at least one alternative is assigned to more than one category.

setCredibilities

public boolean setCredibilities(Alternative alternative,
                                Map<Category,Double> credibilities)
Sets, replaces, or removes the assignment of an alternative and the associated degrees of credibility. The used ordering is the one given by getCategories(). A zero value as a degree of credibility is considered as equivalent to a missing entry: it is interpreted as meaning that the given alternative is not assigned to the corresponding category.

Parameters:
alternative - not null.
credibilities - null or empty to assign the alternative to no category, i.e., to remove the assignment of the given alternative. The map entries may not contain a null key or value, the values must be positive or zero, the categories must be contained in getCategories(). If the map contains only zeroes, it is considered empty.
Returns:
true iff the call changed the assignments, i.e., iff the assignment existed and has been removed, or existed and has changed (be it a change in some credibility degrees or a change of category), or did not exist and has been added.

remove

public NavigableMap<Category,Double> remove(Alternative alternative)

setCategories

public boolean setCategories(Alternative alternative,
                             Set<Category> categories)

Sets, replaces, or removes the assignment of an alternative. The given categories ordering must have been defined.

When this method is used to add an assignment, evenly shared degrees of credibility are added automatically for compatibility with getCredibilities(Alternative).

Parameters:
alternative - not null.
categories - null or empty to assign the alternative to no category, i.e., to remove the assignment of the given alternative. Otherwise, must be a subset of the categories returned by getCategories().
Returns:
true iff the call changed the assignments, i.e. true iff the given alternative was assigned and the assignment has been removed, or was assigned to a not identical set of categories, or was not assigned and has been.

getCredibilities

public Map<Category,Double> getCredibilities(Alternative alternative)

getCredibilitiesSorted

public NavigableMap<Category,Double> getCredibilitiesSorted(Alternative alternative)

getCategories

public Set<Category> getCategories(Alternative alternative)

setCategory

public boolean setCategory(Alternative alternative,
                           Category category)
Sets, replaces, or removes the assignment of an alternative. A credibility value of one is used. The given category must exist in the categories order, otherwise the sorted categories returned by getCategoriesSorted() would not be a superset of the used categories any more.

Parameters:
alternative - not null.
category - null to remove the assignment.
Returns:
true iff the call changed the assignments, i.e. true iff the given alternative was assigned and the assignment has been removed, or was assigned to a different category, or was not assigned and has been assigned to a category.

getCategory

public Category getCategory(Alternative alternative)

The alternative must not be assigned to more than one category (otherwise an exception is raised). Note that this object needs this supplementary condition and thus can't implement correctly the interface for the single category case, because it already implements more complex cases, hence there is no guarantee that all alternatives are assigned to no more than one category.

Parameters:
alternative - not null.
Returns:
the category to which this alternative is assigned, or null iff this alternative is not assigned.

getCategories

public Set<Category> getCategories()

getAlternatives

public Set<Alternative> getAlternatives(Category category)

getCategoriesSorted

public NavigableSet<Category> getCategoriesSorted()

getAlternatives

public Set<Alternative> getAlternatives()

getCategoriesSorted

public NavigableSet<Category> getCategoriesSorted(Alternative alternative)

clear

public boolean clear()


Copyright © 2011. All Rights Reserved.