<jupyter_start><jupyter_text>Reading libraries<jupyter_code>import math
import numpy as np
import pandas as pd
%config Completer.use_jedi = False # this speeds up autocomplete<jupyter_output><empty_output><jupyter_text>Replicating "An Extended VIKOR method for ranking online graduate business programs" This is a methods replication of the following article:<NAME>. (2014). An Extended VIKOR method for ranking online graduate business programs. *International Journal of Information and Education Technology*, *4*(1). https://doi.org/10.7763/IJIET.2014.V4.378Each value is derived from that article. Code is mine.We're trying to define the best online graduate business program in the US.This is a typical multicriteria decision-making (MCDM) problem. VIKOR is the algorithm used to solve it.<jupyter_code>nome_faculdades = ['Arizona State University (Carey)',
                   'Indiana University-Bloomington (Kelley)',
                   'Washington State University',
                   'University of Florida (Hough)',
                   'Auburn University',
                   'University of Connecticut',
                   'California State University–Fullerton',
                   'University of Illinois–Springfield',
                   'Worcester Polytechnic Institute',
                   'Pennsylvania State University–World Campus',
                   'University of San Diego',
                   'University of Nebraska–Lincoln',
                   'Georgia College & State University (Bunting)',
                   'University of Massachusetts–Amherst (Isenberg)',
                   'Thunderbird School of Global Management',
                   'Central Michigan University',
                   'University of Michigan–Dearborn',
                   'University of North Texas',
                   'University of Tennessee–Martin',
                   'Syracuse University (Whitman)'
                  ]

id_faculdades = ['U1', 'U2', 'U3', 'U4', 'U5',
                 'U6', 'U7', 'U8', 'U9', 'U10',
                 'U11', 'U12', 'U13', 'U14', 'U15',
                 'U16', 'U17', 'U18', 'U19', 'U20']

nome_colunas = ['faculty', 'services',
                'engagement', 'selectivity', 'reputation']

criteria = ['+', '+', '+', '+', '+']
weight = [0.11, 0.11, 0.28, 0.25, 0.25]

matrix = [
    [71.7, 44.0, 81.8, 74.0, 74.0],
    [75.6, 40.0, 74.4, 71.4, 84.0],
    [84.2, 44.0, 87.1, 80.0, 58.0],
    [79.4, 46.7, 66.6, 75.0, 76.0],
    [86.6, 34.0, 79.3, 58.7, 64.0],
    [80.5, 34.0, 76.0, 64.2, 64.0],
    [83.0, 48.0, 84.8, 67.0, 54.0],
    [93.0, 46.0, 74.9, 48.4, 60.0],
    [67.9, 44.0, 74.6, 69.0, 56.0],
    [83.3, 40.0, 81.2, 46.0, 58.0],
    [56.9, 38.0, 85.3, 47.0, 58.0],
    [73.0, 34.0, 65.7, 73.2, 58.0],
    [95.7, 42.7, 75.0, 51.2, 56.0],
    [71.1, 45.3, 75.1, 44.9, 64.0],
    [55.8, 36.0, 70.8, 45.3, 76.0],
    [88.7, 44.0, 78.2, 68.2, 52.0],
    [68.3, 22.0, 81.6, 61.7, 56.0],
    [82.6, 42.0, 71.9, 60.9, 54.0],
    [81.7, 37.9, 79.3, 73.5, 48.0],
    [67.6, 47.2, 66.7, 39.8, 68.0]
]

# Transformando matriz em dataframe
df = pd.DataFrame(matrix,
                  columns = nome_colunas,
                  index = nome_faculdades)
df
# Hiperparâmetros
matrix = np.array(matrix).T

n_columns = np.shape(matrix)[0]
n_lines = np.shape(matrix)[1]

Sj_list = []
Rj_list = []
Sj_temp_list = []
Qj_list = []
v = 0.5

