Michael, keep in mind that SPIN rules are defined on a class and executed for each instance, pre-binding the instance to the SPIN-reserved variable ?this.  Therefore your query should be written as defined (assuming it is defined in the spin:rule property of :Task):

     CONSTRUCT {
        ?this :suitableTool ?tool .
    }
    WHERE {
        ?this :numRestrictions ?x .
        {
            SELECT ?tool ((COUNT(?constraint)) AS ?fulfilled)
            WHERE {
                ?this :hasConstraintRestriction ?constraint .
                ?constraint :fulfilledby ?tool .
            }
            GROUP BY ?tool
            HAVING (?fulfilled > ?x)
        } .
    }

...give that a try first.  From the description, it may just be a matter of placing the query on the wrong class. 

-- Scott

On 1/21/2014, 8:09 AM, Michael B. wrote:
Hi everyone!

I've got a weird case here. I am trying to use SPIN rules to match tools and tasks. Each my:Task has a set of owl:Restriction instances. A set of spin rules tries to find tools that fulfil specific requirements. I then would like to use another SPIN rule to find tools that fulfil ALL the requirements of a task.

I came up with something like this:

CONSTRUCT {
    ?task :suitableTool ?tool .
}
WHERE {
?task a :Task.
    ?task :numRestrictions ?x .
    {
        SELECT ?tool ((COUNT(?constraint)) AS ?fulfilled)
        WHERE {
            ?task :hasConstraintRestriction ?constraint .
            ?constraint :fulfilledby ?tool .
        }
        GROUP BY ?tool
    } .
    FILTER (?fulfilled > ?x) .
}

Since it's quite hard to compare two sets, I'm going with counts here...

In the SPARQL view, I'm getting a nice table of
X suitableTool B.
X suitableTool C.
Y suitableTool C.

When I add this to the spin:rule section of my Task class (I tried Thing as well), nothing happens. 

The numRestrictions property is filled by a SPIN rule as well:

CONSTRUCT {
    ?this :numRestrictions ?count .
}
WHERE {
    {
        SELECT ?this ((COUNT(?res)) AS ?count)
        WHERE {
            ?this :hasConstraintRestriction ?res .
        }
        GROUP BY ?this
    } .
}

Is it possible that the order in which the rules are executed causes the property to "disappear" (shouldn't incremental reasoning prevent this?) during the reasoning?

Regards,
Michael 
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to