lsa-planer
LSA-Planer Professional – Planungssoftware für Lichtsignalanlagen nach RiLSA 2015 und § 45 StVO. EUPL-1.2.
| 1 | import { describe, expect, it } from 'vitest'; |
| 2 | import { compareCycleTimeMethods, computeCycleTime, minimumCycleTime } from '@/domain/rilsa/cycle'; |
| 3 | |
| 4 | describe('Umlaufzeitermittlung', () => { |
| 5 | it('rechnet Webster korrekt und rastert auf 5 s', () => { |
| 6 | // (1,5 * 20 + 5) / (1 - 0,6) = 35 / 0,4 = 87,5 -> 90 s |
| 7 | const result = computeCycleTime('webster', { lostTime: 20, criticalFlowRatios: [0.35, 0.25] }); |
| 8 | expect(result.totalFlowRatio).toBeCloseTo(0.6, 6); |
| 9 | expect(result.raw).toBeCloseTo(87.5, 2); |
| 10 | expect(result.cycleTime).toBe(90); |
| 11 | expect(result.bounded).toBe('keine'); |
| 12 | }); |
| 13 | |
| 14 | it('rechnet Akcelik als eigenstaendiges Verfahren', () => { |
| 15 | // (1,4 * 20 + 6) / (1 - 0,6) = 34 / 0,4 = 85 s |
| 16 | const result = computeCycleTime('akcelik', { lostTime: 20, criticalFlowRatios: [0.6] }); |
| 17 | expect(result.raw).toBeCloseTo(85, 2); |
| 18 | // Der Altbestand rechnete hier Webster * 1,1 bzw. * 1,2. |
| 19 | expect(result.raw).not.toBeCloseTo(87.5 * 1.1, 1); |
| 20 | }); |
| 21 | |
| 22 | it('beruecksichtigt beim kapazitaetsorientierten Verfahren die Saettigungsgrade', () => { |
| 23 | // L * x / (x - Y) = 20 * 0,85 / (0,85 - 0,6) = 17 / 0,25 = 68 s |
| 24 | const result = computeCycleTime('hbs', { lostTime: 20, criticalFlowRatios: [0.6] }); |
| 25 | expect(result.raw).toBeCloseTo(68, 2); |
| 26 | // Der Altbestand rechnete L / (1 - 0,85) = 133,3 s, unabhaengig von Y. |
| 27 | expect(result.raw).not.toBeCloseTo(133.3, 0); |
| 28 | }); |
| 29 | |
| 30 | it('erkennt einen uebersaettigten Knotenpunkt statt still auf 30 s zu klemmen', () => { |
| 31 | const result = computeCycleTime('webster', { lostTime: 20, criticalFlowRatios: [0.7, 0.35] }); |
| 32 | expect(result.notes.some((n) => n.code === 'uebersaettigt' && n.severity === 'fehler')).toBe( |
| 33 | true, |
| 34 | ); |
| 35 | // Der Altbestand lieferte hier stillschweigend die Mindestumlaufzeit. |
| 36 | expect(result.cycleTime).not.toBe(30); |
| 37 | }); |
| 38 | |
| 39 | it('meldet fehlende Verkehrsstaerken, statt einen Wert zu erfinden', () => { |
| 40 | const result = computeCycleTime('webster', { lostTime: 20, criticalFlowRatios: [] }); |
| 41 | expect(result.notes.some((n) => n.code === 'saettigungsgrade-fehlen')).toBe(true); |
| 42 | }); |
| 43 | |
| 44 | it('haelt die Mindestumlaufzeit ein', () => { |
| 45 | const result = computeCycleTime('webster', { |
| 46 | lostTime: 10, |
| 47 | criticalFlowRatios: [0.2], |
| 48 | minimumCycle: 75, |
| 49 | }); |
| 50 | expect(result.cycleTime).toBe(75); |
| 51 | expect(result.bounded).toBe('mindestumlauf'); |
| 52 | }); |
| 53 | |
| 54 | it('meldet eine Ueberschreitung des Hoechstwerts als Fehler', () => { |
| 55 | const result = computeCycleTime('webster', { lostTime: 40, criticalFlowRatios: [0.55, 0.3] }); |
| 56 | expect(result.cycleTime).toBe(120); |
| 57 | expect(result.bounded).toBe('maximum'); |
| 58 | expect(result.notes.some((n) => n.code === 'umlaufzeit-ueber-hoechstwert')).toBe(true); |
| 59 | }); |
| 60 | |
| 61 | it('liefert eine begruendete Empfehlung statt NaN', () => { |
| 62 | const comparison = compareCycleTimeMethods({ lostTime: 20, criticalFlowRatios: [0.6] }); |
| 63 | // Der Altbestand addierte Objekte auf eine Zahl; das Ergebnis war immer NaN. |
| 64 | // |
| 65 | // SEIT FASSUNG 5.28.0 ist die Empfehlung ein WERT und kein |
| 66 | // Verfahrensergebnis mehr - bei Gleichstand entschied zuvor die |
| 67 | // Reihenfolge des Objektliterals. Die Faelle dazu stehen in |
| 68 | // umlaufzeitvergleichEhrlichkeit.test.ts; hier bleibt die alte Frage: Ist |
| 69 | // ueberhaupt eine Zahl herausgekommen? |
| 70 | expect(comparison.recommendedCycleTime).not.toBeNull(); |
| 71 | expect(Number.isFinite(comparison.recommendedCycleTime ?? Number.NaN)).toBe(true); |
| 72 | expect(comparison.recommendedCycleTime ?? 0).toBeGreaterThan(0); |
| 73 | expect(comparison.reason).toContain('Empfohlen'); |
| 74 | for (const method of ['webster', 'akcelik', 'hbs', 'hcm'] as const) { |
| 75 | expect(Number.isFinite(comparison.results[method].cycleTime)).toBe(true); |
| 76 | } |
| 77 | }); |
| 78 | |
| 79 | it('summiert die Mindestumlaufzeit aus Freigabe- und Uebergangszeiten', () => { |
| 80 | expect(minimumCycleTime([5, 5, 5], [6, 6, 6])).toBe(33); |
| 81 | expect(minimumCycleTime([Number.NaN, 5], [6])).toBe(11); |
| 82 | }); |
| 83 | }); |