# Definindo valores
for j in range(0, n_columns):
    
    for i in range(0, n_lines):
        
        if (criteria[j] == '-'):

            Fi_plus = min(matrix[j]) # best criteria value
            Fi_minus = max(matrix[j]) # worst criteria value
        
        else:
            Fi_plus = max(matrix[j]) # best criteria value
            Fi_minus = min(matrix[j]) # worst criteria value
        
        w = weight[j]
        case = matrix[j][i] # case value
        
        Sj = w * (Fi_plus - case)/(Fi_plus - Fi_minus)
        Sj_temp_list.append(Sj)

# Criando Sj e Rj
Sj_temp_list = np.reshape(Sj_temp_list, (n_columns, n_lines)).T
        
for i in range(0, n_lines):
    Sj = sum(Sj_temp_list[i])
    Sj_list.append(Sj)
    
    Rj = max(Sj_temp_list[i])
    Rj_list.append(Rj)
    
# Criando Qj
for i in range(0, n_lines):
    S_min = min(Sj_list)
    S_max = max(Sj_list)
    R_min = min(Rj_list)
    R_max = max(Rj_list)
    
    diff_S = S_max - S_min
    diff_R = R_max - R_min
    
    S = Sj_list[i]
    R = Rj_list[i]
    
    Qj = v * (S - S_min)/diff_S + (1 - v) * (R - R_min)/diff_R
    
    Qj_list.append(Qj)

# Acceptable Advantages C1
C1 = []
for i in range(0, n_lines):
     
    if i == n_lines - 1:
        C1.append('No')
    
    else:
        Q_a2 = Qj_list[i + 1]
        Q_a1 = Qj_list[i]
        
        DQ = 1/(n_lines - 1)
        
        if (Q_a2 - Q_a1 >= DQ):
            C1.append('Yes')
        else:
            C1.append('No')
            
# Acceptable Stability
C2 = []
for i in range(0, n_lines):
    if i >= 2:
        C2.append('No')
    else:
        if ((min(Sj_list) == Sj_list[i]) or (min(Rj_list) == Rj_list[i])):
            C2.append('Yes')
        else:
            C2.append('No')

# Visualizando
df['S'] = [round(num, 4) for num in Sj_list]
df['R'] = [round(num, 4) for num in Rj_list]
df['Q'] = [round(num, 4) for num in Qj_list]
df['C1'] = C1
df['C2'] = C2

df = df.sort_values(by = 'Q')
df['Rank'] = range(1, n_lines + 1)
df<jupyter_output><empty_output><jupyter_text>Replicating "Multi-criteria decision making with the VIKOR and SMARTER Methods for optimal seller selection from several e-marketplaces" This is a methods replication of the following article:<NAME>., <NAME>., & <NAME>. (2020). Multi-criteria decision making with the VIKOR and SMARTER Methods for optimal seller selection from several e-marketplaces. *E3S Web of Conferences*, *202*(14002). https://doi.org/10.1051/e3sconf/202020214002Each value is derived from that article. Code is mine.We're trying to define the best buyer for our product.This is a typical multicriteria decision-making (MCDM) problem. VIKOR is the algorithm used to solve it.<jupyter_code>nome_marketplace = [
    'A1', 'A2', 'A3', 'A4',
    'A5', 'A6', 'A7', 'A8',
    'A9', 'A10', 'A11', 'A12',
    'A13', 'A14', 'A15']

nome_marketplace = [
    "one's_olshop",
    "Distributor Ponsel",
    "varelie ponsel",
    "Barokah Online Abadi",
    "HN Store 2003",
    "quenzyqee",
    "murah2019",
    "nashop7979",
    "hnstore2003",
    "shopeedia",
    "JAYA STORE",
    "Xiaomi Store",
    "Gojap",
    "Dsun Shop",
    "Metta Cell Bekasi"
]

nome_colunas = ['Seller Rating', 'Nob. 5 Stars', 'Price',
                'Products Sold', 'Distance']

criteria = ['+', '+', '-', '+', '-']

weight = [0.46, 0.26, 0.16, 0.09, 0.04]

