def eliminate_redundant_inequalities(A,b):
    ''' Input format is  A x + b <= 0'''
    # H-representation: A x + b >= 0
    A_plot = Matrix(hstack([-b.reshape((A.shape[0],1)), -A]), number_type=NUMBER_TYPE)
    A_plot.rep_type = RepType.INEQUALITY
    A_plot.canonicalize()
    A_plot = np.array(A_plot)
    b_plot, A_plot = -A_plot[:, 0], -A_plot[:, 1:]
    return (A_plot, b_plot);
Example #2
0
def eliminate_redundant_inequalities(A,b):
    
    # H-representation: A x + b >= 0
    A_plot = Matrix(hstack([b.reshape((A.shape[0],1)), -A]), number_type=NUMBER_TYPE)
    A_plot.rep_type = RepType.INEQUALITY
    A_plot.canonicalize()
    A_plot = np.array(A_plot)
    b_plot, A_plot = A_plot[:, 0], -A_plot[:, 1:]
    return (A_plot, b_plot);
Example #3
0
    def discard_redundant(self):
        """Remove redundant elements from the credal set

        Redundant elements are those that are not vertices of the credal set's
        convex hull.

        >>> K = CredalSet('abc')
        >>> K.add({'a': 1, 'b': 1, 'c': 1})
        >>> assert (
        ...     K ==
        ...     CredalSet(
        ...         {PMFunc({'a': '1/3', 'c': '1/3', 'b': '1/3'}),
        ...          PMFunc({'a': 1}), PMFunc({'b': 1}), PMFunc({'c': 1})}
        ...     )
        ... )
        >>> K.discard_redundant()
        >>> assert (
        ...     K ==
        ...     CredalSet(
        ...         {PMFunc({'a': 1}), PMFunc({'b': 1}), PMFunc({'c': 1})})
        ... )

        """
        pspace = list(self.pspace())
        K = list(self)
        mat = Matrix(list([1] + list(p[x] for x in pspace) for p in K),
                     number_type='fraction')
        mat.rep_type = RepType.GENERATOR
        lin, red = mat.canonicalize()
        for i in red:
            self.discard(K[i])
Example #4
0
def get_coh_hrep_via_vreps(K, num_type='fraction'):
    """Compute a minimal H-representation for coherence

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

    """
    vrep = generate_asl_vrep(K, num_type)
    hreplist = [Polyhedron(vrep).get_inequalities()]
    for i in xrange(len(K)):
        vrep = generate_Sasl_vrep(K, i, num_type)
        hreplist.append(Polyhedron(vrep).get_inequalities())
    constraints = ([list(t) for t in hrep[:]] for hrep in hreplist)
    constraintslist = list(chain.from_iterable(constraints))
    hrep = Matrix(constraintslist, number_type=num_type)
    hrep.rep_type = RepType.INEQUALITY
    hrep.canonicalize()
    return hrep