Open Constraint Programming - PowerPoint PPT Presentation

1 / 82
About This Presentation
Title:

Open Constraint Programming

Description:

'A 3-bedroom apartment between 9th to 12th floor, located within 500m radius of ... outcome: Bob and Jill swap their cams; Don is left waiting for buyer ... – PowerPoint PPT presentation

Number of Views:134
Avg rating:3.0/5.0
Slides: 83
Provided by: kenn1
Category:

less

Transcript and Presenter's Notes

Title: Open Constraint Programming


1
Open Constraint Programming
  • Kenny Q. Zhu
  • School of Computing
  • National University of Singapore
  • Email kzhu_at_comp.nus.edu.sg

2
The Challenge
  • Automated programmed agents
  • Cooperation and coordination
  • Reaction to changing environment
  • Shared knowledge
  • Concurrency control
  • Putting them all together Reactive knowledge
    base for interacting agents
  • But how to do it??

3
Outline
  • Introduction to Open Constraint Programming (OCP)
  • Theory
  • Implementation of an OCP system
  • A dynamic index structure for OCP system
  • Key OCP Applications
  • Extending OCP to speculation
  • Future directions

4
Introduction to OCP
  • What is OCP?

5
A Stock Trading System
6
Traders Commands
  • Trader A if price of IBM 50, then sell 100
    shares of IBM
  • Trader B if the price of Dell 2 times the
    price of IBM, then buy 100 shares of IBM and sell
    100 shares of Dell
  • Trader C if the value of my cheap stocks is
    different from my dear stocks by 10, then
    re-balance my portfolio to equalize them

7
The Knowledge Base (KB)
  • Dynamic facts
  • price(ibm, 34).
  • price(dell, 45).
  • cash(ken, 1000).
  • own(ken, ibm, 100).
  • Rules for user bundles/conditions
  • cheap_stock(S) ? price(S, P), P
  • dear_stock(S) ? price(S, P), P100.
  • Rules for actions (updates)
  • buy(User, Stock, Amt) ?
  • own(User, Stock, Old),
  • update(own(User, Stock, Old), own(User, Stock,
    OldAmt)),
  • price(Stock, P),
  • update(cash(User, C), cash(User, C-AmtP)).

8
A GUI for Traders
9
http//www.tradestation.com
10
TradeStation allows traders to design, test, and
execute active rules based on hundreds of
parameters and conditions by using the
EasyLanguage
11
(No Transcript)
12
OCP Can Do All That andMUCH MORE!
13
The OCP Framework
  • A complex updateable knowledge base that
    represents facts, rules and constraints (the
    world)
  • A reactive programming paradigm involving the use
    of reactors which are program fragments
    embedded in autonomous agent programs, to react
    to, synchronize with and update the knowledge
    base
  • A runtime system that supports efficient
    scheduling of the reactors

14
The OCP Framework (pictorial view)
15
OCP is more powerful because
  • The KB allows sophisticated waiting conditions,
    bundles, actions
  • Reactor language has rich features such as
    conditional actions, parallel computation,
    choices and loops
  • Advanced triggering permits the concurrency
    control of large number of reactive commands

16
Why O.C.P.?
  • Open
  • any number of agents can interact with the center
    KB and possibly update the KB
  • Constraints
  • highly structured shared data realized by
    constraints and logic, as well as basic facts
  • Programming
  • both the agents and the KB are highly programmable

17
OCP is
  • A shared memory computing framework
  • A concurrent reactive programming paradigm
  • A coordination language
  • An architecture for multi-agent system
  • A reactive database

18
Theory
  • Knowledge base
  • Reactor language

19
Knowledge Base and Updates
  • Consists of a number of logical predicates such
    as dynamic facts and rules.
  • Update (d) to KB usually insert, delete of a
    predicate or combination of both
  • Changes the state of KB

20
Knowledge Base
  • Example (Constraint Logic Database)
  • good_stock(X) ? price(X, P), 1P10,
  • volume(X, V), V1000.
  • price(ibm, 10).
  • price(dell, 6).
  • volume(dell, 2000).
  • Implied by the database
  • good_stock(dell) is true
  • What happens if we insert volume(ibm, 4000) ?
  • Implied by the database
  • good_stock(dell).
  • good_stock(ibm).

21
Reactor Language
22
Reactors
  • Example (Trader B)
  • Example (Loop and choice)

23
Implementation
  • Programming OCP agents
  • OCP runtime system architecture

24
Programming OCP Agents
  • Python as one possible agent language
  • Reduced set of reactor constructs in a library
  • atomic updates ocp_rb(X, p), ocp_wb(p),
    ocp_ub(p1, p2), etc.
  • sustain sustain(c) r desustain()
  • choice multiple processes with unique choice id
  • transaction ocp_run(r)
  • Other reactor features are programmed in the
    agent language
  • Primitive reactor (condition ? action, choiceid)