matrix = [
    [4.9,  76, 1604000, 1093, 480],
    [4.7, 276, 1636000, 2207, 452],
    [5.0, 110, 1665000,  484, 452],
    [4.8,  64, 1625000,  207,  34],
    [5.0,  40, 1620000,  607, 446],
    [4.9,  93, 1600000,  453, 485],
    [4.9,   9, 1609999,   62, 463],
    [4.9,  39, 1610000,   70, 405],
    [4.8,   8, 1620000,   13, 446],
    [4.7,   6, 1675000,   20, 452],
    [4.7,  16, 1674000,   41, 444],
    [4.2,   1, 1673070,    8, 446],
    [4.8,  95, 1675000,  438, 452],
    [5.0,   9, 1625000,   13, 480],
    [5.0,   5, 1670000,   14, 424]
]

# Transformando matriz em dataframe
df = pd.DataFrame(matrix,
                  columns = nome_colunas,
                  index = nome_marketplace)
df
# Hiperparâmetros
matrix = np.array(matrix).T

n_columns = np.shape(matrix)[0]
n_lines = np.shape(matrix)[1]

Sj_list = []
Rj_list = []
Sj_temp_list = []
Qj_list = []
v = 0.5

# Definindo valores
for j in range(0, n_columns):
    
    for i in range(0, n_lines):
        
        if (criteria[j] == '-'):

            Fi_plus = min(matrix[j]) # best criteria value
            Fi_minus = max(matrix[j]) # worst criteria value
        
        else:
            Fi_plus = max(matrix[j]) # best criteria value
            Fi_minus = min(matrix[j]) # worst criteria value
        
        w = weight[j]
        case = matrix[j][i] # case value
        
        Sj = w * (Fi_plus - case)/(Fi_plus - Fi_minus)
        Sj_temp_list.append(Sj)

# Criando Sj e Rj
Sj_temp_list = np.reshape(Sj_temp_list, (n_columns, n_lines)).T
        
for i in range(0, n_lines):
    Sj = sum(Sj_temp_list[i])
    Sj_list.append(Sj)
    
    Rj = max(Sj_temp_list[i])
    Rj_list.append(Rj)
    
# Criando Qj
for i in range(0, n_lines):
    S_min = min(Sj_list)
    S_max = max(Sj_list)
    R_min = min(Rj_list)
    R_max = max(Rj_list)
    
    diff_S = S_max - S_min
    diff_R = R_max - R_min
    
    S = Sj_list[i]
    R = Rj_list[i]
    
    Qj = v * (S - S_min)/diff_S + (1 - v) * (R - R_min)/diff_R
    
    Qj_list.append(Qj)

# Acceptable Advantages C1
C1 = []
for i in range(0, n_lines):
     
    if i == n_lines - 1:
        C1.append('No')
    
    else:
        Q_a2 = Qj_list[i + 1]
        Q_a1 = Qj_list[i]
        
        DQ = 1/(n_lines - 1)
        
        if (Q_a2 - Q_a1 >= DQ):
            C1.append('Yes')
        else:
            C1.append('No')
            
# Acceptable Stability
C2 = []
for i in range(0, n_lines):
     
    if i >= 2:
        C2.append('No')
    
    else:
        if ((min(Sj_list) == Sj_list[i]) or (min(Rj_list) == Rj_list[i])):
            C2.append('Yes')
        
        else:
            C2.append('No')

# Visualizando
df['S'] = [round(num, 2) for num in Sj_list]
df['R'] = [round(num, 2) for num in Rj_list]
df['Q'] = [round(num, 2) for num in Qj_list]
df['C1'] = C1
df['C2'] = C2

