for (g in network.generators){
    if (!g.id.contains('BAT')) {
        mapToGenerators{
            timeSeriesName g.id
            filter {generator.id==g.id}
        }
    }
}

for (l in network.loads){
mapToLoads{
timeSeriesName l.id
filter {load.id==l.id}
}
}

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 }
        }
    }
}