Пример #1
0
def TwoHops_CF_ICFsch3(Ps, P3, P4, g13, g14, g23, g24):
    '''
    First, take the intersection of rate regions of 1st and 2nd hop
    Then, the the convex hull.
    Note: 
    Conceptually, we should do 
    1). for bigR1, take the intersection of CF_bigR1 and ICF_bigR2
    2). for bigR2, take the intersection of CF_bigR2 and ICF_bigR2
    3). take the union of the above two intersections 
    4). take the convex hull. 
    Actually, we did
    a) take the union of ICF_bigR1 and ICF_bigR2
    b) take the intersection of a) and CF_whole
    c) take the convex hull of b)
    '''
    alternative = True
    if alternative:
        # use alternative_rate_region.py 
        return rr.intersection( [rr.union( [alternative_compute.ICF_sch3_bigR1(P3, P4), 
                                 alternative_compute.ICF_sch3_bigR2(P3, P4)]),
                      CF_scheme_integerCoeff(Ps, g13, g14, g23, g24)] ).convexHull()
    else:
        # use rate_region.py
        return rr.intersection( [rr.union( [ICF_sch3_bigR1(P3, P4), 
                                 ICF_sch3_bigR2(P3, P4)]),
                      CF_scheme_integerCoeff(Ps, g13, g14, g23, g24) ] ).convexHull()
Пример #2
0
def TwoHops_CF_ICFsch3_fromRegions(cf_scheme_integerCoeff,
                                   *icf_sch3
                                   ):
    '''
    compute the achievable rate region for the (whole) two-hop network from the 
    given rate regions for the 1st and 2nd hops 
    '''
    if len(icf_sch3) == 1:
        return rr.intersection( [rr.union( [icf_sch3[0],
                                            icf_sch3[0].symmetricRegion_yEqualToX() ]),
                                 cf_scheme_integerCoeff] ).convexHull() 
    elif len(icf_sch3) == 2: 
        return rr.intersection( [rr.union( [icf_sch3[0],
                                            icf_sch3[1]]),
                                 cf_scheme_integerCoeff] ).convexHull()  
Пример #3
0
def TwoHops_CF_ICFsch2_fromRegions(icf_sch2_bigR1, 
                                   icf_sch2_bigR2,
                                   cf_scheme_integerCoeff):
    '''
    compute the achievable rate region for the (whole) two-hop network from the 
    given rate regions for the 1st and 2nd hops 
    '''
    return rr.intersection( [rr.union( [icf_sch2_bigR1,
                                        icf_sch2_bigR2]),
                             cf_scheme_integerCoeff ] ).convexHull()                        
def display(oneSimulation,pathString ,saveOnly=True):
    '''
    Produce a graph that compare three ICF schemes
    '''
    self = oneSimulation
    
    # get the union rate region for plotting 
    icf_sch1 = rr.union( [self.icf_sch1_bigR1, self.icf_sch1_bigR2] )
    icf_sch2 = rr.union( [self.icf_sch2_bigR1, self.icf_sch2_bigR2] )
    icf_sch3 = rr.union( [self.icf_sch3_bigR1, self.icf_sch3_bigR2] )

    pylab.rc('axes', linewidth=2) # make the axes boundary lines bold 
    fig, ax = plt.subplots()
    rr.plot( icf_sch1, 'g', axes=ax, label='Scheme 1')
    rr.plot( icf_sch2, 'b', axes=ax, label='Scheme 2')
    rr.plot( icf_sch3, 'r', axes=ax, label='Scheme 3')  
    
    # plot the line: R2 = R1
    tmp = np.asarray(self.icf_sch1_bigR1._geometry.boundary)
    tmp2 = [[0, tmp[1, 0]], [0, tmp[1, 1] ] ]
    ax.plot( [0, tmp[1, 0]], [0, tmp[1, 1] ] , 'k--', lw=2)

    ax.set_title(r'$ P_3={}, \, P_4={}, \, N=1$'.format(self.P3, self.P4) , fontdict=self.font)
    ax.set_xlabel('$R_1$', fontdict=self.font)
    ax.set_ylabel('$R_2$', fontdict=self.font)
    ax.set_xlim(xmin=0, xmax=3.5) 
    ax.set_ylim(ymin=0, ymax=3.5) 
    ax.legend(loc='upper right')
    
    savefig.save(path='{}/compare_three_ICF_Schemes/P3P4_{}_{}'.format(pathString, self.P3, self.P4 ), ext='pdf', close=saveOnly, verbose=True)
    if (0):
        # add annotations for 3 regions
        plt.text(0.7, 2.3, 'capacity region by coherent coding with cardinality-bounding', color='red')
        plt.text(1, 1.8, 'non-coherent coding with cardinality-bounding', color='blue')
        plt.text(1.3, 1.4, 'capacity region by coherent coding with cardinality-bounding', color='green')
        
        bbox_props = dict(boxstyle="round,pad=0.1", fc="white", ec="g", lw=1)
        plt.text(1, 0.5, r'$1$', color='black', bbox=bbox_props)
        bbox_props = dict(boxstyle="round,pad=0.1", fc="white", ec="b", lw=1)
        plt.text(1.7, 0.4, r'$2$', color='black', bbox=bbox_props)
        bbox_props = dict(boxstyle="round,pad=0.1", fc="white", ec="r", lw=1)
        plt.text(2.2, 0.3, r'$3$', color='black', bbox=bbox_props)