dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
KPInstance.h
Go to the documentation of this file.
1 
11 #ifndef DIGNEA_EKPSOLUTION_H
12 #define DIGNEA_EKPSOLUTION_H
13 
15 
27 class KPInstance : public AbstractInstance<int, float> {
28  public:
29  KPInstance();
30 
31  explicit KPInstance(const int &nVars, const int &nObjs = 1,
32  bool reducedSpace = false);
33 
34  KPInstance(const KPInstance &solution);
35 
36  explicit KPInstance(const KPInstance *solution);
37 
38  KPInstance(unique_ptr<KPInstance> &ptr) = delete;
39 
40  KPInstance &operator=(const KPInstance &copy);
41 
42  bool operator==(const KPInstance &other) const;
43 
44  virtual ~KPInstance() = default;
45 
46  inline void setCapacity(const int &Q) { this->capacity = Q; };
47 
48  inline int getCapacity(void) const { return this->capacity; };
49 
53  vector<float> getFeatures() const override;
54 
55  void setVariables(const vector<int> &vars) override;
56 
59  bool isReducedSpace() const { return reducedSpace; }
60 
61  json to_json() const override;
62 
63  virtual void to_instance(std::ostream &os) const;
64 
65  protected:
66  int capacity; // Capacity of the Knapsack
67  bool reducedSpace; // Flag to search in the PCA space
68 };
69 
70 #endif // DIGNEA_EKPSOLUTION_H
Solution for a Instance Generation Problem used in the EIG. This is a solution for AbstractDomain.
Definition: AbstractInstance.h:30
Instance Knapsack Problem Solution. Class which represents the solution for the Instance Knapsack Pro...
Definition: KPInstance.h:27
vector< float > getFeatures() const override
Get the features. If reducedSpace is true in IKProblem the features are the (x0, x1) principal compon...
Definition: KPInstance.cpp:99
KPInstance & operator=(const KPInstance &copy)
Copies a solution using the assignment operator.
Definition: KPInstance.cpp:40
virtual void to_instance(std::ostream &os) const
Generates a instance representation of the KP problem.
Definition: KPInstance.cpp:168
void setVariables(const vector< int > &vars) override
Sets the variables of the solution. Expected to be twice of number of vars since it stores the pairs ...
Definition: KPInstance.cpp:83
bool isReducedSpace() const
Check if the search is performed in a PCA space.
Definition: KPInstance.h:59
bool operator==(const KPInstance &other) const
Compares whether two solutions are equal.
Definition: KPInstance.cpp:70
json to_json() const override
Creates a JSON object with the information of the KPInstance.
Definition: KPInstance.cpp:116
int nVars
Definition: Solution.h:194
int nObjs
Definition: Solution.h:195