Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#PARSER PQL
#DOREWRITE false

#DEFINE PATH_LOCAL '/media/mydata/dev/odysseus_workspace/phd-workspace/Moving Object/Evaluation/scenarios/energy/energy_data.csv'
#ADDQUERY


input = ACCESS({
            source='households',
            wrapper='GenericPull',
            schema=[
              ['id','Integer'],
              ['wh','Integer'],
              ['BaseDateTime','StartTimeStamp']
            ],
            inputschema=['Integer','Integer','Integer'],
            transport='File',
            protocol='csv',
            datahandler='Tuple',
            metaattribute = ['TimeInterval',  'PredictionTimes'],
            options=[
              ['filename', ${PATH_LOCAL}],
              ['Delimiter',','],
              ['TextDelimiter','"'],
              ['delay','1000'],
              ['readfirstline','false'],
              ['BaseTimeUnit','MINUTES']
            ]                                                                                                                                
          }                                                                                                        
        )
        
/// Only use the last two measured values
time = TIMEWINDOW({
            size = [20, 'minutes']                                                                                                                                                                                                                                                                              
          },
          input
        )
        
/// Convert the wh-attribute to a temporal double
temporalize = AGGREGATION({
                  aggregations = [
                    ['function' = 'ToTemporalDouble', 'input_attributes' = 'wh', 'output_attributes' = 'temp_wh']
                  ],
                  group_by = ['id'],
                  eval_at_outdating = false                                                                                                                                                                                                                                                                                                                                                                                
                },
                time
              )
              
predTime = PREDICTIONTIME({
                addtostartvalue = [0, 'MINUTES'],
                addtoendvalue = [15, 'MINUTEs']                                                                      
              },
              temporalize
            )
            
            
/// Energy consumption per household per minute in the next 15 minutes
derivative = MAP({
                  expressions = [
                    ['derivative(temp_wh, PredictionTimes)','whPerMinute'],
                    ['id','id']
                  ]           
                },
                predTime
              )
              
/// Energy consumption per household per minute in the next 15 minutes
watts = MAP({
                  expressions = [
                    ['whPerMinute * 60','watt'],
                    ['id','id']
                  ]           
                },
                derivative
              )

/// Filter out elements with a low energy consumption              
highConsumption = SELECT({
                      predicate = 'watt > 300'
                    },
                    watts
                  )

Text

Code Block
titleenergy_data.csv
id,wh,time
1,0,0
2,0,3
3,0,6
1,115,15
2,50,18
3,250,21
1,200,30
2,60,33
3,500,36
1,210,45
2,100,48
3,600,51