This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (47 loc) · 1.52 KB
/
main.cpp
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
#include <fstream>
#include <iostream>
#include "boost/property_tree/json_parser.hpp"
#include "algorithms.h"
#include "moves_local_search.h"
#include "parse.h"
int main(int argc, const char *argv[]) {
if (argc != 3 && argc != 4) {
std::cout << "Usage: ./Main <input> <output> [<out_path>]" << std::endl;
std::exit(-1);
}
std::ifstream in_file(argv[1]);
if (!in_file) {
std::cerr << "Error opening input file" << std::endl;
std::exit(-1);
}
std::ofstream out_file(argv[2]);
if (!out_file) {
std::cerr << "Error opening output file" << std::endl;
std::exit(-1);
}
PTree pt;
boost::property_tree::json_parser::read_json(in_file, pt);
Input input = parseInput(pt);
std::cout << "Input file successfully parsed." << std::endl;
State state(input);
assignWithMinimumNumberPerGroup(state, MIN_GROUP_SIZE);
assertMinNumCourse(state, CourseType::Mathe, 5);
std::vector<int> num_ratings(NUM_RATINGS, 0);
for (ParticipantID part = 0; part < state.numParticipants(); ++part) {
Rating r = state.rating(part).at(state.assignment(part));
int num = 1;
if (state.isTeam(part)) {
num = state.teamData(part).size();
}
num_ratings.at(r.index) += num;
}
for (uint32_t i = 0; i < NUM_RATINGS; ++i) {
std::cout << "Number of " << Rating(i).getName() << ": "
<< num_ratings.at(i) << std::endl;
}
PTree result = writeOutputToTree(state);
boost::property_tree::json_parser::write_json(out_file, result);
if (argc == 4) {
writeOutputToFiles(state, argv[3]);
}
}