@@ -270,77 +270,87 @@ private static boolean p0RespectsConstraints(CSVRecord staticRecord, Map<String,
270270 Optional <Double > parsedLead = Optional .empty ();
271271 if (!staticRecord .get (LEAD_TIME ).isEmpty ()) {
272272 parsedLead = Optional .of (parseDoubleWithPossibleCommas (staticRecord .get (LEAD_TIME )));
273- lead = Optional .of ((int ) Math .ceil ( parsedLead .get ()/ timestampDuration ));
273+ lead = Optional .of ((int ) Math .ceil (parsedLead .get () / timestampDuration ));
274274 }
275275 if (!staticRecord .get (LAG_TIME ).isEmpty ()) {
276276 double parsedLag = parseDoubleWithPossibleCommas (staticRecord .get (LAG_TIME ));
277277 double parsedLagAndLead = parsedLead .map (aDouble -> aDouble + parsedLag ).orElse (parsedLag );
278- lagAndLead = Optional .of ((int ) Math .ceil ( parsedLagAndLead / timestampDuration ));
278+ lagAndLead = Optional .of ((int ) Math .ceil (parsedLagAndLead / timestampDuration ));
279279 }
280280 double maxGradient = staticRecord .get (MAXIMUM_POSITIVE_POWER_GRADIENT ).isEmpty () ?
281281 MAX_GRADIENT : parseDoubleWithPossibleCommas (staticRecord .get (MAXIMUM_POSITIVE_POWER_GRADIENT ));
282282 double minGradient = staticRecord .get (MAXIMUM_NEGATIVE_POWER_GRADIENT ).isEmpty () ?
283283 -MAX_GRADIENT : -parseDoubleWithPossibleCommas (staticRecord .get (MAXIMUM_NEGATIVE_POWER_GRADIENT ));
284284
285-
286285 // Intermediate variables
287- boolean count_lag = false ;
288- int count_consecutive_null_values = 0 ;
286+ boolean countLag = false ;
287+ int countConsecutiveNullValues = 0 ;
289288
290289 Iterator <OffsetDateTime > dateTimeIterator = dateTimes .iterator ();
291290 OffsetDateTime currentDateTime = dateTimeIterator .next ();
292291 while (dateTimeIterator .hasNext ()) {
293292 OffsetDateTime nextDateTime = dateTimeIterator .next ();
294- double next_p0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (nextDateTime .getHour () + OFFSET ));
295- double current_p0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (currentDateTime .getHour () + OFFSET ));
293+ double nextP0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (nextDateTime .getHour () + OFFSET ));
294+ double currentP0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (currentDateTime .getHour () + OFFSET ));
296295 Optional <Double > pMinRD = parseValue (seriesRecord , P_MIN_RD , currentDateTime , 1 );
297296 double pMin = pMinRD .orElse (ON_POWER_THRESHOLD );
298297
299298 // 1- Check gradients
300- if (!areGradientsRespected (staticRecord , next_p0 , current_p0 , maxGradient , minGradient , currentDateTime )) return false ;
299+ if (!areGradientsRespected (staticRecord , nextP0 , currentP0 , maxGradient , minGradient , currentDateTime )) {
300+ return false ;
301+ }
301302
302303 // 2 - Check Pmin is respected
303- if (!isPminRespected (staticRecord , current_p0 , pMin , currentDateTime )) return false ;
304+ if (!isPminRespected (staticRecord , currentP0 , pMin , currentDateTime )) {
305+ return false ;
306+ }
304307
305308 // 3 - Starting up next timestamp
306309 // a) Check start up is allowed
307310 // b) Check lead time is respected
308311 // c) Check lag time + lead time is respected
309- if (current_p0 < pMin ) {
310- count_consecutive_null_values += 1 ;
312+ if (currentP0 < pMin ) {
313+ countConsecutiveNullValues += 1 ;
311314 }
312- if (current_p0 < pMin && next_p0 >= pMin ) {
313- if (!isStartUpRespected (staticRecord , startUpAllowed , currentDateTime )) return false ;
314- if (!isLeadTimeRespected (staticRecord , lead , count_consecutive_null_values , currentDateTime )) return false ;
315- if (count_lag ) {
316- if (!isLeadTimeAndLagTimeRespected (staticRecord , count_consecutive_null_values , lagAndLead , currentDateTime ))
315+ if (currentP0 < pMin && nextP0 >= pMin ) {
316+ if (!isStartUpRespected (staticRecord , startUpAllowed , currentDateTime )) {
317+ return false ;
318+ }
319+ if (!isLeadTimeRespected (staticRecord , lead , countConsecutiveNullValues , currentDateTime )) {
320+ return false ;
321+ }
322+ if (countLag ) {
323+ if (!isLeadTimeAndLagTimeRespected (staticRecord , countConsecutiveNullValues , lagAndLead , currentDateTime )) {
317324 return false ;
325+ }
318326 // Re-initialize
319- count_lag = false ;
327+ countLag = false ;
320328 }
321329 }
322330 // 4 - Shutting down next timestamp
323331 // a) Check shut down is allowed
324332 // activate lag time + lead time checking
325- if (current_p0 >= pMin && next_p0 < pMin ) {
326- if (!isShutDownRespected (staticRecord , shutDownAllowed , currentDateTime )) return false ;
333+ if (currentP0 >= pMin && nextP0 < pMin ) {
334+ if (!isShutDownRespected (staticRecord , shutDownAllowed , currentDateTime )) {
335+ return false ;
336+ }
327337 if (lagAndLead .isPresent ()) {
328- count_lag = true ;
338+ countLag = true ;
329339 }
330340 }
331341
332- // Re-init count_consecutive_null_values
333- if (current_p0 >= pMin ) {
334- count_consecutive_null_values = 0 ;
342+ // Re-init countConsecutiveNullValues
343+ if (currentP0 >= pMin ) {
344+ countConsecutiveNullValues = 0 ;
335345 }
336346 currentDateTime = nextDateTime ;
337347 }
338348
339349 // Last timestamp
340- double current_p0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (currentDateTime .getHour () + OFFSET ));
350+ double currentP0 = parseDoubleWithPossibleCommas (seriesRecord .get (P0 ).get (currentDateTime .getHour () + OFFSET ));
341351 Optional <Double > pMinRD = parseValue (seriesRecord , P_MIN_RD , currentDateTime , 1 );
342352 double pMin = pMinRD .orElse (ON_POWER_THRESHOLD );
343- return isPminRespected (staticRecord , current_p0 , pMin , currentDateTime );
353+ return isPminRespected (staticRecord , currentP0 , pMin , currentDateTime );
344354 }
345355
346356 private static boolean isShutDownRespected (CSVRecord staticRecord , Boolean shutDownAllowed , OffsetDateTime currentDateTime ) {
@@ -352,19 +362,19 @@ private static boolean isShutDownRespected(CSVRecord staticRecord, Boolean shutD
352362 return true ;
353363 }
354364
355- private static boolean isLeadTimeAndLagTimeRespected (CSVRecord staticRecord , int count_consecutive_null_values , Optional <Integer > lagAndLead , OffsetDateTime currentDateTime ) {
356- if (count_consecutive_null_values < lagAndLead .get ()) {
365+ private static boolean isLeadTimeAndLagTimeRespected (CSVRecord staticRecord , int countConsecutiveNullValues , Optional <Integer > lagAndLead , OffsetDateTime currentDateTime ) {
366+ if (countConsecutiveNullValues < lagAndLead .get ()) {
357367 BUSINESS_WARNS .warn ("Redispatching action {} is not imported (hour {}): lagTime + leadTime ({}) not respected. RA was OFF after shut down for only {} timestamps" ,
358- staticRecord .get (0 ), currentDateTime .getHour (), lagAndLead .get (), count_consecutive_null_values );
368+ staticRecord .get (0 ), currentDateTime .getHour (), lagAndLead .get (), countConsecutiveNullValues );
359369 return false ;
360370 }
361371 return true ;
362372 }
363373
364- private static boolean isLeadTimeRespected (CSVRecord staticRecord , Optional <Integer > lead , int count_consecutive_null_values , OffsetDateTime currentDateTime ) {
365- if (lead .isPresent () && count_consecutive_null_values < lead .get ()) {
374+ private static boolean isLeadTimeRespected (CSVRecord staticRecord , Optional <Integer > lead , int countConsecutiveNullValues , OffsetDateTime currentDateTime ) {
375+ if (lead .isPresent () && countConsecutiveNullValues < lead .get ()) {
366376 BUSINESS_WARNS .warn ("Redispatching action {} is not imported (hour {}): leadTime ({}) not respected. RA was OFF before start up for only {} timestamps" ,
367- staticRecord .get (0 ), currentDateTime .getHour (), lead .get (), count_consecutive_null_values );
377+ staticRecord .get (0 ), currentDateTime .getHour (), lead .get (), countConsecutiveNullValues );
368378 return false ;
369379 }
370380 return true ;
@@ -379,8 +389,8 @@ private static boolean isStartUpRespected(CSVRecord staticRecord, Boolean startU
379389 return true ;
380390 }
381391
382- private static boolean areGradientsRespected (CSVRecord staticRecord , double next_p0 , double current_p0 , double maxGradient , double minGradient , OffsetDateTime currentDateTime ) {
383- double diff = next_p0 - current_p0 ;
392+ private static boolean areGradientsRespected (CSVRecord staticRecord , double nextP0 , double currentP0 , double maxGradient , double minGradient , OffsetDateTime currentDateTime ) {
393+ double diff = nextP0 - currentP0 ;
384394 if (diff > maxGradient || diff < minGradient ) {
385395 BUSINESS_WARNS .warn (
386396 "Redispatching action {} is not imported (hour {}): does not respect power gradients : min/max/diff = {} / {} / {}" ,
@@ -391,16 +401,15 @@ private static boolean areGradientsRespected(CSVRecord staticRecord, double next
391401 return true ;
392402 }
393403
394- private static boolean isPminRespected (CSVRecord staticRecord , double current_p0 , double pMin , OffsetDateTime currentDateTime ) {
395- if (current_p0 < pMin && current_p0 > ON_POWER_THRESHOLD ) {
404+ private static boolean isPminRespected (CSVRecord staticRecord , double currentP0 , double pMin , OffsetDateTime currentDateTime ) {
405+ if (currentP0 < pMin && currentP0 > ON_POWER_THRESHOLD ) {
396406 BUSINESS_WARNS .warn ("Redispatching action {} is not imported (hour {}): does not respect Pmin : P0 is {} and Pmin at {}" ,
397- staticRecord .get (0 ), currentDateTime .getHour (), current_p0 , pMin );
407+ staticRecord .get (0 ), currentDateTime .getHour (), currentP0 , pMin );
398408 return false ;
399409 }
400410 return true ;
401411 }
402412
403-
404413 /**
405414 * Verifies whether the range of redispatching parameters is valid for the input time series,
406415 * ensuring that redispatching values are non-negative and exceed a minimum threshold.
0 commit comments