25
Reactor Invocation
Invoke stage
Return stage
26
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Wakeup list
Trigger Unit
CLP(R) System
Index Structure
Queries/ Updates
Return
Output Queue
27
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Return
Output Queue
28
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Update
Return
Output Queue
29
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Return
Output Queue
30
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Query
Return
Output Queue
31
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Return
Output Queue
32
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Update
Return
Output Queue
33
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Return
Output Queue
34
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Wakeup list
Trigger Unit
CLP(R) System
Index Structure
Query
Return
Output Queue
35
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Return
Output Queue
36
OCP Runtime System Architecture
Blocked reactors
Input Queue
Invoke
Reception Unit
Trigger Unit
CLP(R) System
Index Structure
Query
Return
Output Queue
37
Triggering
  • Premise every update d affects a small fraction
    of blocked reactors
  • Need to efficiently index the blocking conditions
  • Conditions are indexible objects
  • Updates (changing the KB) give point queries
  • What is this index like?

38
RC-tree
  • A new spatial index structure for OCP

39
Motivating Examples
  • Property purchase
  • A 3-bedroom apartment between 9th to 12th floor,
    located within 500m radius of the MRT station and
    along the river bank
  • Stock portfolio balancing
  • In my portfolio, the combined value of stock A
    and stock B being less than or equal to two times
    that of stock C and stock D

40
What are we indexing?
  • Conjunctions of linear constraints, e.g.
  • Abstract regions of interest or shapes
  • Multi-dimensional spatial objects
  • May overlap each other

41
Existing Techniques
  • GIS applications usually rigid objects with no
    overlapping
  • Minimum Bounding Rectangles (MBR) approximations
  • Manual segmentation into smaller boxes (consider
    a freeway!)
  • Segmentation either too coarse (dead space) or
    too fine (space and time cost)

42
Highways in Germany (segmentation)
43
Existing Techniques
  • MBR-based indices
  • R-tree, R-tree, R-tree, etc
  • Point-based indices
  • Kd-tree, quad-tree, etc
  • Centroids-based spatial indices
  • Skd-tree, Matsuyamas kd-tree
  • None of them handles approximation and
    segmentation of objects dynamically!

44
What is RC-tree?
  • Reducible Clip-tree
  • A general weight-balanced binary tree for dynamic
    search and update of k-dimensional spatial
    objects
  • Designed for main-memory use
  • Intermediate nodes space-partitioning
    hyper-planes as discriminators
  • Leaf nodes (overflow nodes) indexed objects
  • Objects that intersects with the discriminators
    are clipped and domain-reduced

45
Clipping and Domain Reduction
  • A Original objects
  • B MBR-based indexing
  • C RC-tree with discriminators d1, d2, and d3

46
Benefits of Domain Reduction
47
Weight-balancing
TL
TR
  • RC-tree T is a-balanced if
  • Partial rebuilding
  • Balancing condition is checked per insertion
  • Extract all objects from sub-tree and re-pack
  • Packing a subtree involves inserting and
    splitting

w1
w2
48
Spacing Factor
  • Spacing factor s is the largest ratio of the
    largest extent of an object to the smallest
    extent of an object in any given dimension

49
Main Results
  • Assuming bounded spacing factor s and fixed
    dimensionality k, given n spatial objects
  • Amortized insertion cost log(n)
  • Amortized query cost log(n)
  • Worst case space linear

50
Search cost GIS data
51
Search cost synthetic data (log scale)
52
Space usage GIS data
53
Hit rates (negative log scale)
54
Insertion cost vs. log(n)
55
Query cost vs. log(n)
56
Summary of RC-tree
  • RC-tree performs orders of magnitude better in
    search than existing MBR-based spatial index
  • Revives the research on clip-based indexing
    techniques
  • Very useful in both GIS and abstract shape
    indexing applications such as stock trading
    system, online property rental system, purchasing
    database, etc.

57
Applications Multi-Agent Systems
  • E-marketplace
  • Intelligent transportation
  • Distributed simulation
  • Coordination

58
E-marketplace (flight booking system)
  • Dynamic facts
  • flight(newyork, singapore, 2).
  • flight(memphis, los_angeles, 1).
  • flight(los_angeles, singapore, 0).
  • flight(singapore, capetown, 2).
  • Rules
  • connected_flight(A, B) - flight(A, B, Seats),
    Seats0.
  • connected_flight(A, B) - flight(A, C, Seats),
    Seats0,
  • connected_flight(C,
    B).
  • roundtrip(A, B) - connected_flight(A, B),
  • connected_flight(B, A).

59
E-marketplace (flight booking system)
  • More rules (actions)
  • booktrip(A, B) - oneway(A, B), oneway(B, A).
  • oneway(A, B) - flight(A, B), book(A, B).
  • oneway(A, B) - flight(A, C), book(A, C),
  • oneway(C, B).
  • John wants to travel from Memphis, TN to either
    Cape town, SA or Sydney, AU

60
Business Relevance
  • Provide a platform for e-business modeling,
    strategies building, game theories (possible
    collaboration with School of business and School
    of economics and social sciences)
  • Establish relationship with industry players such
    as e-Bay, Singapore stock exchange, Singapore
    airlines, etc to build real marketplaces or
    trading systems for automated, reactive business
    transactions

