dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
TSPDomain Class Reference

Instance Generator TSP Problem. Problem for the EIG to generate TSP Instances. More...

#include <TSPDomain.h>

Inheritance diagram for TSPDomain:
AbstractDomain< TSP, TSPInstance > Problem< S >

Public Member Functions

 TSPDomain ()
 Creates a default TSPDomain.
 
 TSPDomain (const int &numberOfVars, const int &numberOfObjs=1)
 Creates a TSPDomain object with the number of variables. The number of variables (dimension) is set as the double of the number of variables which it is used to create an object. This is because the ITPSolution must be twice size of the nVars since it stores the pairs (x,y) coordinates for each city. The default limits for the coordinates are [0, 1000], eps = 5.0 and minNeighbors = 2. More...
 
 TSPDomain (const TSPDomain *prob)
 Creates a TSPDomain object copying the information from other object. More...
 
 TSPDomain (const string &pathToInstance)=delete
 Not allowed here. More...
 
 TSPDomain (const int &numberOfVars, const int &numberOfObjs, const float &maxL, const float &minL, const float e=5.0, const int minN=2)
 Creates a TSPDomain with the DBSCAN parameters to compute the features. More...
 
shared_ptr< TSPgenOptProblem (const TSPInstance &instance) const override
 Generates a TSP problem with the information in the TSPInstance to be solved in the EIG by the algorithms in the portfolio. More...
 
void evaluate (TSPInstance &solution) const override
 Not implemented. More...
 
vector< TSPInstancecreateSolutions (const int &maxSolutions) const override
 Creates a vector of initial instances (ITSPSolutions) for the EIG. More...
 
void beforeEvaluation (vector< TSPInstance > &) override
 Performs problem dependent operations before evaluating the instances in the EIG. More...
 
void afterEvaluation (vector< TSPInstance > &) override
 Performs problem dependent operatiions after evaluating the instances in the EIG. Computes the features of the instance. For the TSP are: "size", "mean_dist", "std_dist", "centroid", "radius", "cluster_ratio", "cluster_radius". More...
 
TSPInstance createSolution () const override
 Creates a single solution (TSP instance) More...
 
TSPInstance createSolution (ParallelPRNG &engine) const override
 Creates a single solution (TSP instance) More...
 
bool evaluateConstraints (TSPInstance &solution) const override
 Not implemented here. More...
 
int getOptimizationDirection (const int i) const override
 Returns the optimization direction for each dimension. Minimize in each case. More...
 
string getName () const override
 Get the problem name. More...
 
float getUpperLimit (const int i) const override
 Get the upper limit of the ith dimension (default = 1000) More...
 
float getLowerLimit (const int i) const override
 Get the lower limit of the ith dimension (default = 0) More...
 
void setUpperLimit (const float &l)
 Set the upper limit for the ith dimension. More...
 
void setLowerLimit (const float &l)
 Set the lower limit for the ith dimension. More...
 
void setEPS (const float e)
 Set the epsilon parameter for the DBSCAN algorithm. More...
 
float getEPS () const
 Get the epsilon parameter of the DBSCAN algorithm. More...
 
void setMinNeighbors (const int m)
 Set the minimum number of neighbors to consider a cluster in the DBSCAN algorithm. More...
 
int getMinNeighbors () const
 Get the minimum number of neighbors to consider a cluster in the DBSCAN algorithm. More...
 
void readData (const string &path) override
 Not implemented here. More...
 
- Public Member Functions inherited from AbstractDomain< TSP, TSPInstance >
 AbstractDomain ()
 Construct a new AbstractDomain<OptProblem, InstSolution>AbstractDomain object. More...
 
 AbstractDomain (const int &numberOfVars, const int &numberOfObjectives, const int &nCons)
 Construct a new AbstractDomain<OptProblem, InstSolution>AbstractDomain object. More...
 
- Public Member Functions inherited from Problem< S >
 Problem ()
 Creates a new Problem with all parameters to zero. More...
 
 Problem (const int &numberOfVars, const int &numberOfObjectives, const int &nCons)
 Construct a new Problem with all the given parameters. More...
 
 Problem (const Problem *copy)
 
virtual bool evaluateConstraints (S &sol) const =0
 Method to evaluate whether a solution is feasible or not. This method must be implemented in the subclasses. More...
 
virtual void evaluate (S &sol) const =0
 Method to evaluate a solution using the proper problem formulation. This method must be implemented in the subclasses. More...
 
virtual void readData (const std::string &path)=0
 Method to read problem information from the given path. This method must be implemented in the subclasses. More...
 
virtual json to_json () const
 Creates a JSON object with the information of the Problem. More...
 
int getNumberOfVars () const
 Get the number of variables (dimension) of the problem. More...
 
void setNumberOfVars (int nVars)
 Sets the number of variables (dimension) of the problem. More...
 
int getNumberOfObjs () const
 Get the number of objectives of the problem. More...
 
void setNumberOfObjs (int nObjs)
 Sets the number of objectives to the problem. More...
 
int getNumberOfCons () const
 Get the number the constraint of the problem. More...
 
void setNumberOfCons (int nCons)
 Sets the number of constraint of the problem. More...
 

Additional Inherited Members

- Protected Attributes inherited from AbstractDomain< TSP, TSPInstance >
int internalDimension
 
- Protected Attributes inherited from Problem< S >
int numberOfVars
 
int numberOfObjs
 
int numberOfCons
 

Detailed Description

Instance Generator TSP Problem. Problem for the EIG to generate TSP Instances.

Constructor & Destructor Documentation

◆ TSPDomain() [1/4]

