Пример #1
0
def analyse_sloution():
    max_ts = []
    with open('discrete_dijkstra_system.out', 'r') as f:
        e = int(f.readline().split()[-1])
        while True:
            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(e):
                line = [float(x) for x in f.readline().split()[-e:]]
                for j in range(e):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('E{}:'.format(e))
            print('SS: i={} j={} T={}'.format(i_max, j_max, max_t))
            max_ts.append(max_t)

            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(1, e):
                line = [float(x) for x in f.readline().split()[-e:]]
                for j in range(e):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('US: i={} j={} T={}'.format(i_max, j_max, max_t))


            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(1, e):
                line = [float(x) for x in f.readline().split()[-i:]]
                for j in range(i):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('PUS: i={} j={} T={}'.format(i_max, j_max, max_t))
            e = f.readline()
            if e:
                e = int(e.split()[-1])
            else:
                return max_ts
Пример #2
0
def analyse_sloution():
    max_ts = []
    with open('discrete_dijkstra_system.out', 'r') as f:
        e = int(f.readline().split()[-1])
        while True:
            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(e):
                line = [float(x) for x in f.readline().split()[-e:]]
                for j in range(e):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('E{}:'.format(e))
            print('SS: i={} j={} T={}'.format(i_max, j_max, max_t))
            max_ts.append(max_t)

            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(1, e):
                line = [float(x) for x in f.readline().split()[-e:]]
                for j in range(e):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('US: i={} j={} T={}'.format(i_max, j_max, max_t))

            i_max = j_max = max_t = 0
            f.readline()
            f.readline()
            for i in range(1, e):
                line = [float(x) for x in f.readline().split()[-i:]]
                for j in range(i):
                    if line[j] > max_t:
                        i_max, j_max, max_t = i, j, line[j]
                        max_t = line[j]
            print('PUS: i={} j={} T={}'.format(i_max, j_max, max_t))
            e = f.readline()
            if e:
                e = int(e.split()[-1])
            else:
                return max_ts
Пример #3
0
    def setExpression(self, expr):
        """
        Set form expression
        @param expr expression, eg x**2 * dx ^ dz + sin(pi*y)* dy ^ dx
        """
        if self.formPat == '':
            self.terms[''] = expr
            return

        coordName2Index = {'x': 0, 'y': 1, 'z': 2}
        # break the expresssion into independent terms
        continueFlag = True
        e = expr[:] # copy
        coords = []
        while continueFlag:
            m = re.search(self.formPat, e)
            if m:
                coords.append(tuple([coordName2Index[m.group(1 + o)] for o in range(self.order)]))
                e = re.sub(re.escape(m.group(0)), ',', e, 1) # replace the first occurrence only
                e = re.sub(r'\,$', '', e)
            else:
                continueFlag = False
        self.terms = dict(zip(coords, e.split(',')))