jmetal.core
Class Algorithm

java.lang.Object
  extended by jmetal.core.Algorithm
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbYSS, acGA, aMOCell1, aMOCell2, aMOCell3, CellDE, CMAES, cMOEAD, DE, DENSEA, dMOPSO, ElitistES, FastPGA, FastSMSEMOA, GDE3, gGA, IBEA, MOCell, MOCHC, MOEAD, MOEAD_DRA, NonElitistES, NSGAII, NSGAIIAdaptive, NSGAIIRandom, OMOPSO, PAES, PESA2, pgGA, pMOEAD, pNSGAII, pSMPSO, PSO, RandomSearch, scGA, sMOCell1, sMOCell2, SMPSO, SMPSOhv, SMSEMOA, SPEA2, ssGA, ssNSGAII, ssNSGAIIAdaptive, ssNSGAIIRandom

public abstract class Algorithm
extends java.lang.Object
implements java.io.Serializable

This class implements a generic template for the algorithms developed in jMetal. Every algorithm must have a mapping between the parameters and and their names, and another mapping between the operators and their names. The class declares an abstract method called execute, which defines the behavior of the algorithm.

See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object> inputParameters_
          Stores algorithm specific parameters.
protected  java.util.Map<java.lang.String,Operator> operators_
          Stores the operators used by the algorithm, such as selection, crossover, etc.
protected  Problem problem_
          Stores the problem to solve
 
Constructor Summary
Algorithm(Problem problem)
          Constructor
 
Method Summary
 void addOperator(java.lang.String name, Operator operator)
          Offers facilities for add new operators for the algorithm.
abstract  SolutionSet execute()
          Launches the execution of an specific algorithm.
 java.lang.Object getInputParameter(java.lang.String name)
          Gets an input parameter through its name.
 Operator getOperator(java.lang.String name)
          Gets an operator through his name.
 java.lang.Object getOutputParameter(java.lang.String name)
          Gets an output parameter through its name.
 Problem getProblem()
          Returns the problem to solve
 void setInputParameter(java.lang.String name, java.lang.Object object)
          Sets an input parameter to an algorithm.
 void setOutputParameter(java.lang.String name, java.lang.Object object)
          Sets an output parameter that can be obtained by invoking getOutputParame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

problem_

protected Problem problem_
Stores the problem to solve


operators_

protected java.util.Map<java.lang.String,Operator> operators_
Stores the operators used by the algorithm, such as selection, crossover, etc.


inputParameters_

protected java.util.Map<java.lang.String,java.lang.Object> inputParameters_
Stores algorithm specific parameters. For example, in NSGA-II these parameters include the population size and the maximum number of function evaluations.

Constructor Detail

Algorithm

public Algorithm(Problem problem)
Constructor

Parameters:
problem - The problem to be solved
Method Detail

execute

public abstract SolutionSet execute()
                             throws JMException,
                                    java.lang.ClassNotFoundException
Launches the execution of an specific algorithm.

Returns:
a SolutionSet that is a set of non dominated solutions as a result of the algorithm execution
Throws:
JMException
java.lang.ClassNotFoundException

addOperator

public void addOperator(java.lang.String name,
                        Operator operator)
Offers facilities for add new operators for the algorithm. To use an operator, an algorithm has to obtain it through the getOperator method.

Parameters:
name - The operator name
operator - The operator

getOperator

public Operator getOperator(java.lang.String name)
Gets an operator through his name. If the operator doesn't exist or the name is wrong this method returns null. The client of this method have to check the result of the method.

Parameters:
name - The operator name
Returns:
The operator if exists, null in another case.

setInputParameter

public void setInputParameter(java.lang.String name,
                              java.lang.Object object)
Sets an input parameter to an algorithm. Typically, the method is invoked by a Main object before running an algorithm. The parameters have to been inserted using their name to access them through the getInputParameter method.

Parameters:
name - The parameter name
object - Object that represent a parameter for the algorithm.

getInputParameter

public java.lang.Object getInputParameter(java.lang.String name)
Gets an input parameter through its name. Typically, the method is invoked by an object representing an algorithm

Parameters:
name - The parameter name
Returns:
Object representing the parameter or null if the parameter doesn't exist or the name is wrong

setOutputParameter

public void setOutputParameter(java.lang.String name,
                               java.lang.Object object)
Sets an output parameter that can be obtained by invoking getOutputParame. Typically this algorithm is invoked by an algorithm at the end of the execute to retrieve output information

Parameters:
name - The output parameter name
object - Object representing the output parameter

getOutputParameter

public java.lang.Object getOutputParameter(java.lang.String name)
Gets an output parameter through its name. Typically, the method is invoked by a Main object after the execution of an algorithm.

Parameters:
name - The output parameter name
Returns:
Object representing the output parameter, or null if the parameter doesn't exist or the name is wrong.

getProblem

public Problem getProblem()
Returns the problem to solve

Returns:
Problem The problem to solve