+ All Categories
Home > Documents > Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our...

Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our...

Date post: 31-Mar-2015
Category:
Upload: vicente-shroff
View: 213 times
Download: 1 times
Share this document with a friend
Popular Tags:
23
Modeling Logic with Decision Tables and Trees
Transcript
Page 1: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

Modeling Logic with Decision Tables and Trees

Page 2: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

2

Decision Trees and Decision Tables• Often our problem solutions require decisions to be made

according to two or more conditions or combinations of conditions

• Decision trees represent such decision as a sequence of steps• Decision tables describe all possible combinations of

conditions and the decision appropriate to each combination• Decision table: a matrix representation of the logic of a

decision which specifies the possible conditions for the decision and the resulting actions.

• Best used for complicated decision logic.

Page 3: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

3

Example Decision Trees/Tables

Consider the following excerpt from an actual requirements document:

If the customer account is billed using a fixed rate method, a minimum monthly charge is assessed for consumption of less than 100 kwh. Otherwise, apply a schedule A rate structure. However, if the account is billed using a variable rate method, a schedule A rate structure will apply to consumption below 100 kwh, with additional consumption billed according to schedule B.

[taken from Software Engineering: A Practitioner's Approach by Roger Pressman]

Page 4: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

4

Decision Tree for this Example

fixed rate

variablerate

< 100 kwh

>= 100 kwh

< 100 kwh

>= 100 kwh

minimum charge

schedule A

schedule A

?

Page 5: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

5

Decision Tree for this Example

fixed rate

variablerate

< 100 kwh

>= 100 kwh

< 100 kwh

>= 100 kwh

minimum charge

schedule A

schedule A

schedule A onfirst 99 kwhschedule B onkwh 100 and above

Page 6: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

6

Decision Table for Example – Version 1

Conditions 1 2 3 4 5Rules

Fixed rate acct T T F F FVariable rate acct F F T T FConsumption < 100 kwh T F T FConsumption >= 100 kwh F T F T

Minimum charge XSchedule A X XSchedule A on first 99 kwh, XSchedule B on kwh 100 +

Actions

Is this a validbusiness case? Did we miss something?

Page 7: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

7

Decision Table for Example – Version 2

Conditions 1 2 3 4Rules

Account type fixed fixed variable variable Consumption < 100 >=100 <100 >= 100

Minimum charge XSchedule A X XSchedule A on first 99 kwh, XSchedule B on kwh 100 +

Actions

Page 8: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

8

ExerciseConsider the following description of a company’s matching retirement contribution plan:

Acme Widgets wants to encourage its employees to save for retirement. To promote this goal, Acme will match an employee’s contribution to the approved retirement plan by 50% provided the employee keeps the money in the retirement plan at least two years. However, the company limits its matching contributions depending on the employee’s salary and time of service as follows. Acme will match five, six, or seven percent of the first $30,000 of an employee's salary if he or she has been with the company for at least two, five, or ten years respectively. If the employee has been with the company for at least five years, the company will match up to four percent of the next $25,000 in salary and three percent of any excess. Ten-year plus workers get a five percent match from $30,000 to $55,000. Long-term service employees (fifteen years or more) get seven percent on the first $30,000 and five percent after that.

Page 9: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

9

Exercise (cont’d)

1) Do one of the following (your choice):a) Create a decision tree that captures the decision

rules in this policy.b) Create a decision table that captures the decision

rules in this policy.2) Did your analysis uncover any questions, ambiguities, or

missing rules?3) If so, do you think these would be as easy to spot and to

analyze using only the narrative description of this policy?

Page 10: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.
Page 11: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

More Complex Description of a Decision Table

Page 12: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

© 2011 Pearson Education, Inc. Publishing as Prentice Hall

12Chapter 7

Modeling Logic with Decision Tables

FIGURE 7-18Complete decision table for payroll system example

Page 13: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

© 2011 Pearson Education, Inc. Publishing as Prentice Hall

13Chapter 7

Modeling Logic with Decision Tables (Cont.)

• Condition stubs: that part of a decision table that lists the conditions relevant to the decision

• Action stubs: that part of a decision table that lists the actions that result for a given set of conditions

Page 14: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

© 2011 Pearson Education, Inc. Publishing as Prentice Hall

14Chapter 7

Modeling Logic with Decision Tables (Cont.)

• Rules: that part of a decision table that specifies which actions are to be followed for a given set of conditions

• Indifferent condition: in a decision table, a condition whose value does not affect which actions are taken for two or more rules

Page 15: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

© 2011 Pearson Education, Inc. Publishing as Prentice Hall

15Chapter 7

Modeling Logic with Decision Tables (Cont.)

• Procedure for Creating Decision Tables– Name the condition and the values that each

condition can assume.– Name all possible actions that can occur.– List all possible rules.– Define the actions for each rule.– Simplify the table.

Page 16: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

LAB EXERCISE

Page 17: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

© 2011 Pearson Education, Inc. Publishing as Prentice Hall

17Chapter 7

Modeling Logic with Decision Tables (Cont.)

FIGURE 7-19Reduced decision table for payroll system example

Page 18: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.
Page 19: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.
Page 20: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.
Page 21: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

Decision Table Construction

Page 22: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

Decision Table Construction

Page 23: Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.

Decision Table Construction – the final table


Recommended