Ejemplo n.º 1
0
    def get_rels_elems1(self, tcs):
        if __debug__:
            assert len(tcs) >= 1, tcs

        aeterms = tcs[0].keys()

        #Find rels among array elements
        logger.debug('Find linear eqts over {} array elems'
                     .format(len(aeterms)))
        aeterms = [SR(1)] + aeterms

        from dig_polynomials import Eqt
        solverE = Eqt(aeterms, tcs, self.xinfo)
        
        logger.info('Select traces (note: |tcs|=|terms|={})'.format(len(aeterms)))
        
        ntcs_extra = 200
        solverE.tcs, solverE.tcs_extra = get_traces(tcs,len(aeterms),ntcs_extra=200)

        solverE.do_refine=False
        solverE._go()
        
        from dig_refine import Refine
        rf = Refine(solverE.sols)
        rf.rfilter(tcs=solverE.tcs_extra)
        ps = [p.p for p in rf.ps]
        
        return ps
Ejemplo n.º 2
0
    def mk_traces(self):
        # will be modified in preprocess
        tcs_all = Miscs.keys_to_str(self.tcs) 
        tcs,_ = get_traces(tcs_all,
                           ntcs=1,#using only 1 array
                           ntcs_extra = 0)

        tcs_extra = tcs_all #refine on all tcs
        return tcs, tcs_extra
Ejemplo n.º 3
0
 def mk_traces(self):
     """
     No need to do too much filtering because 
     most eqts obtained are valid
     """
     tpercent = 150  # terms % for inv gen
     ntcs = int(round(len(self.terms) * tpercent / 100.00))
     ntcs_extra = 200
     return get_traces(self.tcs, ntcs, ntcs_extra)
Ejemplo n.º 4
0
 def mk_traces(self):
     """
     No need to do too much filtering because 
     most eqts obtained are valid
     """
     tpercent = 150 # terms % for inv gen
     ntcs = int(round(len(self.terms) * tpercent / 100.00))
     ntcs_extra = 200
     return get_traces(self.tcs, ntcs, ntcs_extra)
Ejemplo n.º 5
0
    def mk_traces(self):
        """
        E.g., 
        |tcs| = 100 then 80 for invgen, 20 for filter
        |tcs| = 1000 then 300 for invgen, 700 for filter
        |tcs| = 10000 then 300 for invgen, 1000 for filter
        """
        max_ntcs = 300
        max_ntcs_extra = 1000

        if len(self.tcs) <= 100:
            tpercent = 100
        else:
            tpercent = 80  # traces % for inv gen
        ntcs = int(round(len(self.tcs) * tpercent / 100.00))
        ntcs = min(ntcs, max_ntcs)

        ntcs_extra = len(self.tcs) - ntcs
        ntcs_extra = min(ntcs_extra, max_ntcs_extra)

        return get_traces(self.tcs, ntcs, ntcs_extra)
Ejemplo n.º 6
0
    def mk_traces(self):
        """
        E.g., 
        |tcs| = 100 then 80 for invgen, 20 for filter
        |tcs| = 1000 then 300 for invgen, 700 for filter
        |tcs| = 10000 then 300 for invgen, 1000 for filter
        """
        max_ntcs = 300
        max_ntcs_extra = 1000

        if len(self.tcs)<=100:
            tpercent=100
        else:
            tpercent = 80 # traces % for inv gen
        ntcs = int(round(len(self.tcs) * tpercent / 100.00))
        ntcs = min(ntcs,max_ntcs)

        ntcs_extra = len(self.tcs) - ntcs
        ntcs_extra = min(ntcs_extra,max_ntcs_extra)
        
        return get_traces(self.tcs, ntcs, ntcs_extra)
Ejemplo n.º 7
0
    def get_rels_elems2(self, tcs, tsinfo):
        """
        Instead of solving a large N+M eqts once, we can solve 
        just a tuple of size N (N is the number of arrays) N*M times.
        This has a O(N^M) complexity, which is lower than solving N+M
        equations when M = 2.  


        Doesn't work really well in practice (even when M=2) because 
        the large number of invocations to the equation solver.
        """
        
        from dig_polynomials import Eqt
        from itertools import product

        ps = []
        for i,aeterms in enumerate(product(*tsinfo.values())):
            #Find rels among array elements
            logger.debug('{}. Find linear eqts over {} array elems {}'
                         .format(i, len(aeterms), aeterms))
            aeterms = [SR(1)] + list(aeterms)
            solverE = Eqt(aeterms, tcs, self.xinfo)
        
            logger.info('Select traces (note: |tcs|=|terms|={})'
                        .format(len(aeterms)))

            ntcs_extra = 200
            solverE.tcs, solverE.tcs_extra = get_traces(tcs,len(aeterms),ntcs_extra=200)
            solverE.do_refine = False
            solverE._go()
            ps.extend(solverE.sols)
        
        from dig_refine import Refine
        rf = Refine(ps)
        rf.rfilter(tcs=tcs)
        ps = rf.ps
        ps = [p.p for p in ps]
        return ps