mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-02-24 09:01:18 +00:00
Compare commits
2 Commits
74ab4df9fe
...
d36edfc063
Author | SHA1 | Date | |
---|---|---|---|
d36edfc063 | |||
e452b7acbf |
@ -45,9 +45,9 @@ class WEISurveyForm2021(forms.Form):
|
||||
rng = Random(information.seed)
|
||||
|
||||
words = []
|
||||
for _ in range(information.step + 1):
|
||||
for _ignored in range(information.step + 1):
|
||||
# Generate N times words
|
||||
words = [rng.choice(WORDS) for _ in range(10)]
|
||||
words = [rng.choice(WORDS) for _ignored2 in range(10)]
|
||||
words = [(w, w) for w in words]
|
||||
if self.data:
|
||||
self.fields["word"].choices = [(w, w) for w in WORDS]
|
||||
@ -162,7 +162,7 @@ class WEISurveyAlgorithm2021(WEISurveyAlgorithm):
|
||||
while free_surveys: # Some students are not affected
|
||||
survey = free_surveys[0]
|
||||
buses = survey.ordered_buses() # Preferences of the student
|
||||
for bus, _ in buses:
|
||||
for bus, _ignored in buses:
|
||||
if self.get_bus_information(bus).has_free_seats(surveys):
|
||||
# Selected bus has free places. Put student in the bus
|
||||
survey.select_bus(bus)
|
||||
|
@ -5,7 +5,7 @@ from argparse import ArgumentParser, FileType
|
||||
from django.core.management import BaseCommand
|
||||
from django.db import transaction
|
||||
|
||||
from wei.forms import CurrentSurvey
|
||||
from ...forms import CurrentSurvey
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -1,11 +1,13 @@
|
||||
import math
|
||||
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import random
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
|
||||
from wei.forms.surveys.wei2021 import WEIBusInformation2021, WEISurvey2021, WORDS, WEISurveyInformation2021
|
||||
from wei.models import Bus, WEIClub, WEIRegistration
|
||||
from ..forms.surveys.wei2021 import WEIBusInformation2021, WEISurvey2021, WORDS, WEISurveyInformation2021
|
||||
from ..models import Bus, WEIClub, WEIRegistration
|
||||
|
||||
|
||||
class TestWEIAlgorithm(TestCase):
|
||||
@ -102,6 +104,6 @@ class TestWEIAlgorithm(TestCase):
|
||||
max_score = buses[0][1]
|
||||
penalty += (max_score - score) ** 2
|
||||
|
||||
self.assertLessEqual(max_score - score, 20) # Always less than 20 % of tolerance
|
||||
self.assertLessEqual(max_score - score, 25) # Always less than 25 % of tolerance
|
||||
|
||||
self.assertLessEqual(penalty / 100, 25) # Tolerance of 5 %
|
||||
|
Loading…
x
Reference in New Issue
Block a user