Loading...
Searching...
No Matches
KP_Instance.h
1//
2// Created by henri on 12/10/22.
3//
4
5#ifndef IDOL_KP_INSTANCE_H
6#define IDOL_KP_INSTANCE_H
7
8#include <vector>
9#include <string>
10
11namespace idol::Problems::KP {
12 class Instance;
13 Instance read_instance(const std::string& t_filename);
14 Instance read_instance_kplib(const std::string& t_filename);
15}
16
18protected:
19 std::vector<double> m_profit;
20 std::vector<double> m_weight;
21 double m_capacity = 0;
22public:
23 explicit Instance(unsigned int t_n_items);
24
25 Instance(const Instance&) = default;
26 Instance(Instance&&) noexcept = default;
27
28 Instance& operator=(const Instance&) = default;
29 Instance& operator=(Instance&&) noexcept = default;
30
31 ~Instance() = default;
32 [[nodiscard]] unsigned int n_items() const { return m_profit.size(); }
33 [[nodiscard]] double profit(unsigned int t_item) const { return m_profit[t_item]; }
34 [[nodiscard]] double weight(unsigned int t_item) const { return m_weight[t_item]; }
35 [[nodiscard]] double capacity() const { return m_capacity; }
36
37 void set_profit(unsigned int t_item, double t_value) { m_profit[t_item] = t_value; }
38 void set_weight(unsigned int t_item, double t_value) { m_weight[t_item] = t_value; }
39 void set_capacity(double t_value) { m_capacity = t_value; }
40};
41
42#endif //IDOL_KP_INSTANCE_H