Presentation is loading. Please wait.

Presentation is loading. Please wait.

Service-Oriented Computing: Semantics, Processes, Agents

Similar presentations


Presentation on theme: "Service-Oriented Computing: Semantics, Processes, Agents"— Presentation transcript:

1 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Aplicatii Web bazate pe semantica, agenti si servicii Universitatea Politehnica Bucuresti Anul universitar , Master Adina Magda Florea © Singh & Huhns

2 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Reguli de productie Avantaje ale regulilor Tipuri de reguli Sisteme bazate pe reguli Web Rule Languages © Singh & Huhns

3 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 1. Reguli - avantaje Avantaje Cunostinte procedurale in maniera declarativa Permit atasare procedurala Se pot combina cu ontologiile: derivare concepte Modelarea proceselor, inclusiv a celor de business Exprimarea protocoalelor de business Exprimarea conditiilor de exceptie © Singh & Huhns

4 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 De ce ne intereseaza? Utilizate de agenti pentru a descrie comportarea Utilizate ca specificare a compunerii serviciilor Utilizate in modelarea proceselor de business © Singh & Huhns

5 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 2. Tipuri de reguli Reguli reactive – forma ECA on eveniment if conditie then (executa) actiune Utilizare triggers in SMBD codificarea proceselor (si apoi compunerea lor) detectarea exceptiilor + ce se face reguli de integritate In practica se vor combina cu regulile de inferenta © Singh & Huhns

6 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Tipuri de reguli Reguli de inferenta if anecedent then consecinta Antecedent: conjunctie de clauze Se permit si disjunctii de clauze caci se pot transforma in mai multe reguli Concesinta: conjunctie de clauze Nu se permit disjunctii Fapte © Singh & Huhns

7 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Exemplu (deftemplate person (slot first_name) (slot last_name) (slot age (type INTEGER)) ) (defrule eighteen_pers (person (first_name ?first_n) (age ?p_age)) (test (== ?p_age 18))) => (assert (eighteen_p (name ?first_n))) ) © Singh & Huhns

