Sunteți pe pagina 1din 527

Excel Solver Treeplan

SilverDecisions Gambit SageMath







Maximin
Maximin
Minmax Regret
Minmax Regret
Maximax
The Principle of Insufficient Reason
Decision aking Under Risk
Expected Value Criterion
)Expected Monetary Value (EMV
Expected Value of Perfect Information
EVPI
Decision Trees

Treeplan
Rolling Back

SilverDecision
SilverDecision
Case Studies



Tree of the Game
Matrix of the Game

Two Persons Zero Sum Games


Dominance
Game Information
)(


6
6
9
9
9
9
9
11
12
15
16
18
21
22
21
22
23
24
24
27
40
42
44
44
53
67
92
94
99
100
116
120
129
153
153
154
157
158




Excel Solver
Equilibrium
Dominant Strategy Equilibrium
Nash Equilibrium


Gambit
Gambit
Gambit
Gambit
Extensive Form
Iterated dominance Equilibrium
Weak Iteration
Pareto Efficiency
Pareto Dominance
Gambit
Case Studies


)(







Shapley and Nash Method

N-Person Games

The Core
Stable Sets
The Nucleus
Shaplet Function Values

159
163
163
168
178
179
180
180
181
182
183
192
198
200
204
214
218
218
225
238
257
259
270
275
282
282
287
287
289
291
294
311
318
315
331
334
335
341
347
351



Sage
Sage
Sage
- Many-Person Games
Coalition Form and Characteristic Function
Supersdditivity Monotone Constant-Sum
Imputation and the Core

Essential Games
The Core


Sage
Matching Games
Combinatorial Games
Simple Take-Away Game
P P-positions and N-positions N
Subtraction Games
The Game of Nim
Nim Sum

Utility Theory

: LINGO
: SageMath
:

351
373
386
391
399
399
399
400
409
409
410
410
411
412
412
428
434
434
436
437
439
440
443
446
463
482
484
488
499


] .
" "
.

.
.
.
) (
.

Excel Excel Solver Treeplan
Gambit Sage
.SageMath

Linear Program Simplex Tableau
Excel Solver
) ( .


) (.

http://www.abarry.ws/
] .

2015/8/23


Decision Analysis
Alternatives
Uncertainity .
Optimal Payoff
.Decision Criterion
Maximizing Expected Profit
.

Maximizing the Utility Function


Risks .

Payoff Table Analysis


:
-1 .Discrete
-2 .
:
-1 .
-2 .
-3 ) States of Nature
) Mutually Exclusive
() and Collectively Exhaustive
(.
6

-4 .

1000 .
5 :
-1 .Gold
-2 .Bond
-3 .Stock
-4 .Certificate of Deposit
-5 .Stock Option Hedge
) (
.
.
: .

-1 .
-2 .
-3 .
-4 )( .

S1

S2

S3

S4

A1

p(1,1)

p(1,2)

p(1,3)

p(1,4)

p1

A2

p(2,1)

p(2,2)

p(2,3)

p(2,4)

p2

A3

p(3,1)

p(3,2)

p(3,3)

p(3,4)

p3


.
. . -

Decision
Alternativs
Gold
Bond
Stock
C/D account
Stock option

Decision
Alternativs
Gold
Bond
Stock
C/D account
Stock option

Larg rise
-100
250
500
60
200

States of Nature
Small rise
No change
Small fall
100
200
300
200
150
-100
250
100
-200
60
60
60
150
150
-200

Large fall
0
-150
-600
60
-150

Larg rise
-100
250
500
60
200

Small rise
100
200
250
60
150

Large fall
0
-150
-600
60
-150

No change
200
150
100
60
150

Small fall
300
-100
-200
60
-200

: Dominance :
A1
A2 A1 . A2

.

Decision Making Criteria


:
-1 : Future
.State-of-Nature
-2 :
.
-3 :
.
Decision Making Under Uncertainty
-1 .
-2 :
Maximin . Minimax Regret . Maximax . Principle of Insufficient Reasoning .
9

: Maximin
Worst-Case Scenario
. . . : -1 .
-2 " ".
Minimum
Payoff
-100
-150
-600
60

Large fall
0
-150
-600
60

States of Nature - The Maximum Criterion


Larg rise Small rise No change Small fall
-100
100
200
300
250
200
150
-100
500
250
100
-200
60
60
60
60

10

Decision
Alternativs
Gold
Bond
Stock
C/D
account

Maxmin
Maxmin

11

: Minimax Regret
:Minimax Regret
-1 .
-2 " "Lost Opportunity
"."Regret
-3 .
: -1 .
-2 Regret .
Maximum Regret . - .

12


Decision
Gold
Bond
Stock
C/D
account
Decision
Alternativs
Gold
Bond
Stock
C/D
account

States of Nature - The Payoff Table


Larg rise Small rise No change
-100
100
200
250
200
150
500
250
100
60
60
60

Small fall
300
-100
-200
60

Large fall
0
-150
-600
60

States of Nature - The Maximum Criterion


Larg rise Small rise No change Small fall
600
150
0
0
250
50
50
400
0
0
100
500
440
190
140
240

Large fall
60
210
660
0

= : :
-
. Stock

Decision
Gold
Bond
Stock
C/D
account

States of Nature - The Payoff Table


Larg rise Small rise No change
-100
100
200
250
200
150
500
250
100
60
60
60

500 - (-100) = 600

13

Small fall
300
-100
-200
60

Large fall
0
-150
-600
60

Decision
Alternativs
Gold
Bond
Stock
C/D
account

States of Nature - The Regret Table


Larg rise Small rise No change
-100
100
200
250
200
150
500
250
100
60
60
60

Small fall
300
-100
-200
60

Large fall
0
-150
-600
60

Minimum
Regret
600
400
660
440

. 600
.400 Bonds

14

Minimax Regret

15

16

: Maximax
.
.
) (.
: -1 .
-2 .

Minimum
Payoff
300
200
500
60

Large fall
0
-150
-600
60

States of Nature - The Maximax Criterion


Larg rise Small rise No change Small fall
-100
100
200
300
250
200
150
-100
500
250
100
-200
60
60
60
60

17

Decision
Alternativs
Gold
Bond
Stock
C/D
account

18

- Decision Making Under


Uncertainty - The Principle of Insufficient Reason
)(.
. : -1 .
-2 .

600 Gold -1
350 Bond -2
50 Stock -3
300 CD Acc -4
- .

19

20

Decision Making Under Risk


) ( .
.Expected Payoff
Expected Value Criterion
:)Expected Payoff = (Probability)(Payoff

. : " " Expected Monetary
) .Value ( EMV
)Expected Monetary Value (EMV

21


: -1 .
-2 .
Expected Value of Perfect Information
Gain Expected Return
:
)Expected Value of Perfect Information (EVPI
EVPI
" "
Stock
22

EVPI
EVPI = ERPI - EREV
Expected Return with Perfect Information :ERPI

ERPI = (probability)(Max payoff )
Expected Return of the EV Criterion :EREV
EV

23

Decision Trees
Nonsequential .Single Stage
.
Multistage.Decision Processes

Chronological . - Nodes .Branches

24

. )( .
3 . . : -1 Event Node .
Chance Node Uncontrollable
.
-2 ) Decision Node (
Controllable .
-3 )( Terminal Node )
(Combination .
.

) Mutually Exclusive (
) and Collectively Exhaustive ( .
Subjective .
Decision Branch .

25

) Mutually Exclusive
() and Collectively Exhaustive (.
.Event Branch : Terminal Values ) Payoff Value Outcome Value
.Endpoint Value

26

Treeplan
Treeplan Excel Add-In
Treeplan Excel .
Excel: -1 Tools => Add-Ins...:

27

Treeplan Excel Treeplan


Excel .
-2 Treeplan Excel
File => Open treeplan.xla
xla .Excel
Tools => Decision Tree... :

28

Ctrl-t : Treeplan

29

New Tree:

Ctrl-t
:

30

) Decision 1 Decision 2

31

32

)( Treeplan
http://www.treeplan.com
:
BGD
:
: -1 300000.
-2 500000.
-3 950000 .
-4 30000.
%40 . 260000.
3 20000 .
5000. :1- P(Consultant predict approval| approval granted) = 0.7
2- P(Consultant predict denial| approval denied) = 0.8
: -1 / .
-2 .

33


-1 .
-2 :
Treeplan

34

35

36


.
A B

. .

. :
: .


) 3( .
:
.A .B A .B37

. :
.A .B Treeplan
-

38

39

Rolling Back

Expected Monetary Value ) EMV (
. EMV .
EMV A
0.4 :
Max(EMV) = 3.4

40

) ( Payoff
: 2 .EMV 2
.EMV=3.4

41

-1 EMV
-2 Maximum Possible Payoff
Maximax
-3 EVC .EVPI
Rolling Back
)
( Event Node
1 0.4 13 0.6
12 1
EMV(node 1) =0.4 x 13 + 0.6 x -12 = -2.0
EMV(node 2) =0.4 x -8 + 0.6 x 11 = 3.4
EMV(node 3) =0.4 x 5 + 0.6 x -1 = 1.4
EMV(node 4) =0.4 x 0 + 0.6 x 0 = 0.0
EMV 0 4
.-2 ,3.4 ,1.4 ,0
.EMV

42

EMV(node 0) = 3.4
EMV " .B

43

SilverDecisions
Open-Source
Decision Support Analysis Division Warsaw School of
Economics

Microsoft Silverlight .
:
-1 Microsoft Silverlight
http://www.microsoft.com/getsilverlight/GetStarted/Install/Default.aspx
-2
http://silverdecisions.pl/

44

-3 Run

45


.
:
-1

-
46

Decision Tree Designer

Label .
47

48

49

50

.Bold lines
:

51

52

Case Studies :
:1
4
:
20 :1 0.4 .
30 :2 20 0.3 .
40 :3 30 0.2 .
60 :4 100 0.1 .

:

Probability
0.20
0.20
0.30
0.20
0.10

Time
minutes
minutes
minutes
minutes
minutes

10
30
60
100
150


:
:
1 10 = 20 24= 0.4 X10 +
1 30 = 20 32= 0.4 X30 +
1 60 = 20 44= 0.4 X60 +

53

1 100 = 20 60= 0.4 X100 +


1 150 = 20 80= 0.4 X150 +
2 10 = 30 = 30 ) 20 (
2 30 = 30 33= 0.3 X10 + ) 20
(
2 60 = 30 42= 0.3 X40 + ) 20
(
2 100 = 30 54= 0.3 X80 + ) 20
(
2 150 = 30 69= 0.3 X130 + )20
(
3 10 = 40 = 40 ) 30 (
3 30 = 40 = 40 ) 30 (
3 60 = 40 46= 0.2 X 30 + ) 30
(
3 100 = 40 54= 0.2 X 70 + ) 30
(
3 150 = 40 64= 0.2 X 120 + )30
(
4 10 = 60 = 60 ) 100 (
4 30 = 60 = 60 ) 100 (
4 60 = 60 = 60 ) 100 (
4 100 = 60 = 60 ) 100 (

54

4 150 = 60 65= 0.1 X50 + ) 100