df = df.sort_values(by = 'Q')
df['Rank'] = range(1, n_lines + 1)
df<jupyter_output><empty_output><jupyter_text>Replicando "Selection of industrial robots using compromise ranking and outranking methods" This is a methods replication of the following article:<NAME>., <NAME>., & <NAME>. (2010). Selection of industrial robots using compromise ranking and outranking methods. *Robotics and Computer-Integrated Manufacturing*, *26*, 483–489. https://doi.org/10.1016/j.rcim.2010.03.007Each value is derived from that article. Code is mine.We're trying to define the best robot to operate based on the ELECTRE outranking method.This is a typical multicriteria decision-making (MCDM) problem. ELECTRE is the algorithm used to solve it.<jupyter_code># Criando nome dos robôs
nome_robos = ['asea_irb', 'cincinatti', 'cybotech',
             'hitachi', 'unimation', 'us_robots', 'yaskawa']
# Criando matriz com valores dos robôs
matrix = [
    [60, 0.40, 2540, 500, 990],
    [6.35, 0.15, 1016, 3000, 1041],
    [6.8, 0.10, 1727.2, 1500, 1676],
    [10, 0.20, 1000, 2000, 965],
    [2.5, 0.10, 560, 500, 915],
    [4.5, 0.08, 1016, 350, 508],
    [3, 0.10, 177, 1000, 920]
]

weight = [0.036, 0.192, 0.326, 0.326, 0.120]
criteria = ['+', '-', '+', '+', '+']

# Criando nome das colunas
nome_colunas = ['load_capacity', 'repeatability',
                'maximum tip speed', 'memory capacity', 'manipulator reach'
               ]

# Transformando matriz em dataframe
df = pd.DataFrame(matrix, columns = nome_colunas, index = nome_robos)
df
# Hiperparâmetros
matrix = np.array(matrix).T

n_columns = np.shape(matrix)[0]
n_lines = np.shape(matrix)[1]

Sj_list = []
Rj_list = []
Sj_temp_list = []
Qj_list = []
v = 0.5

# Definindo valores
for j in range(0, n_columns):
    
    for i in range(0, n_lines):
        
        if (criteria[j] == '-'):

            Fi_plus = min(matrix[j]) # highest criteria value
            Fi_minus = max(matrix[j]) # lowest criteria value
        
        else:
            Fi_plus = max(matrix[j]) # highest criteria value
            Fi_minus = min(matrix[j]) # lowest criteria value
        
        w = weight[j]
        case = matrix[j][i] # case value
        
        Sj = w * (Fi_plus - case)/(Fi_plus - Fi_minus)
        Sj_temp_list.append(Sj)

# Criando Sj e Rj
Sj_temp_list = np.reshape(Sj_temp_list, (n_columns, n_lines)).T
        
for i in range(0, n_lines):
    Sj = sum(Sj_temp_list[i])
    Sj_list.append(round(Sj, 4))
    
    Rj = max(Sj_temp_list[i])
    Rj_list.append(round(Rj, 4))
    
# Criando Qj
for i in range(0, n_lines):
    S_min = min(Sj_list)
    S_max = max(Sj_list)
    R_min = min(Rj_list)
    R_max = max(Rj_list)
    
    diff_S = S_max - S_min
    diff_R = R_max - R_min
    
    S = Sj_list[i]
    R = Rj_list[i]
    
    Qj = v * (S - S_min)/diff_S + (1 - v) * (R - R_min)/diff_R
    
    Qj_list.append(round(Qj, 4))

# Acceptable Advantages C1
C1 = []
for i in range(0, n_lines):
     
    if i == n_lines - 1:
        C1.append('No')
    
    else:
        Q_a2 = Qj_list[i + 1]
        Q_a1 = Qj_list[i]
        
        DQ = 1/(n_lines - 1)
        
        if (Q_a2 - Q_a1 >= DQ):
            C1.append('Yes')
        else:
            C1.append('No')
            
# Acceptable Stability
C2 = []
for i in range(0, n_lines):
    if i >= 2:
        C2.append('No')
    else:
        if ((min(Sj_list) == Sj_list[i]) or (min(Rj_list) == Rj_list[i])):
            C2.append('Yes')
        else:
            C2.append('No')

