Using Artificial Markets to Teach Computer Science Through Trading Robots

Post on 09-Jan-2016

33 views 2 download

Tags:

description

Using Artificial Markets to Teach Computer Science Through Trading Robots. How to get students interested in algorithms, combinatorial optimization and software development. Karl Lieberherr, Northeastern University, Boston. Outline. Specker Derivative Game (SDG) history example, bottom up - PowerPoint PPT Presentation

transcript

SDG Mittagsseminar 1

Using Artificial Markets to Teach Computer Science Through

Trading Robots How to get students interested in

algorithms, combinatorial optimization and software development

Karl Lieberherr, Northeastern University, Boston

SDG Mittagsseminar 2

Outline

• Specker Derivative Game (SDG)– history– example, bottom up– top-down

• derivatives, raw materials, finished products

• Risk analysis for a derivative• Problem reductions – noise elimination• SDG(MAX-SAT): risk analysis using polynomials• Conclusions

SDG Mittagsseminar 3

History• Diplomarbeit with Ernst Specker on two-dimensional automata.• Around 1975: working on non-chronological backtracking for MAX-

SAT for my PhD with Erwin Engeler.• Ernst Specker analyzed MAX-SAT which lead to the Golden Ratio

Result: joint FOCS 79 and JACM 1981 paper. Ideas applicable to MAX-CSP.

• 2006: sabbatical at Novartis reactivated my interest in MAX-SAT.• 2007: Turned Golden Ratio Result into a game SDG(Max)

parameterized by a maximization problem Max.• 2007/2008: Taught SDG to students who had a lot of fun trying to

produce a winning robot.

SDG Mittagsseminar 4

SDG Example

• derivative(CNF{(2,0),(1,1)}, 0.70)

• 4 variables maximum

• would you like to buy it?

• you will get two rights– you will receive a CNF R of the given type.– if you can satisfy fraction q of clauses in R, I

will pay back q to you.

SDG Mittagsseminar 5

CNF{(2,0),(1,1)} raw materials

2: a2: b3: c1: d3: !a !b9: !a !c7: !b !c1: !a !d6: !b !d6: !c !d

2: a3: b1: c8: !a !b6: !b !c

1: a1: b8: !a !b

2: a2: b2: c1: !a !b1: !b !c

SDG Mittagsseminar 6

CNF{(2,0),(1,1)} raw materials,finished products

2: a2: b3: c1: d3: !a !b9: !a !c7: !b !c1: !a !d6: !b !d6: !c !d

2: a3: b1: c8: !a !b6: !b !c

1: a1: b8: !a !b

17/20=0.85

9/10=0.9

35/40 = 0.875

2: a2: b2: c1: !a !b1: !b !c

6/8=0.75

price of 0.7seems fair!?

SDG Mittagsseminar 7

Oops

• Our analysis was not thorough enough!

• 2 kinds of uncertainty:– worst formula?– best assignment?

SDG Mittagsseminar 8

Playing with the weights

x: ax: bx: cx: dy: !a !by: !a !cy: !b !cy: !a !dy: !b !dy: !c !d

x =1, y=1best assignmenta=1, b=0, c=0, d=0: (1+6)/10=7/10=0.7

x = 2, y=1best assignmenta=1, b=1, c=0, d=0: (4+5)/14=9/14=0.64

derivative(CNF{(2,0),(1,1)}, 0.70)LOSS: 0.06

SDG Mittagsseminar 9

The SDG Game: Two high level views

• Financial: Implement trading robots that survive in an artificial derivative market through offering derivatives, and buying and processing derivatives produced by other trading robots.

• Biological: Implement organisms that survive in an artificial world through offering outsourced services, and consuming and processing outsourced services produced by other organisms.

SDG Mittagsseminar 10

Derivative: (pred, p, s) bought by b

• Max is an NP-hard maximization problem with objective function range [0,1].

• Buyer b buys derivative at price p.• Seller s delivers raw material R (instance of Max)

satisfying predicate pred. • Raw material R is finished by buyer with outcome O

