dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
Problem< S > Class Template Referenceabstract

Class to represent a Problem in the tool. It includes the basic information for a problem a few methods that must be implemented in the subclasses. More...

#include <Problem.h>

Inheritance diagram for Problem< S >:
AbstractDomain< TSP, TSPInstance > AbstractDomain< BPP, BPPInstance > AbstractDomain< KPNR, KPInstance > TSPDomain BPPDomain KPDomain

Public Member Functions

 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 S createSolution () const =0
 Creates a new solution for the problem. Usually uses problem information and generates a solution randomly. This method must be implemented in the subclasses. More...
 
virtual S createSolution (ParallelPRNG &engine) const =0
 
virtual int getOptimizationDirection (const int i) const =0
 Returns the optimization direction for each objective in the problem. It returns Minimize or Maximize accordingly. This method must be implemented in the subclasses. More...
 
virtual float getUpperLimit (const int i) const =0
 Returns the upper bound to the problem at dimension i. This method must be implemented in the subclasses. More...
 
virtual float getLowerLimit (const int i) const =0
 Returns the lower bound to the problem at dimension i. This method must be implemented in the subclasses. More...
 
virtual string getName () const =0
 Returns the name of the problem. 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...
 

Protected Attributes

int numberOfVars
 
int numberOfObjs
 
int numberOfCons
 

Detailed Description

template<class S>
class Problem< S >

Class to represent a Problem in the tool. It includes the basic information for a problem a few methods that must be implemented in the subclasses.

Template Parameters
SType of individual in the population

Constructor & Destructor Documentation

◆ Problem() [1/2]

template<class S >
Problem< S >::Problem

Creates a new Problem with all parameters to zero.

Template Parameters
S

◆ Problem() [2/2]

template<class S >
Problem< S >::Problem ( const int &  nVars,
const int &  nObjs,
const int &  nCons 
)

Construct a new Problem with all the given parameters.

Template Parameters
S
Parameters
nVarsNumber of variables in the problem
nObjsNumber of objectives in the problem
nConsNumber of constraint in the problem

Member Function Documentation

◆ createSolution()

template<class S >
virtual S Problem< S >::createSolution ( ) const
pure virtual

Creates a new solution for the problem. Usually uses problem information and generates a solution randomly. This method must be implemented in the subclasses.

Returns
S Solution (S)

Implemented in ZDT, TSP, Sphere, Rastrigin, KP, DoubleSphere, BPP, TSPDomain, KPDomain, and BPPDomain.

◆ evaluate()

template<class S >
virtual void Problem< S >::evaluate ( S &  sol) const
pure virtual

Method to evaluate a solution using the proper problem formulation. This method must be implemented in the subclasses.

Parameters
solSolution (S) to evaluate

Implemented in BPP, TSP, ZDT, Sphere, Rastrigin, DoubleSphere, KPNR, and KP.

◆ evaluateConstraints()

template<class S >
virtual bool Problem< S >::evaluateConstraints ( S &  sol) const
pure virtual

Method to evaluate whether a solution is feasible or not. This method must be implemented in the subclasses.

Parameters
solSolution (S) to evaluate
Returns
true if the solution is feasible
false otherwise

Implemented in BPP, TSP, ZDT, Sphere, Rastrigin, DoubleSphere, and KP.

◆ getLowerLimit()

template<class S >
virtual float Problem< S >::getLowerLimit ( const int  i) const
pure virtual

Returns the lower bound to the problem at dimension i. This method must be implemented in the subclasses.

Parameters
i
Returns
float

Implemented in ZDT, TSP, Sphere, Rastrigin, KP, DoubleSphere, BPP, TSPDomain, KPDomain, and BPPDomain.

◆ getName()

template<class S >
virtual string Problem< S >::getName ( ) const
pure virtual

Returns the name of the problem. This method must be implemented in the subclasses.

Returns
string

Implemented in ZDT, TSP, Sphere, Rastrigin, KP, DoubleSphere, BPP, TSPDomain, KPDomain, and BPPDomain.

◆ getNumberOfCons()

template<class S >
int Problem< S >::getNumberOfCons ( ) const
inline

Get the number the constraint of the problem.

Returns
int

◆ getNumberOfObjs()

template<class S >
int Problem< S >::getNumberOfObjs ( ) const
inline

Get the number of objectives of the problem.

Returns
int

◆ getNumberOfVars()

template<class S >
int Problem< S >::getNumberOfVars ( ) const
inline

Get the number of variables (dimension) of the problem.

Returns
int

◆ getOptimizationDirection()

template<class S >
virtual int Problem< S >::getOptimizationDirection ( const int  i) const
pure virtual

Returns the optimization direction for each objective in the problem. It returns Minimize or Maximize accordingly. This method must be implemented in the subclasses.

Parameters
iDimension to check
Returns
Minimize or Maximize constants.

Implemented in ZDT, Sphere, Rastrigin, DoubleSphere, TSP, KP, BPP, TSPDomain, KPDomain, BPPDomain, AbstractDomain< OptProblem, InstSolution >, AbstractDomain< TSP, TSPInstance >, AbstractDomain< BPP, BPPInstance >, and AbstractDomain< KPNR, KPInstance >.

◆ getUpperLimit()

template<class S >
virtual float Problem< S >::getUpperLimit ( const int  i) const
pure virtual

Returns the upper bound to the problem at dimension i. This method must be implemented in the subclasses.

Parameters
iDimension to check
Returns
float

Implemented in ZDT, TSP, Sphere, Rastrigin, KP, DoubleSphere, BPP, TSPDomain, KPDomain, and BPPDomain.

◆ readData()

template<class S >
virtual void Problem< S >::readData ( const std::string &  path)
pure virtual

Method to read problem information from the given path. This method must be implemented in the subclasses.

Parameters
pathFile path to get the information

◆ setNumberOfCons()

template<class S >
void Problem< S >::setNumberOfCons ( int  nCons)
inline

Sets the number of constraint of the problem.

Parameters
nCons

◆ setNumberOfObjs()

template<class S >
void Problem< S >::setNumberOfObjs ( int  nObjs)
inline

Sets the number of objectives to the problem.

Parameters
nObjs

◆ setNumberOfVars()

template<class S >
void Problem< S >::setNumberOfVars ( int  nVars)
inline

Sets the number of variables (dimension) of the problem.

Parameters
nVars

◆ to_json()

template<class S >
json Problem< S >::to_json
virtual

Creates a JSON object with the information of the Problem.

Template Parameters
S
Returns
a json representation of the problem

Reimplemented in TSP, KP, BPP, KPDomain, and BPPDomain.

Member Data Documentation

◆ numberOfCons

template<class S >
int Problem< S >::numberOfCons
protected

Number of constraints of the solution.

◆ numberOfObjs

template<class S >
int Problem< S >::numberOfObjs
protected

Number of objectives of the solution.

◆ numberOfVars

template<class S >
int Problem< S >::numberOfVars
protected

Number of variables of the solution (dimension).


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