# Visualizando
df['S'] = Sj_list
df['R'] = Rj_list
df['Q'] = Qj_list
df['C1'] = C1
df['C2'] = C2

df = df.sort_values(by = 'Q')
df['Rank'] = range(1, n_lines + 1)
df<jupyter_output><empty_output><jupyter_text>Choosing the best computer to buy (https://www.youtube.com/watch?v=WMX3SVnvRls)<jupyter_code>nome_pc = ['Dell',
           'HP',
           'Lenovo',
           'Asus',
           'Acer',
           'Sony',
           'Apple',
           'Toshiba']

nome_colunas = ['price', 'ram', 'hard_disc', 'weight']
criteria = ['-', '+', '+', '-']

weight = [0.25, 0.25, 0.25, 0.25]

matrix = [
    [43000,  4, 1000, 1.5],
    [45000,  6,  750, 1.7],
    [35000,  8, 1000, 2.0],
    [38000,  6,  750, 2.1],
    [39000,  8,  900, 1.8],
    [46000,  6,  750, 1.2],
    [50000,  6,  600, 1.1],
    [42000, 10,  800, 2.5]
]

# Transformando matriz em dataframe
df = pd.DataFrame(matrix,
                  columns = nome_colunas,
                  index = nome_pc)
df
# Hiperparâmetros
matrix = np.array(matrix).T

n_columns = np.shape(matrix)[0]
n_lines = np.shape(matrix)[1]

Sj_list = []
Rj_list = []
Sj_temp_list = []
Qj_list = []
v = 0.5

# Definindo valores
for j in range(0, n_columns):
    
    for i in range(0, n_lines):
        
        if (criteria[j] == '-'):

            Fi_plus = min(matrix[j]) # highest criteria value
            Fi_minus = max(matrix[j]) # lowest criteria value
        
        else:
            Fi_plus = max(matrix[j]) # highest criteria value
            Fi_minus = min(matrix[j]) # lowest criteria value
        
        w = weight[j]
        case = matrix[j][i] # case value
        
        Sj = w * (Fi_plus - case)/(Fi_plus - Fi_minus)
        Sj_temp_list.append(Sj)

# Criando Sj e Rj
Sj_temp_list = np.reshape(Sj_temp_list, (n_columns, n_lines)).T
        
for i in range(0, n_lines):
    Sj = sum(Sj_temp_list[i])
    Sj_list.append(round(Sj, 4))
    
    Rj = max(Sj_temp_list[i])
    Rj_list.append(round(Rj, 4))
    
# Criando Qj
for i in range(0, n_lines):
    S_min = min(Sj_list)
    S_max = max(Sj_list)
    R_min = min(Rj_list)
    R_max = max(Rj_list)
    
    diff_S = S_max - S_min
    diff_R = R_max - R_min
    
    S = Sj_list[i]
    R = Rj_list[i]
    
    Qj = v * (S - S_min)/diff_S + (1 - v) * (R - R_min)/diff_R
    
    Qj_list.append(round(Qj, 4))

# Acceptable Advantages C1
C1 = []
for i in range(0, n_lines):
     
    if i == n_lines - 1:
        C1.append('No')
    
    else:
        Q_a2 = Qj_list[i + 1]
        Q_a1 = Qj_list[i]
        
        DQ = 1/(n_lines - 1)
        
        if (Q_a2 - Q_a1 >= DQ):
            C1.append('Yes')
        else:
            C1.append('No')
            
# Acceptable Stability
C2 = []
for i in range(0, n_lines):
    if i >= 2:
        C2.append('No')
    else:
        if ((min(Sj_list) == Sj_list[i]) or (min(Rj_list) == Rj_list[i])):
            C2.append('Yes')
        else:
            C2.append('No')

# Visualizando
df['S'] = Sj_list
df['R'] = Rj_list
df['Q'] = Qj_list
df['C1'] = C1
df['C2'] = C2

