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

Instance Generator Knapsack Problem. Problem for the Instance Generator to generate Knapsack Problem Instances 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 KPInstance must be twice size of the nVars. More...

#include <KPDomain.h>

Inheritance diagram for KPDomain:
AbstractDomain< KPNR, KPInstance > Problem< S >

Public Member Functions

 KPDomain (const int &numberOfVars, const int &numberOfObjs=1)
 
 KPDomain (const string &pathToInstance)=delete
 
 KPDomain (const int &numberOfVars, const int &numberOfObjs, const int &numOfInstances, const int &lowerWeight, const int &upperWeight, const int &lowerProfit, const int &upperProfit, bool reducedSpace=false)
 
shared_ptr< KPNRgenOptProblem (const KPInstance &instance) const override
 
void evaluate (KPInstance &solution) const override
 
vector< KPInstancecreateSolutions (const int &maxSolutions) const override
 
void beforeEvaluation (vector< KPInstance > &) override
 
void afterEvaluation (vector< KPInstance > &) override
 Method applied after evaluation the population of solutions. More...
 
KPInstance createSolution () const override
 
KPInstance createSolution (ParallelPRNG &engine) const override
 
KPInstance createSolution ()
 
KPInstance createSolution (ParallelPRNG &engine)
 
bool evaluateConstraints (KPInstance &solution) const override
 
int getOptimizationDirection (const int i) const override
 
string getName () const override
 Returns the name of the problem. This method must be implemented in the subclasses. More...
 
float getUpperLimit (const int i) const override
 
float getLowerLimit (const int i) const override
 
int getNumberOfInstances () const
 
void setNumberOfInstances (int numberOfInstances)
 
int getLowWeight () const
 
void setLowWeight (int lowWeight)
 
int getUpWeight () const
 
void setUpWeight (int upWeight)
 
int getLowProfit () const
 
void setLowProfit (int lowProfit)
 
int getUpProfit () const
 
void setUpProfit (int upProfit)
 
int getGeneratedInstances () const
 
void setGeneratedInstances (int generatedInstances)
 
bool isReducedSpace () const
 Check if the search is performed in a PCA space. More...
 
json to_json () const override
 Creates a JSON object with the information of the Problem. More...
 
void readData (const string &path) override
 
- Public Member Functions inherited from AbstractDomain< KPNR, KPInstance >
 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...
 
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 numberOfInstances
 
int lowWeight
 
int upWeight
 
int lowProfit
 
int upProfit
 
int generatedInstances
 
bool reducedSpace
 
- Protected Attributes inherited from AbstractDomain< KPNR, KPInstance >
int internalDimension
 
- Protected Attributes inherited from Problem< S >
int numberOfVars
 
int numberOfObjs
 
int numberOfCons
 

Detailed Description

Instance Generator Knapsack Problem. Problem for the Instance Generator to generate Knapsack Problem Instances 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 KPInstance must be twice size of the nVars.

Member Function Documentation

◆ afterEvaluation()

void KPDomain::afterEvaluation ( vector< KPInstance > &  solutions)
overridevirtual

Method applied after evaluation the population of solutions.

Parameters
solutions

Implements AbstractDomain< KPNR, KPInstance >.

◆ beforeEvaluation()

void KPDomain::beforeEvaluation ( vector< KPInstance > &  solutions)
overridevirtual

Method which re-calculates the capacity of the instances before evaluate them

Parameters
vector1

Implements AbstractDomain< KPNR, KPInstance >.

◆ createSolution() [1/2]

KPInstance KPDomain::createSolution ( )

Generates a new solution without args

Returns

◆ createSolution() [2/2]

KPInstance KPDomain::createSolution ( ) const
overridevirtual

Generates a new solution without args

Returns

Implements Problem< S >.

◆ createSolutions()

vector< KPInstance > KPDomain::createSolutions ( const int &  maxSolutions) const
overridevirtual

Creates a population of solutions

Parameters
maxSolutions
Returns

Implements AbstractDomain< KPNR, KPInstance >.

◆ evaluate()

void KPDomain::evaluate ( KPInstance solution) const
override

Method which evaluates a solution of the Knapsack Instance Generation Problem

Parameters
solution

◆ genOptProblem()

shared_ptr< KPNR > KPDomain::genOptProblem ( const KPInstance instance) const
overridevirtual

Creates a Optimisation Problem for the Configurations on the EIG In this case, KPNR Problem

Returns

Unfolded loop which creates a KPNR problem from a KPInstance The KPInstance stores the weights and profits in a single array This loop creates two arrays from the one in the KPInstance object

  • variables.size() => instance.getNumberOfVars() * 2

Implements AbstractDomain< KPNR, KPInstance >.

◆ getLowerLimit()

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

Returns the lower bound for the variable i

Parameters
i
Returns

Implements Problem< S >.

◆ getName()

string KPDomain::getName ( ) const
inlineoverridevirtual

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

Returns
string

Implements Problem< S >.

◆ getOptimizationDirection()

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

Method which returns the optimisation direction for each objective Minimize

Parameters
i
Returns

Reimplemented from AbstractDomain< KPNR, KPInstance >.

◆ getUpperLimit()

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

Returns the upper bound for the variable i

Parameters
i
Returns

Implements Problem< S >.

◆ isReducedSpace()

bool KPDomain::isReducedSpace ( ) const
inline

Check if the search is performed in a PCA space.

Returns
true if reducedSpace false otherwise

◆ to_json()

json KPDomain::to_json ( ) const
overridevirtual

Creates a JSON object with the information of the Problem.

Template Parameters
S
Returns
a json representation of the problem

Reimplemented from Problem< S >.


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