jmetal.core
Class SolutionSet

java.lang.Object
  extended by jmetal.core.SolutionSet
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Archive, NonDominatedSolutionList, NonDominatedSolutionList2

public class SolutionSet
extends java.lang.Object
implements java.io.Serializable

Class representing a SolutionSet (a set of solutions)

See Also:
Serialized Form

Field Summary
protected  java.util.List<Solution> solutionsList_
          Stores a list of solution objects.
 
Constructor Summary
SolutionSet()
          Constructor.
SolutionSet(int maximumSize)
          Creates a empty solutionSet with a maximum capacity.
 
Method Summary
 boolean add(int index, Solution solution)
           
 boolean add(Solution solution)
          Inserts a new solution into the SolutionSet.
 Solution best(java.util.Comparator 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
 int indexWorst(java.util.Comparator 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 printFeasibleFUN(java.lang.String path)
          Write the function values of feasible solutions into a file
 void printFeasibleVAR(java.lang.String path)
          Write the encodings.variable values of feasible solutions into a file
 void printObjectives()
           
 void printObjectivesToFile(java.lang.String path)
          Writes the objective function values of the Solution objects into the set in a file.
 void printVariablesToFile(java.lang.String path)
          Writes the decision encodings.variable values of the Solution solutions objects into the set in a file.
 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)
           
 int size()
          Returns the number of solutions in the SolutionSet.
 void sort(java.util.Comparator 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 comparator)
          Returns the worst Solution using a Comparator.
 double[][] writeObjectivesToMatrix()
          Copies the objectives of the solution set to a matrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

solutionsList_

protected final java.util.List<Solution> solutionsList_
Stores a list of solution objects.

Constructor Detail

SolutionSet

public SolutionSet()
Constructor. Creates an unbounded solution set.


SolutionSet

public SolutionSet(int maximumSize)
Creates a empty solutionSet with a maximum capacity.

Parameters:
maximumSize - Maximum size.
Method Detail

add

public boolean add(Solution solution)
Inserts a new solution into the SolutionSet.

Parameters:
solution - The Solution to store
Returns:
True If the Solution has been inserted, false otherwise.

add

public boolean add(int index,
                   Solution solution)

get

public Solution get(int i)
Returns the ith solution in the set.

Parameters:
i - Position of the solution to obtain.
Returns:
The Solution at the position i.
Throws:
java.lang.IndexOutOfBoundsException - Exception

getMaxSize

public int getMaxSize()
Returns the maximum capacity of the solution set

Returns:
The maximum capacity of the solution set

sort

public void sort(java.util.Comparator comparator)
Sorts a SolutionSet using a Comparator.

Parameters:
comparator - Comparator used to sort.

best

public Solution best(java.util.Comparator comparator)
Returns the best Solution using a Comparator. If there are more than one occurrences, only the first one is returned

Parameters:
comparator - Comparator used to compare solutions.
Returns:
The best Solution attending to the comparator or null if the SolutionSet is empty

indexWorst

public int indexWorst(java.util.Comparator comparator)
Returns the index of the worst Solution using a Comparator. If there are more than one occurrences, only the index of the first one is returned

Parameters:
comparator - Comparator used to compare solutions.
Returns:
The index of the worst Solution attending to the comparator or -1 if the SolutionSet is empty

worst

public Solution worst(java.util.Comparator comparator)
Returns the worst Solution using a Comparator. If there are more than one occurrences, only the first one is returned

Parameters:
comparator - Comparator used to compare solutions.
Returns:
The worst Solution attending to the comparator or null if the SolutionSet is empty

size

public int size()
Returns the number of solutions in the SolutionSet.

Returns:
The size of the SolutionSet.

printObjectivesToFile

public void printObjectivesToFile(java.lang.String path)
Writes the objective function values of the Solution objects into the set in a file.

Parameters:
path - The output file name

printVariablesToFile

public void printVariablesToFile(java.lang.String path)
Writes the decision encodings.variable values of the Solution solutions objects into the set in a file.

Parameters:
path - The output file name

printFeasibleFUN

public void printFeasibleFUN(java.lang.String path)
Write the function values of feasible solutions into a file

Parameters:
path - File name

printFeasibleVAR

public void printFeasibleVAR(java.lang.String path)
Write the encodings.variable values of feasible solutions into a file

Parameters:
path - File name

clear

public void clear()
Empties the SolutionSet


remove

public void remove(int i)
Deletes the Solution at position i in the set.

Parameters:
i - The position of the solution to remove.

iterator

public java.util.Iterator<Solution> iterator()
Returns an Iterator to access to the solution set list.

Returns:
the Iterator.

union

public 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.

Parameters:
solutionSet - SolutionSet to join with the current solutionSet.
Returns:
The result of the union operation.

replace

public void replace(int position,
                    Solution solution)
Replaces a solution by a new one

Parameters:
position - The position of the solution to replace
solution - The new solution

writeObjectivesToMatrix

public double[][] writeObjectivesToMatrix()
Copies the objectives of the solution set to a matrix

Returns:
A matrix containing the objectives

printObjectives

public void printObjectives()

setCapacity

public void setCapacity(int capacity)

getCapacity

public int getCapacity()