of quality q and seller pays q to buyer.• Buyer only buys if she thinks q > p.• Uncertainty for buyer: which raw material R will I

get? Only know the predicate! What is the quality of the solution of Max I can achieve for R?

SDG Mittagsseminar 11

Seller s Buyer b

(pi,p,s)

SDG Mittagsseminar 12

Seller s Buyer b

(p2,0.9,s)

(p1,0.7,s)sold

R

O0.8

O0.8

R

0.7

0.8

Buyer makes profit of 0.8 - 0.7 = 0.1

R satisfies pi

Derivatives

SDG Mittagsseminar 13

Artificial markets

• Trading Robots that survive in a virtual world of an artificial market of financial derivatives. – Trading Robots that don’t follow the world rules don’t

survive.– Trading Robots are ranked based on their bank

account.– Teaches students about problem solving, software

development and analyzing and approximating combinatorial maximization problems.

SDG Mittagsseminar 14

Survive in an artificial market

• Each robot contains a:– Derivative buying agent– Derivative offering agent– Raw material production agent– Finished product agent (solves Max)

• Winning in robot competitions strongly influences the final grade.

• Game is interesting even if robots are far from perfect.

• Focus today: how to play the game perfectly (never losing)

SDG Mittagsseminar 15

SDG(Max)

• Derivative = (Predicate, Price in [0,1], Player).

• Players offer and buy derivatives.• Buying a derivative gives you the rights:

– to receive raw material R satisfying the predicate.

– upon finishing the raw material R at quality q (trying to find the maximum solution), you receive q in [0,1].

SDG Mittagsseminar 16

To play well: solve min max

instancesselected by predicate(an infinite set)

maximumsolutions

0.8

0.91

0.618

0.62

0.619 minimum

Analysis for one Derivative

SDG Mittagsseminar 17

To play well: solve min max

instancesselected by predicate(an infinite set)

maximumsolutions

0.8

0.91

0.618

0.62

0.619 minimum

Analysis for one Derivative

0.62

Noise

small subset of raw materialsguaranteed to containminimum of maxima

SDG Mittagsseminar 18

Raw material selected

0.7

all possible finished products

Noise small subset of finished productsguaranteed to contain maximum

0.7

0.7

SDG Mittagsseminar 19

Risk analysis

• Life cycle of a derivative (pred,p)– offer

• risk high if I can find rm and fp with q(fp) > p

– buy• risk high if I can find rm and fp with q(fp) < p

– raw material (rm)– finished product (fp ,quality q(fp))

• Two uncertainties– raw material is not the worst (uncertainty_rm)– finished product is not the best (uncertainty_fp)

SDG Mittagsseminar 20

To play SDG perfectlyeliminate risk

• buy– break-even price

• sell– break-even price

• produce – efficiently find worst case example

• process– efficiently achieve break-even quality

SDG Mittagsseminar 21

Goal: never lose with offer/buy

• Choose algorithms RM and FP

SDG Mittagsseminar 22

Analysis of SDG(Max)

tpred = infall raw materials rmsatisfying predicate pred maxall finished products fpproduced for rm q(fp)

SDG Mittagsseminar 23

Analysis of SDG(Max)

tpred = lim n -> ∞ minall raw materials rm of size nsatisfying predicate pred maxall finished products fpproduced for rm q(fp)

SDG Mittagsseminar 24

Spec for RM and FP

tpred = lim n -> ∞ minall raw materials rm of size nsatisfying predicate pred andhaving property WORST(rm) maxsmall subset of all finished products fp produced for rm q(fp)

SDG Mittagsseminar 25

Analysis of SDG(Max)

tpred = lim n -> ∞ minminallall raw materialss rm of size n produced by RMsatisfying predicate pred maxallall finished productss fp produced for rm by FP q(fp)

SDG Mittagsseminar 26

Hope

• Max is NP-hard

• SDG(Max) simplifies Max if our goal is to never lose.

SDG Mittagsseminar 27

SDG(MAX-SAT)

• Predicates using clause types.

• Example predicate PairSat = All CNFs with clauses of any length but clauses of length 1 must contain one positive literal.