8 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Alt exemplu (deftemplate room (slot nember) (slot capacity (type INTEGER)(default 4)) (slot sexes_are) (slot vacancies (type INTEGER)) (multislot occupants)) (deftemplate student (slot name) (slot sex) (slot placed_in) (slot special_considerations (default no)) (defrule assign-student-empty-room ?unplaced_student  (student (name ?stud_name) (placed_in nil) (sex ?gender)) ?empty_room  (room (number ?room_no) (capacity ?room_cap) (vacancies ?max_size)) => (modify ?unplaced_student (placed_in ?room_no)) (modify ?empty_room (occupants ?stud_name) (sexes_are ?gender) (vacancies (-- ?max_size)) ) © Singh & Huhns

9 Inlantuirea regulilor
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Inlantuirea regulilor Inlantuire inainte (forward chaining) Inlantuire inapoi (backward chaining) © Singh & Huhns

10 3. Sisteme bazate pe reguli
Service-Oriented Computing: Semantics, Processes, Agents August 2004 3. Sisteme bazate pe reguli Ciclul recunoastere-actiune: Match Select Act WME = working memory element Identificat printr-un "time tag" Instantiere: multime de WME care satisface o regula Multime de conflicte (CS) Rezolvarea conflictelor © Singh & Huhns

11 Ciclul recunoastere-actiune
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Ciclul recunoastere-actiune Rule Base Working Memory Rules . WMEs . Facts Match Act Instantiations . 1 Instantiation Conflict set Conflict resolution © Singh & Huhns

12 Ciclul recunoastere-actiune
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Ciclul recunoastere-actiune Match O regula se poate aplica daca conditiile din antecedent sunt satisfacute de WMEs din WM Procesul are 2 aspecte: match intra-element match inter-element (defrule teenager (person (firstName ?name) (age ?age)) => (printout t ?name " is " ?age " years old." crlf)) © Singh & Huhns

13 Ciclul recunoastere-actiune
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Ciclul recunoastere-actiune match inter-element (defrule assign-private-room (student (name ?stud_name) (placed_in nil) (special_consideration yes)) (room (number ?room_no) (capacity 1) (vacancies 1) => … Instantiations (CS) assign-private-room 41 9 assign-private-room 41 17 assign-private-room 52 9 assign-private-room 52 17 WMEs 41 (student name Mary sex F placed_in nil special_consideration yes) 52 (student name Peter sex M placed_in nil 9 (room number 221 capacity 1 vacancies 1) 12 (room number 346 capacity 2 vacancies 1) 17 (room number 761 capacity 1 vacancies 1) © Singh & Huhns

14 Rezolvarea conflictelor
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Rezolvarea conflictelor Diferite strategii Refractie = o aceeasi instantiere nu este executata de mai multe ori (2 instantieri sunt la fel daca au acelasi nume de regula si aceleasi time tags, in aceeasi ordine) Momentu utilizarii = Se prefera instantierile care au identificat cu WMEs cu cele mai recente time tags sau invers Specificitate = Au prioritate instantierile cu LHS mai specifice = nr de valori testate in LHS teste asupra: nume clasa, predicat cu 1 arg constanta, predicat cu un operator variabila legata © Singh & Huhns

15 Rezolvarea conflictelor
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Rezolvarea conflictelor Strategia LEX Elimina din CS instantierile care au fost deja executate Ordoneaza instantierile pe baza momentului utilizarii Daca mai multe instantieri au aceleasi time tags, utilizeaza specificitate Daca mai multe instantieri au aceeasi specificitate alege arbitrar Strategia MEA – aceeasi dar utilizeaza primul time tag © Singh & Huhns

16 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Eficienta executiei Match – cam 80% din timpul ciclului recunoastere-actiune Fiecare WME este comparat cu fiecare conditie din fiecare regula O(R*FP), R – nr de reguli, P nr mediu de conditii in LHS regula, F – nr WME RETE match algorithm – OPS5 Salveaza starea de match intre 2 cicluri recunoastere-actiune La crearea unui WME, acesta este comparat cu toate elementele conditie din program si este memorat impreuna cu fiecare element conditie cu care a identificat => Numai schimbarile incrementale din WM sunt identificate in fiecare ciclu O(R*F*P) aprox © Singh & Huhns

17 Service-Oriented Computing: Semantics, Processes, Agents
Compilarea regulilor August 2004 Se compileaza conditiile regulilor intr-o retea de noduri de test Un test este un predicat cu o constanta sau variabila legata sau o disjunctie Procesul de match are loc numai la adaugarea sau la eliminarea unui WME (modify este retract urmat de assert) (gate (type or) (value true)) (gate (type or) (value false)) Node sharing 1 = gate type = or value = true value = false © Singh & Huhns

18 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Compilarea regulilor Un pointer la noul WME este trecut prin retea, incepand de la nodul radacina Fiecare nod actioneaza ca un switch Cand un nod primeste un pointer la un WME, testeaza WME asociat. Daca testul reuseste, nodul se deschide si WME trece mai departe Altfel nu se intampla nimic Daca un WME va trece prin retea, va fi combinat cu alte WME care trec pentru a forma o instantiere in CS Pointerii la WME sunt trimisi prin reteaua RETE ca tokens = pointer + stare (assert sau retract) © Singh & Huhns

19 Tipuri de noduri in retea
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Tipuri de noduri in retea Nod cu 1 intrare = test intra-element realizat de noduri cu 1 intrare feicare nod efectueaza un test corespunzator unei conditii Testarea aceleiasi variabile – tot noduri cu 1 intrare 1 = gate type = or value = true value = false © Singh & Huhns

20 Sisteme bazate pe reguli
Service-Oriented Computing: Semantics, Processes, Agents August 2004 Sisteme bazate pe reguli Foarte multe cele mai influente OPS5 ART CLIPS Jess Familia Web Rule languages In special RuleML si SWRL Interoperabilitatea regulilor © Singh & Huhns

21 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML RuleML Initiative - August 2000 Pacific Rim International Conference on Artificial Intelligence. RuleML Initiative dezvolta limbaje bazate pe reguli deschise XML/RDF Aceasta permite schimbul de reguli intre diferite sisteme, inclusiv componete software distribuite pe Web si sisteme client-server eterogene Limbajul RuleML – sintaxa XML pentru reprezentarea cunostintelor sub forma de reguli Integrarea cu ontologii: sistemul de reguli trebuie sa deriveze/utilizeze cunostinte din ontologie © Singh & Huhns

22 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML RuleML – se bazeaza pe Datalog Datalog = limbaj de interogare si reguli pentru baze de date deductive Subset al Prolog cu restrictii: argumente ne-functionale (constante sau variabile) limitari in nivelul de apeluri recursive variabilele din concluzie trebuie sa apara in predicate ne-negate din ipoteza Hornlog – Datalog extins cu variabile functionale (termeni generali) © Singh & Huhns

23 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML Reguli reactive = Observa/verifica anumite evenimente/conditii si executa o actiune – numai forward Constrangeri de integritate = reguli speciale care semnaleaza inconistente cand se indeplinesc anumite conditii – numai forward Reguli de inferenta (derivare) = reguli reactive speciale cu actiuni care adauga o concluzie daca conditiile (premisele sunt adevarate) - Se pot aplica atat forward cat si backward Fapte = reguli de inferenta particulare cu premise Regui reactive Constangeri de integritate Reguli de derivare Fapte © Singh & Huhns

24 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML Reguli reactive <rule> <_body> <and> prem1 ... premN </and> </_body> <_head> action </_head> </rule> Constrangeri de integritate <ic> <_head> inconsistency </_head> <_body> <and> prem1 ... premN </and> </_body> </ic> implementate ca <_head> <signal> inconsistency </signal> </_head> © Singh & Huhns

25 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML Reguli de inferenta/derivare <imp> <_head> conc </_head> <_body> <and> prem1 ... premN </and> </_body> </imp > implementate prin <rule> <_body> <and> prem1 ... premN </and> </_body> <_head> <assert> conc </assert> </_head> </rule> Fapte <atom> <_head> conc </_head> </atom> <imp> <_head> conc </_head> <_body> <and> </and> </_body> </imp> © Singh & Huhns

26 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 RuleML Fapte <atom> <rel>spending</rel> <ind>Peter Miller</ind> <ind>min 5000 euro</ind> <ind>previous year</ind> </atom> spending(petterMiller, min5000euro, previousYear). © Singh & Huhns

27 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Reguli de inferenta/derivare <imp> <head> <atom> <rel>discount</rel> <var>customer</var> <var>product</var> <ind>7.5 percent</ind> </atom> </head> <body> <and> <atom> <rel>premium</rel> <rel>luxury</rel> </and> </body> </imp> discount(Customer, Product, 7.5_percent):- premium(Customer), luxury(Product). © Singh & Huhns

28 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 SWRL SWRL = Semantic Web Rule Language Propunere W3C in 2004 Combina OWL DL si OWL Lite cu RuleML Regulile sunt exprimate in termenii conceptelor OWL (classe, proprietati, indivizi, …). SWRL – sintaxa abstracta pt "Horn-like rules" Regulile sunt salvate ca parte a ontologiei Implementari in: Bossam, R2ML, Hoolet, Pellet, KAON2, RacerPro, SWRLTab © Singh & Huhns

29 Service-Oriented Computing: Semantics, Processes, Agents
hasParent(?x, ?y) ^ hasBrother(?y, ?z) -> hasUncle(?x, ?z) <ruleml:imp> <ruleml:_rlab ruleml:href="#example1"/> <ruleml:_body> <swrlx:individualPropertyAtom swrlx:property="hasParent"> <ruleml:var>x</ruleml:var> <ruleml:var>y</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property="hasBrother"> <ruleml:var>z</ruleml:var> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property="hasUncle"> </ruleml:_head> </ruleml:imp> SWRL August 2004 © Singh & Huhns

30 Service-Oriented Computing: Semantics, Processes, Agents
August 2004 Editorul SWRL Editorul SWRL – extensie a Protegé OWL care permite editarea de reguli SWRL; Inclus in Protégé OWL Accesibil ca un tab Ofera un Java API pentru interoperabilitate cu motoare de inferenta © Singh & Huhns

31

32

33

34 Verificari ale editorului
Numai regulile sintactic valide sunt salvate si care se leaga de entitati OWL Se face o verificare semantica de baza:orice variabila referita in concluzie trebuie sa fie referita si in ipoteza Cu toate acestea, regulile pot contrazice restrictiile din ontolgia OWL

35 Cum se salveaza regulile
Regulile sunt salvate ca indivizi OWL Clasele care descriu acesti indivizi se gasesc in ontologia SWRL Aceste clase includ: swrl:Imp – reprezinta o regula SWRL swrl:Atom – reprezinta un atom in regula swrl:AtomList – reprezinta o lista de atomi Motoare de inferenta bazate pe reguli pot folosi aceste reguli

36 Interactiunea cu reguli in Protege
Prin fisiere – regulile SWRL sunt salvate in format standard SWRL API – crearea si manipularea regulilor SWRL Utilizata de editorul SWRL Accesibila dezvoltatorilor Se pot adauga motoare de inferenta; de ex Jess

37 Interactiunea cu MI Extrage cunostintele OWL relevante pentru inferente Nu toate cunostintele trebuie extrase Cunostintele necesare pot fi determinate din fiecare regula Exemplu: Man(Fred) ^ Man(?y) ^ hasParent(Fred, ?y) ^ hasBrother(?y,?z) -> hasUncle(Fred, ?z) necesita: Individul Fred Toti indivizii din clasa Man si subclase Proprietatile hasProperty ale lui Fred si toate sub-proprietatile acestora Toti indivizii cu proprietatea hasBrother si sub-proprietati asociate

38

39

40

41

42


Download ppt "Service-Oriented Computing: Semantics, Processes, Agents"

Similar presentations


Ads by Google