Quantcast

Calculating average yields no result

classic Classic list List threaded Threaded
11 messages Options
aya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Calculating average yields no result

aya
Hello,

I am using Protege to build an ontology for connected vehicles. I have a class called traffic_flow_sensor that records the average speed of the Vehicles on a given Road. I am trying to build a SWRL rule to calculate the average speed and update the record_speed property with the calculated value:

Road(?r) ^ Vehicle(?v) ^ Location_Sensor(?ls) ^ locationSensor_Vehicle(?ls, ?v) ^ recorded_location(?ls, ?r) ^ vehicleSpeed(?v, ?vs) ^ Avg_Speed_Sensor(?ass) ^ avgSpeedSensor_Infrastructue(?ass, ?r) ˚ sqwrl:makeBag(?b, ?vs) ^ sqwrl:groupBy(?b, ?r) ˚ sqwrl:avg(?avg, ?b) -> recorded_speed(?ass, ?avg) ^ sqwrl:select(?v, ?avg)

This rule basically checks that the Vehicle ?v is located in Road ?r using what the location sensor records. If the vehicle ?v is located in Road ?r then its speed is added to the bag ?b then using the sqwrl:avg operator, I calculate the average of the speeds in the bag ?b and set that average as the recorded speed for the avgSpeedSensor that is located in the Road ?r   

However, the SWRL tab does not allow me to execute this rule. Also, the SQWRL tab allows me to run the rule but does not yield any results.

Can anyone point out to me what is the problem? It seems logical, but I just can't seem to get it to run and update the class individuals. 

Best Regards,
Aya

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Martin O'Connor-2

Note that SQWRL collection operators should not be used to make inferences. They should be used in SQWRL queries only. They should not be used in rules.

You should not be attempting to make inferences with these operators (which is why the SWRLTab plugin will not allow them to be executed in the rule editor).

It is also possible that your query does not match anything.

You can debug it by writing a sequence of queries with incrementally more atoms from the query body, e.g.,

Road(?r) -> sqwrl:select(?r)
Road(?r) ^ Vehicle(?v) -> sqwrl:select(?r, ?v)
etc.

Martin

> On May 14, 2017, at 2:03 PM, Aya Hamdy <[hidden email]> wrote:
>
> Hello,
>
> I am using Protege to build an ontology for connected vehicles. I have a class called traffic_flow_sensor that records the average speed of the Vehicles on a given Road. I am trying to build a SWRL rule to calculate the average speed and update the record_speed property with the calculated value:
>
> Road(?r) ^ Vehicle(?v) ^ Location_Sensor(?ls) ^ locationSensor_Vehicle(?ls, ?v) ^ recorded_location(?ls, ?r) ^ vehicleSpeed(?v, ?vs) ^ Avg_Speed_Sensor(?ass) ^ avgSpeedSensor_Infrastructue(?ass, ?r) ˚ sqwrl:makeBag(?b, ?vs) ^ sqwrl:groupBy(?b, ?r) ˚ sqwrl:avg(?avg, ?b) -> recorded_speed(?ass, ?avg) ^ sqwrl:select(?v, ?avg)
>
> This rule basically checks that the Vehicle ?v is located in Road ?r using what the location sensor records. If the vehicle ?v is located in Road ?r then its speed is added to the bag ?b then using the sqwrl:avg operator, I calculate the average of the speeds in the bag ?b and set that average as the recorded speed for the avgSpeedSensor that is located in the Road ?r  
>
> However, the SWRL tab does not allow me to execute this rule. Also, the SQWRL tab allows me to run the rule but does not yield any results.
>
> Can anyone point out to me what is the problem? It seems logical, but I just can't seem to get it to run and update the class individuals.
>
> Best Regards,
> Aya
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
aya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

aya
Thank you so much, Martin; I will try to do that. But, is there a possible way if I want to set the value of the recorded_speed property of the avgSpeed_Sensor  from the speeds of the vehicles using inference? or using the result of the SQWRL query? 

I am trying to avoid setting the value for the recorded_speed manually when creating individual sensors. That is why I added a vehicle property called vehicle_speed to record individual vehicles' speed.

Is it possible to use the result of the query as an input to a SWRL rule for instance? (from what I understand, SWRL inferences are included in the results of the SQWRL queries, but is it possible to do the reverse for instance?) 

Best Regards,
Aya

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Martin O'Connor-2

You are attempting to perform closed world reasoning. OWL and SWRL both adopt the open world assumption. 

See:


If you search on the mailing list for the terms “closed world” and “open world” you will find quite a few discussions on this topic.

Martin

On May 14, 2017, at 2:27 PM, Aya Hamdy <[hidden email]> wrote:

Thank you so much, Martin; I will try to do that. But, is there a possible way if I want to set the value of the recorded_speed property of the avgSpeed_Sensor  from the speeds of the vehicles using inference? or using the result of the SQWRL query? 

I am trying to avoid setting the value for the recorded_speed manually when creating individual sensors. That is why I added a vehicle property called vehicle_speed to record individual vehicles' speed.

Is it possible to use the result of the query as an input to a SWRL rule for instance? (from what I understand, SWRL inferences are included in the results of the SQWRL queries, but is it possible to do the reverse for instance?) 

Best Regards,
Aya
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
aya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

aya
ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Martin O'Connor-2

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
aya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

aya
I have the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2. 

The problem is that this is all the error says. I have taken a screenshot attached as 11.PNG; no further explanation is provided.

