11 #ifndef __DIGNEA_KNP_H__
12 #define __DIGNEA_KNP_H__
14 #include <dignea/core/Problem.h>
15 #include <dignea/types/SolutionTypes.h>
16 #include <dignea/utilities/random/PseudoRandom.h>
22 using iEff = pair<int, float>;
36 KP(
const string &pathToInstance);
38 KP(
const int &
numberOfVars,
const int &capacity,
const vector<int> &weights,
39 const vector<int> &profits);
43 KP(
const int &
numberOfVars,
const int &lowerWeight,
const int &upperWeight,
44 const int &lowerProfit,
const int &upperProfit);
54 string getName()
const override {
return "Knapsack Problem"; };
64 int getLowWeight()
const;
66 void setLowWeight(
int lowWeight);
68 int getUpWeight()
const;
70 void setUpWeight(
int upWeight);
72 int getLowProfit()
const;
74 void setLowProfit(
int lowProfit);
76 int getUpProfit()
const;
78 void setUpProfit(
int upProfit);
80 const vector<int> &getProfits()
const;
82 void setProfits(
const vector<int> &profits);
84 const vector<int> &getWeights()
const;
86 void setWeights(
const vector<int> &weights);
88 int getCapacity()
const;
90 void setCapacity(
int capacity);
92 void readData(
const string &path)
override;
96 vector<iEff> getItemsSortedByEff()
const {
return itemsEff; }
112 std::string pathToInstance;
114 vector<iEff> itemsEff;
117 static const string INSTANCE;
118 static const string PROFITS;
119 static const string WEIGHTS;
120 static const string CAPACITY;
Class representing a Knapsack Problem.
Definition: KP.h:28
void repair(BoolFloatSolution &solution) const
Definition: KP.cpp:237
void readData(const string &path) override
Definition: KP.cpp:155
string getName() const override
Returns the name of the problem. This method must be implemented in the subclasses.
Definition: KP.h:54
void evaluate(BoolFloatSolution &solution) const override
Definition: KP.cpp:262
json to_json() const override
Definition: KP.cpp:359
float getUpperLimit(int i) const override
Returns the upper bound to the problem at dimension i. This method must be implemented in the subclas...
Definition: KP.cpp:194
float getLowerLimit(int i) const override
Returns the lower bound to the problem at dimension i. This method must be implemented in the subclas...
Definition: KP.cpp:202
int getOptimizationDirection(const int i) const override
Returns the optimization direction for each objective in the problem. It returns Minimize or Maximize...
Definition: KP.cpp:317
BoolFloatSolution createSolution() const override
Definition: KP.cpp:277
void computeEfficiency()
Definition: KP.cpp:331
bool evaluateConstraints(BoolFloatSolution &ptr) const override
Definition: KP.cpp:214
Class to represent a Problem in the tool. It includes the basic information for a problem a few metho...
Definition: Problem.h:29
int numberOfVars
Definition: Problem.h:155
Class to represent a solution to the optimization problems in the tool.
Definition: Solution.h:25