Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu

42
Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu April 2004

description

Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu April 2004. Agenda. Objectives of Project Background of Horse Racing Major Business Functions of Objects System Design Simulation Algorithm Conclusion Q & A. - PowerPoint PPT Presentation

Transcript of Horse Racing Simulation System Presented By Ting Hin Chau Supervised By Professor Michael R. Lyu

Horse Racing Simulation System

Presented By Ting Hin ChauSupervised By Professor Michael R. Lyu

April 2004

Agenda Objectives of Project Background of Horse Racing Major Business Functions of Objects System Design Simulation Algorithm Conclusion Q & A

Objectives

To demonstrate CORBA implementation

To demonstrate horse racing simulation

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Background of Horse Racing

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Jockey Club

Stable

Gambler

Background of Horse Racing

Inefficient Procedures Race Registration: Paper Work

Betting: Off-course betting branches

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Background of Horse Racing

Difficult Result Prediction

Personal Judgement

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Business Functions

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Jockey Club Formulating Horse Racing

Schedule Schedule Query by Stable Processing Horse Registration for a

Race by Stable

Business Functions

Jockey Club Race Query by Gamblers Accepting Bets from Gamblers Calculating Odds (Appendix 1) Running Races Dividend Payout

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Business Functions

Stable Horse Query by Gamblers

Horse Registration for a Race

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Business Functions

Gambler Depositing Money to Betting

Account

Placing Bets

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Interaction

Object Request Broker (VisiBroker for Java 4.0)

Database (Oracle 8i)

Server Object 1

Server Object N

Client Object 1

Client Object N

Java Applet

System Design

Object Request Broker VisiBroker for Java 4.0 Service Lookup Object Instantiation Connection Setup between Client

and Server Objects

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Object Request Broker

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Server Objects Interfaces defined in CORBA/IDL

interface Buyer { attribute unsigned longBuyerID;attribute stringBuyerPassword;attribute stringBuyerName;attribute floatBalance;attribute stringAccountNumber;exception NotEnoughMoneyInAccount { };

void deposit(in float amount);void withdraw(in unsigned long amount)

raises(NotEnoughMoneyInAccount); void edit(in string buyerName, in string buyerPassword, in string accountNumber);

};

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

CORBA/IDL to Java Mapping

IDL Java

module package

interface interface

operation method

attribute method pair

exception exception

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

idl2java Interface file Helper file Holder file Stub file POA file

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Server Objects Buyer BuyerProcessor Stable StableProcessor Race

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Client GUI RaceAdminClient StableClient BuyerClient

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Client GUI RaceAdminClient

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Client GUI StableClient

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Client GUI BuyerClient

Objectives / Background / Business Functions / System Design / Simulation Algorithm

System Design

Database Server Oracle 8i Persistent storage of data Maintaining data integrity E-R diagram (Appendix 2)

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Monte Carlo Simulation Simulation with a built-in random

process

Different possible outcomes

Simulation Algorithm

Steps of Simulation (Appendix 3)1. Data Input Gather data on historical ranks of a

horse Transform these ranks to a value

R/N, which is rank/number of horses in the race

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Steps of Simulation2. Distribution Construction Form frequency distribution Form probability distribution Form cumulative probability

distribution

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Steps of Simulation

The distribution of Rank of a horse

00.020.040.060.080.1

0.120.140.16

0 5 10 15

Rank X

P(X

= x

)

The cumulative distribution of a horse

0

0.2

0.4

0.6

0.8

1

0 2 4 6 8 10 12 14

Rank X

F(x)

= P

(X

<=

x)

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Steps of Simulation3. Draw a sample from distribution Generate a random number N from

0 to 1 N refers to P(X <= x), where X is R/N

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Steps of Simulation

The relationship between x, F(x) and G(F(x))

0

0.2

0.4

0.6

0.8

1

0 2 4 6 8 10 12 14

G(F(x)) = x

F(x)

= P

(X

<=

x)

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Steps of Simulation4. Compare R/N across horses Sort the R/N values of the horses in

a race A horse with a smaller R/N beats

out a horse with a higher R/N

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Simulation Algorithm

Assumptions of Simulation Independent distribution of R/N Factors including location of

racecourse, lane, and jockey are insignificant

Data from the 10 most recent races are used

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Conclusion

CORBA Language independent Different platforms ORB expensive

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Conclusion

Simulation Mimics the “random” factor in horse

