PriceOfAnarchy: Compoute the Price of Anarchy for a Routing Game.

Description Usage Arguments Value Examples

Description

'PriceOfAnarchy()' returns Price of Anarchy (PoA) for a routing game. This is a routing game solver for a generic network. For this to work properly, set the inputs as shown in the examples. This is as a tibble, with one column containing the cost functions, and another containing the flow.

Usage

1
PriceOfAnarchy(cost.and.flow.tibble, variable.limits)

Arguments

cost.and.flow.tibble

A tibble with 2 columns, cost which contains the cost functions, and flow containing the respective flows. When defining the flow functions, use all variables as inputs for each function.

variable.limits

A vector of limits for each variable, described by the proportions at each source node.

Value

Returns the Price of Anarchy, Optimal cost and the respective parameters, Nash cost and the respective parameters.

Requires tidyverse, pracma and nloptr packacges

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(stats, "na.omit")
library(dplyr)
library(tibble)
library(pracma)
library(nloptr)

### 2 player game ###
player2 <- tibble(cost = c(function(x){0}, function(x){0}, function(x){NA},
                 function(x){x^2}, function(x){(3/2)*x},  function(x){x}),
                  flow = c(function(alpha,beta){(1/2)-alpha},function(alpha,beta){(1/2)-beta},
                    function(alpha,beta){NA},function(alpha,beta){alpha},
                    function(alpha,beta){beta},function(alpha, beta){1-alpha-beta}))
PriceOfAnarchy(player2, c((1/2), (1/2)))

### 3 player - 2x2 middle ###
player3middle2x2 <- tibble(cost = c(function(x){0}, function(x){x},function(x){x^2},
function(x){x},function(x){x},function(x){0},function(x){x},function(x){x^2},
function(x){x^2},function(x){x},function(x){(1/2)*x},function(x){x}),
                          flow = c(function(d1,d2,d3,d4,d5){d1},
                          function(d1,d2,d3,d4,d5){1-d1},function(d1,d2,d3,d4,d5){d2},
                          function(d1,d2,d3,d4,d5){1-d2},function(d1,d2,d3,d4,d5){d3},
                          function(d1,d2,d3,d4,d5){1-d3},function(d1,d2,d3,d4,d5){d4},
                          function(d1,d2,d3,d4,d5){d1+d2+d3-d4},function(d1,d2,d3,d4,d5){d5},
                          function(d1,d2,d3,d4,d5){1-d1-d2-d3-d5},
                          function(d1,d2,d3,d4,d5){d4+d5},function(d1,d2,d3,d4,d5){1-d4-d5}))
PriceOfAnarchy(player3middle2x2, c((6/10),(1/10),(3/10),1,1))

PoA documentation built on May 2, 2019, 3:47 p.m.

Related to PriceOfAnarchy in PoA...