980 likes | 1.13k Vues
This overview explores key concepts in distributed AI, focusing on concurrency and communication through various programming paradigms, including Agent-Oriented Programming 3APL and Concurrent Constraint Programming. It examines foundational topics such as mutual exclusion, scheduling, and the principles of communicating sequential processes. By discussing the evolution of these frameworks and their applications in bioinformatics, multi-agent systems, and cognitive robotics, this guide aims to master the complexities of modern computational processes while addressing issues like deadlock and resource management.
E N D
Gedistribueerde AI: Overview • Concurrency - Communicating Sequential Processes - Concurrent Constraint Programming • Agent-Oriented Programming - 3APL
Evolution Mastering Complexity: From Operating Systems (mutual exclusion, scheduling) To Global Computing Bioinformatics Multi-Agent Systems (negotiation, human interactions)
Abstraction Procedures Classes (Objects) Agents (Subjects)
Concurrency Main Features • Communication • Coordination • Real-Time • Non-determinism • Deadlock • Livelock
Founding Fathers • E.W. Dijkstra: - Guarded Command Language - Weakest Precondition Calculus - Semaphores (Mutual Exclusion) • T. Hoare - Hoare Logic - Communicating Sequential Processes (CSP) - Monitors • R. Milner - Calculus of Commincating Systems (CCS) - PI-calculus (mobility) • V. Saraswatt - Concurrent Constraint Programming (CCP)
CSP Process consists of • Internal Computation • Interface - Static (Signature) - Dynamic (Behavior)
A Coffee Machine Events: coffee, thee A machine with buttons (menu) coffee thee
Interfaces in OO Class Stack push pop Events: push(v), pop(v) Behavior: ?
Operational Semantics Labeled Transitions: P Q • P,Q: Processes • =a,b,c,.. , - a,b,c,..: External Events - : Termination - : Internal action
Computation 1 2 3 P1 P2 P2 … • Finite • - successfull termination • - deadlock • Infinite • - fairness (strong, weak)
The STOP-Process The process models inaction STOP STOP
Performing Events a P Event Prefixing: Intuitive meaning: do firstathen P Formally (a P) P a
A Light Bulb on (on (off stop)) (off stop) off on (off stop) stop off
Finite Automata P1 on P0 off stop P1 = on (off stop)) P1=(off stop)
Making Choices(what’s life all about, isn’t it?) Choice Construct Meaning choose aA and continue with P(a) Formally x: A P(x) (with A) (x:AP) P(a) for aA a
Example x : coffee,chocolate P(x) P(coffee) = x : milk,black stop P(chocolate) = x : hot, cold stop
Example (Cont’d) coffee (x : coffee,chocolate P(x)) (x : milk,black stop) stop milk
Example (Cont’d) P0 chocolate P2 coffee hot cold milk P1 stop black
Compound Events Communication Events C.V C: Channel V: Value syntax behavior C!V P C.V (C!V P) P output C?x P(x) C.V (C?x P(x)) P(V) input
Example: A Simple Filter in?x out!op(x) stop in op out
Unix-Shell Scripts ECHO ! “please enter your name” READ ? name ECHO ! “welcome name” stop
Recursion N=P N: name P: process Example: light = on(off light) P Q N=P N Q
The Light Bulb (again) on (on (off light)) (off light) on (off light) light on light P off
The Dining Philospher P=think leftforkrightfork eatP
Cognitive Robotics Sense-Act Cycle Cycle= x: Events Act(x) Act(x) = a(x) Cycle
Deriving Transitions Proof Rules 1 1 P1 Q1 … Pn Qn P Q
Mutual Recursion Example LIGHT=on ON ON=off LIGHT
Counter Example inc dec count(0) = inc count(1) count(n+1) = x:{inc,dec} P(x) P(inc) = count(n+2) P(dec) = count(n)
Computation Graph inc inc inc count(0) count(1) count(2) count(3) … dec dec dec
External Choice Syntax Semantics P Q a P P' P P' a P Q P' Q P Q P'
Fifo Buffer in buffer out B() = in?x B(<x>) B(<v>.s) = in?x B(<x,v>.s) out!v B(s)
Internal Choice Syntax Semantics P Q P Q P
Tossing a Coin Toss = (head Toss) (tail Toss ) toss P head tail Q
Termination SKIP The process indicates successful termination: SKIP STOP
Sequential Composition Syntax Semantics P;Q P P' P P' P ; Q P';Q P ; Q Q
Purchase Purchase=Choose;Pay Select= select (SKIP return Select) Pay= cash receipt SKIP card swipe (receipt sign SKIP reject Pay)
A One-Time Stack A Finite Representation Push = in?x (Push; (out!xSKIP)) pop SKIP
A Computation in.5 Push Push; (out!5 SKIP) Push;(out!3SKIP); (out!5 SKIP) SKIP;(out!3SKIP); (out!5 SKIP) (out!3SKIP); (out!5 SKIP) SKIP; (out!5 SKIP) out!5 SKIP SKIP in.3 pop out.3 out.5
Concurrency Communication: Message Receiver Sender • Synchronous • Asynchronous • Broadcast
Rendez-Vous parameters Callee Caller synchronization suspended method result
Parallel Composition • Interleaving • Synchronization on common actions P | Q
Architecture b a c P Q b b Interface(P) = {a,b} Interface(Q) = {b,c}
Semantics Interleaving Synchronization P P' P || Q P' || Q P P' P Q' P || Q P' || Q '
A Skating Race Syntax A Run start finish1 STOP || start finish2 STOP start start finish1 STOP || start finish2 STOP finish1 finish1 STOP || finish2 STOP finish2 STOP || finish2 STOP STOP || STOP
Modeling a False Start Pi= start finish1 STOP + starti Pi
Interleaving Syntax Semantics P ||| Q P P' P ||| Q P' ||| Q
The Counter Example Revisited Count= inc (dec STOP) ||| Count) dec STOP dec STOP dec (dec STOP) ||| Count STOP ||| Count
Dynamic Process Creation inc Count (dec STOP) ||| Count (dec STOP) ||| (dec STOP) ||| Count inc
A Bag Syntax A computation step Bag Bag = in?x (out!x STOP) ||| Bag) in.3 (out!3 STOP) ||| Bag)
Buffers P= c?x d!x P Q= d?x e!x Q One-place Buffers A Pipeline Synchronization on events: P || Q d.v