lio.generators
Class GreedyConstructor

java.lang.Object
  extended by lio.generators.GreedyConstructor
All Implemented Interfaces:
LiOResource, Generator

public class GreedyConstructor
extends java.lang.Object
implements Generator

This class constructs solutions with a greedy algorithm. In order to use it, current task must implement LiOGreedyTask. It's important pointing out that the object constructs an individual by carrying out greedy steps UNTIL A VALID INDIVIDUAL IS FOUND. That is the case of using permutations for solving problems such as TSP or Strip Packing problems.

See Also:
GreedyConstruction

Constructor Summary
GreedyConstructor()
          Constructor
GreedyConstructor(int pNumCandidates)
          Constructor
 
Method Summary
static Individual expandSolution(Individual individual, int pNumCandidates)
          Performs an step on the solution construction process.
 Individual[] generate(int nIndividuals)
          Generates a number of individuals.
static Individual generateSolution(int pNumCandidates)
          Generates an individual by means of a greedy construction.
static Individual generateStartingPoint()
          Generates the starting point of a solution.
 LiOResourceDefinition getDefinition()
          Return a LiOResDescription object which holds the name and all parameters that describe the resource.
 int getNumCandidates()
          Getter for property numCandidates.
static boolean isComplete(Individual individual)
          Determines whether solution is a complete one or not.
static void main(java.lang.String[] args)
          Main class that allows testing the class.
 void setNumCandidates(int numCandidates)
          Setter for property numCandidates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GreedyConstructor

public GreedyConstructor()
Constructor


GreedyConstructor

public GreedyConstructor(int pNumCandidates)
Constructor

Parameters:
Number - of candidates that will be used in each step of the construction of the solutions.
Method Detail

generate

public Individual[] generate(int nIndividuals)
Generates a number of individuals.

Specified by:
generate in interface Generator
Parameters:
nIndividuals - Number of individuals that must be generated.
Returns:
an array of individuals.

generateSolution

public static Individual generateSolution(int pNumCandidates)
Generates an individual by means of a greedy construction.

Parameters:
pNumCandidates - Number of candidates considered at each step of the construction.
Returns:
a Solution

generateStartingPoint

public static Individual generateStartingPoint()
Generates the starting point of a solution.

Returns:
a Partial solution

expandSolution

public static Individual expandSolution(Individual individual,
                                        int pNumCandidates)
Performs an step on the solution construction process.

Parameters:
individual - The partial solution that is going to be expanded
The - number of candidate steps considered to expand the solution.

isComplete

public static boolean isComplete(Individual individual)
Determines whether solution is a complete one or not. For instance, with a permutation, representing a tour, it would return true only if the tour is complete.

Parameters:
individual - Partial solution.
Returns:
If it is a complete solution.

getDefinition

public LiOResourceDefinition getDefinition()
Return a LiOResDescription object which holds the name and all parameters that describe the resource.

Specified by:
getDefinition in interface LiOResource
Returns:
A definition of the resource.

main

public static void main(java.lang.String[] args)
Main class that allows testing the class.

Parameters:
args - Arguments passed by command line

getNumCandidates

public int getNumCandidates()
Getter for property numCandidates.

Returns:
Value of property numCandidates.

setNumCandidates

public void setNumCandidates(int numCandidates)
Setter for property numCandidates.

Parameters:
numCandidates - New value of property numCandidates.