(

55

:2
.
800 1100
. 1 4 .
%50 .
100 .

maximin .maximum regret
:
:

56


P(Demand = 1) = 0.30
P(Demand = 2) = 0.10
P(Demand = 3) = 0.40
P(Demand = 4) = 0.20

57

:3


. 3 .
expected present worth profit
.
)(:
Average Number of Daily Customers
4
8
12
16
20
150
350
850

200
400
500

200
350
250

150
50
-100

100
-200
-400

A
B
C

Restaurant
Format


:
P(4) = 0.10, P(8) = 0.20, P(12) = 0.30, P(16) =0.30


:
.

58

:4

. 300 650 400
.
50 .
200
. 1 4
100
.
:
:
3 2 1300
2 1200 ) (( 50 - 650) X 2
200

1,200 + 200 - 1,300 = 100.


4
0
-400
0
400
800

3
0
-300
100
500
400

Demand
2
0
-200
200
100
0

1
0
-100
-200
-300
-400

0
1
2
3
4

Number
Ordered

(1 Maxmin
(2
59

(3
:
.

60

:5

. 3 .
.
.
:
Demand Growth for Chemical
Low
0
100
-300
-500

Medium
0
130
240
120

High
0
140

Do Nothing
Minor

150
200

Moderate
Major

Compound
Expansion

(1 minimize maximum
regret
(2 principle of
insufficient reason
(3 :
P(High Growth) = 0.20
P(Medium Growth) =0 .30
= 0.50

61

)P(Low Growth

(4
.
:
P(Expert predicts positive | High Growth) = 0.60
P(Expert predicts positive | Medium Growth) = 0.40
P(Expert predicts positive | Low Growth) = 0.20

:
.

62

:6
1 4 .
:

Total Cost
110,000
150,000
230,000
315,000

Number of Cars Ordered


1
2
3
4

90,000 .
75,000 .
5,000
.
:
Number of Cars Demanded by Customers
1
2
3
4
-20
-25
-30
-35
15
30
25
20
10
25
40
35
0
15
30
45

1
2
3
4

Number of
Cars
Purchased

(1

(2 :
Probability
.20
.20
.30
.30

63

Demand
1
2
3
4


(3
:
P(favorably inclined | 1 Cars demanded) = 0.20
P(favorably inclined | 2 Cars demanded) = 0.40
P(favorably inclined | 3 Cars demanded) = 0.80
P(favorably inclined | 4 Cars demanded) = 0.90


:
.

64

:7
. 4

.
. :

High
600
540
490
470

State
Moderate
350
350
375
350

Low
200
250
300
300

Action
1
2
3
4

. 3
4 4 .

Max
600
540
490

Min
200
250
300

High
600
540
490

State
Moderate
350
350
375

Low
200
250
300

Action
1
2
3


- MAXIMIN
- MAXIMAX
- MINIMAX REGRET CRITERIA.
MAXIMIN

65

3 300 1 200
2 .250
MAXIMAX

1 600 2 540
3 .490
MINIMAX REGRET

:
i }A={1,2,3,4

) (

lij = max rmj rij


mA

Max Regret
100
60
110

High
0
60
110

State
Moderate
25
25
0

Low
100
50
0

Action
1
2
3

2 .60

P(Low) = 0.1
P(Moderate) = 0.5
P(High) = 0.4

66

Expected Monetary Value


Criterion .

Expected Value
435
416
413

)3 (High
0.4
600
540
490

)2 (Moderate
0.5
350
350
375

)1 (Low
0.1
200
250
300

State
Probability
)1 (A
)2 (B
)3 (C

Action

1 435.
:
:
.

67

68

69

:8

. )(
1000
8000 . )( 1500
12000 .

2000.
:
a1: bid on neither contract
a2: bid on the first contract but not the second
a3: bid on the second contract but not the first
a4: bid on both contracts
:

s1: both bids rejected


s2: bid on first contract accepted but not the second
s3: bid on second contract accepted but not first
s4: both bids accepted
16
rij , i = 1, 2,..., 4, j = 1, 2,..., 4 :
- - ) (
2 3
70

0 - 1000 = -1000
:
s4

s3

s2

s1

0
7
10.5
7.5

0
-1
10.5
9.5

0
7
-1.5
5.5

0
-1
-1.5
-2.5

States
a1
a2
a3
a4

Actions

.
0.8 0.5


P[Both are rejected] = P[First rejected Second rejected] = (1 0.8)(1 0.5) = 0.1
P[First accepted and second rejected] = 0.8(1 0.5) = 0.4
P[First rejected and second accepted] = (1 0.8)(0.5) = 0.1
P[Both are accepted] = 0.8(0.5) = 0.4


s4
0.4
0
7
10.5
7.5

s3
0.1
0
-1
10.5
9.5

s2
0.4
0
7
-1.5
5.5

s1
0.1
0
-1
-1.5
-2.5

71

States
Probabilit
ies
a1
a2
a3
a4

Actions

:Maximin ) ( a1
:Maximax a2
:Minimax regret a4
: EMV
EMV(1) = 0.1(0) + 0.4(0) + 0.1(0) + 0.4(0) = 0
EMV(2) = 0.1(-1) + 0.4(7) + 0.1(-1) + 0.4(7) = 5.4
EMV(3) = 0.1(-1.5) + 0.4(-1.5) + 0.1(10.5) + 0.4(10.5) = 4.5
EMV(4) = 0.1(-2.5) + 0.4(5.5) + 0.1(9.5) + 0.4(7.5) = 5.9
a4
:

72

73

74

75

:9
85000
.

. 5000
50-50 .
microwave cellular
infrared
.
:
Equipment Cost
4,000
5,000
4,000

Technology
Microwave
Cellular
Infrared


) research and development (R&D
. best-case worst-case

:
Possible R&D Costs
Case
Worst Case
Prob.
Cost
Prob.
0.4
60,000
0.6
0.8
70,000
0.2
0.9
80,000
0.1

76

Best
Cost
30,000
40,000
40,000

Microwave
Cellular
Infrared

.
:

:
.

77

78

:
.
. 25
15 .
%75 .%30

) (:
Demand
High
Low
$175
$ 95
$125
$105

79

Factory Size
Large
Small


(1

State of Nature
3

35

75

50

60

50

40

30

35

40

Decision


)(2
.
.

. :
Weather Condition
very cold
Normal
Light
10
7
3
8
8
6
4
4
4
)Payoffs (in $1000s

Size of Order
Large
Medium
Small

0.25 0.6
0.15.
(

maximax
80

minimax regret

EMV

)(3

30000 . .
stock mutual fund one-year
) .certificate of deposit (CD %8 .
%16 %9 %2-
.
0.1 0.85 .0.05
(1

(2

maximax

(3

maximin

(4

minimax regret

(5

EMV

81

)(4
3
Fixed Monthly Payment
200
300

Additional Cost Per Kilo


0.095 per Kilo.
0.061 for the first 6,000
kilos; 0.050 thereafter.
0.000 for the first 6,000
kilos; 0.14 per kilo
thereafter.

170

Plan
I
II
III

15000 35000
:
P(driving 15,000 kilos) = 0.1
P(driving 20,000 kilos) = 0.2
P(driving 25,000 kilos) = 0.2
P(driving 30,000 kilos) = 0.3
P(driving 35,000 kilos) = 0.2
(1 .
(2 ) maximax (
(3 maximin
(4 minimax regret
(5 EMV

82

)(5
.
2.45
.3.95 1.25 .

:
20

19

18

17

16

14

15

13

12

11

10

Demand

Probability 0.02 0.06 0.09 0.11 0.13 0.15 0.18 0.11 0.07 0.05 0.03

(1 .
(2 maximax
(3 maximin
(4 minimax regret
(5 EMV
(6 2.25
15 .

)(6
. 200
.
)(

83

.
:
Dust Damage
105
0.08

90

75

60

45

30

15

)(in 1000

Probability 0.25 0.08 0.10 0.12 0.15 0.12 0.10

:
-1 47000 %100
.
-2 25000 35000
.
-3
.
( 1 .
(2 maximax
(3 maximin
(4 minimax regret
(5 EMV
(6 .

)(7

. ) (

84


:
Market Demand
Low
Medium
High
400
400
400
200
500
500
-400
300
800
)(Payoffs in 1000

Size of Development
Small
Medium
Large

%21.75
%35.5 .%42.75
(1 maximax
(2 maximin
(3 minimax regret
(4 EMV
( 5 .

85

)(8
) (

:

High
0.0100
0.0350
0.3825

Actual Demand
Low
Medium
0.1600 0.0300
0.0350 0.2800
0.0225 0.0450

Forecasted Demand
Low
Medium
High

) : %82.25
(
(1 .
(2 EMV
(3 EMV
)(9
.
3
. .
:
Cost of Test
$1.75
$2.00
$2.40

Probability of Failure
0.125
0.075
0.140

.
86

Component
X
Y
Z

)(10

300000 9 .
:
-1 ) fixed rate loan (FRL %9.
-2 ) adjustable rate loan (ARL
%6 .
%7 0.1 %9 0.25 %11
0.65.
-3 ) adjustable rate loan (ARL
%4 3
%6 0.05 %8 0.3 %10 .0.65
%1 0.1 %1
0.2 %3 0.7.
(1
.
(2 .expected total interest

87

)(11

16 7 .

10 0.4 6 .0.6
0.15
0.35 .0.50
120 28
. 5
.
(1 .
(2 EMV
)(12
.
%60 .

. .
1.25 %25
1.45 %45 1.85
%85 .
2.2 .
1.15.

88

-1 .
-2 EMV
)(13
10 100 .
%90
. %95
.

)(14
.
240000 450000
. . 1500
.
. )( 125000 4
5000
. )( 85000 3
.
.%40
)( )( . )(
.
)( 20000

89

.
.
-1 .
-2 EMV

90

(15)

91

(16

92

(17

93

(18

(19

94

(20

95

(21

96

(22

(23

97

(24

98

(25

(26

99

(27

100

(28

101

(29

102

(30

103

104

Game Theory
: .

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

: .

162

:
.
Two-person Game Theory:
.

Payoff .
: ) (
.

Constant Sum .Variable Sum
:
: Players .
:Strategies .
:Strategic Game
.
:Payoff
.
) ( :Utility
.
" :Equilibrium Strategy"
.
:Equilibrium in a Game
) ( .

163

) ( :Rational Play
.
Constant-Sum :Zero-Sum
.
Games of Pure Conflict
.
:Mixed Strategy
.
:Simultaneous-Move Game )
(
.
Sequential-Move :Dynamic Games
) (
.
: Single-Stage Games
Single-Stage One-Shot
.Unrepeated Games
:Repeated Games
Multi-Stage n-Stage


.Meta-Strategies

164

Cooperative :Non-Cooperative Games



.

) . : (.
N N :N-Player Games .
2-Players Two-Person
N-Player ) N > 2 :
2-Players (.
:Game Move
:
: conscious Move .
:Random Move .

165

Game Information

. )
( . :
:Perfect Information .
:Incomplete Information "" Nature "" Chance
.
:Asymmetric Information
.


Two-Players Zero-sum Games

) - = 1 .( 2
.
A B m n
Payoff Matrix A:

166

B2 Bn
a12 a1n
a22 a2n

am1 amn

B1
a11

a21

am1

A i B j
A aij B . aij

167

A1
A2

Am


:
. A
A1 A2 . A3 B
B1 B2 B3
. B4
. :A

Rowmin
3
5 Maxmin
9

B4

B3

B2

B1

8 2 9 3
6 5 6 8

2 4 9 5
Column 8 5
9 8
A1
A2
A3

Minimax

max

Best of the Worst


.Maxmin A A1
B A 3.0%
.B .
A2 A 5% B .
A3 9% A .B
" ."Rowmin A
168

A2 Maximin
"."Rowmin
.B A
B Minimax
B . B2
A2 B2
A 5%
B . Value of the Game
5% A B . Saddle-point Solution

B B1 B3 B4 A
A2 B ) %6 .(8%

A ) A2 A1 B B4
9% A A3 B B3 2% .(A
:
.

169

Excel


A B
H .T .
) HH (TT A B B.
A
A B

BT rowmin
1
1
1
1
1

170

BH
AH
1
AT
1
colmax
1

Maximin = -1
Minimax = +1
Minimax

Maxinin

. A
AH B BT .A
A AT .

.
Minimax Maximin

Maximin value value of the game Minimax value



:
-1 :
) ( .
.
-2 : .

171

Graphical Solution
) (2 x n A.
A A1 A2 x1

1 x1 . 0 x1 1 B B1 Bn y1
yn y j 0 j = 1, 2,..., n

y1 + y1 + + yn = 1

y2

y1

yn

B2 Bn

B1

a11 a12 a1n


a

21 a22 a2 n

x1 : A1
1 x1 : A2

A j B
:

a2 j ) x1 + a2 j , j = 1,2,..., n

(a

1j

A x1
:

172

max min ( a1 j a2 j ) x1 + a2 j
j

x1


2 x4 A:

B4
1
6

B3

B2

B1

2
4

A1
A2

. A
B :

A's expected payoff

. 0 x1 1

173

B's pure strategy

2 x1 + 4

x1 + 3

x1 + 2

7 x1 + 6

x1 = 0.5
3 4:

from line 3
from line 4

1
5

+
2
=
,

2
2
v=
7 1 + 6 = 5 ,
2
2

B B3 B4

y1 = y2 = 0 y4 = 1 y3
B A :

174

B' expected payoff

A's pure strategy

4 y3 -1

- 4 y3 + 6

B :

4 y3 1 = 4 y3 + 6

7
:
8

= y3

: .
A A1 A2

1 7

B B3 B4
8 8

: . .

175


x1 , x2 ,..., xm A :
m
m

max min ai1 xi , ai 2 xi ,..., ain xi


xi
i=1

i =1
i =1

x1 + x2 + + xm = 1

xi 0, i = 1,2,..., m

m
m
m

v = min ai1 xi , ai 2 xi ,..., ain xi


i=1

i =1
i =1

176

a x

ij i

v, j = 1, 2,..., n

i =1

: LP A

maximize

z=v

Subjet to
m

v aij xi 0,

j = 1, 2,..., n

i =1

x1 + x2 + + xm = 1
xi 0, i = 1, 2,..., m
v unrestricted
. v
: LP y1 , y2 ,..., yn B
n
n

min max a1 j y j , a2 j y j ,..., amj y j


yj
j =1
j =1
j =1

y1 + y2 + + yn = 1

y j 0,

j = 1, 2,..., n
: LP B

minimize w = v
Subjet to
n

v aij y j 0, i = 1, 2,..., m
j =1

y1 + y2 + + yn = 1
y j 0,

j = 1, 2,..., n

v unrestricted
177

) v ( .

maximize : v
st :
v 2 x1 4 x2 0
v 2 x1 3x2 0
v 3 x1 2 x2 0
v + x1 6 x2 0
x1 + x2 = 1
x1 0, x1 0, v unrestricted
Excel Solver

178

179


LP .B

:

r min
3
2
6

A LP

180

B3

B2

1 3
4 1

6 2
4 2

B1
3
2
A2

A3

5
c max
3
A1

maximize v
st
v 3x1 + 2 x2 + 5 x3 0
v x1 4 x2 + 6 x3 0
v + 3x1 + x2 2 x3 0
x1 + x2 + x3 = 1
x1 , x2 , x3 0
v unrestricted
LP B

minimize v
st
v 3 y1 + y2 + 3 y3 0
v + 2 y1 4 y2 + y3 0
v + 5 y1 + 6 y2 2 y3 0
y1 + y2 + y3 = 1
y1 , y2 , y3 0
v unrestricted
Excel Solver
:A

181

:B

Solver B

182


A B
.
B
. : A

B
produce groceries ba ker y
6
4

meat
2
produce 2

groceries 2
meat


A x1 x2
x3 . A :

max v
st
v 2 x1 + 2 x2 2 x3 0
7 x3 0

v 2 x1

v + 8 x1 6 x2 x3 0
v 6 x1 + 4 x2 + 3 x3 0
x1 + x2 + x3 = 1
x1 , x2 , x3 0, v unrestrected

183

Solver
:Excel

184

185

186

:Case Study
A ) B Single
(Simultaneous Move Game

:
Payoff from A to B
Bs Move
b
6
8
4

a
4
5
3

a
b
c

As Move

B ) (a ) (b A ) (a ) (b
) (c A ) (b B ) (a A B 5 .
A ) (c B ) (a B 3 .A
The Minimax Strategy
. A
) (b 8 B ) (a 5
.
Random Strategy
.
:
BMi = probability B makes move i, i = a or b,
187

AMi = probability A makes move i, i = a, b, or c.


B BMi B:
A ) (a Expected Loss:
4 BMa 6 BMb.
A ) (b Expected Loss:
5 BMa + 8 BMb.
A ) (c ExpecteL loss:
3 BMa 4 BMb.
.A
B BMi
Minimize the Maximum Expected Loss Minimax
Strategy : B BMi
A B . LB
B
) :(LINGO
;MIN = LB
;! Probabilities must sum to 1
;BMa + BMb = 1
;)! Expected loss if A chooses (a
;-LB + 4 * BMa - 6 * BMb <= 0
;)! Expected loss if A chooses (b
;-LB - 5 * BMa + 8 * BMb <= 0
;)! Expected loss if A chooses (c
;-LB + 3 * BMa - 4 * BMb <= 0

:
188

Global optimal solution found.


Objective value:
Infeasibilities:
Total solver iterations:

0.2000000
0.000000
2

Variable
LB
BMA
BMB
Row
1
2
3
4
5

Value
0.2000000
0.6000000
0.4000000

Reduced Cost
0.000000
0.000000
0.000000

Slack or Surplus
0.2000000
0.000000
0.2000000
0.000000
0.000000

Dual Price
-1.000000
-0.2000000
0.000000
0.3500000
0.6500000

( b) 0.6 ( a) B :
0.2 B 0.4
A .A
PA Expected Profit Minimum Maximizing
: A
MAX = PA;
! Probabilities sum to 1;
AMa + AMb + AMc = 1;
! Expected profit if B chooses (a);
-PA + 4 * AMa - 5 * AMb + 3 * AMc >= 0;
! Expected profit if B chooses (b);
-PA - 6 * AMa + 8 * AMb - 4 * AMc >= 0;

: A
Global optimal solution found.
Objective value:
Infeasibilities:
Total solver iterations:

0.2000000
0.000000
3

Variable
PA
AMA
AMB

Value
0.2000000
0.000000
0.3500000

189

Reduced Cost
0.000000
0.2000000
0.000000

0.000000
Dual Price
1.000000
0.2000000
-0.6000000
-0.4000000

AMC

0.6500000
Slack or Surplus
0.2000000
0.000000
0.000000
0.000000

Row
1
2
3
4

: A ) (b 0.35 ) (c 0.65
) (a .0.2
A .B B
A .0.2 Expected Transfer 0.2

) ( 0.2
B .A Biased A 0.2 .

.Mixed Strategy
: . LP and Dual LP

190

Equilibrium
.
Equilibrium Strategy "" "" .
Equilibrium in a game .
Rational Play .
) (
) Simultaneous Moves Static-move ( Hidden-move

.
Pay-off Matrix .Strategic Forms
Sequential Moves Dynamic Games
. Extensive Forms
.Game Trees
) Single-Stage ( ) Repeated Games (

191


Dominant Strategy Equilibrium
.
:
.

Nash Equilibrium
:
.
.
Nash Strategies

A B
:

) p ( Ai , Bi A Ai B . Bi
) p ( Ai , Bi A Ai B . Bi
p ( Ai , B i ) - A Ai B . Bi

192

Strictly Dominant Strategy


Ai A A i Bi:

) p ( Ai , Bi ) > p ( A i , Bi

) p ( Ai , Bi ) > p ( A i , B i

B A
:
) p ( Bi , Ai B Bi A . Ai
) p ( Bi , Ai B Bi A . Ai
) p ( Bi , A i B Bi A . Ai ) (...
Strictly Dominant Strategy
Bi B Bi A i:

) p ( Bi , Ai ) > p ( B i , Ai

) p ( Bi , Ai ) > p ( B i , A i
193


Ai Bi :

) p ( Ai , Bi ) > p ( A i , Bi

) p ( Bi , Ai ) > p ( B i , Ai

) = >(
Weak Nash Equilibrium Strong Nash
.Equilibrium

B
raise price lower price
A raise price
5,5
1, 2
lower price
2,1
3,3

:
Bimatrix .

}{raise price, raise price }price, lower price

{lower
194

} {raise price, raise price


} {lower price, lower price
.

195

Gambit
Gambit
Extensive Form
.Strategy Form OpenSource
http://www.gambit-project.org/


view Strategic game

196

197

. A
.B

198

199

Compute Nash equlibria

200

. . .OK

201

202

203

:
.

204

Gambit

205

206

207

208


Create a new strategic game

209

210

: Prisoners Dilemma

. .
.
. :
.
:

prisoner 2
deny confess
prisoner1 deny
1, 1 10,0
confess 0, 10 5, 5
Gambit

211

: .

212

Extensive Forms

213

) ( Insert move

214

215



)
( . 1
3

) 2 ( .

.
:

216

Iterated-dominance Equilibrium

.

217

218

219

220

221

222

223

224

225

226

Weak Iteration

)(

227

228

:
:
(1

(2

(3

229

230

Pareto Efficiency

.
Pareto Domination
) ( 1 ) ( 2
) .(1
: pure conflict

. :

231

232

1-3

233

234

235

Gambit

236

237

Gambit
: . A
A1 A2 . A3 B
B1 B2 B3
. B4
. :A

B4

B3

B2

B1

8 2 9 3
6 5 6 8

2
4

9
5

238

A1
A2
A3

239

240

241

242


A B
H .T . )
HH (TT A B B.
: A

BT
1
1
Gambit

243

BH
1
1

AH
AT

: .

244


2 x 4 A:

B4
1
6
.

245

B3

B2

B1

2
4

A1
A2

246

: .

247


:Gambit

B3

B2

B1

3 1 3
2 4 1

5 6 2
:

248

A1
A2
A3

249

: .

250

:Case Studies
(1
.

. .
) ( :


.
:

251

252

253

254

255

: ) (8- 2
" " 52

256

257

258

:
:Excel Solver

259

260

:Gambit

261

262

263

264

265

266

267

268

269

: .

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

: .

398

:Sage Normal Form


Strategic Form
Sage
:

B
1
A

1 3, 2 1,1

2 0, 0 2,3

or
3 1
2 1
A=
, B =

0 2
0 3

sage: A = matrix([[3, 1], [0, 2]])


sage: B = matrix([[2, 1], [0, 3]])
sage: b_of_s = NormalFormGame([A, B])
sage: b_of_s
sage: b_of_s.obtain_nash(algorithm=enumeration)
[[(0, 1), (0, 1)],[(3/4, 1/4),(1/4, 3/4)],[(1, 0), (1, 0)]]

A ( s1 , s2 )

s1 A s2

s1 B s2
sage: for ne in
b_of_s.obtain_nash(algorithm=enumeration):
....:

print "Utility for {}: ".format(ne)

....:

print vector(ne[0]) * A * vector(ne[1]),


vector(ne[0]) * B * vector(ne[1])

Utility for [(0, 1), (0, 1)]:

399

2 3
Utility for [(3/4, 1/4), (1/4, 3/4)]:
3/2 3/2
Utility for [(1, 0), (1, 0)]:
3 2

.Gambit :
:
B
1
A

1 1, 1 1,1

2 1,1 1, 1

or
1 1
1 1
A=
, B =

1 1
1 1

sage:
sage:
sage:
sage:

A = matrix([[1, -1], [-1, 1]])


B = matrix([[-1, 1], [1, -1]])
m_p = NormalFormGame([A, B])

m_p.obtain_nash(algorithm=enumeration)
[[(1/2, 1/2), (1/2, 1/2)]]

sage: [vector([1/2, 1/2]) * M * vector([1/2, 1/2])


....:
for M in m_p.payoff_matrices()]
[0, 0]
sage: m_p.payoff_matrices()
(
[ 1 -1] [-1 1]
[-1 1], [ 1 -1])
:
:
sage: A = matrix([[0, -1, 1, 1, -1],
....:

[1, 0, -1, -1, 1],

....:

[-1, 1, 0, 1 , -1],

400

....:

[-1, 1, -1, 0, 1],

....:

[1, -1, 1, -1, 0]])

sage: g = NormalFormGame([A])
sage: g.obtain_nash(algorithm=enumeration)
[[(1/5, 1/5, 1/5, 1/5, 1/5), (1/5, 1/5, 1/5, 1/5, 1/5)]]

sage: g.payoff_matrices()
:
sage: A = matrix([[10, 500, 44],
....:

[15, 10, 105],

....:

[19, 204, 55],

....:

[20, 200, 590]])

sage: B = matrix([[2, 1, 2],


....:

[0, 5, 6],

....:

[3, 4, 1],

....:

[4, 1, 20]])

sage: g=NormalFormGame([A, B])


sage: g.obtain_nash(algorithm=lrs) # optional - lrslib
[[(0, 0, 0, 1), (0, 0, 1)]]
sage: g.obtain_nash(algorithm=lrs, maximization=False) #
optional - lrslib
[[(2/3, 1/12, 1/4, 0), (6333/8045, 247/8045, 293/1609)],
[(3/4, 0, 1/4, 0), (0, 11/307, 296/

sage: A = matrix([[3,3],
....:

[2,5],

....:

[0,6]])

sage: B = matrix([[3,2],
....:

[2,6],

401

....:

[3,1]])

sage: g = NormalFormGame([A, B])


sage: g.obtain_nash(algorithm=enumeration)
[[(0, 1/3, 2/3), (1/3, 2/3)], [(4/5, 1/5, 0), (2/3,
1/3)], [(1, 0, 0), (1, 0)]]

sage: A = matrix([[160, 205, 44],


....:

[175, 180, 45],

....:

[201, 204, 50],

....:

[120, 207, 49]])

sage: B = matrix([[2, 2, 2],


....:

[1, 0, 0],

....:

[3, 4, 1],

....:

[4, 1, 2]])

sage: g=NormalFormGame([A, B])


sage: g.obtain_nash(algorithm=enumeration)
[[(0, 0, 3/4, 1/4), (1/28, 27/28, 0)]]
sage: g.obtain_nash(algorithm=lrs) # optional lrslib
[[(0, 0, 3/4, 1/4), (1/28, 27/28, 0)]]
sage: g.obtain_nash(algorithm=LCP) # optional gambit
[[(0.0, 0.0, 0.75, 0.25), (0.0357142857, 0.9642857143,
0.0)]]

sage: player1 = matrix([[2, 8, -1, 1, 0],

402

....:

[1, 1, 2, 1, 80],

....:

[0, 2, 15, 0, -12],

....:

[-2, -2, 1, -20, -1],

....:

[1, -2, -1, -2, 1]])

sage: player2 = matrix([[0, 8, 4, 2, -1],


....:

[6, 14, -5, 1, 0],

....:

[0, -2, -1, 8, -1],

....:

[1, -1, 3, -3, 2],

....:

[8, -4, 1, 1, -17]])

sage: fivegame = NormalFormGame([player1, player2])


sage: fivegame.obtain_nash(algorithm=enumeration)
[[(1, 0, 0, 0, 0), (0, 1, 0, 0, 0)]]
sage: fivegame.obtain_nash(algorithm=lrs) #
optional - lrslib
[[(1, 0, 0, 0, 0), (0, 1, 0, 0, 0)]]
sage: fivegame.obtain_nash(algorithm=LCP) #
optional - gambit
[[(1.0, 0.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0,
0.0)]]
Here is an example of a 3 by 2 game with 3 Nash
equilibrium:
sage: A = matrix([[3,3],
....:

[2,5],

....:

[0,6]])

sage: B = matrix([[3,2],
....:

[2,6],

....:

[3,1]])

403

sage: g = NormalFormGame([A, B])


sage: g.obtain_nash(algorithm=enumeration)
[[(0, 1/3, 2/3), (1/3, 2/3)], [(4/5, 1/5, 0), (2/3, 1/3)],
[(1, 0, 0), (1, 0)]]

sage: p1 = matrix([[1, 2], [3, 4]])


sage: p2 = matrix([[3, 3], [1, 4]])
sage: g = NormalFormGame([p1, p2])
sage: g.payoff_matrices()
(
[1 2] [3 3]
[3 4], [1 4]
)
:Sage
.
1)
sage: g =
game_theory.normal_form_games.PrisonersDilemma()
sage: g.obtain_nash()
[[(0, 1), (0, 1)]]
sage: d = {(0, 0): [-2, -2], (0, 1): [-5, 0], (1,
0): [0, -5], (1, 1): [-4, -4]}
sage: g == d
True

404

2)
sage: g =
game_theory.normal_form_games.AntiCoordinationGame()

sage: g
Anti coordination game - Normal Form Game with the
following utilities: ...
sage: d ={(0, 1): [1, 5], (1, 0): [5, 1],
....: (0, 0): [3, 3], (1, 1): [0, 0]}
sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (1, 0)], [(1/3, 2/3), (1/3, 2/3)], [(1,
0), (0, 1)]]
3)
sage: g =
game_theory.normal_form_games.BattleOfTheSexes()
sage: g
Battle of the sexes - Coordination game Normal Form Game with the following utilities: ...
sage: d = {(0, 1): [1, 1], (1, 0): [0, 0], (0, 0):
[3, 2], (1, 1): [2, 3]}
sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (0, 1)], [(3/4, 1/4), (1/4, 3/4)], [(1,
0), (1, 0)]]

405

4)
sage: g = game_theory.normal_form_games.Chicken()
sage: g
Chicken - Anti coordination game Normal Form Game with the following utilities: ...
sage: d = {(0, 1): [-1, 1], (1, 0): [1, -1],
....: (0, 0): [0, 0], (1, 1): [-10, -10]}
sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (1, 0)], [(9/10, 1/10), (9/10, 1/10)],
[(1, 0), (0, 1)]]
5)
sage: g =
game_theory.normal_form_games.CoordinationGame()
sage: g
Coordination game - Normal Form Game with the
following utilities: ...
sage: d = {(0, 1): [0, 0], (1, 0): [0, 0],
....: (0, 0): [10, 5], (1, 1): [5, 10]}
sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (0, 1)], [(2/3, 1/3), (1/3, 2/3)], [(1,
0), (1, 0)]]

406

6)
sage: g = game_theory.normal_form_games.HawkDove()
sage: g
Hawk-Dove - Anti coordination game Normal Form Game with the following utilities: ...
sage: d ={(0, 1): [2, 0], (1, 0): [0, 2],
....: (0, 0): [-2, -2], (1, 1): [1, 1]}
sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (1, 0)], [(1/3, 2/3), (1/3, 2/3)], [(1,
0), (0, 1)]]
7)
sage: g =
game_theory.normal_form_games.MatchingPennies()
sage: g
Matching pennies - Normal Form Game with the
following utilities: ...
sage: d ={(0, 1): [-1, 1], (1, 0): [-1, 1],
....: (0, 0): [1, -1], (1, 1): [1, -1]}
sage: g == d
True
sage: g.obtain_nash()
[[(1/2, 1/2), (1/2, 1/2)]]

407

8)
sage: g =
game_theory.normal_form_games.PrisonersDilemma()
sage: g
Prisoners dilemma - Normal Form Game with the
following utilities: ...
sage:

d = {(0, 0): [-2, -2], (0, 1): [-5, 0], (1, 0): [0, -5],

....:

(1, 1): [-4, -4]}

sage: g == d
True
sage: g.obtain_nash()
[[(0, 1), (0, 1)]]
9)
sage: g = game_theory.normal_form_games.RPS()
sage: g
Rock-Paper-Scissors - Normal Form Game with the
following utilities: ...
sage:

d = {(0, 1): [-1, 1], (1, 2): [-1, 1], (0, 0): [0, 0],

....:

(2, 1): [1, -1], (1, 1): [0, 0], (2, 0): [-1, 1],

....:

(2, 2): [0, 0], (1, 0): [1, -1], (0, 2): [1, -1]}

sage: g == d
True
sage: g.obtain_nash()
[[(1/3, 1/3, 1/3), (1/3, 1/3, 1/3)]]

408

10)
sage: g = game_theory.normal_form_games.RPSLS()
sage: g
Rock-Paper-Scissors-Lizard-Spock Normal Form Game with the following utilities: ...
sage:

d = {(1, 3): [-1, 1], (3, 0): [-1, 1], (2, 1): [1, -1],

....:

(0, 3): [1, -1], (4, 0): [1, -1], (1, 2): [-1, 1],

....:

(3, 3): [0, 0], (4, 4): [0, 0], (2, 2): [0, 0],

....:

(4, 1): [-1, 1], (1, 1): [0, 0], (3, 2): [-1, 1],

....:

(0, 0): [0, 0], (0, 4): [-1, 1], (1, 4): [1, -1],

....:

(2, 3): [1, -1], (4, 2): [1, -1], (1, 0): [1, -1],

....:

(0, 1): [-1, 1], (3, 1): [1, -1], (2, 4): [-1, 1],

....:

(2, 0): [-1, 1], (4, 3): [-1, 1], (3, 4): [1, -1],

....:

(0, 2): [1, -1]}

sage: g == d
True
sage: g.obtain_nash()
[[(1/5, 1/5, 1/5, 1/5, 1/5), (1/5, 1/5, 1/5, 1/5, 1/5)]]

11)
sage: g = game_theory.normal_form_games.StagHunt()
sage: g
Stag hunt - Coordination game Normal Form Game with the following utilities: ...
sage: d =
....:

{(0, 1): [0, 4], (1, 0): [4, 0],

(0, 0): [5, 5], (1, 1): [2, 2]}

sage: g == d
True

409

sage: g.obtain_nash()
[[(0, 1), (0, 1)], [(2/3, 1/3), (2/3, 1/3)], [(1, 0), (1, 0)]]

12)
sage: g =
game_theory.normal_form_games.TravellersDilemma()
sage: g
Travellers dilemma - Normal Form Game with the
following utilities: ...
sage: d = {(7, 3): [5, 1], (4, 7): [1, 5], (1, 3): [5, 9],
....: (4, 8): [0, 4], (3, 0): [9, 5], (2, 8): [0, 4],
....: (8, 0): [4, 0], (7, 8): [0, 4], (5, 4): [7, 3],
....: (0, 7): [1, 5], (5, 6): [2, 6], (2, 6): [2, 6],
....: (1, 6): [2, 6], (5, 1): [7, 3], (3, 7): [1, 5],
....: (0, 3): [5, 9], (8, 5): [4, 0], (2, 5): [3, 7],
....: (5, 8): [0, 4], (4, 0): [8, 4], (1, 2): [6, 10],
....: (7, 4): [5, 1], (6, 4): [6, 2], (3, 3): [7, 7],
....: (2, 0): [10, 6], (8, 1): [4, 0], (7, 6): [5, 1],
....: (4, 4): [6, 6], (6, 3): [6, 2], (1, 5): [3, 7],
....: (8, 8): [2, 2], (7, 2): [5, 1], (3, 6): [2, 6],
....: (2, 2): [8, 8], (7, 7): [3, 3], (5, 7): [1, 5],
....: (5, 3): [7, 3], (4, 1): [8, 4], (1, 1): [9, 9],
....: (2, 7): [1, 5], (3, 2): [9, 5], (0, 0): [10, 10],
....: (6, 6): [4, 4], (5, 0): [7, 3], (7, 1): [5, 1],
....: (4, 5): [3, 7], (0, 4): [4, 8], (5, 5): [5, 5],
....: (1, 4): [4, 8], (6, 0): [6, 2], (7, 5): [5, 1],
....: (2, 3): [5, 9], (2, 1): [10, 6], (8, 7): [4, 0],
....: (6, 8): [0, 4], (4, 2): [8, 4], (1, 0): [11, 7],
....: (0, 8): [0, 4], (6, 5): [6, 2], (3, 5): [3, 7],
....: (0, 1): [7, 11], (8, 3): [4, 0], (7, 0): [5, 1],

410

....: (4, 6): [2, 6], (6, 7): [1, 5], (8, 6): [4, 0],
....: (5, 2): [7, 3], (6, 1): [6, 2], (3, 1): [9, 5],
....: (8, 2): [4, 0], (2, 4): [4, 8], (3, 8): [0, 4],
....: (0, 6): [2, 6], (1, 8): [0, 4], (6, 2): [6, 2],
....: (4, 3): [8, 4], (1, 7): [1, 5], (0, 5): [3, 7],
....: (3, 4): [4, 8], (0, 2): [6, 10], (8, 4): [4, 0]}

sage: g == d
True
sage: g.obtain_nash() # optional - lrs
[[(0, 0, 0, 0, 0, 0, 0, 0, 1), (0, 0, 0, 0, 0, 0, 0, 0, 1)]]

sage: g =
game_theory.normal_form_games.TravellersDilemma(5)
sage: g
Travellers dilemma - Normal Form Game with the
following utilities: ...
sage: d = {(0, 1): [2, 6], (1, 2): [1, 5], (3, 2): [4, 0],
....: (0, 0): [5, 5], (3, 3): [2, 2], (3, 0): [4, 0],
....: (3, 1): [4, 0], (2, 1): [5, 1], (0, 2): [1, 5],
....: (2, 0): [5, 1], (1, 3): [0, 4], (2, 3): [0, 4],
....: (2, 2): [3, 3], (1, 0): [6, 2], (0, 3): [0, 4],
....: (1, 1): [4, 4]}

sage: g == d
True
sage: g.obtain_nash()
[[(0, 0, 0, 1), (0, 0, 0, 1)]]

411

SageMath

.
Coalitions
Games in Coalitional Form
- Many-Prson Games
-1 .
-2 .
-3 Transferrable Utility Side
Payments .
) (
-4 .
Coalitional Form. Characteristic
Functions

n2

1 n

}N = {1,2,...n

S N S N
) 2 N Empty
(Coalition N Grand Coalition n = 2

{
}
8 } { ,{1} ,{2} ,{3} ,{1,2} ,{1,3} ,{2,3} , N n

) ( 4 ,{1} ,{2} , N n = 3

2 N 2n .
412

:
n n-person ) ( N , v
} N = {1,2,...n v
Characterstic Function 2 N
:
v ( ) = 0 (1
(2 S T S T =
) ) v ( S ) + v (T ) v ( S T (Superadditivity
) v ( S S N
S .
) (1 ) (2
) (
.
:
Monotone v ( S ) v (T ) T S

:
Constant-Sum
) v ( S ) + v ( S ) = v ( N S 2 N
Zero-Sum . v ( N ) = 0

413

:
3 I II III 1 2

(1 I 1

III
1

)( 0,3,1) ( 2,1,1
)( 4,2,3) (1,0,0

II 1
2

(2 I 1

III
2

)(1,0,0) (1,1,1
)(0,0,1) (0,1,1

II 1
2

:I
I1: first row
)(I1,II1,III1): (0,3,1
)(I1,II1,III2): (2.1.1
)(I1,II2,III1): (4,2,3
)(I1,II2,III2): (1,0,0
I2: second row
)(I2,II1,III1): (1,0,0
)(I2,II1,III2): (1,1,1
)(I2,II2,III1): (0,0,1
)(I2,II2,III2): (0,1,1
414

v ( ) = 0

) v ( N ) (1,2,1 )( 4,2,3
v ( N ) = 9 ) } v ({1 I
):(II,III

) ( II , III
1,1 1,2 2,1 2,2
I 1 0 2 4 1
2 1 1 0 0

)]] sage: A = matrix([[0, 2, 4, 1 ],[1, 1, 0, 0
)]sage: gI = NormalFormGame([A
)(sage: M = gI.obtain_nash
sage: M
]])[[(1/2, 1/2), (1/2, 0, 0, 1/2
sage: for ne in gI.obtain_nash():
)]print vector(ne[0]) * A * vector(ne[1

...
1/2

Gambit
. v ({1} ) = 1 2
) }v ({2

415

II1: first row


(I1,II1,III1): (0,3,1)
(I1,II1,III2): (2.1.1)
(I2,II1,III1): (1,0,0)
(I2,II1,III2): (1,1,1)
II2: second row
(I1,II2,III1): (4,2,3)
(I1,II2,III2): (1,0,0)
(I2,II2,III1): (0,0,1)
(I2,II2,III2): (0,1,1)

( I , III )
1,1 1,2 2,1 2,2
II

sage:
sage:
sage:
sage:
[[(0,
sage:
...
0
0

A =
gII
M =
M
1),
for

matrix([[3, 1, 0, 1 ],[2, 0, 0, 1 ]])


= NormalFormGame([A])
gII.obtain_nash()
(0, 0, 1, 0)], [(1, 0), (0, 0, 1, 0)]]
ne in gII.obtain_nash():
print vector(ne[0]) * A * vector(ne[1])

Gambit
v ({2} ) = 0

416

v ({3} )

III1: first row


(I1,II1,III1): (0,3,1)
(I1,II2,III1): (4,2,3)
(I2,II1,III1): (1,0,0)
(I2,II2,III1): (0,0,1)
III2: second row
(I1,II1,III2): (2.1.1)
(I1,II2,III2): (1,0,0)
(I2,II1,III2): (1,1,1)
(I2,II2,III2): (0,1,1)

( I , II )
1,1 1,2 2,1 2,2
III

1 3

sage: A = matrix([[1, 3, 0, 1 ],[1, 0, 1, 1 ]])


sage: gIII = NormalFormGame([A])
sage: M = gIII.obtain_nash()
sage: M
[[(1/4, 3/4), (0, 1/4, 3/4, 0)]]
sage: for ne in gIII.obtain_nash():
...

print vector(ne[0]) * A * vector(ne[1])

3/4

417

Gambit
v ({3} ) = 3 4

: II III I v ( {1,3} )
I,III: II1 first column
(I1,II1,III1): (0,3,1) 1
(I1,II1,III2): (2,1,1) 3
(I2,II1,III1): (1,0,0) 1
(I2,II1,III2): (1,1,1) 2
I,III: II2 second column
(I1,II2,III1): (4,2,3) 7
(I1,II2,III2): (1,0,0) 1
(I2,II2,III1): (0,0,1) 1
(I2,II2,III2): (0,1,1) 1

II
1 2

I , III

1,1

1 7

1,2

3 1

2,1
2,2

1 1
2 1

sage: A = matrix([[1, 7], [3, 1 ],[1, 1], [2, 1 ]])


sage: gI_III = NormalFormGame([A])
sage: M = gI_III.obtain_nash()
sage: M
[[(1/4, 3/4, 0, 0), (3/4, 1/4)]]

418

sage: for ne in gI_III.obtain_nash():


...

print vector(ne[0]) * A * vector(ne[1])

5/2

v ({1,3} ) = 5 2

Gambit
I III II v ( {1,2} ) III II I
v ({2,3} )

I,II: III1 first column


(I1,II1,III1): (0,3,1) 3
(I1,II2,III1): (4,2,3) 6
(I2,II1,III1): (1,0,0) 1
(I2,II2,III1): (0,0,1) 0
I,II: III2 second column
(I1,II1,III2): (2,1,1) 3
(I1,II2,III2): (1,0,0) 1
(I2,II1,III2): (1,1,1) 2
(I2,II2,III2): (0,1,1) 1

III
1 2

I , II

1,1

3 3

1,2

6 1

2,1
2,2

1 2
0 1

419

sage: A = matrix([[3, 3], [6, 1 ],[1, 2], [0, 1 ]])


sage: gI_II_III = NormalFormGame([A])
sage: M = gI_II_III.obtain_nash()
sage: M
[[(1, 0, 0, 0), (0, 1)]]
sage: for ne in gI_II_III.obtain_nash():
...

print vector(ne[0]) * A * vector(ne[1])

v ( {1,2} ) = 3

II,III: I1 first column


(I1,II1,III1): (0,3,1) 4
(I1,II1,III2): (2,1,1) 2
(I1,II2,III1): (4,2,3) 5
(I1,II2,III2): (1,0,0) 0
II,III: I2 second column
(I2,II1,III1): (1,0,0) 0
(I2,II1,III2): (1,1,1) 2
(I2,II2,III1): (0,0,1) 1
(I2,II2,III2): (0,1,1) 2

420

I
1 2

II , III

1,1

4 0

1,2

2 2

2,1
2,2

5 1
0 2

sage: A = matrix([[4, 0], [2, 2 ],[5, 1], [0, 2 ]])


sage: gII_III_I = NormalFormGame([A])
sage: M = gII_III_I.obtain_nash()
sage: M
[[(0, 1, 0, 0), (0, 1)]]
sage: for ne in gII_III_I.obtain_nash():
...

print vector(ne[0]) * A * vector(ne[1])

v ({2,3} ) = 2

v( ) = 0
v({1}) = 0.5
v({2}) = 0
v({3}) = 0.75
v({1,2}) = 3
v({1,3}) = 2.5
v({2,3}) = 2
v({N}) = 9

421

:

)1

I ,1

III
1

)( 2,1,1) (1, 4,3


) (1,3, 4 ) (10, 5, 4

II

I ,2

III
1

)( 1, 2,3

) ( 4,2,2
) (12, 6, 6 ) ( 1,3, 2

II

2
)2

I ,1

III
1

)(1,2,1

)( 3,0,1
)( 1,6, 3) ( 3,2,1

1
2

I ,2

III
2

)( 1,2,4 ) (1,0,3
)( 7,5,4 ) ( 3,2,1

422

II

1
2

II

Imputation and the Core


.
Superadditivity ) v ( N
.
.
.
Imputation

x = x , x ,..., xn .
1 2
xi i .
) . v ( N
:

x = x , x ,..., xn Group Rational


1 2
n
Efficient ) xi = v ( N
i=1

) ( . ) } xi v ({i
.
:

x = x , x ,..., xn Individually
1 2
Rational ) } xi v ({i . i = 1,2,..., n
.
423

} { x = ( x1, x2,..., xn ) : iN xi = v ( N ) and xi v ({i}) i N


)

x = x , x ,..., xn ) }xi v ({i


1 2
n
i = 1,2,..., n ) . xi = v ( N
i=1

.
Essential Games

n
n
) v ({i} ) = v ( N ) . v ({i} ) < v ( N
i=1
i=1
The Core
:
x S
v ( S ) > iS xi S x
S .
:
C

424

( {

C = x = x , x ,..., xn : iN xi = v ( N ) and iS xi v ( S ) S N
1 2

: .
.
.
:

v ( {1,2} ) = 4
v ( {1,3} ) = 3 v ({1,2,3} ) = 8

v ({1} ) = 1
v ( ) = 0 v ({2} ) = 0

v ({3} ) = 1 v ({2,3} ) = 5
x , x , x
1 2 3

x 1, x 0, x 1
1
2
3

x + x + x = 8,
1 2 3

:
v ) v ( S S
) v ( S ) = f ( S . f
The Shapley Value

v ) ( v ) = ( v ) , ( v ) ,...,n ( v
1
2
) i ( v i .
:
) (Fairness ) : ( v

(1 iN i ( v ) = v ( N ) : Efficiency
425

(2 :Symmetry i j ) } v ( S {i} ) = v ( S { j
S i j ) i ( v ) = j ( v

(3 : Dummy Axiom i ) } v ( S ) = v ( S {i
S i i ( v ) = 0

(4 :Additivity u v
) (u + v ) = (u ) + ( v

) )((1
:
.
:

= , ,...,n
1 2

( S 1)!( n S )! v ( S ) v ( S {i} ) , i = 1,..., n

!n

= ) i ( v
SN
iS

S . i
) } v ( S ) v ( S {i S ) i
)} ( v(S-{i i .S
module
SageMath
) : (SageMath
Sage
426

v ( ) = 0
v ({1} ) = 1
v ({2} ) = 0
v ({3} ) = 1
v ({1,2} ) = 4
v ({1,3} ) = 3
v ({2,3} ) = 5
v ({1,2,3} ) = 8
:
https://sagecell.sagemath.org/
:
integer_function = { ():0, (1,):1, (2,):0, (3,):1,
(1,2,):4, (1,3,):3, (2,3,):5, (1,2,3,):8}
integer_game = CooperativeGame(integer_function)
integer_game
integer_game.shapley_value()
integer_game.is_monotone()
integer_game.is_superadditive()

427

8 7/3
17/6 .

:
i_fun = { ():0, (1,):0.5, (2,):0, (3,):0.75,
}(1,2,):3, (1,3,):2.5, (2,3,):2, (1,2,3,):9
)l_g = CooperativeGame(i_fun
l_g

428

l_g.shapley_value()
l_g.is_monotone()
l_g.is_superadditive()

429

430

:
sage: integer_function = {(): 0,
....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: letter_function = {(): 0,
....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game =
CooperativeGame(letter_function)
sage: letter_function = {(): 0,
....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

431

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game = ooperativeGame(letter_function)


sage: letter_game.is_monotone()
sage: letter_game.is_superadditive()
sage: letter_game
sage: letter_game.shapley_value()
sage: payoff_vector = letter_game.shapley_value()
sage: letter_game.is_efficient(payoff_vector)
sage: letter_game.nullplayer(payoff_vector)
sage: letter_game.is_symmetric(payoff_vector)
sage: payoff_vector = {A: 0, C: 35, B: 3}
sage: letter_game.is_efficient(payoff_vector)
sage: letter_game.nullplayer(payoff_vector)
sage: letter_game.is_symmetric(payoff_vector)

sage: letter_function = {(): 0,


....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

432

....:

(A, B,): 12,

....:

(C, A,): 42,

....:

(B, C,): 42,

....:

(B, A, C,): 42}

sage: letter_game = ooperativeGame(letter_function)


sage: letter_game.shapley_value()
{A: 2, B: 5, C: 35}
sage: letter_game.is_monotone()
sage: letter_game.is_superadditive()
sage: letter_game.is_efficient({A: 2, C: 35,
B: 5})
sage: letter_game.nullplayer({A: 2, C: 35, B:
5})
sage: letter_game.is_symmetric({A: 2, C: 35,
B: 5})
sage: letter_game.is_efficient({A: 0, C: 35,
B: 3})
sage: letter_game.nullplayer({A: 0, C: 35, B:
3})
sage: letter_game.is_symmetric({A: 0, C: 35,
B: 3})
sage: letter_function = {(): 0,
....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

433

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game =
CooperativeGame(letter_function)
sage: letter_game.is_efficient({A: 14, B: 14,
C: 14})
sage: letter_function = {(): 0,
....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game = ooperativeGame(letter_function)


sage: letter_game.is_efficient({A: 10, B: 14,
C: 14})
sage: long_function = {(): 0,
....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

434

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

sage: long_game = CooperativeGame(long_function)


sage: long_game.is_efficient({1: 20, 2: 20, 3: 5,
4: 20})
sage: integer_function = {(): 0,
....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: integer_game.is_monotone()

sage: integer_function = {(): 0,

435

....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 10,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: integer_game.is_monotone()
sage: long_function = {(): 0,
....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

436

sage: long_game = CooperativeGame(long_function)


sage: long_game.is_monotone()

sage: integer_function = {(): 0,


....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: integer_game.is_superadditive()
sage: A_function = {(): 0,
....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 18,

....:

(1, 3,): 48,

....:

(2, 3,): 55,

....:

(1, 2, 3,): 80}

sage: A_game = CooperativeGame(A_function)


sage: A_game.is_superadditive()

437

sage: long_function = {(): 0,


....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

sage: long_game = CooperativeGame(long_function)


sage: long_game.is_superadditive()
sage: long_function = {(): 0,
....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 55,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

438

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 85}

sage: long_game = CooperativeGame(long_function)


sage: long_game.is_superadditive()
sage: letter_function = {(): 0,
....:

(A,): 6,

....:

(B,): 12,

....:

(C,): 42,

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game =
CooperativeGame(letter_function)
sage: letter_game.is_symmetric({A: 5, B: 14,
C: 20})
sage: integer_function = {(): 0,
....:

(1,): 12,

....:

(2,): 12,

439

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: integer_game.is_symmetric({1: 2, 2: 5, 3:
35})
sage: long_function = {(): 0,
....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

sage: long_game = CooperativeGame(long_function)

440

sage: long_game.is_symmetric({1: 20, 2: 20, 3: 5,


4: 20})
sage: letter_function = {(): 0,
....:

(A,): 0,

....:

(B,): 12,

....:

(C,): 42,

....:

(A, B,): 12,

....:

(A, C,): 42,

....:

(B, C,): 42,

....:

(A, B, C,): 42}

sage: letter_game =
CooperativeGame(letter_function)
sage: letter_game.nullplayer({A: 0, B: 14, C:
14})
sage: A_function = {(): 0,
....:

(1,): 0,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 55,

....:

(1, 2, 3,): 55}

sage: A_game = CooperativeGame(A_function)


sage: A_game.nullplayer({1: 10, 2: 10, 3: 25})

441

sage: long_function = {(): 0,


....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

sage: long_game = CooperativeGame(long_function)


sage: long_game.nullplayer({1: 20, 2: 20, 3: 5, 4:
20})
sage: A_function = {(): 0,
....:

(1,): 42,

....:

(2,): 12,

....:

(3,): 0,

....:

(1, 2,): 55,

....:

(1, 3,): 42,

....:

(2, 3,): 12,

442

....:

(1, 2, 3,): 55}

sage: A_game = CooperativeGame(A_function)


sage: A_game.nullplayer({1: 10, 2: 10, 3: 25})
sage: integer_function = {(): 0,
....:

(1,): 6,

....:

(2,): 12,

....:

(3,): 42,

....:

(1, 2,): 12,

....:

(1, 3,): 42,

....:

(2, 3,): 42,

....:

(1, 2, 3,): 42}

sage: integer_game =
CooperativeGame(integer_function)
sage: integer_game.player_list
sage: integer_game.shapley_value()
sage: long_function = {(): 0,
....:

(1,): 0,

....:

(2,): 0,

....:

(3,): 0,

....:

(4,): 0,

....:

(1, 2): 0,

....:

(1, 3): 0,

....:

(1, 4): 0,

....:

(2, 3): 0,

....:

(2, 4): 0,

443

....:

(3, 4): 0,

....:

(1, 2, 3): 0,

....:

(1, 2, 4): 45,

....:

(1, 3, 4): 40,

....:

(2, 3, 4): 0,

....:

(1, 2, 3, 4): 65}

sage: long_game = CooperativeGame(long_function)


sage: long_game.shapley_value()

444

:Matching Games
N Suitors N
Reviewers Rank Preferences
.
:
N S R N
S R : Preference List

g: R SN

and

f : S RN

} S = { J , K , L, M
}R = { A, B, C, D

if s = J ,
if s = K ,
if s = L,
if s = M ,

) ( A, D, C, B
) ( A, B, C, D
) ( B, D, C, A
) ( C, A, B, D

( s ) =

( L, J , K , M ) if s = A,
( J , M , L, K ) if s = B,
( K , M , L, J ) if s = C,
( M , K , J , L ) if = s = D.

445

g ( s ) =

Sage
sage: suitr_pref = {J: (A, D, C, B),
K: (A, B, C, D),

....:

L: (B, D, C, A),

....:

})M: (C, A, B, D

....:

sage: reviewr_pref = {A: (L, J, K, M),


B: (J, M, L, K),

....:

C: (K, M, L, J),

....:

})D: (M, K, J, L

....:

)]sage: m = MatchingGame([suitr_pref, reviewr_pref


sage: m
A matching game with 4 suitors and 4 reviewers
)(sage: m.suitors
)(K, J, M, L
)(sage: m.reviewers
)(A, C, B, D

:
M Bijection S . R s S r R
M . M ( s ) = r
Stable
.
:
Blocking Pairs
) ( s, r M ( s ) r s r ) M(r r s ).M-1(r

446

: Sage
sage: m.solve()
{J: A, K: C, L: D, M: B}
Bipartite Graphs
sage: plot(m)
Graphics object consisting of 13 graphics
primitives

:
sage: left_dict = {a: (A, B, C),
....:

b: (B, C, A),

....:

c: (B, A, C)}

sage: right_dict = {A: (b, c, a),


....:

B: (a, c, b),

....:

C: (a, b, c)}

447

sage: quick_game = MatchingGame([left_dict,


right_dict])
sage: quick_game.solve()
{a: A, b: C, c: B}
sage: quick_game.solve(invert=True)
{A: c, B: a, C: b}

sage: suitr_pref = {J: (A, D, C, B),


....:

K: (A, B, C, D),

....:

L: (B, D, C, A),

....:

M: (C, A, B, D)}

sage: reviewr_pref = {A: (L, J, K, M),


....:

B: (J, M, L, K),

....:

C: (K, M, L, J),

....:

D: (M, K, J, L)}

sage: m = MatchingGame([suitr_pref, reviewr_pref])


sage: m._suitors
[K, J, M, L]
sage: m._reviewers
[A, C, B, D]
sage: suit = {0: (3, 4),
....:

1: (3, 4)}

sage: revr = {3: (0, 1),


....:

4: (1, 0)}

sage: g = MatchingGame([suit, revr])

448

sage: g = MatchingGame(3)
sage: g
sage: for s in g.suitors():
....:

s, s.pref
(1, [])
(2, [])
(3, [])

sage: for r in g.reviewers():


....:

r, r.pref
(-1, [])
(-2, [])
(-3, [])

sage: g.solve()
sage: for s in g.suitors():
....:

s.pref = (-1, -2, -3)

sage: for r in g.reviewers():


....:

r.pref = (1, 2, 3)

sage: g.solve()
{1: -1, 2: -2, 3: -3}

449


Combinatorial Games two-
person .

.
. .
.
:
-1 Impartial Games
.
-2 Partizan Games
.
: :A Simple Take-Away Game
:
-1 A .B
-2 21.
-3
.
-4 A.
-5 )
(.

450

.
: Backward Induction

.
4
.
4 . 5 6
7 4 .
8 5 6 7
.
0 4 8 12 16 ...
Target Positions .
21 . 21 4
. 20
.

:
:
-1 .
451

-2 .
-3
.
.
-4 .
-5 .
-6 .
-7 .
-8
.
P :P-positions, N-positions N
0 4 8 12 16 ...
) Previous player ( 1 2 3
5 6 7 9 10 11 ... Next player
.
P N P
4
.
P N Labelling
) Terminal Position (.
P :N
:1 .P

452

:2 P .N
:3 N
.P
:4 P 3 . 2
P
P N P
P .
P N :
P N :
-1 .P
-2 N .P
-3 P .N

:Subtraction Games

.
S . S
:
n .
s s S .

}. S = {1, 2,3

453

} S = {1,3, 4
.P
.0 1 3 4 N
.0 2 P
2 1 N 5 6 N
.2 7 P
7 6 4 3 .N
8 10 11 N 9 P 12 13
N 14 P P
} P = {0, 2,7,9,14,16,...
0 2 .7 N
} N = {1,3, 4,5,6,8,10,11,12,13,15,... :

9 10 11 12 13 14...

position P

P ...

P N P N N N N 7 .
100
P 0 2 .(Modulus 7) 7
100 2 7 100 P
.
:

454

-1 Misere Version
. .
-2 }. S = {1, 2,3, 4,5,6
- .
- P
- 31
-3 m n ) ( m, n
m > 0 . n > 0 .

. ) . (1,1
. .P
-4 P :
)( }. S = {1,3,5,7
)( }. S = {1,3,6
)( 100

:The Game of Nim


:
-1 3 x1 x2 x3 )
5 7 9 (.
-2 .

455

-3 .

.
-4 .
:
http://www.chlond.demon.co.uk/Nim.html
http://www.dotsphinx.com/nim/
:
) ( 0,0,0 ) . P
: ( .
) ( 0,0, x x > 0
. N P
) ( 0,1,1 ) ( 0, 2, 2


.
.
) (1,1,1 ) (1,1, 2 ) (1,1,3 ) (1, 2, 2 N
) (1,1,0 ) ( 0, 2, 2 ) (1, 2,3
P N .
P ) (1, 4,5 ) ( 2, 4,6
) ( 5,7,9 P ) (15, 23,30 P
456


.
:Nim Sum
without carry
.2
: x 2

x = xm 2m + xm1 2m1 + + x1 21 + x0
.m xi .1
( xm xm1...x1 x0 )2 x .

22 = 1 16 + 0 8 + 1 4 + 1 2 + 0 1 = (10110 )2
2
2 :
: ( xm x0 )2 ( ym y0 )2 ( zm z0 )2

( xm x0 )2 ( ym y0 )2 = ( zm z0 )2
k

) zk = xk + yk ( mod 2

1, xk + yk = 1
zk =
0, otherwise
:

(10110 )2 (110011)2 = (100101)2


22 51 = 37
457

22 = 0 1 0 1 1 02
51 = 1 1 0 0 1 12
nim sum = 1 0 0 1 0 12 = 37
:
2

0 0 1 1

0 1 0 1

sum 0 1 1 0
) ( x ( xor ) y x y

:
) ( x1 , x2 , x3 P
. x1 x2 x3 = 0
) ( x1 , x2 , x3 ) = (13,12,8 P

13 12 : 8

13 = 1 1 0 12
12 = 1 1 0 02
1 0 0 02
= 9

nim sum = 1 0 0 12

N .

458

=8

P
1 . 9 13 4
:

1 0 02

=4

12 = 1 1 0 02
1 0 0 02
= 0

=8

nim sum = 0 0 0 02

7 12 5 .

:
3
4 .

) ( x1 , x2 , x3 , x4 P . x1 x2 x3 x4 = 0
)
(.
: N )
(1 ) .(1
.

:Gambit
459

. 5 .
.
.

:
-1 27 17
-2 38 x 25 x
-3 :
( 3 12 19 .27
460

( 4 13 17 19 .23
( )( )(
: Misere Version
.
-4 :
http://www.chlond.demon.co.uk/Coins.html
http://www.chlond.demon.co.uk/Northcott.html
http://www.math.ucla.edu/~tom/Games/Moore.htm

461

:Utility Theory
) (
a1 a2 .
"
" .

.

.
Preferences Consistent .
""
Utility

.
P P1 , P2 ,... . P
:
Preference relation P P
)( :
) -1 (Linearity P1 P2 P P1 P2 ) P2 P1
(.

462

) -2 (Transitivity P1 P2 P3 P P1 P2 P2 P3
. P1 P3 P1 P2 P2 P1 P1 P2
Equivalent . P1 P2
P
. P1 P2 P1 P2
P2 P1 . P1 P2 P1 P2

) Indifferent ( P1 P2 P1 P2 P2
P1 .
P2 P1
P2 . P1
)( Lottery .
:
Lottery . P
*. P
P1 P2 P3 p P1 1/2

P2 1/4 P3 1/4 . p1 p2
p3 *. P
p1 p2 0 1 p1 + (1 ) p2
.
P
* P.

463

* P Utility
.Function
:
Utility Function . P . u : P
) u ( P Domain u * P
) u ( p P* p

* p P P1 , P2 ,..., Pk 1 , 2 ,..., k

i 0 = 1

)(1

) u ( p ) = i u ( Pi
i =1

.p u
* P :

p1 p2

) u ( p1 ) u ( p2

)( 2

) p1 p2 u ( p1 ) u ( p2

.
* P u P ) (2
:
:A1 p1 p2 q * P 0 1

)( 3

p1 p2 p1 + (1 ) q p2 + (1 ) q
464

:A2 p1 p2 q *P

)( 4

p1 p2 > 0 : p1 q + (1 ) p2

)( 5

p1 p2 > 0 : q + (1 ) p1 p2

A1 :

q p1 . p2 p2
. p1 p2
.
A2 Continuity Axiom ) (4
p1 q + (1 ) p2 = 0
. A2
.
:
* P A1 A2
u P ) .(2 u unique
location .scale
) u ( P ) (2 a b > 0

) u ( P ) = a + b u ( P
) .(2 u
.
* P
1 2 P
465

.

.
) : (Utility Theory
:

(1) u ( p1 ) u ( p2 ) p1 p2
) (2) u p1 + (1 ) p2 = u ( p1 ) + (1 ) u ( p2

) u ( P ) = a + b u ( P ) (1 ).(2
: Prisoners Dilemma

. .
.
. :
.
:

Payoffs

prisoner 2
deny confess
prisoner1 deny
1, 1 10,0
confess 0, 10 5, 5

)
(:
Payoffs: -10, -5, -1, 0
466

10 ) 0 : (Satisfaction
5 )(5 :
1 )(10 :
0 )(15 :
:
Payoff Utility (Satisfaction) Utility Function
0
5
10
15

0
0.33
0.66
1

- 10
-5
-1
0

Utility

prisoner 2
deny confess
prisoner1 deny 10,10
0,15
confess 15,0
5,5
:

Utility Function

prisoner 2
deny
confess
prisoner1 deny 0.66,0.66
0,1
confess
1,0
0.33,0.33
:

467

Utility Function
1

0
10

Prison Time

:Gambit
:

468

Satisfaction

0.5

469

470

471

472

473

474

475

:
. A
A1 A2 . A3 B
B1 B2 B3
. B4
. :A

476

Payoff
A1
A2
A3

B1

B2

B3

B4

8 2 9 3
6 5 6 8

2 4 9 5
:

Payoffs Scale
-9
-3
-2
4
5
6
8
9

Utility
A1
A2
A3

B1

B2

0
1
2
3
4
5
6
7

B3

Utility
0
0.142857
0.285714
0.428571
0.571429
0.714286
0.857143
1

B4

1
0.143
0.857 0.286
0.714 0.571 0.714 0.857

0.286 0.429
0
0.571

477

utility
1

0.8

0.6

0.4

0.2

0
9

:
-1 .
-2 .Gambit
-3 .SageMath
:
.

478

-3

-6

-9

:
:
Excel Solver .Gambit .SageMath(1

.
:A

B4

B3

B2

B1

)(a

A1

A2

A3

B2

B1

B4

B3

4 4 5

3 4 9 2

A2

3 9

A4

(2
. :A

479

A1
A3

8 9
5

)(b

B4

B3

B2

B1

)(a

A1

A2

5 2 10

A3

A4

B3

B2

B1

)(a

A1

10

A2

A3

A4

4 2 5
B4

B3

B2

B1

)(c

A1

A2

A3

B4

B3

B2

B1

) (d

A1

A2

A3

(3
. %50
.
.
.

480

. %50
%30 %20
.

.
(4
.

300 %50
2
%30 ) 300(.
.
(5
A :

B2

B1

B3
50

50

A1

0.1

A2

10

10

A3

5
1
A , 0, B
6
6
49 5

, .
, 0
54 54
(6
.
481

B1

B2

B3

B4

A1

3 2

A2

3 3 0

A3

2 2 2

A4

1 2

1 2

4 1
(7

482

(8

483

(9

484

(10

(11

485

(12

(13

486

(14

(15

487

(16

(17

488

(18

(19

489

(20

(21

490

(22

(23

491

(24

(25

492

(26

493

(27

494

(28

495

(29

496

(30

497

(31

498


Applied Management Science, By J.A. Lawrence and B.A.
Pasternack, 2nd ed. Wiley
Operations Research, an introduction, By Hamdy Taha, 8th
ed. Prentice-Hall
A Guide to Game Theory,By Fiona Carmichael, 1st. ed.
Prentice-Hall
Game Theory, Thomas S. Ferguson, Publisher: UCLA 2008
Spreadsheet Modeling & Decision Analysis,Cliff T.
Ragsdale,5e. Thomson, South-Western
Treeplan Manual, http://www.treeplan.com.
Gambit: Software Tools for Game Theory, online Manual,
http://www.gambit-project.org/doc/index.html.
Sage Reference Manual: Game Throry Release 6.8, Jan
29,2015.
. . .
. . .

499

:LINGO :
For lingo

maximize : v
st :
v 2 x1 4 x2 0
v 2 x1 3x2 0
v 3 x1 2 x2 0
v + x1 6 x2 0
x1 + x2 = 1
x1 0, x1 0, v unrestricted
MIN = v;
-v - 2*x1 - 4*x2 <= 0;
-v - 2*x1 -3*x2 <=0;
-v - 3*x1 -2*x2 <= 0;
-v + x1 - 6*x2 <= 0;
x1 + x2 =1;
@FREE(v);
Global optimal solution found.
Objective value:
Infeasibilities:
Total solver iterations:

-2.500000
0.000000
3

Variable
V
X1
X2
Row
1
2
3
4
5
6

Value
-2.500000
0.5000000
0.5000000
Slack or Surplus
-2.500000
0.5000000
0.000000
0.000000
0.000000
0.000000

500

Reduced Cost
0.000000
0.000000
0.000000
Dual Price
-1.000000
0.000000
0.000000
0.8750000
0.1250000
2.500000

maximize v
st
v 3x1 + 2 x2 + 5 x3 0
v x1 4 x2 + 6 x3 0
v + 3x1 + x2 2 x3 0
x1 + x2 + x3 = 1
x1 , x2 , x3 0
v unrestricted
MIN = v;
-v - 3*x1
-v - x1 -v + 3*x1
x1 + x2 +
@FREE(v);

+ 2*x2 + 5*x3 <= 0;


4*x2 + 6*x3 <=0;
+ x2 - 2*x3 <= 0;
x3 =1;

Global optimal solution found.


Objective value:
Infeasibilities:
Total solver iterations:

0.8350515
0.000000
4

Variable
V
X1
X2
X3
Row
1
2
3
4
5

Value
0.8350515
0.4432990
0.2061856
0.3505155
Slack or Surplus
0.8350515
0.000000
0.000000
0.000000
0.000000

501

Reduced Cost
0.000000
0.000000
0.000000
0.000000
Dual Price
-1.000000
0.2989691
0.9278351E-01
0.6082474
-0.8350515

minimize v
st
v 3 y1 + y2 + 3 y3 0
v + 2 y1 4 y2 + y3 0
v + 5 y1 + 6 y2 2 y3 0
y1 + y2 + y3 = 1
y1 , y2 , y3 0
v unrestricted
max v

st
v 2 x1 + 2 x2 2 x3 0
v 2 x1

7 x3 0

v + 8 x1 6 x2 x3 0
v 6 x1 + 4 x2 + 3 x3 0
x1 + x2 + x3 = 1
x1 , x2 , x3 0, v unrestrected
MIN = v;
-v - 2*x1
-v - 2*x1
-v + 8*x1
-v - 6*x1
x1 + x2 +
@FREE(v);

+ 2*x2
- 0*x2
- 6*x2
+ 4*x2
x3 =1;

2*x3 <= 0;
7*x3 <=0;
x3 <= 0;
3*x3 <= 0;

Global optimal solution found.


Objective value:
Infeasibilities:
Total solver iterations:

0.4440892E-15
0.000000
4

Variable
V
X1
X2

Value
0.000000
0.3888889
0.5000000

502

Reduced Cost
0.000000
0.000000
0.000000

X3
Row
1
2
3
4
5
6

0.1111111
Slack or Surplus
0.000000
0.000000
1.555556
0.000000
0.000000
0.000000

503

0.000000
Dual Price
-1.000000
0.3333333
0.000000
0.3333333
0.3333333
0.000000

: SageMath :
open-source
Python R .
Matlab Mathematica Maple.
http://www.sagemath.org/
) (Linux Virtual
Box SageMathCloud
https://cloud.sagemath.com SageMathCell
https://sagecell.sagemath.org
http://sagemath.wikispaces.com
SageMath

.
.
Notebook Command Line
.
):
(sage:
SageMath : Python
http://www.abarry.ws/Statistics with Python by Example.pdf

504

:
sage:
sage:
5
sage:
True
sage:
False
sage:
True
sage:
True

a = 5
a
2 == 2
2 == 3
2 < 3
a == 5

sage: 2**3
# ** means exponent
8
sage: 2^3
# ^ is a synonym for **
(unlike in Python)
8
sage: 10 % 3 # for integer arguments, %
means mod, i.e., remainder
1
sage: 10/4
5/2
sage: 10//4
# for integer arguments, //
returns the integer quotient
2
sage: 4 * (10 // 4) + 10 % 4 == 10
True
sage: 3^2*4 + 2%5
38
sage: sqrt(3.4)
1.84390889145858
sage: sin(5.135)
-0.912021158525540
505

sage: sin(pi/3)
1/2*sqrt(3)
sage: exp(2)
e^2
sage: n(exp(2))
7.38905609893065
sage: sqrt(pi).numerical_approx()
1.77245385090552
sage: sin(10).n(digits=5)
-0.54402
sage: N(sin(10),digits=10)
-0.5440211109
sage: numerical_approx(pi, prec=200)
3.141592653589793238462643383279502884197169
3993751058209749
sage: a = 5
# a is an integer
sage: type(a)
<type 'sage.rings.integer.Integer'>
sage: a = 5/3 # now a is a rational number
sage: type(a)
<type 'sage.rings.rational.Rational'>
sage: a = 'hello' # now a is a string
sage: type(a)
<type 'str'>
sage: 011
9
sage: 8 + 1
9
sage: n = 011
sage: n.str(8)
# string representation of
n in base 8
'11'
:
506

sage: tan?
Type:
<class
'sage.calculus.calculus.Function_tan'>
Definition: tan( [noargspec] )
Docstring:
The tangent function
EXAMPLES:
sage: tan(pi)
0
sage: tan(3.1415)
-0.0000926535900581913
sage: tan(3.1415/4)
0.999953674278156
sage: tan(pi/4)
1
sage: tan(1/2)
tan(1/2)
sage: RR(tan(1/2))
0.546302489843790
sage: log2?
Type:
<class
'sage.functions.constants.Log2'>
Definition: log2( [noargspec] )
Docstring:
The natural logarithm of the real number
2.
EXAMPLES:
sage: log2
log2
sage: float(log2)
0.69314718055994529
507

sage: RR(log2)
0.693147180559945
sage: R = RealField(200); R
Real Field with 200 bits of precision
sage: R(log2)
0.693147180559945309417232121458176568075500
13436025525412068
sage: l = (1-log2)/(1+log2); l
(1 - log(2))/(log(2) + 1)
sage: R(l)
0.181232218299282499487613818646503114233306
09774776013488056
sage: maxima(log2)
log(2)
sage: maxima(log2).float()
.6931471805599453
sage: gp(log2)
0.6931471805599453094172321215
# 32-bit
0.69314718055994530941723212145817656807
# 64-bit
sage: sudoku?
File:
sage/local/lib/python2.5/sitepackages/sage/games/sudoku.py
Type:
<type 'function'>
Definition: sudoku(A)
Docstring:
Solve the 9x9 Sudoku puzzle defined by the
matrix A.
EXAMPLE:

508

sage: A = matrix(ZZ,9,[5,0,0, 0,8,0, 0,4,9,


0,0,0, 5,0,0,0,3,0, 0,6,7, 3,0,0, 0,0,1,
1,5,0, 0,0,0, 0,0,0, 0,0,0, 2,0,8, 0,0,0,
0,0,0, 0,0,0, 0,1,8, 7,0,0, 0,0,4, 1,5,0,
0,3,0, 0,0,2,0,0,0, 4,9,0, 0,5,0, 0,0,3])
sage: A
[5 0 0 0 8 0 0 4 9]
[0 0 0 5 0 0 0 3 0]
[0 6 7 3 0 0 0 0 1]
[1 5 0 0 0 0 0 0 0]
[0 0 0 2 0 8 0 0 0]
[0 0 0 0 0 0 0 1 8]
[7 0 0 0 0 4 1 5 0]
[0 3 0 0 0 2 0 0 0]
[4 9 0 0 5 0 0 0 3]
sage: sudoku(A)
[5 1 3 6 8 7 2 4 9]
[8 4 9 5 2 1 6 3 7]
[2 6 7 3 4 9 5 8 1]
[1 5 8 4 6 3 9 7 2]
[9 7 4 2 1 8 3 6 5]
[3 2 6 7 9 5 4 1 8]
[7 8 2 9 3 4 1 5 6]
[6 3 5 1 7 2 8 9 4]
[4 9 1 8 5 6 7 2 3]
:
sage: def is_even(n):
....:
return n%2 == 0
sage: is_even(2)
True
sage: is_even(3)
False
sage: def is_divisible_by(number,
divisor=2):
509

....:
return number%divisor == 0
sage: is_divisible_by(6,2)
True
sage: is_divisible_by(6)
True
sage: is_divisible_by(6, 5)
False
sage: is_divisible_by(6, divisor=5)
False
sage: is_divisible_by(divisor=2, number=6)
True
sage: def even(n):
....:
v = []
....:
for i in range(3,n):
....:
if i % 2 == 0:
....:
v.append(i)
....:
return v
Syntax Error:
return v
sage: def even(n):
....:
v = []
....:
for i in range(3,n):
....:
if i % 2 == 0:
....:
v.append(i)
....:
return v
sage: even(10)
[4, 6, 8]
sage: a = 5; b = a + 3; c = b^2; c
64

510

sage: 2 + \
....:
3
5
sage: for i in range(3):
....:
print i
0
1
2
sage: for i in range(2,5):
....:
print i
2
3
4
sage: for i in range(1,6,2):
....:
print i
1
3
5
sage: for i in range(5):
....:
print '%6s %6s %6s'%(i, i^2, i^3)
0
0
0
1
1
1
2
4
8
3
9
27
4
16
64
sage: range(2,10)
[2, 3, 4, 5, 6, 7, 8, 9]

511

sage: v = [1, "hello", 2/3, sin(x^3)]


sage: v
[1, 'hello', 2/3, sin(x^3)]
sage: v[0]
1
sage: v[3]
sin(x^3)
sage: len(v)
4
sage: v.append(1.5)
sage: v
[1, 'hello', 2/3, sin(x^3),
1.50000000000000]
sage: del v[1]
sage: v
[1, 2/3, sin(x^3), 1.50000000000000]
sage: d = {'hi':-2,
sage: d['hi']
-2
sage: d[e]
pi

3/8:pi,

e:pi}

sage: class Evens(list):


....:
def __init__(self, n):
....:
self.n = n
....:
list.__init__(self, range(2,
n+1, 2))
....:
def __repr__(self):
512

....:
up to n."

return "Even positive numbers

sage: e = Evens(10)
sage: e
Even positive numbers up to n.
sage: list(e)
[2, 4, 6, 8, 10]
sage: e.n
10
sage: e[2]
6
:
sage: u = var('u')
sage: diff(sin(u), u)
cos(u)
sage: x = var('x')
sage: solve(x^2 + 3*x + 2, x)
[x == -2, x == -1]
sage:
sage:
[x ==
1/2*b

x, b, c = var('x b c')
solve([x^2 + b*x + c == 0],x)
-1/2*b - 1/2*sqrt(b^2 - 4*c), x == + 1/2*sqrt(b^2 - 4*c)]

sage: x, y = var('x, y')


sage: solve([x+y==6, x-y==4], x, y)
[[x == 5, y == 1]]

513

sage: var('x y p q')


(x, y, p, q)
sage: eq1 = p+q==9
sage: eq2 = q*y+p*x==-6
sage: eq3 = q*y^2+p*x^2==24
sage: solve([eq1,eq2,eq3,p==1],p,q,x,y)
[[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3,
y == 1/6*sqrt(5)*sqrt(2) - 2/3],
[p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y
== -1/6*sqrt(5)*sqrt(2) - 2/3]]
sage: solns =
solve([eq1,eq2,eq3,p==1],p,q,x,y,
solution_dict=True)
sage: [[s[p].n(30), s[q].n(30), s[x].n(30),
s[y].n(30)] for s in solns]
[[1.0000000, 8.0000000, -4.8830369, 0.13962039],
[1.0000000, 8.0000000, 3.5497035, 1.1937129]]
sage: theta = var('theta')
sage: solve(cos(theta)==sin(theta), theta)
[sin(theta) == cos(theta)]
sage: phi = var('phi')
sage: find_root(cos(phi)==sin(phi),0,pi/2)
0.785398163397448...
sage: u = var('u')
sage: diff(sin(u), u)
514

cos(u)
sage: diff(sin(x^2), x, 4)
16*x^4*sin(x^2) - 48*x^2*cos(x^2) 12*sin(x^2)
sage:
sage:
sage:
2*x
sage:
34*y

x, y = var('x,y')
f = x^2 + 17*y^2
f.diff(x)
f.diff(y)

sage: integral(x*sin(x^2), x)
-1/2*cos(x^2)
sage: integral(x/(x^2+1), x, 0, 1)
1/2*log(2)
sage: f = 1/((1+x)*(x-1))
sage: f.partial_fraction(x)
-1/2/(x + 1) + 1/2/(x - 1)
sage: t = var('t')
# define a variable t
sage: x = function('x',t)
# define x to be
a function of that variable
sage: DE = diff(x, t) + x - 1
sage: desolve(DE, [x,t])
(_C + e^t)*e^(-t)
sage: s = var("s")
sage: t = var("t")
sage: f = t^2*exp(t) - sin(t)
sage: f.laplace(t,s)
-1/(s^2 + 1) + 2/(s - 1)^3
515


http://doc.sagemath.org/html/en/tutorial/

516

:
:
)1
sage.game_theory.catalog_normal_form_games.AntiCoor
)dinationGame(A=3, a=3,B=5, b=1,C=1, c=5,D=0, d=0


.
:

D
c

a
B =
b

A=

< and < , < , <

)2
sage.game_theory.catalog_normal_form_games.B
)(attleOfTheSexes
.
.

517

0 2

2 1

B=
0 3

A=

3
-1
-2
-3 %75 %75 .
)3
(sage.game_theory.catalog_normal_form_games.Chicken
)A=0,a=0, B=1, b=-1,C=-1, c=1,D=-10, d=-10

2 .
. .

D
c

A=

B =

b d

< and < , < , < > >



0

1 10

0
1

B=
1 10

A=

518

3
-1 .
-2 .
-3 1 10 .
)4
sage.game_theory.catalog_normal_form_games.Coordina
tionGame
)(A=10, a=5, B=0, b=0, C=0, c=0,D=5, d=10

D
c

a
B =
b

A=

> , > > > ,


10

0 5

5 0

B=
0 10

A=

)5
sage.game_theory.catalog_normal_form_games.HawkDove
)(v=2, c=3

519

.
) ( )(.
-1
.
-2 .
-3 ) (
c .c > v

v

2c v

0
v 2

v 2c
0

B=
v

v
2

A=

= 2 . = 3
2

0
1

2 0

B=
2

A=

anti coordination game 3


:
-1 .
-2 .
)6
sage.game_theory.catalog_normal_form_games.Matching
)(Pennies

520


. 1 .
:

A=


.
)7
)(sage.game_theory.catalog_normal_form_games.Pigs

. . .
6

. 3/4
.
. 1/3
.
)
.(A

521

6 0

1
4

B=
1 0

A=

.
)8
sage.game_theory.catalog_normal_form_games.Prisoner
sDilemma
)(R=-2, P=-4, S=-5,T=0


.
.
.
.

:
R

T P

R T

B=
S P

A=

> > > .


R -1 .
S -2 .

522

P -3 .
T -4 .
:
2

0
4

2
0

B=
5 4

A=

.
)9
)(sage.game_theory.catalog_normal_form_games.RPS

- -
. 3
.
) (
) ( .
) ( .
.

523

1
0
1

A= 1

)10
)(sage.game_theory.catalog_normal_form_games.RPSLS

.
-1 .
-2 .
-3 .
-4 ) (.
-5 .
-6 .
-7 .
-8 .
-9 .
-10 .
:

1
1
0

1 1

1 1 0
1 1 1

A = 1

)11
sage.game_theory.catalog_normal_form_games.StagHunt
)(

524

. .
.
.
.
:
5

4 2

5 4

B=
0 2

A=

. 3 :
-1 .
-2 .
-3 2/3.
)12
sage.game_theory.catalog_normal_form_games.Travelle
)rsDilemma(max_value=10

.
.
10

2 10 .
525


.
2
2 .

:

6 5 4 3 2 1 0

6 5 4 3 2 1

0
0
0
0
0

10 8 5 4 3 2 1
9 7 4 3 2 1

8 8 6 3 2 1

7 7 7 5 2 1

6 6 6 6 4 1

5 5 5 5 5 3
4 4 4 4 4 4

5
4

11 10 9 8 7 6 5 4

9 10 9 8 7 6 5 4

9 8 7 6 5 4

2 2 2 4 5 4

1 1 1 1 3 4

0 0 0 0 0 2

1
0

1
0

7 8 7 6 5 4
4 6 7 6 5 4
3 3 5 6 5 4

526

10

11

10

A = 8

4
10

B = 4

527

S-ar putea să vă placă și