racing Choice of size of distribution is hard

to determine Error of prediction can be estimated

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 1

Calculation of Odds1. Win Odds dw = bi / bw

2. Place Odds dw1 = (bi - bw1 - bw2 - bw3) /( 3 * bw1) + 1

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 2

Stable_t

Passw

ordSID

Status

Horse_t

HID

Weig

ht

Birth

day

Status

Gam

bler_t

Passw

ordG

ID

Status

Gam

blerN

ame

Acc

ountN

um

BetA

ccountB

al

Race_t

HL

ane

RaceE

ventNum

ber

Race

Date

TxnS

tatus

Horse

Rank

Joins

Owns

Bet_t

BetT

ype

BetA

mount

Gambler-bet

Race-bet

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation

Race R N R/N R N R/N R N R/N R N R/N1 2 8 0.25 4 10 0.4 3 10 0.3 5 10 0.52 3 10 0.3 6 12 0.5 2 8 0.25 6 11 0.545453 1 14 0.07143 5 10 0.5 3 12 0.25 6 12 0.54 1 9 0.11111 4 8 0.5 4 11 0.36364 8 14 0.571435 4 14 0.28571 4 10 0.4 3 9 0.33333 12 12 16 3 12 0.25 7 14 0.5 1 7 0.14286 13 14 0.928577 2 8 0.25 8 12 0.66667 1 8 0.125 8 14 0.571438 1 10 0.1 8 14 0.57143 5 12 0.41667 6 10 0.69 1 10 0.1 6 10 0.6 4 10 0.4 N/A   N/A 0.5355 

10 2 8 0.25 5 8 0.625 N/A  N/A  0.4805   N/A N/A   0.5010

Horse 1 Horse 2 Horse 3 Horse 4

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation CalculationCumulative Probability (R/N)

Horse 1R/N

Horse 2R/N

Horse 3R/N

Horse 4R/N

0 0 0 0 00.1 0.07143 0.4 0.125 0.50.2 0.1 0.4 0.14286 0.50.3 0.1 0.5 0.25 0.5010.4 0.11111 0.5 0.25 0.53550.5 0.25 0.5 0.3 0.545460.6 0.25 0.5 0.33333 0.571430.7 0.25 0.57143 0.36364 0.571430.8 0.25 0.6 0.4 0.60.9 0.28571 0.625 0.41667 0.92857

1 0.3 0.66667 0.4805 1

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation

Random Number

Horse 1 0.537978366Horse 2 0.210962962Horse 3 0.022299918Horse 3 0.492061261

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation Two points on the cumulative distribution

(x1, y1) and (x2, y2), for instance, for horse 1, they correspond to (0.25, 0.5) and (0.25, 0.6), will be used to calculate the final score of a horse by linear equation , based on the random number generated.

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation For horse 1, point 1 (x1, y1) is (0.4, 0.2)

and point 2 (x2, y2) is (0.5, 03) R/N of horse 1

= (rand1-y1)*((x2-x1)/(y2-y1)) + x1= (0.5379783655654367 – 0.2)* (0.25 – 0.25)/(0.6-0.5) + 0.25= 0.25

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation For horse 2, point 1 (x1, y1) is (0.4, 0.2)

and point 2 (x2, y2) is (0.5, 0.3). R/N of horse 2

= (rand2-y1)*((x2-x1)/(y2-y1)) + x1= (0.21096296234313094 – 0.2)* (0.5 – 0.4)/(0.3-0.2) + 0.4= 0.410962962

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation For horse 3, point 1 (x1, y1) is (0, 0) and

point 2 (x2, y2) is (0.125, 0.1). R/N of horse 3

= (rand2-y1)*((x2-x1)/(y2-y1)) + x1= (0.02229991816731558 – 0)* (0.125 – 0)/(0.1-0) + 0= 0.027874898

Objectives / Background / Business Functions / System Design / Simulation Algorithm

Appendix 3

Simulation Calculation For horse 4, point 1 (x1, y1) is (0.5355, 0.4)

and point 2 (x2, y2) is (0.545455, 0.5). R/N of horse 3

= (rand2-y1)*((x2-x1)/(y2-y1)) + x1= (0.4920612612595172 – 0.4) * (0.545455 – 0.5355)/(0.5-0.4) + 0.5355= 0.544664699

Objectives / Background / Business Functions / System Design / Simulation Algorithm