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

Function test_iteration

tests/test_ProgressPrinter.py:78–104  ·  view source on GitHub ↗

Tests that calling iteration prints a line about the solution costs and their feasibility.

(ok_small, caplog)

Source from the content-addressed store, hash-verified

76
77
78def test_iteration(ok_small, caplog):
79 """
80 Tests that calling iteration prints a line about the solution costs and
81 their feasibility.
82 """
83 curr = Solution(ok_small, [[1, 2, 3, 4]])
84 cand = Solution(ok_small, [[2, 1], [4, 3]])
85 best = Solution(ok_small, [[1, 2], [3, 4]])
86 cost_eval = CostEvaluator([20], 6, 6)
87
88 stats = Statistics()
89 stats.collect(cand, curr, best, cost_eval)
90
91 printer = ProgressPrinter(should_print=True, display_interval=0.0)
92
93 printer.iteration(stats)
94 out = caplog.text
95 assert_equal(stats.num_iterations, 1)
96
97 # Statistics about solver progress should be printed.
98 assert_(str(stats.num_iterations) in out)
99 assert_(str(round(sum(stats.runtimes))) in out)
100
101 # Statistics about solution costs and their feasibility.
102 assert_("28408 N" in out) # current
103 assert_("10012 Y" in out) # candidate
104 assert_("9725 Y" in out) # best
105
106
107def test_should_print_false_no_output(ok_small, caplog):

Callers

nothing calls this directly

Calls 6

collectMethod · 0.95
iterationMethod · 0.95
SolutionClass · 0.90
CostEvaluatorClass · 0.90
StatisticsClass · 0.90
ProgressPrinterClass · 0.90

Tested by

no test coverage detected