Exemple #1
0
def get_coh_hrep_as_coeff_vrep(K, num_type='fraction'):
    """Compute a minimal H-representation for coherence

    See Procedure C.4 in my ISIPTA '13 paper “Characterizing coherence,
    correcting incoherence”.

    """
    k = len(K)
    lhs, rhs = get_asl_lhs_rhs_as_coeff_vrep(K)
    for i in xrange(k):
        S = generate_Sasl_pos_dirs(k, i)
        minusS = generate_Sasl_neg_dirs(k, i)
        coeff_one_lhs = transpose(K) + minusS
        coeff_one_rhs = ([1] * (len(coeff_one_lhs) - k)) + ([0] * k)
        coeff_one_hrep = make_hrep(coeff_one_lhs, coeff_one_rhs, num_type)
        coeff_one_vrep = Polyhedron(coeff_one_hrep).get_generators()
        lhs.extend(list(t[1:]) for t in coeff_one_vrep[:])
        rhs.extend(t[0] for t in coeff_one_vrep[:])
        coeff_zero_lhs = transpose(K) + minusS + S
        coeff_zero_rhs = ([0] * (len(coeff_zero_lhs) - k)) + ([1] * k)
        coeff_zero_hrep = make_hrep(coeff_zero_lhs, coeff_zero_rhs, num_type)
        coeff_zero_vrep = Polyhedron(coeff_zero_hrep).get_generators()
        lhs.extend(list(t[1:]) for t in coeff_zero_vrep[:])
        rhs.extend([0] * len(coeff_zero_vrep))
    pos_lhs = diagonallists([-1] * k)
    pos_rhs = ([0] * k)
    hrep = make_hrep(lhs + pos_lhs, rhs + pos_rhs, num_type)
    hrep.rep_type = RepType.INEQUALITY
    hrep.canonicalize()
    return hrep
Exemple #2
0
def generate_asl_vrep(K, num_type='fraction'):
    """Generate the V-representation of avoiding sure loss

    See Equation (5) in my ISIPTA '13 paper “Characterizing coherence,
    correcting incoherence”.

    """
    deg_prevs = transpose(K)
    neg_dirs = diagonallists([-1] * len(K))
    return make_vrep(deg_prevs, neg_dirs, num_type)
Exemple #3
0
def get_asl_hrep_as_coeff_vrep(K, num_type='fraction'):
    """Compute a minimal H-representation for positive avoiding sure loss

    See Procedure B.3 in my ISIPTA '13 paper “Characterizing coherence,
    correcting incoherence”; this function adds positivity costraints and
    does redundancy removal on the output of
    `get_asl_lhs_rhs_as_coeff_vrep`.

    """
    k = len(K)
    lhs, rhs = get_asl_lhs_rhs_as_coeff_vrep(K, num_type)
    pos_lhs = diagonallists([-1] * k)
    pos_rhs = ([0] * k)
    hrep = make_hrep(lhs + pos_lhs, rhs + pos_rhs, num_type)
    hrep.canonicalize()
    return hrep
Exemple #4
0
def get_asl_lhs_rhs_as_coeff_vrep(K, num_type='fraction'):
    """Compute a partial H-representation for positive avoiding sure loss

    See Procedure B.3 in my ISIPTA '13 paper “Characterizing coherence,
    correcting incoherence”; this function does not add positivity
    costraints or do redundancy removal.

    """
    k = len(K)
    coeff_lhs = transpose(K) + diagonallists([-1] * k)
    coeff_rhs = ([1] * (len(coeff_lhs) - k)) + ([0] * k)
    coeff_hrep = make_hrep(coeff_lhs, coeff_rhs, num_type)
    coeff_vrep = Polyhedron(coeff_hrep).get_generators()
    lhs = [list(t[1:]) for t in coeff_vrep[:]]
    rhs = [t[0] for t in coeff_vrep[:]]
    return lhs, rhs
Exemple #5
0
def generate_Sasl_pos_dirs(k, i):
    """Generate diagonal list of size `k` with 1s, apart from -1 at `i`"""
    pre = i
    post = k - i - 1
    return diagonallists([1] * pre + [-1] + [1] * post)