mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-08-02 21:54:24 +02:00
Algorithm changed again
This commit is contained in:
@@ -30,7 +30,7 @@ class TestWEIAlgorithm(TestCase):
|
||||
)
|
||||
|
||||
self.buses = []
|
||||
for i in range(10):
|
||||
for i in range(8):
|
||||
bus = Bus.objects.create(wei=self.wei, name=f"Bus {i}", size=10)
|
||||
self.buses.append(bus)
|
||||
information = WEIBusInformation2025(bus)
|
||||
@@ -74,7 +74,7 @@ class TestWEIAlgorithm(TestCase):
|
||||
Buses are full of first year people, ensure that they are happy
|
||||
"""
|
||||
# Add a lot of users
|
||||
for i in range(95):
|
||||
for i in range(80):
|
||||
user = User.objects.create(username=f"user{i}")
|
||||
registration = WEIRegistration.objects.create(
|
||||
user=user,
|
||||
@@ -90,6 +90,7 @@ class TestWEIAlgorithm(TestCase):
|
||||
information.step = len(WORDS['questions']) + 1
|
||||
information.save(registration)
|
||||
registration.save()
|
||||
survey = WEISurvey2025(registration)
|
||||
|
||||
# Run algorithm
|
||||
WEISurvey2025.get_algorithm_class()().run_algorithm()
|
||||
@@ -104,8 +105,9 @@ class TestWEIAlgorithm(TestCase):
|
||||
survey = WEISurvey2025(r)
|
||||
chosen_bus = survey.information.get_selected_bus()
|
||||
buses = survey.ordered_buses()
|
||||
score = min(v for bus, v in buses if bus == chosen_bus)
|
||||
max_score = buses[0][1]
|
||||
self.assertIn(chosen_bus, [x[0] for x in buses])
|
||||
score = min(v for bus, (v, __) in buses if bus == chosen_bus)
|
||||
max_score = buses[0][1][0]
|
||||
penalty += (max_score - score) ** 2
|
||||
|
||||
self.assertLessEqual(max_score - score, 1) # Always less than 25 % of tolerance
|
||||
|
Reference in New Issue
Block a user