public class SolutionSet
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Solution> |
solutionsList_
Stores a list of
solution objects. |
Constructor and Description |
---|
SolutionSet()
Constructor.
|
SolutionSet(int maximumSize)
Creates a empty solutionSet with a maximum capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Solution solution)
Inserts a new solution into the SolutionSet.
|
Solution |
best(java.util.Comparator<Solution> comparator)
Returns the best Solution using a
Comparator . |
void |
clear()
Empties the SolutionSet
|
Solution |
get(int i)
Returns the ith solution in the set.
|
int |
getCapacity() |
int |
getMaxSize()
Returns the maximum capacity of the solution set
|
java.util.List<Solution> |
getSolutionSet() |
int |
indexBest(java.util.Comparator<Solution> comparator)
Returns the index of the best Solution using a
Comparator . |
int |
indexWorst(java.util.Comparator<Solution> comparator)
Returns the index of the worst Solution using a
Comparator . |
java.util.Iterator<Solution> |
iterator()
Returns an
Iterator to access to the solution set list. |
void |
remove(int i)
Deletes the
Solution at position i in the set. |
void |
replace(int position,
Solution solution)
Replaces a solution by a new one
|
void |
setCapacity(int capacity_) |
void |
setSolutionSet(java.util.List<Solution> solutionsList_) |
int |
size()
Returns the number of solutions in the SolutionSet.
|
void |
sort(java.util.Comparator<Solution> comparator)
Sorts a SolutionSet using a
Comparator . |
SolutionSet |
union(SolutionSet solutionSet)
Returns a new
SolutionSet which is the result of the union
between the current solution set and the one passed as a parameter. |
Solution |
worst(java.util.Comparator<Solution> comparator)
Returns the worst Solution using a
Comparator . |
double[][] |
writeObjectivesToMatrix()
Copies the objectives of the solution set to a matrix
|
protected java.util.List<Solution> solutionsList_
solution
objects.public SolutionSet()
public SolutionSet(int maximumSize)
maximumSize
- Maximum size.public boolean add(Solution solution)
solution
- The Solution
to storeSolution
has been inserted, false
otherwise.public int getCapacity()
public void setCapacity(int capacity_)
public Solution get(int i)
i
- Position of the solution to obtain.Solution
at the position i.java.lang.IndexOutOfBoundsException
public int getMaxSize()
public void sort(java.util.Comparator<Solution> comparator)
Comparator
.comparator
- Comparator
used to sort.public int indexBest(java.util.Comparator<Solution> comparator)
Comparator
.
If there are more than one occurrences, only the index of the first one
is returnedcomparator
- Comparator
used to compare solutions.-1 if the SolutionSet is empty
public Solution best(java.util.Comparator<Solution> comparator)
Comparator
. If there are
more than one occurrences, only the first one is returnedcomparator
- Comparator
used to compare solutions.null
if the SolutionSet is empty
public int indexWorst(java.util.Comparator<Solution> comparator)
Comparator
.
If there are more than one occurrences, only the index of the first one
is returnedcomparator
- Comparator
used to compare solutions.-1 if the SolutionSet is empty
public Solution worst(java.util.Comparator<Solution> comparator)
Comparator
. If there are
more than one occurrences, only the first one is returnedcomparator
- Comparator
used to compare solutions.null
if the SolutionSet is empty
public int size()
public void clear()
public void remove(int i)
Solution
at position i in the set.i
- The position of the solution to remove.public java.util.Iterator<Solution> iterator()
Iterator
to access to the solution set list.Iterator
.public SolutionSet union(SolutionSet solutionSet)
SolutionSet
which is the result of the union
between the current solution set and the one passed as a parameter.solutionSet
- SolutionSet to join with the current solutionSet.public void replace(int position, Solution solution)
position
- The position of the solution to replacesolution
- The new solutionpublic java.util.List<Solution> getSolutionSet()
public void setSolutionSet(java.util.List<Solution> solutionsList_)
public double[][] writeObjectivesToMatrix()