MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / collect

Method collect

pyvrp/Statistics.py:65–103  ·  view source on GitHub ↗

Collect iteration statistics. Parameters ---------- current The current solution. candidate The candidate solution. best The best solution. cost_evaluator CostEvaluator used to compute costs for

(
        self,
        current: Solution,
        candidate: Solution,
        best: Solution,
        cost_evaluator: CostEvaluator,
    )

Source from the content-addressed store, hash-verified

63 return self._collect_stats
64
65 def collect(
66 self,
67 current: Solution,
68 candidate: Solution,
69 best: Solution,
70 cost_evaluator: CostEvaluator,
71 ):
72 """
73 Collect iteration statistics.
74
75 Parameters
76 ----------
77 current
78 The current solution.
79 candidate
80 The candidate solution.
81 best
82 The best solution.
83 cost_evaluator
84 CostEvaluator used to compute costs for solutions.
85 """
86 if not self._collect_stats:
87 return
88
89 start = self._clock
90 self._clock = perf_counter()
91
92 self.runtimes.append(self._clock - start)
93 self.num_iterations += 1
94
95 datum = _Datum(
96 cost_evaluator.penalised_cost(current),
97 current.is_feasible(),
98 cost_evaluator.penalised_cost(candidate),
99 candidate.is_feasible(),
100 cost_evaluator.penalised_cost(best),
101 best.is_feasible(),
102 )
103 self.data.append(datum)
104
105 @classmethod
106 def from_csv(cls, where: Path | str, delimiter: str = ",", **kwargs):

Callers 12

runMethod · 0.95
test_eqFunction · 0.95
test_more_eqFunction · 0.95
test_not_collectingFunction · 0.95
test_iterationFunction · 0.95
test_plot_resultFunction · 0.95

Calls 3

_DatumClass · 0.85
appendMethod · 0.80
is_feasibleMethod · 0.80

Tested by 11

test_eqFunction · 0.76
test_more_eqFunction · 0.76
test_not_collectingFunction · 0.76
test_iterationFunction · 0.76
test_plot_resultFunction · 0.76