The current version of the ontology which I am testing this on is attached as connectedvehicle.owl . 

Thank you and Best Regards,
Aya

On Sun, May 14, 2017 at 10:32 PM, Martin O'Connor <[hidden email]> wrote:

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

11.PNG (12K) Download Attachment
connectedvehicle.owl (123K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Martin O'Connor-2

Thanks for the ontology.

I took a look at this and can reproduce the problems you describe. Unfortunately, I cannot spot the immediate source of the bug. I will try to find the source of the problem this week and generate a patch release.

Martin

On May 14, 2017, at 3:43 PM, Aya Hamdy <[hidden email]> wrote:

I have the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2. 

The problem is that this is all the error says. I have taken a screenshot attached as 11.PNG; no further explanation is provided.

The current version of the ontology which I am testing this on is attached as connectedvehicle.owl . 

Thank you and Best Regards,
Aya

On Sun, May 14, 2017 at 10:32 PM, Martin O'Connor <[hidden email]> wrote:

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


<11.PNG><connectedvehicle.owl>_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Lorenz B.
@Aya

You should use SPARQL 1.1 Update for your use-case.

Thanks for the ontology.

I took a look at this and can reproduce the problems you describe. Unfortunately, I cannot spot the immediate source of the bug. I will try to find the source of the problem this week and generate a patch release.

Martin

On May 14, 2017, at 3:43 PM, Aya Hamdy <[hidden email]> wrote:

I have the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2. 

The problem is that this is all the error says. I have taken a screenshot attached as 11.PNG; no further explanation is provided.

The current version of the ontology which I am testing this on is attached as connectedvehicle.owl . 

Thank you and Best Regards,
Aya

On Sun, May 14, 2017 at 10:32 PM, Martin O'Connor <[hidden email]> wrote:

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


<11.PNG><connectedvehicle.owl>_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

Biswanath Dutta


@Aya, yes, I agree with Lorenz. I think SPARQL 1.1 is a possible answer to your problem. In your case, at least the one you expressed, the rule is not required. 

On Mon, May 15, 2017 at 12:49 PM, Lorenz B. <[hidden email]> wrote:
@Aya

You should use SPARQL 1.1 Update for your use-case.


Thanks for the ontology.

I took a look at this and can reproduce the problems you describe. Unfortunately, I cannot spot the immediate source of the bug. I will try to find the source of the problem this week and generate a patch release.

Martin

On May 14, 2017, at 3:43 PM, Aya Hamdy <[hidden email]> wrote:

I have the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2. 

The problem is that this is all the error says. I have taken a screenshot attached as 11.PNG; no further explanation is provided.

The current version of the ontology which I am testing this on is attached as connectedvehicle.owl . 

Thank you and Best Regards,
Aya

On Sun, May 14, 2017 at 10:32 PM, Martin O'Connor <[hidden email]> wrote:

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


<11.PNG><connectedvehicle.owl>_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
aya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calculating average yields no result

aya
Thank you guys I will give sparql a shot then. Your suggestion is much appreciated :D 

On May 15, 2017 12:31 PM, "Biswanath Dutta" <[hidden email]> wrote:


@Aya, yes, I agree with Lorenz. I think SPARQL 1.1 is a possible answer to your problem. In your case, at least the one you expressed, the rule is not required. 

On Mon, May 15, 2017 at 12:49 PM, Lorenz B. <[hidden email]> wrote:
@Aya

You should use SPARQL 1.1 Update for your use-case.


Thanks for the ontology.

I took a look at this and can reproduce the problems you describe. Unfortunately, I cannot spot the immediate source of the bug. I will try to find the source of the problem this week and generate a patch release.

Martin

On May 14, 2017, at 3:43 PM, Aya Hamdy <[hidden email]> wrote:

I have the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2. 

The problem is that this is all the error says. I have taken a screenshot attached as 11.PNG; no further explanation is provided.

The current version of the ontology which I am testing this on is attached as connectedvehicle.owl . 

Thank you and Best Regards,
Aya

On Sun, May 14, 2017 at 10:32 PM, Martin O'Connor <[hidden email]> wrote:

Can you post the full exception. 

(Also make sure you are running the latest 2.0.0 version of the SWRLTab plugin in Protege 5.2).

Also post the ontology if possible.

Martin

On May 14, 2017, at 3:29 PM, Aya Hamdy <[hidden email]> wrote:

ok! Thank you so much. 

I tried your suggestion, running the query incrementally by adding atoms. The run goes smoothly up until I add the ˚ sqwrl:makeBag(?b, ?vs) ˚ sqwrl:avg(?avg, ?b) and try to select ?avg. When I try to select ?avg Protege initiates a message :

Exception when running SQWRL query AA: error running SQWRL queries: error running Drools rule engine

(Sometimes it gives me the above exception and sometimes it says that SQWRL query AA did not generate any result. I don't get it) 


If I do not include ?avg in the sqwrl:select, nothing happens: No error is generated, and of course no column for ?avg is added either in the output. I tried to use sqwrl:size(?size,?b)  to check the size of the bag also because I suspected that may be the makeBag operator is the issue, but the same thing happened with ?size added in the select as with ?avg. 


Also, when the exception message appears, all the other queries which work properly refuse to run and give me the same exception. 

Do you have any insights on the source of the error? I cannot find an explanation on google.


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


<11.PNG><connectedvehicle.owl>_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user



_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Loading...