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
/
definitions.h
154 lines (105 loc) · 3.31 KB
/
definitions.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#pragma once
#include <functional>
#include <string>
#include <vector>
static const size_t NUM_RATINGS = 5;
static const uint32_t MIN_GROUP_SIZE = 12;
static const uint32_t MAX_GROUP_SIZE = 16;
static const double CAPACITY_BUFFER = 1.05;
static const bool VERBOSE = false;
// ####################################
// ######## Input Data ########
// ####################################
struct Rating {
uint32_t index;
Rating(uint32_t index);
uint32_t getValue() const;
const char *getName() const;
bool operator==(const Rating &other) const;
bool operator!=(const Rating &other) const;
};
using GroupID = uint32_t;
using StudentID = uint32_t;
using ParticipantID = uint32_t;
enum class CourseType {
Info = 0,
Mathe = 1,
Any = 2,
};
enum class DegreeType {
Bachelor = 0,
Master = 1,
Any = 2,
};
struct GroupData {
std::string name;
StudentID capacity;
CourseType course_type;
DegreeType degree_type;
GroupData(std::string name, StudentID capacity, CourseType ct, DegreeType dt);
};
struct StudentData {
std::string name;
CourseType course_type;
DegreeType degree_type;
bool is_commuter;
StudentData(std::string name, CourseType ct, DegreeType dt, bool is_commuter);
};
struct TeamData {
std::string name;
std::vector<StudentID> members;
TeamData(std::string name, std::vector<StudentID> members);
size_t size() const;
};
struct Input {
std::vector<GroupData> groups;
std::vector<StudentData> students;
std::vector<TeamData> teams;
std::vector<std::vector<Rating>> ratings;
};
// #########################################
// ######## Assignment Data ########
// #########################################
bool ratingsEqual(const std::vector<Rating> &r1, const std::vector<Rating> &r2);
struct Participant {
uint32_t index;
bool is_team;
int32_t assignment;
Participant(uint32_t index, bool is_team);
};
class State {
std::reference_wrapper<const Input> _data;
std::vector<StudentID> _group_capacities;
std::vector<bool> _group_enabled;
std::vector<std::vector<std::pair<StudentID, ParticipantID>>>
_group_assignments;
std::vector<uint32_t> _group_weights;
std::vector<Participant> _participants;
public:
State(const Input &data);
const Input &data() const;
GroupID numGroups() const;
GroupID numActiveGroups() const;
StudentID totalActiveGroupCapacity() const;
const GroupData &groupData(GroupID id) const;
StudentID groupCapacity(GroupID id) const;
bool groupIsEnabled(GroupID id) const;
const std::vector<std::pair<StudentID, ParticipantID>> &
groupAssignmentList(GroupID id) const;
StudentID groupSize(GroupID id) const;
uint32_t groupWeight(GroupID id) const;
ParticipantID numParticipants() const;
bool isTeam(ParticipantID id) const;
bool isAssigned(ParticipantID id) const;
const StudentData &studentData(ParticipantID id) const;
const TeamData &teamData(ParticipantID id) const;
GroupID assignment(ParticipantID id) const;
const std::vector<Rating> &rating(ParticipantID id) const;
void disableGroup(GroupID id);
bool assignParticipant(ParticipantID participant, GroupID target);
void unassignParticipant(ParticipantID participant, GroupID group);
// groups are still disabled
void resetWithCapacity(StudentID capacity);
void reset();
void decreaseCapacity(GroupID id, int32_t val);
};