-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.h
More file actions
103 lines (82 loc) · 2.96 KB
/
Program.h
File metadata and controls
103 lines (82 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
Program.h: interface for the Program class.
The Program class contains the Batch and Source_Rack struct definitions, a vector that
holds all the Source_Rack objects in the program, and a vector containing all the
completed Batch objects. The methods of the Program class execute all of the functioning
that combines Source_Racks into a Batch, utilizing additional data members like the
sample_frequencies hash map and a testing vector to guide Batch creation.
*/
#ifndef PROGRAM_H
#define PROGRAM_H
#include <vector>
#include <array>
#include <unordered_map>
using namespace std;
//number of spots in a rack, usually 96
const int RACK_CAPACITY = 96;
//number of total racks in a batch, usually 20
const int BATCH_CAPACITY = 20;
class Program {
public:
//constructor
Program() {
//initialize sample_frequencies array
for (int i = 0; i < RACK_CAPACITY + 1; i++) {
sample_frequencies.push_back(0);
}
}
//read and analyze data about the rack sample numbers
void read_data();
void populate_frequencies();
//create all batches
void distribute_racks();
//print methods for displaying results
void print_summary();
void export_results();
private:
//temporary vector finding the best combination of sample numbers before modifying actual all_sources array, cleared with each new batch
vector<int> testing_array;
// vector that holds the testing array found during choose_num_sources, a backup if strategy doesn't work
vector<int> backup_array;
//definition for Source_Rack
struct Source_Rack {
string id;
int num_samples;
};
//definition for Batch
struct Batch {
int batch_num;
//hold sources in batch
vector<Source_Rack> batch_sources;
};
//all undistributed sources in program, samples are removed once added to a batch
vector<Source_Rack> all_sources;
//all currently finished batches in the program
vector<Batch> finished_batches;
//vector to store frequencies of each sample number, with the index matching up with the sample number (index 0 is unused)
vector<int> sample_frequencies;
//higher-level methods for creating batches
void create_new_batch(int num_source_spots);
int choose_num_sources();
bool add_all_except_last(int num_source_spots);
void add_ratios(int num_source_spots);
Batch finalize_spots();
Source_Rack find_source(int sample_num);
void distribute_remainder();
//lower-level helper methods for creating batches
bool is_valid(int num);
int find_smallest();
int ideal_last(int num_source_spots);
int total_testing_samples();
bool decrease_testing_total(int& ideal_last_spot, int& to_add, int& num_source_racks);
void increase_testing_total(int& ideal_last_spot, int& to_add, int& num_source_racks, bool &approximate);
void add_in_order(vector<int>& which_vector, int to_add);
void remove_from_testing(int to_remove);
int find_next_smallest_valid(int current);
int find_next_highest_valid(int current);
//print methods for testing purposes
void print_frequencies();
void print_sources();
void print_testing_array();
};
#endif