org.decisiondeck.xmcda_oo.structure
Class Coalitions

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.structure.Coalitions
All Implemented Interfaces:
ICoalitions

public class Coalitions
extends Object
implements ICoalitions

Represents coalitions of criteria, by the way of a majority threshold and a set of weights.

TODO Better document (e.g. can weights be null?).


Constructor Summary
Coalitions()
           
Coalitions(ICoalitions source)
           
Coalitions(Weights weights)
           
Coalitions(Weights weights, double majorityThreshold)
           
 
Method Summary
 boolean approxEquals(ICoalitions c2, double tolerance)
           
 boolean equals(Object obj)
           
 Set<Criterion> getCriteria()
          Retrieves a read-only view of the set of criteria on which weights are defined.
 Double getMajorityThreshold()
           
 Double getNormalizedWeight(Criterion criterion)
           
 Weights getNormalizedWeights()
          TODO talk about tolerance (through weights); provide a r-o view.
 Double getWeight(Criterion criterion)
           
 Weights getWeights()
          Retrieves a view that reads and writes through to this object.
 int hashCode()
           
 boolean hasNulWeight()
          Must have at least one weight and lambda set.
 boolean isEmpty()
          Tests whether this object contains no information.
 boolean isNormalized()
           
 int numberOfWeights()
           
 void putAll(Weights weights)
           
 Double putWeight(Criterion criterion, double weight)
          Sets or replaces the weight associated to the given criterion.
 Double removeMajorityThreshold()
          Removes the possibly associated majority threshold.
 Double removeWeight(Criterion criterion)
           
 Double setMajorityThreshold(double majorityThreshold)
          Sets or replaces the majority threshold.
 void setMajorityThreshold(Double majorityThreshold)
          TODO remove and replace with set and with remove.
 void setWeight(Criterion criterion, Double weight)
          TODO implement remove.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Coalitions

public Coalitions(Weights weights,
                  double majorityThreshold)
Parameters:
weights - not null.
majorityThreshold - a valid value (not infinite or NaN).

Coalitions

public Coalitions(ICoalitions source)

Coalitions

public Coalitions()

Coalitions

public Coalitions(Weights weights)
Parameters:
weights - not null.
Method Detail

toString

public String toString()
Overrides:
toString in class Object

hasNulWeight

public boolean hasNulWeight()
Must have at least one weight and lambda set. TODO remove from here.

Returns:
true iff at least one weight is semantically nul, i.e. does not take part in any winning coalition except the total one. If true, at least the smallest weight is nul.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

approxEquals

public boolean approxEquals(ICoalitions c2,
                            double tolerance)
Specified by:
approxEquals in interface ICoalitions

getMajorityThreshold

public Double getMajorityThreshold()
Specified by:
getMajorityThreshold in interface ICoalitions
Returns:
null iff no threshold. Otherwise, a positive or zero value.

setMajorityThreshold

public Double setMajorityThreshold(double majorityThreshold)
Description copied from interface: ICoalitions
Sets or replaces the majority threshold.

Specified by:
setMajorityThreshold in interface ICoalitions
Parameters:
majorityThreshold - a positive or zero value.
Returns:
the previous majority threshold value, or null iff it was not set.

getNormalizedWeights

public Weights getNormalizedWeights()
Description copied from interface: ICoalitions
TODO talk about tolerance (through weights); provide a r-o view.

Specified by:
getNormalizedWeights in interface ICoalitions
Returns:
not null.

getWeight

public Double getWeight(Criterion criterion)
Specified by:
getWeight in interface ICoalitions
Parameters:
criterion - not null.
Returns:
the weight of the given criterion (a positive or zero number), or null if the given criterion is unknown.

isNormalized

public boolean isNormalized()
Specified by:
isNormalized in interface ICoalitions

putAll

public void putAll(Weights weights)

numberOfWeights

public int numberOfWeights()

getWeights

public Weights getWeights()
Description copied from interface: ICoalitions
Retrieves a view that reads and writes through to this object. Changing the tolerance in the returned weights also changes the tolerance used by this object.

Specified by:
getWeights in interface ICoalitions
Returns:
not null.

getCriteria

public Set<Criterion> getCriteria()
Description copied from interface: ICoalitions
Retrieves a read-only view of the set of criteria on which weights are defined.

Specified by:
getCriteria in interface ICoalitions
Returns:
not null.

setMajorityThreshold

public void setMajorityThreshold(Double majorityThreshold)
TODO remove and replace with set and with remove.

Parameters:
majorityThreshold - a valid value (not infinite or NaN). To unset the value, set it to null.

setWeight

public void setWeight(Criterion criterion,
                      Double weight)
TODO implement remove. Delete this method.

Specified by:
setWeight in interface ICoalitions
Parameters:
criterion - not null.
weight - a positive or zero value, or null to remove it.

putWeight

public Double putWeight(Criterion criterion,
                        double weight)
Description copied from interface: ICoalitions
Sets or replaces the weight associated to the given criterion.

Specified by:
putWeight in interface ICoalitions
Parameters:
criterion - not null.
weight - a positive or zero value.
Returns:
the weight that was previously associated to that criterion (positive or zero), or null if it was unknown.

removeMajorityThreshold

public Double removeMajorityThreshold()
Description copied from interface: ICoalitions
Removes the possibly associated majority threshold. If not set, this method has no effect.

Specified by:
removeMajorityThreshold in interface ICoalitions
Returns:
the previous value of the majority threshold, or null iff it was not set.

getNormalizedWeight

public Double getNormalizedWeight(Criterion criterion)
Specified by:
getNormalizedWeight in interface ICoalitions

removeWeight

public Double removeWeight(Criterion criterion)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

isEmpty

public boolean isEmpty()
Description copied from interface: ICoalitions
Tests whether this object contains no information.

Specified by:
isEmpty in interface ICoalitions
Returns:
true iff this object contains no weights and no majority threshold.


Copyright © 2011. All Rights Reserved.