예제 #1
0
    def _search(self):
        logger.info(line_contain_word("RECORD", char="-"))
        result, count = -1, 0
        i, j = self.min_edges_num, self.max_edges_num

        if self._count(i) > 90:
            logger.info(f"Min: {i} edges can make the graph converge.")

        elif self._count(j) < 90:
            logger.info(f"Max: {j} edges cannot make the graph converge.")

        else:
            while i <= j:
                mid = i + (j - i) // 2
                proportion = self._count(mid)
                if proportion >= 90:
                    result = mid
                    j = mid - self.precision
                else:
                    i = mid + self.precision

                count += 1
                logger.info(f"{count}: {mid} edges, {proportion}%")
            logger.info(f"Found: {result} edges can make the graph converge.")

        logger.info(line_contain_word("RECORD", char="-"))
        self.result = result
    def _run(self):
        logger.info(line_contain_word("RECORD", char="-"))

        self.learning.emerge(self.init_iter_num)
        self._desc(0)
        self._update()

        for i in range(self.one_time_edge_num,
                       self.edge_sum + self.one_time_edge_num,
                       self.one_time_edge_num):
            if self._has_global_norm():
                self._desc(i)
                continue

            if self.edges:
                self.strategy.add_edge(
                    self.one_time_edge_num, self.mode,
                    self.edges[i - self.one_time_edge_num:i])
            else:
                self.strategy.add_edge(self.one_time_edge_num, self.mode)

            self.learning.emerge(self.iter_num)
            self._desc(i)
            self._update()

        logger.info(line_contain_word("RECORD", char="-"))
예제 #3
0
    def _run(self):
        logger.info(line_contain_word("RECORD", char="-"))

        self._desc(0)
        self._update()

        flag = False

        for i in range(self.one_time_edge_num,
                       self.edge_sum + self.one_time_edge_num,
                       self.one_time_edge_num):
            if self._has_global_norm() or flag:
                self._desc(i)
                continue

            for _ in range(self.one_time_edge_num):
                # print(len(self.graph.components()))
                if not self.learning.emerge():
                    flag = True
                    break

            self._desc(i)
            self._update()

        logger.info(line_contain_word("RECORD", char="-"))
예제 #4
0
    def _run(self):
        self.strategy.add_edge(self.edge_sum, self.mode, self.edges)

        logger.info(line_contain_word("RECORD", char="-"))
        for i in range(self.desc_interval, self.iter_num + self.desc_interval,
                       self.desc_interval):
            self.learning.emerge(self.desc_interval)
            self._desc(i)
        logger.info(line_contain_word("RECORD", char="-"))
예제 #5
0
    def _end(self):
        logger.info(f"t: {seconds2datetime(time.time() - self.start_time)}")
        logger.info(line_contain_word("END"))
        logger.info("\n\n")

        for i in self.log_handlers:
            logger.remove(i)
예제 #6
0
 def _start(self):
     logger.info(line_contain_word("START"))
     logger.info(f"g: {self.graph.name}, "
                 f"v: {self.graph.vcount()}, "
                 f"e: {self.graph.ecount()}, "
                 f"i: {self.iter_num}, "
                 f"a: {self.available_action}, "
                 f"m: {self.mode}, "
                 f"s: {self.edge_sum}")
예제 #7
0
 def _start(self):
     logger.info(line_contain_word("START"))
     logger.info(f"g: {self.graph.name}, "
                 f"v: {self.graph.vcount()}, "
                 f"e: {self.graph.ecount()}, "
                 f"i: {self.iter_num}, "
                 f"a: {self.avail_action}, "
                 f"m: {self.mode}, "
                 f"max: {self.max_edges_num}, "
                 f"min: {self.min_edges_num}, "
                 f"rep: {self.repeat_time}, "
                 f"psc: {self.precision}")
    def _run(self):
        logger.info(line_contain_word("RECORD", char="-"))
        interval = self.edge_sum // self.points_num

        for i in range(interval, self.edge_sum + interval, interval):
            if len(set([learner.action for learner in self.learning.learners])) == 1:
                self._desc(i)
                continue

            if self.mode == 0:
                self.strategy.add_edge(interval, self.mode)
            elif self.edges:
                self.strategy.add_edge(interval, self.mode, self.edges[i - interval: i])
            else:
                self.strategy.add_edge(interval, self.mode)

            self.learning.emerge(self.iter_num)
            self._desc(i)
            self._update()

        logger.info(line_contain_word("RECORD", char="-"))