chore: limit optimizer to 2 days horizon

This commit is contained in:
andig 2026-04-16 09:47:18 +02:00
parent f69252e672
commit f126c8c70b

View file

@ -119,8 +119,11 @@ func (site *Site) optimizerUpdate(battery []types.Measurement) error {
if solarTariff != nil && len(solar) > 0 {
minLen = min(minLen, len(solar))
}
const expectedSlots = 8
if minLen < expectedSlots {
// limit to 2 days for sake of performance
minLen = min(96, minLen)
if expectedSlots := 8; minLen < expectedSlots {
if solarTariff != nil {
return fmt.Errorf("not enough forecast slots for meaningful optimization: %d < %d (grid=%d, feedIn=%d, solar=%d)", minLen, expectedSlots, len(grid), len(feedIn), len(solar))
}