aartikis / RTEC

RTEC is an Event Calculus implementation optimised for stream reasoning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange behaviour on my own example

qige96 opened this issue · comments

Hello,

I am now playing with RTEC on my own example. I copied the "toy" example and rename to "test1", and only modify the contents of the 3 important files:

% rules.prolog
initiatedAt(on(X)=true, T) :- happensAt(turn_on(X), T).
terminatedAt(on(X)=true, T) :- happensAt(turn_off(X), T).

grounding(on(X)=true) :- air_conditioner(X) .
grounding(turn_on(X)) :- air_conditioner(X) .
grounding(turn_off(X)) :- air_conditioner(X) .

the data file toy_data.csv:

turn_on|10|10|ac1
turn_off|20|20|ac1

and toy_var_domain.prolog

air_conditioner(ac1).

I added a section in the defaults.toml

[test1]
# RTEC execution parameters 
event_description = '../examples/test1/resources/patterns/rules.prolog'
input_mode = "csv"
input_providers = ['../examples/test1/dataset/csv/toy_data.csv']
results_directory = "../examples/test1/results"
background_knowledge = ['../examples/test1/dataset/auxiliary/toy_var_domain.prolog']
window_size = 10
step = 10
start_time = 0
end_time = 50
clock_tick = 1
goals = []
stream_rate = 1
# Compiler parameters
dependency_graph_flag = true
dependency_graph_directory = '../examples/test1/resources/graphs'
include_input = false

I run the execution script and seems everything goes well

$./run_rtec.sh --app=test1 --interactive
Window size: 10
Step: 10
Start time: 0
End time: 50
Input mode: csv
Stream rate: 1
Clock tick: 1
Event description file (precompiled): ../examples/test1/resources/patterns/rules.prolog
Background knowledge: ../examples/test1/dataset/auxiliary/toy_var_domain.prolog
Input stream providers: ../examples/test1/dataset/csv/toy_data.csv
Results directory: ../examples/test1/results
Predicates to run before invoking RTEC: 
Will a dependency graph be produced?: yes
Dependency graph directory: ../examples/test1/resources/graphs
Will the dependency graph include input entities?: no
Executing: ./aux/compile.sh --event-description=../examples/test1/resources/patterns/rules.prolog --dependency-graph --dependency-graph-directory=../examples/test1/resources/graphs --no-events
Compiled event description: ../examples/test1/resources/patterns/rules.prolog.
Dependency graph without input entities: ../examples/test1/resources/graphs/dependency_graph.png.
Successful compilation! Compiled event description in: ../examples/test1/resources/patterns/compiled_rules.prolog
                                                                 
        8 888888888o. 8888888 8888888888 8 8888888888       ,o888888o.    
        8 8888    `88.      8 8888       8 8888            8888     `88.  
        8 8888     `88      8 8888       8 8888         ,8 8888       `8. 
        8 8888     ,88      8 8888       8 8888         88 8888           
        8 8888.   ,88'      8 8888       8 888888888888 88 8888           
        8 888888888P'       8 8888       8 8888         88 8888           
        8 8888`8b           8 8888       8 8888         88 8888           
        8 8888 `8b.         8 8888       8 8888         `8 8888       .8' 
        8 8888   `8b.       8 8888       8 8888            8888     ,88'  
        8 8888     `88.     8 8888       8 888888888888     `8888888P'   

Current Window                          : (0, 10]
Recognition Time (ms)                   : 0
Input Entities                          : 1
Output Entities (# fluent-value pairs)  : 1
Output Entities (# intervals)           : 1
Output Entities (# timepoints)          : 0
=========================================================
Current Window                          : (10, 20]
Recognition Time (ms)                   : 0
Input Entities                          : 1
Output Entities (# fluent-value pairs)  : 1
Output Entities (# intervals)           : 1
Output Entities (# timepoints)          : 9
=========================================================
Current Window                          : (20, 30]
Recognition Time (ms)                   : 0
Input Entities                          : 0
Output Entities (# fluent-value pairs)  : 0
Output Entities (# intervals)           : 0
Output Entities (# timepoints)          : 0
=========================================================
Current Window                          : (30, 40]
Recognition Time (ms)                   : 0
Input Entities                          : 0
Output Entities (# fluent-value pairs)  : 0
Output Entities (# intervals)           : 0
Output Entities (# timepoints)          : 0
=========================================================
Current Window                          : (40, 50]
Recognition Time (ms)                   : 0
Input Entities                          : 0
Output Entities (# fluent-value pairs)  : 0
Output Entities (# intervals)           : 0
Output Entities (# timepoints)          : 0
=========================================================
Recognition Time average (ms)                   : 0
Input Entities average                          : 0.4
Output Entities (average # fluent-value pairs)  : 0.4
Output Entities (average # intervals)           : 0.4
Output Entities (average # timepoints)          : 1.8
=========================================================
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.15-97-g5c7d1f835)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- holdsFor(on(ac1)=true, I).
I = [].

Here according to the rules and data I supplied, I expected that holdsFor(on(ac1)=true, I). will return I=[(11, 20)], but not an empty list.

Does anyone know what is going wrong? Any comments and feedback will be appreciated. For your full details, here is the zipped folder of my "test1" example:
test1.zip

When processing a window of input entities, RTEC computes the maximal interval of the output entities in the window, stores them in its memory and finally writes them in an output file. Before processing the next window, RTEC retracts the events and the computed intervals that are no longer required for interval computation. For example, closed intervals that end before the start of the window are retracted. Therefore, after processing window (40,50] in your example, the memory of RTEC should contain the intervals required for or computed in window (40, 50], which is no intervals in this case. So, the "interactive" flag is not that useful in this case (I should have mentioned this behavior in the manual). You may set the window and the step size to 50 in order to get the expected result.

Also, the maximal intervals of output entities computed in each window should be in the results folder "../examples/test1/results" that you specified in the toml.

Please inform if this does not resolve the issue, so that I may look further into it.

Thanks. After I updated some settings in defaults.toml

window_size = 30
step = 30
start_time = 0
end_time = 30

I get the expected results in the interactive mode.