Ranking
public class SimpleRanking
extends java.lang.Object
SimpleRankingPosition
instance) may be shared by one or more objects (ex-equo).
Thus, this ranking is a complete preorder (also called weak order).
Places and objects are numbered starting from zero, except from toString
method.
In textual form, which may be for example written to file,
places and objects are numbered starting from zero or from one, depending on incrementIndex
value.Modifier and Type | Field | Description |
---|---|---|
boolean |
incrementIndex |
Tells if objects are numbered starting from zero (
incrementIndex == false )
or from one (incrementIndex == true ) when this ranking is printed to a string
or to a disk file. |
Constructor | Description |
---|---|
SimpleRanking(int[] ranking) |
Constructor for
SimpleRanking class creating simple ranking in which there are no indifferences |
SimpleRanking(java.util.ArrayList<SimpleRankingPosition> ranking) |
Constructor for
SimpleRanking class. |
SimpleRanking(MemoryContainer memoryContainer) |
Converts given memory container to a linear ranking (weak order) of objects for which the decision class is known.
|
SimpleRanking(SimpleRankingPosition[] ranking) |
Constructor for
SimpleRanking class. |
Modifier and Type | Method | Description |
---|---|---|
int[] |
getNumbersOfObjectsAtPlace(int place) |
Gets list with numbers of objects sharing given place.
|
int |
getPlaceOfObject(int objectNumber) |
Gets place of object with given number.
|
int |
getQuantityOfObjects() |
Gets quantity of objects present in this ranking.
|
int |
getQuantityOfPlaces() |
Gets quantity of places in the ranking.
|
java.lang.String |
toSingleLineString() |
Gets single-line textual form of this ranking.
|
java.lang.String |
toString() |
Gets multi-line textual form of this ranking.
|
void |
writeRanking(java.lang.String fileName) |
Writes this ranking to file with given name (path).
|
public boolean incrementIndex
incrementIndex == false
)
or from one (incrementIndex == true
) when this ranking is printed to a string
or to a disk file.public SimpleRanking(int[] ranking)
SimpleRanking
class creating simple ranking in which there are no indifferencesranking
- array storing numbers of objects for subsequent places in ranking (index = place; value = number of object at given place)java.lang.NullPointerException
- when ranking is null
InvalidValueException
- when ranking is empty
or when some number of object is smaller than zeropublic SimpleRanking(java.util.ArrayList<SimpleRankingPosition> ranking)
SimpleRanking
class.
In given ranking each object's number can be present only at one place.
Given ranking is stored directly in this class.
Numbers of objects sharing each place are getting sorted ascendingly.ranking
- array list containing SimpleRankingPosition
objects for subsequent places.
Index = place; value = SimpleRankingPosition
object storing numbers of objects sharing considered place.java.lang.NullPointerException
- when ranking is null
InvalidValueException
- when ranking is emptypublic SimpleRanking(SimpleRankingPosition[] ranking)
SimpleRanking
class.
In given ranking each object's number can be present only at one place.
Given ranking is stored in this class.
Numbers of objects sharing each place are getting sorted ascendingly.ranking
- array containing SimpleRankingPosition
objects for subsequent places.
Index = place; value = SimpleRankingPosition
object storing numbers of objects sharing considered place.java.lang.NullPointerException
- when ranking is null
InvalidValueException
- when ranking is emptypublic SimpleRanking(MemoryContainer memoryContainer)
memoryContainer
- memory container with preference-ordered decision attributeInvalidValueException
- when memory container contains no attributes or no examples
or when memory container does not have exactly one active decision criterionjava.lang.NullPointerException
- when memory container is null
public int getQuantityOfObjects()
public int getQuantityOfPlaces()
public int getPlaceOfObject(int objectNumber)
objectNumber
- number of object whose place should be establishedjava.lang.IndexOutOfBoundsException
- when object's number is less than zeropublic int[] getNumbersOfObjectsAtPlace(int place)
place
- place in ranking for which list with numbers of objects sharing that place should be establishedjava.lang.IndexOutOfBoundsException
- when place is less than zero or greater than or equal to the quantity of all placespublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toSingleLineString()
public void writeRanking(java.lang.String fileName) throws java.io.IOException
fileName
- name (path) of the file in which this ranking should be savedjava.io.IOException
- if file with given name (path) can't be opened for write