Non-integer `technical_lifetime` → error in scaling_investment_costs.gms
- Dominant language
- Jupyter Notebook
- Stars
- 150
- Forks
- 178
- Avg merge
- 17h 32m
- Merged PRs (30d)
- 2
Description
If `technical_lifetime` has non-integer values, the calculation of `beyond_horizon_factor` in scaling_investment_costs.gms errors:
https://github.com/iiasa/message_ix/blob/38461e62eacfba39b6ec52c02b35faaa7fab0bb2/message_ix/model/MESSAGE/scaling_investment_costs.gms#L139
…with a message like:
```
**** Exec Error at line 2056: power: FUNC DOMAIN: pow(x,i), i not integer
```
The `i` argument is `beyond_horizon_lifetime`, which is computed in the same file:
https://github.com/iiasa/message_ix/blob/38461e62eacfba39b6ec52c02b35faaa7fab0bb2/message_ix/model/MESSAGE/scaling_investment_costs.gms#L10-L12 When `technical_lifetime` is real/non-integer, this parameter will also be non-integer.
Because it's not mentioned in the documentation, it's not clear (cf. related issues, below) whether other parts of the GAMS code **also** expect `technical_lifetime` to be *only* integer numbers of years. *Conceptually*, this restriction doesn't make any sense, but *practically* the code may have been written that way.
For this particular error, a **fix** would be to use the GAMS [`**` operator](https://www.gams.com/latest/docs/UG_Parameters.html#UG_Parameters_StandardArithmeticOperations), which accepts real exponents, instead of the [`POWER()` function](https://www.gams.com/latest/docs/UG_Parameters.html#UG_Parameters_dmpower), which does not. The line can also be simplified since (1 / (1 + i))\*\*b is just (1+i)\*\*(-b).
Notes:
- Discovered with @francescolovat working with the code in `message_data.model.transport.data.ikarus`, which reads a source file with a technical lifetime for some technologies of 14.7 years.
- Loosely related issues:
- #137
- #376
- #385
Contributor guide
Research direction
Start in message_ix/model/MESSAGE/scaling_investment_costs.gms, especially lines 10-12 and 139, and reproduce the failure with the message_data.model.transport.data.ikarus data containing a 14.7-year technical lifetime. Check whether the calculation works for non-integer lifetimes and whether related GAMS code or documentation imposes an integer-only restriction; done means the model no longer errors for this case and the supported lifetime behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100