Statistics.c
Go to the documentation of this file.
1 #include "LKH.h"
2 
5 static double TimeMin, TimeMax, TimeSum;
6 
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;
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 
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 }
static GainType CostMax
Definition: Statistics.c:4
static int TrialsMin
Definition: Statistics.c:3
int Trial
Definition: LKH.h:279
void PrintStatistics()
Definition: Statistics.c:41
void printff(char *fmt,...)
Definition: printff.c:10
static GainType CostSum
Definition: Statistics.c:4
static double TimeSum
Definition: Statistics.c:5
static int TrialsMax
Definition: Statistics.c:3
static double TimeMax
Definition: Statistics.c:5
#define MINUS_INFINITY
Definition: GainType.h:21
GainType Optimum
Definition: LKH.h:241
static int TrialSum
Definition: Statistics.c:3
void UpdateStatistics(GainType Cost, double Time)
Definition: Statistics.c:20
static GainType CostMin
Definition: Statistics.c:4
static double TimeMin
Definition: Statistics.c:5
int Runs
Definition: LKH.h:258
#define PLUS_INFINITY
Definition: GainType.h:20
#define GainFormat
Definition: GainType.h:22
static int Successes
Definition: Statistics.c:3
void InitializeStatistics()
Definition: Statistics.c:7
long long GainType
Definition: GainType.h:13
GainType BestCost
Definition: LKH.h:179


glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:27