|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbabase.ranker.ranking.RankingConstraintMultiset
public class RankingConstraintMultiset
A multiset of constraints on rankings, each of the form: individual
i must be ranked above individual j.
Individuals are identified by integers from 0 to
n-1, where n is the total number of
individuals. This multiset of constaints watches changes made to a
Ranking object, and raises exceptions whenever a constraint is
violated. The same constraint can appear multiple times in the multiset; the
constraint will be enforced as long as one copy exists,
| Field Summary | |
|---|---|
protected int[][] |
_constraints
The multiset of constraints, encoded as follows: There is a contraint dictating that individual i must be ranked above
j if and only _constraints[i][j] is
positive. |
protected Ranking |
_ranks
The ranking to which this multiset of constraints applies. |
| Constructor Summary | |
|---|---|
RankingConstraintMultiset(Ranking ranks)
Constructs an empty multiset of ranking constraints for the given ranking. |
|
| Method Summary | |
|---|---|
(package private) void |
addConstraint(int higher,
int lower)
Add to the multiset (one instance of) a constriant that individual higher must be ranked above individual lower. |
(package private) void |
addConstraints(int[] sequence)
Add a sequence of constraints (one instance of each constraint) to the multiset. |
protected boolean |
depthFirstTraversal(int src,
int dst,
boolean[] visited)
Perform a depth-first traversal on the directed graph defined by _constraints starting with node src. |
boolean |
isConstraintImplied(int higher,
int lower)
|
void |
rankingToBeChanged(RankingChangeEvent e)
This method will be invoked on the listerner object immediately before the Ranking object being listened to changes. |
(package private) void |
removeConstraint(int higher,
int lower)
Remove from the multiset (just one instance of) a constriant that individual higher must be ranked above individual
lower. |
(package private) void |
removeConstraints(int[] sequence)
Remove a sequence of constraints (one instance of each constraint) from the multiset. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Ranking _ranks
protected int[][] _constraints
i must be ranked above
j if and only _constraints[i][j] is
positive. The actual value of _constraints[i][j] counts
the number of times this constraint appears in the multiset.
| Constructor Detail |
|---|
public RankingConstraintMultiset(Ranking ranks)
ranks - | Method Detail |
|---|
public boolean isConstraintImplied(int higher,
int lower)
higher - lower -
higher is ranked
higher than lower follows from the constraints in
the multiset.
protected boolean depthFirstTraversal(int src,
int dst,
boolean[] visited)
_constraints starting with node src. There is a
directed edge from node i to node j if and
only if _constraints[i][j] > 0.
src - The source node where the traversal starts.dst - The destination node, which, once encountered, will terminate
the traversal and return true. Use the special
value of -1 to ensure that the traversal covers
all reachable nodes.visited - If visited[i] is already true,
then node i will not be visited again. On the
other hand, if the procedure visits node i,
visited[i] will be set to true.
dst is encountered, the traversal stops
and returns true. If all nodes reachable from
src have been traversed and dst is
not one of them, return false.
void addConstraint(int higher,
int lower)
throws RankingConstraintException.Inconsistency
higher must be ranked above individual lower.
higher - lower -
RankingConstraintException.Inconsistency - Thrown if the contraint to be added does not make sense or is
inconsistent with existing ones in the multiset (i.e., they
already imply that lower is ranked above
higher .
void removeConstraint(int higher,
int lower)
higher must be ranked above individual
lower. This method silently ignores the case where the
constraint to be removed does not exist in the multiset.
higher - lower -
void addConstraints(int[] sequence)
throws RankingConstraintException.Inconsistency
sequence - An array specifying a sequence of constraints: individual
sequence[0] must be ranked higher than
sequence[1], which must be ranked higher than
sequence[2], etc.
RankingConstraintException.Inconsistencyvoid removeConstraints(int[] sequence)
sequence - An array specifying a sequence of constraints: individual
sequence[0] must be ranked higher than
sequence[1], which must be ranked higher than
sequence[2], etc.
public void rankingToBeChanged(RankingChangeEvent e)
throws java.lang.Exception
RankingToBeChangedListenerRanking object being listened to changes.
rankingToBeChanged in interface RankingToBeChangedListenerjava.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||