Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] Finding Maximum of Sum

Martin O'Connor martin.oconnor at stanford.edu
Fri Jul 23 11:38:04 PDT 2010


Firstly, you should be using a bag here [1], not a set. Sets do not 
allow duplicate elements so the sum operator will not work as expected.

Person(?p) ^ unterrichtet_Vorlesung(?p, ?m) ^ AnzahlSWS(?m, ?a)  ˚
sqwrl:makeBag(?b, ?a) ^ sqwrl:groupBy(?b, ?p) ˚
sqwrl:sum(?sum, ?b) ^ swrlb:lessThan(?sum, 16) → sqwrl:select(?sum, ?p)

You can use the core aggregate operators in the consequent to get the 
maximum sum:

Person(?p) ^ unterrichtet_Vorlesung(?p, ?m) ^ AnzahlSWS(?m, ?a)  ˚
sqwrl:makeBag(?b, ?a) ^ sqwrl:groupBy(?b, ?p) ˚
sqwrl:sum(?sum, ?b) → sqwrl:max(?sum)

You can not cascade collections in the way that you are attempting. All 
collection construction operators must be in the connection construction 
clause [2] (between the two ˚s).

If you want the maximum sum and the person you will need to get a little 
creative:

Person(?p) ^ unterrichtet_Vorlesung(?p, ?m) ^ AnzahlSWS(?m, ?a)  ˚
sqwrl:makeBag(?b, ?a) ^ sqwrl:groupBy(?b, ?p) ˚
sqwrl:sum(?sum, ?b) →
sqwrl:select(?sum, ?p) ^ sqwrl:orderByDescending(?sum) ^ sqwrl:firstN(1)

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?CollectionsSQWRL#nidB8S
[2] http://protege.cim3.net/cgi-bin/wiki.pl?CollectionsSQWRL#nidB91

Hakan BULU wrote:
> Hi all,
>  
> from Thomas's mail we have a SWRL rule;
>  
> Person(?p) ^ unterrichtet_Vorlesung(?p, ?m) ^ AnzahlSWS(?m, ?a)  ˚
> sqwrl:makeSet(?s, ?a) ^ sqwrl:groupBy(?s, ?p) ˚
> sqwrl:sum(?sum, ?s)  ^ swrlb:lessThan(?sum, 16)   → sqwrl:select(?sum, ?p)
>  
> i have a rule similar this one. and i'm trying to find maximum ?sum value.
>  
> while trying to sqwrl:makeSet(?set,?sum) ,  i get following exeption: 
> makeSet in rule Rule-3 returned with unbound arguments.
>  
> also sqwrl:max(?max,?sum) is not working, because atom needs a collection.
>  
> best regards...
>
>
> -- 
> Hakan BULU
> Ph.D. student in Dokuz Eylul University
> Department of Computer Engineering
> TURKEY
> +90 232 412 79 73
> +90 536 248 49 10
> ------------------------------------------------------------------------
>
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>   




More information about the protege-owl mailing list