"""
This python file calculates and presents sub-optimality gaps for various settings in Examples 4
Reproduce results in Table 2 in the appendix
"""

import sys
sys.path.append('/Your Path/Data_Code/Methods')
import Sub_Gap as SG
from Pre_Functions import contract_v


# Suboptimality gaps for various settings in Example 4
pos = [1,1/2,1/3,1/4]
v = [1/2,1/2,1/2,1/2,1/4,1/4,1/4,1/4,1/4,1/4]
r = [1,1,1,1,1,1,1,1,1,1]
for i in range(5):
    v_new = contract_v(v,(5-i)/5)
    _, Subgap = SG.Sub_Gap(pos,v_new,r,2)
    print(
        r"Suboptimality gap for Example 4, " + chr(949).lower() + " = " + str(round(max(v_new) - min(v_new), 2)) + ":",
        round(Subgap, 5))