problems.permutation
Class SymmetricTSP

java.lang.Object
  extended by lio.LiOTask
      extended by lio.search.local.greedy.LiOGreedyTask
          extended by problems.permutation.SymmetricTSP
All Implemented Interfaces:
LiOResource

public class SymmetricTSP
extends LiOGreedyTask

Implements a Symmetric TSP task. It reads the instance from a file and codifies the solutions by means of a Permutation object. It works only with Symmetric instances. This task implements LiOGreedyTask so that it can be solved with greedy algorithms.


Constructor Summary
SymmetricTSP()
           
 
Method Summary
 LiOBounds defineIndividuals()
          In most cases, it is necessary to define some common features of a certain kind of individual such as upper and lower limits, size, etc.
 double evaluate(Individual individual)
          Evaluates an individual and returns its fitness.
 Individual[] genCandidateSteps(Individual pSolution, int pNCandidates)
          Returns the best partial solutions that could be built in one step from the given one.
 Individual generateStartingPoint()
          Generates a minimum partial solution randomly.
 LiOResourceDefinition getDefinition()
          Return a LiOResDescription object with the information of each object.
 java.lang.String getFile()
          Getter for property file.
 int getNumCities()
          Getter for property numCities.
 boolean isComplete(Individual pSolution)
          Determines whether solution is a complete one or not.
static void main(java.lang.String[] args)
           
 double optimum()
          Returns the optimum of the function.
 void setFile(java.lang.String file)
          Setter for property file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymmetricTSP

public SymmetricTSP()
Method Detail

defineIndividuals

public LiOBounds defineIndividuals()
In most cases, it is necessary to define some common features of a certain kind of individual such as upper and lower limits, size, etc. In case of permutations we only need the size of each individual.

Specified by:
defineIndividuals in class LiOTask
Returns:
a Bounds object which defines individuals.

evaluate

public double evaluate(Individual individual)
Evaluates an individual and returns its fitness. In case that the individual doesn't codify a complete solution it also returns a numerical value that can be used in greedy based algorithms.

Specified by:
evaluate in class LiOTask
Parameters:
individual - The individual that is going to be evaluated.
Returns:
fitness of a individual.

optimum

public double optimum()
Returns the optimum of the function.

Overrides:
optimum in class LiOTask
Returns:
Optimum of the task.

generateStartingPoint

public Individual generateStartingPoint()
Description copied from class: LiOGreedyTask
Generates a minimum partial solution randomly. For instance, in a permutation representing a tour, it would be the first city.

Specified by:
generateStartingPoint in class LiOGreedyTask

isComplete

public boolean isComplete(Individual pSolution)
Description copied from class: LiOGreedyTask
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.

Specified by:
isComplete in class LiOGreedyTask
Returns:
If it is a complete solution.

genCandidateSteps

public Individual[] genCandidateSteps(Individual pSolution,
                                      int pNCandidates)
Description copied from class: LiOGreedyTask
Returns the best partial solutions that could be built in one step from the given one. For instance, in the tsp problem, it would return the nCandidates cities with the minimum distance to the last one but if there aren't so many left to be visited, it would only return the non visited. In the case of forward feature subset selection in machine learning, it would return nCandidates individual each one of them resulting of adding a variable to the current solution.

Specified by:
genCandidateSteps in class LiOGreedyTask
Parameters:
pSolution - Partial solution that is going to be expanded.
pNCandidates - Number partial solutions that must be generated.
Returns:
An array containing the best possible changes.

setFile

public void setFile(java.lang.String file)
Setter for property file.

Parameters:
file - New value of property file.

getNumCities

public int getNumCities()
Getter for property numCities.

Returns:
Value of property numCities.

getDefinition

public LiOResourceDefinition getDefinition()
Return a LiOResDescription object with the information of each object. That object holds the name and all parameters that describe the object

Specified by:
getDefinition in interface LiOResource
Overrides:
getDefinition in class LiOTask
Returns:
A definition of the object.

getFile

public java.lang.String getFile()
Getter for property file.

Returns:
Value of property file.

main

public static void main(java.lang.String[] args)