-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathttp.h
67 lines (58 loc) · 1.39 KB
/
ttp.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
#ifndef TTP_H
#define TTP_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
// Team names
static const char *const TEAM_NAMES[] = {
"ATL","NYM","PHI","MON",\
"FLA","PIT","CIN","CHI",\
"STL","MIL","HOU","COL",\
"SF", "SD", "LA", "ARI", 0
};
// Array of who each team is playing for a given week
// Teams start at 1, team 0 is unused
typedef struct {
int *team;
} Round;
typedef struct {
unsigned long *team_cost;
int *distance;
unsigned long total_cost;
bool *updated;
} Cost;
// Array of pointers to weeks. Allows for swapping weeks quickly
// weeks start at 0
typedef struct {
int num_teams;
int num_rounds;
int set_vals;
Cost cost;
Round **round;
} Schedule;
// settings for simulated annealing
typedef struct {
double temp;
double beta;
double delta;
double theta;
double weight;
unsigned max_reheat;
unsigned max_phase;
unsigned max_counter;
bool update;
} Settings;
Schedule *CreateSchedule(int num_teams);
bool GenerateSchedule(Schedule *s);
unsigned long InitCost(Schedule *s, char *filename);
void DeleteSchedule(Schedule *s);
void PrintTeamCost(Schedule *s, int t);
void PrintSchedule(Schedule *s, const char * const*team_names);
#define SCHED_INVALID 0x01
int CheckHardReq(Schedule *s);
#define SCHED_ATMOST 0x02
#define SCHED_REPEAT 0x04
int CheckSoftReq(Schedule *s, int *nbv);
// Annealing algorithm
void Anneal(Schedule *s, Settings settings);
#endif /* TTP_H */