df = df.sort_values(by = 'Q')
df['Rank'] = range(1, n_lines + 1)
df<jupyter_output><empty_output><jupyter_text>Choosing which cellphone to get (https://www.youtube.com/watch?v=P09VulFOZIc)<jupyter_code>nome_cel = ['Mobile 1',
           'Mobile 2',
           'Mobile 3',
           'Mobile 4',
           'Mobile 5']

nome_colunas = ['cost', 'storage', 'camera', 'looks']
criteria = ['-', '+', '+', '+']

weight = [0.35, 0.30, 0.20, 0.15]

matrix = [
    [250, 16, 12, 5],
    [200, 16, 8, 3],
    [300, 32, 16, 4],
    [275, 32, 8, 4],
    [225, 16, 16, 2]
]

# Transformando matriz em dataframe
df = pd.DataFrame(matrix,
                  columns = nome_colunas,
                  index = nome_cel)
df
# Hiperparâmetros
matrix = np.array(matrix).T

n_columns = np.shape(matrix)[0]
n_lines = np.shape(matrix)[1]

Sj_list = []
Rj_list = []
Sj_temp_list = []
Qj_list = []
v = 0.5

# Definindo valores
for j in range(0, n_columns):
    
    for i in range(0, n_lines):
        
        if (criteria[j] == '-'):

            Fi_plus = min(matrix[j]) # highest criteria value
            Fi_minus = max(matrix[j]) # lowest criteria value
        
        else:
            Fi_plus = max(matrix[j]) # highest criteria value
            Fi_minus = min(matrix[j]) # lowest criteria value
        
        w = weight[j]
        case = matrix[j][i] # case value
        
        Sj = w * (Fi_plus - case)/(Fi_plus - Fi_minus)
        Sj_temp_list.append(Sj)

# Criando Sj e Rj
Sj_temp_list = np.reshape(Sj_temp_list, (n_columns, n_lines)).T
        
for i in range(0, n_lines):
    Sj = sum(Sj_temp_list[i])
    Sj_list.append(round(Sj, 4))
    
    Rj = max(Sj_temp_list[i])
    Rj_list.append(round(Rj, 4))
    
# Criando Qj
for i in range(0, n_lines):
    S_min = min(Sj_list)
    S_max = max(Sj_list)
    R_min = min(Rj_list)
    R_max = max(Rj_list)
    
    diff_S = S_max - S_min
    diff_R = R_max - R_min
    
    S = Sj_list[i]
    R = Rj_list[i]
    
    Qj = v * (S - S_min)/diff_S + (1 - v) * (R - R_min)/diff_R
    
    Qj_list.append(round(Qj, 4))

# Acceptable Advantages C1
C1 = []
for i in range(0, n_lines):
     
    if i == n_lines - 1:
        C1.append('No')
    
    else:
        Q_a2 = Qj_list[i + 1]
        Q_a1 = Qj_list[i]
        
        DQ = 1/(n_lines - 1)
        
        if (Q_a2 - Q_a1 >= DQ):
            C1.append('Yes')
        else:
            C1.append('No')
            
# Acceptable Stability
C2 = []
for i in range(0, n_lines):
    if i >= 2:
        C2.append('No')
    else:
        if ((min(Sj_list) == Sj_list[i]) or (min(Rj_list) == Rj_list[i])):
            C2.append('Yes')
        else:
            C2.append('No')

# Visualizando
df['S'] = Sj_list
df['R'] = Rj_list
df['Q'] = Qj_list
df['C1'] = C1
df['C2'] = C2

df = df.sort_values(by = 'Q')
df['Rank'] = range(1, n_lines + 1)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15428208251681585, 'fraction_numerical': 0.06366188231555532, 'mean_word_length': 2.163343943709164, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 42, 'https://': 5, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '568707', 'license': 'MIT', 'n_tokens_mistral': 8333, 'n_tokens_neox': 7507, 'n_words': 1786, 'path': 'algorithms/vikor_various_replications.ipynb', 'repo_name': 'GabrielReisR/python_scripts', 'size': '18920'}