Practicum agenttechno 1 - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Practicum agenttechno 1

Description:

meth inc(Value) val := _at_val Value. end. meth init(Value) val := Value. end ... make list with flights and add to database %Book until all flights are sold out ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 27
Provided by: BART194
Category:

less

Transcript and Presenter's Notes

Title: Practicum agenttechno 1


1
Practicum agent-techno 1
  • Introduction to mozart-oz

2
Installation
  • www.mozart-oz.org -gtdownload 1.3.0
  • Mozart is editor for Oz language
  • Learn to use Emacs and keybindings
  • C-x Control x
  • C-x h Control x h
  • M-x Meta x or Alt x
  • ...

3
advantages
  • Oz language
  • Concurrency ultralightweight threads, dataflow
  • Inferencing constraint and logic programming,
    well factored
  • Distribution network transparent, open, fault
    tolerant
  • Graphical user interfaces dynamic, adaptable

4
Concurrency
  • Lightweight threads
  • More than 100000 active threads on standard PC
  • Create a thread whenever the design requires it
  • Dataflow synchronization
  • Declarative deterministic!!
  • stateless
    programming
  • Message-passing (asynchronous)

5
Inferencing
  • Constraint programming
  • Logic programming

6
Distribution
  • Stateless entities simple values, records,
  • lists, chunks, procedures, ...
  • Single assignment logic variables
  • Stateful entities
  • Ports efficient message-passing primitive
  • Cells efficient migratable entity, but not
    robust
  • Objects combination of procedures and cells
  • Complex stateful entities have no distributed
  • behavior dictionaries, arrays, ...

7
Examples
  • Hello World
  • Browse Hello World
  • Declaration of variables
  • declare Foo
  • Or
  • local
  • Foo
  • in
  • ltblablablagt
  • end

8
Procedures/functions
  • procName A1 A2 ?A3
  • Browse A1 A2 A3
  • A3 A1A2
  • end
  • Foo Name 1 3
  • funName A1 A2 A3
  • procName A1 A2 ?A3

9
Classes
  • class Counter    attr val feat
    DontChangeAFeature donttouchme
  •    meth browse       Browse _at_val   end    
    meth inc(Value)      val  _at_val  Value   end 
       meth init(Value)      val  Value   end end

10
Watch out
  • declare
  • procX K G
  • Browse K G
  • case G of K then
  • Browse 'G ' G
  • Browse 'K ' K
  • else
  • skip
  • end
  • Browse 'G ' G
  • Browse 'K ' K
  • end

11
Thread
  • thread
  • do smthng
  • end

12
RTFM
  • TFM
  • http//www.mozart-oz.org/documentation/index.html

13
Exc 1
  • Write a program to count all numbers between 1
    and 10
  • E.g. Browse 12345678910
  • (try something else)

14
Solutions
  • With Lists List.number
  • With recurrent procedure
  • With class and attribute
  • With a Cell
  • Others...?

15
Exc 2
  • Producer-consumer
  • Producers makes 100000 kias
  • Consumer buys kia when its available

16
Solution
  • funProducer ......kiaProducer ... ...end
  • procConsumer Ls
  • Case Ls of kiaLr then buy kia...end
  • Consumer Lr
  • end
  • Not Consumer Producer ...
  • ButConsumer thread Producer... end

17
Use of functors
  • functor
  • import ...
  • export fooBarFooBar...
  • define...procFooBar...end
  • Save as Foo.oz
  • cmd ozc -c Foo.oz
  • Start new ozFile
  • Foo Module.link Foo.oz at
  • x-ozlib//blabla/Foo.ozf
  • Foo.fooBar
  • Or Foo(fooBarFooBar...) ...
  • FooBar

18
There we go
  • Build a flight booking system
  • 1 Data base server from, to, price
  • DB.ozf
  • 2 Graphical flight booking form choose a
    flight, enter name, email,...
  • Form.ozf
  • 3 Main component manages user requests to data
    base and sets up the application
  • LMF.oza

19
Data Base DB.oz
  • functor
  • export
  • add Add
  • get Get
  • getAll GetAll
  • remove Remove
  • ltBody for DB.ozgt
  • end

20
ltBody for DB.ozgt
  • define
  • Data Dictionary.new
  • proc Add X
  • I in
  • I List.length Dictionary.items Data1
  • Dictionary.put Data I X
  • end
  • proc Get ID
  • .....
  • end

21
Form.oz
  • functor import    Tkexport    Bookdefine    
    proc Book Fs ?Get       Takes a list of flight
    s and returns the booked flight       and inform
    ation on the booking user      ltImplementation
    of Bookgt    end end 

22
ltImplementation of Bookgt 
  • T New Tk.toplevel tkInit
  • F1 New Tk.frame tkInit(parentT)
  • V New Tk.variable tkInit(Fs.1.key)
  • Tk.batch
  • grid(b(Map '' 'From' 'To' 'Price'
  • fun A
  • New Tk.label tkInit(parentF1 textA
  • reliefraised bd1)
  • end)
  • padx1 pady1 stickyew)
  • Map Fs
  • fun F
  • grid(New Tk.radiobutton tkInit(parentF1
    varV
  • valueF.key)
  • b(Map 'from' to price
  • fun A
  • New Tk.label tkInit(parentF1 textF.A)
  • end))
  • end

23
  • F2New Tk.frame tkInit(parentT)
  • FN LN EM
  • Map 'First name' 'Last name' 'E-Mail'
  • fun S
  • ENew Tk.entry tkInit(parentF2 width20
    bgwheat)
  • in
  • Tk.send grid(New Tk.label
  • tkInit(parentF2 textS'' anchorw)
  • E
  • stickyew)
  • fun
  • E tkReturnAtom(get )
  • end
  • end
  • BNew Tk.button
  • tkInit(parentT text'TakeThatFlight'
  • action proc
  • Getform(first FN
  • last LN

24
ltImplementation of Bookgt last part
  • in
  • Tk.send pack(F1 F2 B)

25
The Root Functor LMF.oz
  • import DB Form Application
  • define
  • make list with flights and add to database
  • Book until all flights are sold out
  • Application.exit 0
  • end

26
and finally...
  • in the comand window
  • ozc -c DB.oz
  • ozc -c Form.oz
  • ozc -c LMF.oz -o LMF.oza
  • ozengine LMF.oza
Write a Comment
User Comments (0)
About PowerShow.com