|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.decisiondeck.jmcda.structure.sorting.assignment.VersatileAssignments
public class VersatileAssignments
This class implements both the methods from IAssignmentsWithCredibilities and IAssignmentsToMultiple,
and thus provides auto conversion between credibilities and ‘‘no credibilities’’. When an alternative is assigned to
several categories, with no credibilities specification, it is automatically interpreted as meaning that each
category has an associated credibility of one divided by the number of categories to which this alternative has been
assigned. It is probably not such a good idea for a user of this class to rely on that automatic conversion
capability as it can be difficult to read and maintain, but it is permitted, and this allows for this object to be
easily wrapped by objects that implement one of these interfaces specifically. This object may not implement both
these interfaces because the related equality relations are incompatible (see definition in these interfaces
documentation).
This class does not implement IOrderedAssignmentsWithCredibilities or
IOrderedAssignmentsToMultiple, as the ordered case is not compatible with the non-ordered one: the former
demands that the order on the categories be specified beforehand. Also this class can't implement
IAssignmentsRead as this class authorizes an alternative to be assigned to more than one categories. It is
however functionally equivalent if only the setter method appropriate to the single category case is used.
| Constructor Summary | |
|---|---|
VersatileAssignments()
|
|
VersatileAssignments(IAssignmentsWithCredibilitiesRead assignments)
|
|
VersatileAssignments(VersatileAssignments 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)
|
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)
|
boolean |
isCrisp()
|
Map<Category,Double> |
remove(Alternative alternative)
|
boolean |
setCategories(Alternative alternative,
Set<Category> categories)
Sets, replaces, or removes the assignment of an alternative. |
boolean |
setCategories(Set<Category> categories)
Sets the categories this object will return to getCategories(), or removes them and restore the default
behavior. |
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 |
|---|
public VersatileAssignments()
public VersatileAssignments(VersatileAssignments copy)
copy - not null. The source data to be copied into this object.public VersatileAssignments(IAssignmentsWithCredibilitiesRead assignments)
| Method Detail |
|---|
public boolean setCategories(Set<Category> categories)
Sets the categories this object will return to getCategories(), or removes them and restore the default
behavior. The given categories should be a superset of the categories to which objects are and will be assigned,
otherwise the contract of getCategories() will not be fulfilled.
When no categories is associated to this object, it returns the set of categories to which at least one alternative has been assigned.
categories - null to remove the associated categories (all the orderings are lost). A superset of the
categories already used.
true iff the categories changed.public boolean isCrisp()
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.
public boolean setCredibilities(Alternative alternative,
Map<Category,Double> credibilities)
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. If the map contains only zeroes, it is considered empty.
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.public Map<Category,Double> remove(Alternative alternative)
public boolean setCategories(Alternative alternative,
Set<Category> categories)
Sets, replaces, or removes the assignment of an alternative.
When this method is used to add an assignment, evenly shared degrees of credibility are added automatically for
compatibility with getCredibilities(Alternative).
alternative - not null.categories - null or empty to assign the alternative to no category, i.e., to remove the assignment of
the given alternative.
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.public Map<Category,Double> getCredibilities(Alternative alternative)
public Set<Category> getCategories(Alternative alternative)
public boolean setCategory(Alternative alternative,
Category category)
alternative - not null.category - null to remove the assignment.
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.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.
alternative - not null.
null iff this alternative is not
assigned.public Set<Category> getCategories()
public Set<Alternative> getAlternatives()
public Set<Alternative> getAlternatives(Category category)
public boolean clear()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||