61
Intelligent Transportation Systems
  • Facts vehicle positions, time constraints,
    capacity, origins, destinations, the terrain,
    obstacles, traffic conditions, etc.
  • Rules movements, strategies, optimization such
    as shortest-path problems
  • Agents System display, environment setting,
    vehicles, vendors, customers, controllers

62
Business Relevance
  • Study vehicle routing problems, resource
    allocation problems and other transportation
    problem in a dynamic, reactive setting
  • Build a real-time transportation system reactive
    to dynamic customer demands, traffic conditions
    (possible collaboration with FedEx, DHL)
  • A centralized automated taxi routing system that
    reacts to passenger calls, possible route sharing
    requests Shanghai taxi companies could be
    interested!

63
Distributed Simulation (pick-a-mushroom)
Green Team nearest mushrooms Blue Team
largest mushrooms
64
Security Relevance
  • Our nations security
  • A platform for war-game simulation (Our previous
    contact with Ministry of Defense )
  • Advanced triggering and distributed agent setting
    allows massive data and processing not possible
    to MINDEF before

65
Coordinated Problem Solving
  • Solve a set of decision variables X0, X1, , Xn
    subject to a system of constraints
  • KB is a set of sub-problems (sub-trees), and
    partial solutions
  • Master agent generates sub-problems and gives out
    sub-problems to workers
  • Worker agent solves a sub-problem, posts the
    solution back to the KB, and asks for a new job

66
Business Scientific Relevance
  • Study the interplay of reactivity and cooperation
    and coordination in business
  • Build a distributed, Internet-based scientific
    computing platform for scientists and economists
    to solve their hard problems
  • Use OCP in workflow management, university
    courses timetabling, solving resource allocation
    problem

67
Speculative Reaction
  • Extending OCP to speculation

68
The Camera Example
  • Online second hand goods marketplace
  • Bob
  • sell old camera and buy a better camera, or
  • sell old lens and upgrade to a better lens
  • Jill sell good camera and buy an average camera
  • Don sell good lens

69
The Camera Example
  • A good solution is Bob and Jill swap their
    cameras
  • Cyclic data dependency
  • Deadlocks are prone with such cycles, e.g. what
    if Don sells Bob good lens first?
  • Early choices (r1 r2) dont help
  • How do we prevent deadlocks and achieve a good
    solution?

70
The answer is speculation!
  • Let Bob attempt both of his choices
    simultaneously within speculative computation
  • Two choices live in two independent worlds
    Camera world and Lens world
  • Successful completion in one world terminates the
    other world
  • Final outcome Bob and Jill swap their cams Don
    is left waiting for buyer

71
Speculative Reaction
  • A programming paradigm where a computation can
    have a number of distinct possibilities
  • A new construct
  • Parallel computations (including updates)
  • Requires multiple KBs/worlds
  • Committals in some worlds may eliminate some
    other worlds
  • There is one world left eventually the true
    story!

72
SR-tree
  • Every choice in reactor creates an intermediate
    node
  • Leaf node (world) contains a KB and a set of
    reactors
  • Newly arrived reactors are attached to all leaves
    (worlds)
  • If a choice Cid commits in all leaves of one side
    of a subtree rooted at Cid, then the other side
    of is removed.

73
The Good News Is
  • Prevents deadlock
  • Maximizes the chances of an eventual solution
  • Suitable model for applications involving
    uncertainty, cooperation and competition such as
    e-commerce, finance, workflow

74
The Bad News Is
  • Many worlds
  • Many runtime systems
  • Many copies of running reactors
  • Chances of exponential blow-up of the SR-tree!

75
Optimization Ideas
  • Optimize data storage
  • Redistribute data in the SR-tree
  • Optimize running of reactors
  • Redistribute program continuations in SR-tree
  • Optimize the size of the SR-tree
  • Structure-share parts of the SR-tree

76
Future Directions
  • Research
  • Teaching

77
IS Research Directions
  • Reactivity in business process and workflow
  • Modeling business process and workflow
  • Automated business process and workflow
  • Combinatorial problems in real-time
    transportation and JIT manufacturing
  • E-commerce on grid and peer-to-peer systems
    programming models and infrastructures

78
CS Research Directions
  • Spatial indexing for mobile objects
  • Distributed OCP system
  • Optimization in Speculative Reaction

79
Teaching Philosophy
Generally Educated Person
80
Critical Career Skills for IT
  • Learn self-study, read a book/paper, use the
    library, search for resources on the web
  • Think logical thinking, critical thinking,
    creative thinking, analytical skills, and some
    mathematics
  • Solve problem solving methodologies in IT and
    beyond

81
Teaching Interests
  • Coursework
  • Programming in one standard language (C or Java)
  • Problem solving techniques in IT
  • DBMS
  • E-commerce
  • Knowledge base systems / AI
  • Software engineering
  • Heuristics in problem solving
  • Research supervising
  • UROP
  • Graduate research students

82
The End
Write a Comment
User Comments (0)
About PowerShow.com