for (g in network.generators) {
    if (g.id.contains('BAT')) {
        mapToGenerators {
            variable minP
            timeSeriesName g.id + '_minP'
            filter { generator.id == g.id }
        }
        
        mapToGenerators {
            variable maxP
            timeSeriesName g.id + '_maxP'
            filter { generator.id == g.id }
        }
        
        mapToGenerators {
            variable targetP
            timeSeriesName g.id + '_targetP'
            filter { generator.id == g.id }
        }
    }
}