This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Included tests for "LocalSearchAlgorithm". #41
* Fixed bug related with exception handling.
- Loading branch information
1 parent
049e95f
commit d8b83c9
Showing
3 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/test_algorithms/test_heuristics/test_local_search.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
|
||
import jinete as jit | ||
|
||
from tests.utils import ( | ||
generate_vehicles, | ||
generate_trips, | ||
) | ||
|
||
|
||
class TestLocalSearchAlgorithm(unittest.TestCase): | ||
job: jit.Job | ||
fleet: jit.Fleet | ||
|
||
@classmethod | ||
def setUpClass(cls) -> None: | ||
cls.job = jit.Job(generate_trips(10), objective_cls=jit.DialARideObjective) | ||
cls.fleet = jit.Fleet(generate_vehicles(10)) | ||
algorithm = jit.InsertionAlgorithm( | ||
job=cls.job, | ||
fleet=cls.fleet, | ||
) | ||
cls.initial = algorithm.optimize() | ||
|
||
def test_creation(self): | ||
algorithm = jit.LocalSearchAlgorithm( | ||
initial=self.initial, | ||
job=self.job, | ||
fleet=self.fleet, | ||
) | ||
self.assertEqual(algorithm.initial, self.initial) | ||
self.assertEqual(algorithm.job, self.job) | ||
self.assertEqual(algorithm.fleet, self.fleet) | ||
|
||
def test_optimize(self): | ||
algorithm = jit.LocalSearchAlgorithm( | ||
initial=self.initial, | ||
job=self.job, | ||
fleet=self.fleet, | ||
) | ||
result = algorithm.optimize() | ||
|
||
self.assertIsNotNone(result) | ||
self.assertIsInstance(result, jit.Result) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |