TCPSPSuite
solution.hpp
1 #ifndef SOLUTION_HPP
2 #define SOLUTION_HPP
3 
4 #include "../datastructures/maybe.hpp" // for Maybe
5 #include "../util/log.hpp" // for Log
6 
7 #include <vector> // for vector
8 class InconsistentResultError;
9 class Instance;
10 
17 class Solution {
18 public:
19  // TODO FIXME is this still "optimal?"
20 
29  Solution(const Instance & instance, bool optimal,
30  std::vector<Maybe<unsigned int>> & start_times,
31  Maybe<double> lower_bound);
32 
41  Solution(const Instance & instance, bool optimal,
42  std::vector<Maybe<unsigned int>> && start_times,
43  Maybe<double> lower_bound);
44 
55  Solution(const Instance & instance, bool optimal,
56  std::vector<unsigned int> & start_times, Maybe<double> lower_bound);
57 
62  explicit Solution(const Instance & instance);
63 
64  // TODO this only here so Solution can be wrapped in a Maybe.
65  Solution();
66 
67  // Copying & moving
68  Solution(const Solution & other);
69  Solution(Solution && other);
70  Solution & operator=(const Solution & other);
71  Solution & operator=(Solution && other);
72 
77  void print() const;
78 
82  void print_jobs() const;
83 
87  void print_profile() const;
88 
94  double get_costs() const;
95  double get_overshoot_costs() const;
96  double get_investment_costs() const;
97 
103  double get_costs_lower_bound() const;
104 
110  const Instance * get_instance() const;
111 
119  unsigned int get_start_time(unsigned int job_id) const;
120 
127  bool job_scheduled(unsigned int job_id) const;
128 
135  bool is_feasible() const;
136 
143  bool is_optimal() const;
144 
151  double get_max_usage(unsigned int rid) const;
152 
158  Maybe<double> get_lower_bound() const;
159 
163  bool verify(int seed, InconsistentResultError * error_out = nullptr) const;
164 
165 private:
166  const Instance * instance;
167  bool optimal;
168  std::vector<Maybe<unsigned int>> start_times;
169  Maybe<double> lower_bound;
170 
171  void compute_durations() const;
172  mutable std::vector<unsigned int> durations;
173 
174  void compute_costs() const;
175  mutable Maybe<double> costs;
176  mutable Maybe<double> overshoot_costs;
177  mutable Maybe<double> investment_costs;
178 
179  // TODO this is ugly
180  mutable std::vector<double> max_usage;
181 
182  Log l;
183 };
184 
185 #endif
Solution::is_optimal
bool is_optimal() const
Definition: solution.cpp:462
Solution::get_max_usage
double get_max_usage(unsigned int rid) const
Definition: solution.cpp:517
Solution::print_jobs
void print_jobs() const
Definition: solution.cpp:261
Solution::get_instance
const Instance * get_instance() const
Definition: solution.cpp:659
Instance
a TCPSP instance
Definition: instance.hpp:24
Solution::is_feasible
bool is_feasible() const
Definition: solution.cpp:671
Solution::job_scheduled
bool job_scheduled(unsigned int job_id) const
Definition: solution.cpp:685
Solution
a soultion for a TCPSP instance
Definition: solution.hpp:17
Solution::get_costs
double get_costs() const
Definition: solution.cpp:468
Solution::get_lower_bound
Maybe< double > get_lower_bound() const
Definition: solution.cpp:106
Solution::print
void print() const
Definition: solution.cpp:443
Solution::print_profile
void print_profile() const
Definition: solution.cpp:273
Solution::verify
bool verify(int seed, InconsistentResultError *error_out=nullptr) const
Definition: solution.cpp:149
Solution::get_costs_lower_bound
double get_costs_lower_bound() const
Definition: solution.cpp:507
Solution::get_start_time
unsigned int get_start_time(unsigned int job_id) const
Definition: solution.cpp:665