feat(modell): count chips from the first possible operating year

The project owner answered the three questions from part 5b on 2026-11-12
("Ja til dine anbefalinger"), before any result is computed:

- chips are a stock from the solution's first possible operating year, not
  from the decision year (clarification 25 rewritten; the old reading stays
  as a switch that is not part of the verdicts)
- renewable power in C enters operation the same year as the facility
  (clarification 24 stands)
- the other choices in clarifications 21-40 are approved

The default in the code is flipped, seven tests that assumed a stock from
2027 are redone, and the comparison with the independent reader's code is
rerun with its switch set the same way: same numbers in all 9 471 paths
that can be built. The parameter file is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-11-12 12:14:28 +01:00
commit fb13b8fd75
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
6 changed files with 120 additions and 55 deletions

View file

@ -153,32 +153,48 @@ def _plan(**endringer: object) -> ub.Plan:
return ub.utbyggingsplan(**argumenter) # type: ignore[arg-type]
def test_brikker_samles_opp_fra_beslutningsaaret_og_utskifting_gaar_foran() -> None:
def test_brikker_telles_fra_forste_mulige_aar_og_utskifting_gaar_foran() -> None:
"""Hand-computed: 500 MW of chips a year, facilities of 1 000 MW, vintages of three years.
Deliveries count from the first possible operating year, 2030 (clarification 25). Stock
after deliveries: 2030 500, 2031 1 000 (facility 1 starts, 0 left), 2032 500, 2033 1 000
(facility 2 starts), 2034 500 (facility 1's vintage has expired and waits), 2035 1 000
(facility 1's vintage is replaced before facility 3 can start), 2036 500 (facility 2
waits), 2037 1 000 (facility 2 replaced), 2038 500 (facility 1 waits), 2039 1 000
(facility 1 replaced), 2040 500 (facility 2 waits). Facility 3 never gets chips.
"""
plan = _plan()
assert [a.start for a in plan.anlegg] == [2031, 2033]
assert plan.anlegg[0].aarganger == (2031, 2035, 2039)
assert plan.anlegg[1].aarganger == (2033, 2037)
assert not plan.gjennomforbar
assert plan.t_1 == 2031
def test_brikker_spart_opp_fra_beslutningsaaret_er_en_bryter() -> None:
"""The reading the text had before clarification 25 was decided: a stock from 2028.
Stock after deliveries: 2028 500, 2029 1 000, 2030 1 500 (facility 1 starts, 500 left),
2031 1 000 (facility 2 starts, 0 left), 2032 500, 2033 1 000 (facility 1's vintage is
replaced before facility 3 can start), 2034 500 (facility 2's vintage has expired and
waits), 2035 1 000 (facility 2 replaced), 2036 500 (facility 1 waits), 2037 1 000
(facility 1 replaced), 2038 500 (facility 2 waits), 2039 1 000 (facility 2 replaced),
2040 500 (facility 1 waits). Facility 3 never gets chips.
replaced before facility 3 can start), 2034 500 (facility 2 waits), 2035 1 000 (facility
2 replaced), 2036 500, 2037 1 000 (facility 1 replaced), 2038 500, 2039 1 000 (facility
2 replaced), 2040 500. Facility 3 never gets chips.
"""
plan = _plan()
plan = _plan(forste_brikkeaar=2028)
assert [a.start for a in plan.anlegg] == [2030, 2031]
assert plan.anlegg[0].aarganger == (2030, 2033, 2037)
assert plan.anlegg[1].aarganger == (2031, 2035, 2039)
assert not plan.gjennomforbar
assert plan.t_1 == 2030
def test_utlevd_aargang_staar_uten_inntekt_til_den_byttes() -> None:
plan = _plan()
assert plan.aargang(1, 2033) == 2031
assert plan.aargang(1, 2034) is None # expired, no chips in stock
assert plan.aargang(1, 2035) == 2035
assert plan.aargang(0, 2036) is None
assert plan.aargang(0, 2029) is None # not in operation yet
assert plan.i_drift(1, 2034) # the facility is still operated
assert plan.aargang(0, 2033) == 2031
assert plan.aargang(0, 2034) is None # expired, no chips in stock
assert plan.aargang(0, 2035) == 2035
assert plan.aargang(1, 2036) is None
assert plan.aargang(0, 2030) is None # not in operation yet
assert plan.i_drift(0, 2034) # the facility is still operated
def test_den_som_har_ventet_lengst_faar_brikker_forst() -> None: