Ejemplo n.º 1
0
    def __init__(self, p):
        """
        Ex:
        ('lambda A, B, A0: (A[A0]) + (-7*B[2*A0]) + (-3*A0) == 0', 
        [{'A0': 2}, {'A0': 0}, {'A0': 1}])
        """

        if __debug__:
            assert (is_tuple(p) and len(p) == 2 and is_str(p[0])
                    and all(s in p[0] for s in ['lambda', '[', ']'])
                    and is_list(p[1]) and all(is_dict(v) for v in p[1])), p

        super(InvFlatArray, self).__init__(p[0].strip())
        self.idx_info = p[1]
Ejemplo n.º 2
0
    def __init__(self, p): 
        """
        Ex:
        ('lambda A, B, A0: (A[A0]) + (-7*B[2*A0]) + (-3*A0) == 0', 
        [{'A0': 2}, {'A0': 0}, {'A0': 1}])
        """

        if __debug__:
            assert (is_tuple(p) and len(p)==2 and 
                    is_str(p[0]) and 
                    all(s in p[0] for s in ['lambda','[' ,']']) and
                    is_list(p[1]) and all(is_dict(v) for v in p[1])), p
            
        super(InvFlatArray,self).__init__(p[0].strip())
        self.idx_info = p[1]
Ejemplo n.º 3
0
    def __init__(self, p):
        """
        Ex:
        sage: m = InvMPP(('lambda p,r: 422 >= min(p,r + 29)', 'If(p <= r + 29, 422 >= p, 422 >= r + 29)'))
        
        sage: print m
        422 >= min(p,r + 29), If(p <= r + 29, 422 >= p, 422 >= r + 29)

        sage: m.get_score()
        62

        """
        if __debug__:
            assert (is_tuple(p) and len(p) == 2 and is_str(p[0])
                    and 'lambda' in p[0] and is_str(p[1])), p

        super(InvMPP, self).__init__(p[0].strip(), p_str=p[1])
Ejemplo n.º 4
0
    def __init__(self, p): 
        """
        Ex:
        sage: m = InvMPP(('lambda p,r: 422 >= min(p,r + 29)', 'If(p <= r + 29, 422 >= p, 422 >= r + 29)'))
        
        sage: print m
        422 >= min(p,r + 29), If(p <= r + 29, 422 >= p, 422 >= r + 29)

        sage: m.get_score()
        62

        """
        if __debug__:
            assert (is_tuple(p) and len(p)==2 and 
                    is_str(p[0]) and 'lambda' in p[0] and
                    is_str(p[1])), p

        super(InvMPP,self).__init__(p[0].strip(), p_str=p[1])