Main Page
Namespaces
Classes
Files
File List
File Members
src
Statistics.c
Go to the documentation of this file.
1
#include "
LKH.h
"
2
3
static
int
TrialsMin
,
TrialsMax
,
TrialSum
,
Successes
;
4
static
GainType
CostMin
,
CostMax
,
CostSum
;
5
static
double
TimeMin
,
TimeMax
,
TimeSum
;
6
7
void
InitializeStatistics
()
8
{
9
TrialSum
=
Successes
= 0;
10
CostSum
= 0;
11
TimeSum
= 0.0;
12
TrialsMin
= INT_MAX;
13
TrialsMax
= 0;
14
TimeMin
= DBL_MAX;
15
TimeMax
= 0;
16
CostMin
=
PLUS_INFINITY
;
17
CostMax
=
MINUS_INFINITY
;
18
}
19
20
void
UpdateStatistics
(
GainType
Cost,
double
Time)
21
{
22
if
(
Trial
<
TrialsMin
)
23
TrialsMin
=
Trial
;
24
if
(
Trial
>
TrialsMax
)
25
TrialsMax
=
Trial
;
26
TrialSum
+=
Trial
;
27
if
(Cost <=
Optimum
)
28
Successes
++;
29
if
(Cost <
CostMin
)
30
CostMin
= Cost;
31
if
(Cost >
CostMax
)
32
CostMax
= Cost;
33
CostSum
+= Cost;
34
if
(Time <
TimeMin
)
35
TimeMin
= Time;
36
if
(Time >
TimeMax
)
37
TimeMax
= Time;
38
TimeSum
+= Time;
39
}
40
41
void
PrintStatistics
()
42
{
43
int
_Runs =
Runs
, _TrialsMin =
TrialsMin
;
44
double
_TimeMin =
TimeMin
;
45
GainType
_Optimum =
Optimum
;
46
47
printff
(
"Successes/Runs = %d/%d \n"
,
Successes
,
Runs
);
48
if
(_Runs == 0)
49
_Runs = 1;
50
if
(_TrialsMin >
TrialsMax
)
51
_TrialsMin = 0;
52
if
(_TimeMin >
TimeMax
)
53
_TimeMin = 0;
54
if
(
CostMin
<=
CostMax
&&
CostMin
!=
PLUS_INFINITY
) {
55
printff
56
(
"Cost.min = "
GainFormat
", Cost.avg = %0.2f, Cost.max = "
57
GainFormat
"\n"
,
CostMin
, (
double
)
CostSum
/ _Runs,
CostMax
);
58
if
(_Optimum ==
MINUS_INFINITY
)
59
_Optimum =
BestCost
;
60
if
(_Optimum != 0)
61
printff
62
(
"Gap.min = %0.4f%%, Gap.avg = %0.4f%%, Gap.max = %0.4f%%\n"
,
63
100.0 * (
CostMin
- _Optimum) / _Optimum,
64
100.0 * (
CostSum
/ _Runs - _Optimum) / _Optimum,
65
100.0 * (
CostMax
- _Optimum) / _Optimum);
66
67
}
68
printff
(
"Trials.min = %d, Trials.avg = %0.1f, Trials.max = %d\n"
,
69
_TrialsMin, 1.0 *
TrialSum
/ _Runs,
TrialsMax
);
70
printff
71
(
"Time.min = %0.2f sec., Time.avg = %0.2f sec., Time.max = %0.2f sec.\n"
,
72
fabs(_TimeMin), fabs(
TimeSum
) / _Runs, fabs(
TimeMax
));
73
}
CostMax
static GainType CostMax
Definition:
Statistics.c:4
TrialsMin
static int TrialsMin
Definition:
Statistics.c:3
Trial
int Trial
Definition:
LKH.h:279
PrintStatistics
void PrintStatistics()
Definition:
Statistics.c:41
printff
void printff(char *fmt,...)
Definition:
printff.c:10
CostSum
static GainType CostSum
Definition:
Statistics.c:4
TimeSum
static double TimeSum
Definition:
Statistics.c:5
TrialsMax
static int TrialsMax
Definition:
Statistics.c:3
TimeMax
static double TimeMax
Definition:
Statistics.c:5
MINUS_INFINITY
#define MINUS_INFINITY
Definition:
GainType.h:21
Optimum
GainType Optimum
Definition:
LKH.h:241
TrialSum
static int TrialSum
Definition:
Statistics.c:3
UpdateStatistics
void UpdateStatistics(GainType Cost, double Time)
Definition:
Statistics.c:20
CostMin
static GainType CostMin
Definition:
Statistics.c:4
TimeMin
static double TimeMin
Definition:
Statistics.c:5
LKH.h
Runs
int Runs
Definition:
LKH.h:258
PLUS_INFINITY
#define PLUS_INFINITY
Definition:
GainType.h:20
GainFormat
#define GainFormat
Definition:
GainType.h:22
Successes
static int Successes
Definition:
Statistics.c:3
InitializeStatistics
void InitializeStatistics()
Definition:
Statistics.c:7
GainType
long long GainType
Definition:
GainType.h:13
BestCost
GainType BestCost
Definition:
LKH.h:179
glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:27