-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
65 lines (59 loc) · 2.16 KB
/
Copy pathcommon.h
File metadata and controls
65 lines (59 loc) · 2.16 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
#ifndef COMMON_H
#define COMMON_H //birden fazla include edilip tekrar tanımlanmayı engellemek için include guard
/*
* common.h
*
* Bu dosyada bütün kaynak dosyaların ortak kullandığı sabitler ve struct yapıları bulunur.
* Amaç: main.c, input.c, distance.c, validation.c, heuristic.c ve exact.c dosyalarının
* aynı veri tiplerini kullanmasını sağlamaktır.
*/
#define MAX_CLIENTS 1000
#define MAX_VEHICLES 10
#define MAX_ROUTE_SIZE (MAX_CLIENTS + 2)
#define DEPOT 0 // örnekte 0 dan baslandıgı icin depot 0 olarak tanımlandı
#define INF 1e100 //sonsuz değer
#define EXACT_MAX_CLIENTS 11 //backtracking O(n!) olduğundan 11 müşteriden fazlası için çalıştırılmayacak Bu yüzden büyük inputlarda heuristic kullanıyoruz.
#define DEFAULT_ILS_TIME_LIMIT_SECONDS 2.0 //çalışma süresini kontrol altında tutmak ve beklenen süre limitinin altında kalmak için sabit süre limiti kullandım.
/*
* Problem struct'ı inputtan okunan bütün problem verisini tutar.
* 0 indexi depot, 1..clientCount arası müşterilerdir.
*/
typedef struct {
int clientCount;
int vehicleCount;
int maxClientsPerVehicle;
double xCoord[MAX_CLIENTS + 1]; // 0 indexi depot, 1..clientCount arası müşterilerdir.
double yCoord[MAX_CLIENTS + 1];
double distanceMatrix[MAX_CLIENTS + 1][MAX_CLIENTS + 1];
} Problem;
/*
* Solution struct'ı bir algoritmanın ürettiği çözümü tutar.
* routes[vehicle][position] yapısı, her aracın rotasını temsil eder.
*/
typedef struct {
int routes[MAX_VEHICLES][MAX_ROUTE_SIZE];
int routeSizes[MAX_VEHICLES];
double totalDistance;
double recalculatedDistance;
double executionTimeSeconds;
int valid;
int depotCheck;
int clientVisitCheck;
int capacityCheck;
int distanceCheck;
char algorithmName[100];
} Solution;
/*
* ExactResult küçük inputlar için exact backtracking sonucunu tutar.
* Büyük inputlarda exact çalıştırılmaz, skipped = 1 olur.
*/
typedef struct {
int available;
int skipped;
double bestDistance;
double executionTimeSeconds;
int route[MAX_ROUTE_SIZE];
int routeSize;
char message[160];
} ExactResult;
#endif