• What is the right price p for derivative (PairSat, p, Specker)

SDG Mittagsseminar 28

SDG(MAX-SAT)

• Predicate space: any subset of clause types of PairSat

• t all PairSat = (√5 -1)/2

• t {(2,0),(1,1)} = (√5 -1)/2

• t {(100,50), (3,2), (2,0),(1,1)} = (√5 -1)/2

Noise for the purpose of constructing raw material.

SDG Mittagsseminar 29

SDG(MAX-SAT)

• t {(2,0),(1,1)} = t SYM{(2,0),(1,1)} = (√5 -1)/2

• SYM stands for Symmetrization: Idea: if you give me a CNF with a satisfaction ratio f, I give you a symmetric CNF with a satisfaction ratio <= f.

• For a CNF in SYM{(2,0),(1,1)}, the MAX-SAT problem reduces to maximizing a polynomial.

SDG Mittagsseminar 30

Students need to implement trading robots

• Fall semester (undergraduates): SDG(MAX-SAT)

• Spring semester (graduates): SDG(MAX-CSP)

SDG Mittagsseminar 31

Opportunities for learningExample SDG(MAX-SAT)

• Abstraction: What is important to play the game well.– Game reductions: To play game SDG(MAX-

SAT) well, it is sufficient to play game SDG(X) well, where X is simpler than MAX-SAT.

SDG Mittagsseminar 32

Complexity theory connection

• Break-even prices are not only interesting for the SDG game.

• They also have complexity-theoretic significance: they are critical transition points separating P from NP (for “most” predicates).

SDG Mittagsseminar 33

General Dichotomy Theorem

MAX-CSP(G,f): For each finite set G of relationsthere exists an algebraic number tG

For f ≤ tG: MAX-CSP(G,f) has polynomial solutionFor f ≥ tG+ : MAX-CSP(G,f) is NP-complete,

tG critical transition pointeasy (fluid)Polynomial

hard (solid)NP-complete

due to Lieberherr/Specker (1979, 1982)

polynomial solution:Use optimally biased coin.Derandomize.P-Optimal.

SDG Mittagsseminar 34

Other break-even prices(Lieberherr/Specker (1982))

• G = {R0,R1,R2,R3}; Rj : rank 3, exactly j of 3 variables are true. tG= ¼

SDG Mittagsseminar 35

Other break-even prices(unpublished)

(Lieberherr/Specker (1982))• G(p,q) = {Rp,q = disjunctions containing at

least p positive or q negative literals (p,q≥1)}– Let a be the solution of (1-x)p=xq in (0,1).

tG(p,q)=1-aq

SDG Mittagsseminar 36

Lessons learned from SDG

• Developing trading robots and make them survive in an artificial market is very motivating to students

• Students learn experientially about many important topics driven by the single goal of making their robots competitive– software development– problem solving by reduction (noise reduction)– combinatorial optimization– game design– sub-optimal playing is very educational too!

SDG Mittagsseminar 37

Noise reduction: important topic

• seen in solving minimization and maximization problems

• To implement trading robots, we use a tool called DemeterF which is good at noise reduction during programming process: focus on important classes and eliminate noise classes

SDG Mittagsseminar 38

Conclusions

• SDG(Max) is an interesting tool for teaching a wide variety of topics.

• It helps if you give your students a robot that knows the basic rules. Then the students can focus on improving the robots rather than getting all robots to communicate properly.

SDG Mittagsseminar 39

Conclusions

• SDG(Max) is an interesting tool for research.

• Does it always turn an NP-hard maximization problem into a polynomial time approximation algorithm?

SDG Mittagsseminar 40

References

• Lieberherr/Specker (1979, 1981) FOCS and Journal of the ACM

• Lieberherr (1982) Journal of Algorithms

• Workshop paper:

• DemeterF home page

SDG Mittagsseminar 41

Obstacles to finding p

• Try to find a CNF satisfying PairSat in which only a small percentage of the clauses can be satisfied.– Challenge of finding the worst case.– Even if we find the worst case, we might not

find the maximum assignment for that case.