TSPDomain::TSPDomain ( const int &  numberOfVars,
const int &  numberOfObjs = 1 
)
explicit

Creates a TSPDomain object with the number of variables. The number of variables (dimension) is set as the double of the number of variables which it is used to create an object. This is because the ITPSolution must be twice size of the nVars since it stores the pairs (x,y) coordinates for each city. The default limits for the coordinates are [0, 1000], eps = 5.0 and minNeighbors = 2.

Parameters
numberOfVars

◆ TSPDomain() [2/4]

TSPDomain::TSPDomain ( const TSPDomain prob)

Creates a TSPDomain object copying the information from other object.

Parameters
prob

◆ TSPDomain() [3/4]

TSPDomain::TSPDomain ( const string &  pathToInstance)
delete

Not allowed here.

Parameters
pathToInstance

◆ TSPDomain() [4/4]

TSPDomain::TSPDomain ( const int &  numberOfVars,
const int &  numberOfObjs,
const float &  maxL,
const float &  minL,
const float  e = 5.0,
const int  minN = 2 
)

Creates a TSPDomain with the DBSCAN parameters to compute the features.

Parameters
numberOfVarsNumber of variables
maxLUpper bound
minLLower bound
eEpsilon threshold to consider two points neighbors in DBSCAN
minNMinimum number of neighbors to consider a cluster.

Member Function Documentation

◆ afterEvaluation()

void TSPDomain::afterEvaluation ( vector< TSPInstance > &  solutions)
overridevirtual

Performs problem dependent operatiions after evaluating the instances in the EIG. Computes the features of the instance. For the TSP are: "size", "mean_dist", "std_dist", "centroid", "radius", "cluster_ratio", "cluster_radius".

Performs problem dependent operatiions after evaluating the instances in the EIG. Computes the features of the instance. For the TSP are: "size", "mean_dist", "std_dist", "centroid", "radius",.

Parameters

Implements AbstractDomain< TSP, TSPInstance >.

◆ beforeEvaluation()

void TSPDomain::beforeEvaluation ( vector< TSPInstance > &  )
inlineoverridevirtual

Performs problem dependent operations before evaluating the instances in the EIG.

Parameters

Implements AbstractDomain< TSP, TSPInstance >.

◆ createSolution() [1/2]

TSPInstance TSPDomain::createSolution ( ) const
overridevirtual

Creates a single solution (TSP instance)

Returns

Implements Problem< S >.

◆ createSolution() [2/2]

TSPInstance TSPDomain::createSolution ( ParallelPRNG &  engine) const
overridevirtual

Creates a single solution (TSP instance)

Deprecated:
Parameters
engine
Returns

Implements Problem< S >.

◆ createSolutions()

vector< TSPInstance > TSPDomain::createSolutions ( const int &  maxSolutions) const
overridevirtual

Creates a vector of initial instances (ITSPSolutions) for the EIG.

Parameters
maxSolutions
Returns

Implements AbstractDomain< TSP, TSPInstance >.

◆ evaluate()

void TSPDomain::evaluate ( TSPInstance solution) const
inlineoverride

Not implemented.

Parameters
solution

◆ evaluateConstraints()

bool TSPDomain::evaluateConstraints ( TSPInstance solution) const
inlineoverride

Not implemented here.

Parameters
solution
Returns

◆ genOptProblem()

shared_ptr< TSP > TSPDomain::genOptProblem ( const TSPInstance instance) const
overridevirtual

Generates a TSP problem with the information in the TSPInstance to be solved in the EIG by the algorithms in the portfolio.

Parameters
instance
Returns

Implements AbstractDomain< TSP, TSPInstance >.

◆ getEPS()

float TSPDomain::getEPS ( ) const
inline

Get the epsilon parameter of the DBSCAN algorithm.

Returns

◆ getLowerLimit()

float TSPDomain::getLowerLimit ( const int  i) const
overridevirtual

Get the lower limit of the ith dimension (default = 0)

Parameters
i
Returns

Implements Problem< S >.

◆ getMinNeighbors()

int TSPDomain::getMinNeighbors ( ) const
inline

Get the minimum number of neighbors to consider a cluster in the DBSCAN algorithm.

Returns

◆ getName()

string TSPDomain::getName ( ) const
inlineoverridevirtual

Get the problem name.

Returns
a String with the information

Implements Problem< S >.

◆ getOptimizationDirection()

int TSPDomain::getOptimizationDirection ( const int  i) const
overridevirtual

Returns the optimization direction for each dimension. Minimize in each case.

Parameters
i
Returns

Reimplemented from AbstractDomain< TSP, TSPInstance >.

◆ getUpperLimit()

float TSPDomain::getUpperLimit ( const int  i) const
overridevirtual

Get the upper limit of the ith dimension (default = 1000)

Parameters
i
Returns

Implements Problem< S >.

◆ readData()

void TSPDomain::readData ( const string &  path)
inlineoverride

Not implemented here.

Parameters
path

◆ setEPS()

void TSPDomain::setEPS ( const float  e)
inline

Set the epsilon parameter for the DBSCAN algorithm.

Parameters
e

◆ setLowerLimit()

void TSPDomain::setLowerLimit ( const float &  l)
inline

Set the lower limit for the ith dimension.

Parameters
l

◆ setMinNeighbors()

void TSPDomain::setMinNeighbors ( const int  m)
inline

Set the minimum number of neighbors to consider a cluster in the DBSCAN algorithm.

Parameters
m

◆ setUpperLimit()

void TSPDomain::setUpperLimit ( const float &  l)
inline

Set the upper limit for the ith dimension.

Parameters
l

The documentation for this class was generated from the following files: