|
dignea
1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
|
Class representing a Knapsack Problem. More...
#include <KP.h>
Public Member Functions | |
| KP (const int &numberOfVars) | |
| KP (const string &pathToInstance) | |
| KP (const int &numberOfVars, const int &capacity, const vector< int > &weights, const vector< int > &profits) | |
| KP (const int &numberOfVars, const int &lowerWeight, const int &upperWeight, const int &lowerProfit, const int &upperProfit) | |
| KP (const KP *) | |
| float | getUpperLimit (int i) const override |
| Returns the upper bound to the problem at dimension i. This method must be implemented in the subclasses. More... | |
| int | getOptimizationDirection (const int i) const override |
| 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... | |
| float | getLowerLimit (int i) const override |
| Returns the lower bound to the problem at dimension i. This method must be implemented in the subclasses. More... | |
| string | getName () const override |
| Returns the name of the problem. This method must be implemented in the subclasses. More... | |
| void | evaluate (BoolFloatSolution &solution) const override |
| bool | evaluateConstraints (BoolFloatSolution &ptr) const override |
| BoolFloatSolution | createSolution () const override |
| BoolFloatSolution | createSolution (ParallelPRNG &engine) const override |
| 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) |
| const vector< int > & | getProfits () const |
| void | setProfits (const vector< int > &profits) |
| const vector< int > & | getWeights () const |
| void | setWeights (const vector< int > &weights) |
| int | getCapacity () const |
| void | setCapacity (int capacity) |
| void | readData (const string &path) override |
| json | to_json () const override |
| vector< iEff > | getItemsSortedByEff () const |
Public Member Functions inherited from Problem< BoolFloatSolution > | |
| 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 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... | |
Static Public Attributes | |
| static const string | INSTANCE = "Instance" |
| static const string | PROFITS = "Profits" |
| static const string | WEIGHTS = "Weights" |
| static const string | CAPACITY = "Capacity" |
Protected Member Functions | |
| void | computeEfficiency () |
| void | repair (BoolFloatSolution &solution) const |
Protected Attributes | |
| int | lowWeight |
| int | upWeight |
| int | lowProfit |
| int | upProfit |
| vector< int > | profits |
| vector< int > | weights |
| int | capacity |
| std::string | pathToInstance |
| vector< iEff > | itemsEff |
Protected Attributes inherited from Problem< BoolFloatSolution > | |
| int | numberOfVars |
| int | numberOfObjs |
| int | numberOfCons |
Class representing a Knapsack Problem.
| KP::KP | ( | const string & | path | ) |
Crea una instancia del problema de la mochila a partir de la instancia en el directorio recibido
| pathTo |
| KP::KP | ( | const int & | numberOfVars, |
| const int & | capacity, | ||
| const vector< int > & | newWeights, | ||
| const vector< int > & | newProfits | ||
| ) |
Generates a KP problem with all the data given in the arguments
| numberOfVars | |
| capacity | |
| weights | |
| profits |
|
protected |
Calcula la eficiencia de cada elemento de la instancia. La eficiencia de un elemento es el ratio p/w del elemento. Los elementos se ordenan descendentemente
|
overridevirtual |
|
overridevirtual |
Metodo de evaluacion de una solucion al problema KP
| solution |
Implements Problem< BoolFloatSolution >.
Reimplemented in KPNR.
|
overridevirtual |
Evaluacion de las restricciones para la solucion
| ptr |
Implements Problem< BoolFloatSolution >.
|
overridevirtual |
Returns the lower bound to the problem at dimension i. This method must be implemented in the subclasses.
| i |
Implements Problem< BoolFloatSolution >.
|
inlineoverridevirtual |
Returns the name of the problem. This method must be implemented in the subclasses.
Implements Problem< BoolFloatSolution >.
|
overridevirtual |
Returns the optimization direction for each objective in the problem. It returns Minimize or Maximize accordingly. This method must be implemented in the subclasses.
| i | Dimension to check |
Implements Problem< BoolFloatSolution >.
|
overridevirtual |
Returns the upper bound to the problem at dimension i. This method must be implemented in the subclasses.
| i | Dimension to check |
Implements Problem< BoolFloatSolution >.
|
override |
Método para leer un fichero de instancia del KP. La estructura esperada del fichero es la siguiente: nItems Q w0 p0 w1 p1 ... wn-1 pn-1
| path |
|
protected |
Heuristica de reparacion que se encarga de eliminar los elementos menos eficientes
|
overridevirtual |
Generates a JSON object with the information of the KP problem
Reimplemented from Problem< BoolFloatSolution >.