Skip to content

Instantly share code, notes, and snippets.

@gluc
Forked from mayt1992/R code
Last active May 18, 2017 02:24
Show Gist options
  • Save gluc/faa3d536e9024dd5a897dd6d34d6239a to your computer and use it in GitHub Desktop.
Save gluc/faa3d536e9024dd5a897dd6d34d6239a to your computer and use it in GitHub Desktop.
port_risk.ahp for R
Version: 2.0
Alternatives: &alternatives
Port 1:
shortname: p1
Port 2:
shortname: p2
Goal:
name: Port Risk
description: >
Evaluate Port Risk in the perspective of the Belt and Road Initiative.
preferences:
pairwise:
- [Political, Economic, 1/5]
- [Political, Social, 3]
- [Political, Technological, 1/3]
- [Political, Environmental, 5]
- [Political, Legal, 5]
- [Economic, Social, 7]
- [Economic, Technological, 7]
- [Economic, Environmental, 7]
- [Economic, Legal, 1/5]
- [Social, Technological, 1/3]
- [Social, Environmental, 3]
- [Social, Legal, 1/5]
- [Technological, Environmental, 3]
- [Technological, Legal, 1/5]
- [Environmental, Legal, 1/3]
children:
Political:
preferences:
pairwise:
- [Degree of Democracy, Political Stability, 2]
- [Degree of Democracy, Tariffs, 5]
- [Political Stability, Tariffs, 3]
children:
Degree of Democracy:
preferences:
pairwise:
#just for fun, to test pairwise
- [Port 1, Port 2, 3]
children: *alternatives
Political Stability:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Tariffs:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Economic:
preferences:
pairwise:
- [GDP Growth Rate, Openness, 2]
- [GDP Growth Rate, Income Inequality, 5]
- [GDP Growth Rate, Unemployment Rate, 3]
- [Openness, Income Inequality, 3]
- [Openness, Unemployment Rate, 3]
- [Income Inequality, Unemployment Rate, 3]
children:
GDP Growth Rate:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Openness:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Income Inequality:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Unemployment Rate:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Social:
preferences:
pairwise:
- [Incidents of Piracy and Armed Robbery, Education Level, 2]
- [Incidents of Piracy and Armed Robbery, Disease Rate, 5]
- [Incidents of Piracy and Armed Robbery, Control of Corruption, 3]
- [Incidents of Piracy and Armed Robbery, Ethnic Diversity, 3]
- [Education Level, Disease Rate, 3]
- [Education Level, Control of Corruption, 3]
- [Education Level, Ethnic Diversity, 3]
- [Disease Rate, Control of Corruption, 3]
- [Disease Rate, Ethnic Diversity, 3]
- [Control of Corruption, Ethnic Diversity, 3]
children:
Incidents of Piracy and Armed Robbery:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Education Level:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Disease Rate:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Control of Corruption:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Ethnic Diversity:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Technological:
preferences:
pairwise:
- [R&D Activity, Potential Innovation, 2]
children:
R&D Activity:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Potential Innovation:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Environmental:
preferences:
pairwise:
- [Natural Disaster, Structural Constrains, 1/3]
children:
Natural Disaster:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Structural Constrains:
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
Legal:
#You cannot have a single node
preferences:
score:
- Port 1: 1
- Port 2: 2
children: *alternatives
library(ahp)
ahpFile <- "port_risk.yaml"
port_riskAhp <- Load(ahpFile)
library(data.tree)
print(port_riskAhp, filterFun = isNotLeaf)
Visualize(port_riskAhp)
Calculate(port_riskAhp)
print(port_riskAhp, priority = function(x) x$parent$priority["Total", x$name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment