If realized_invest_periods are not given, it should be limited to invest_periods. Now the model can fail if realized_periods has more periods than invest_periods (because realized_invest_periods seems to inherit from realized_periods rather than invest_periods when both of those are given).