예제 #1
0
def init():
    MyDebugger.pre_fix = os.path.join(MyDebugger.pre_fix, "debug")
    debugger = MyDebugger(f"region_tiling",
                          fix_rand_seed=config.rand_seed,
                          save_print_to_file=False)
    plotter = Plotter()
    return debugger, plotter
def show_all_onering_neibors():
    # Driver code
    MyDebugger.pre_fix = os.path.join(MyDebugger.pre_fix, "debug")
    debugger = MyDebugger(f"gen_tile_graph_{config.env_name}", fix_rand_seed=0)
    plotter = Plotter()
    data_env = config.environment

    result_tiles = []
    align_tags = []
    for base_tile in data_env.proto_tiles:
        for align_tile in data_env.proto_tiles:
            neighbour_tiles, align_tag = get_all_tiles(base_tile,
                                                       align_tile,
                                                       integer_align=True)
            for i in range(len(neighbour_tiles)):
                plotter.draw_contours(
                    debugger.file_path(f"{align_tag[i]}.png"), [
                        base_tile.get_plot_attribute(),
                        neighbour_tiles[i].get_plot_attribute()
                    ])
예제 #3
0
    def draw_solution(self, painter: QPainter):
        tiles = self.current_best_solution.get_selected_tiles()

        painter.setPen(self.pens[solution_color])
        painter.setBrush(self.brushes[solution_color])
        scale, translation = self._get_scale_translation(False)
        polygons = [
            Plotter.create_polygon(
                np.array(t.exterior.coords) * scale + translation)
            for t in tiles
        ]
        for p in polygons:
            painter.drawPolygon(p)
예제 #4
0
    def draw_grid(self, scale, translation):
        grid_painter = QPainter(self.pixmap)
        grid_painter.setRenderHint(QPainter.Antialiasing)
        grid_painter.setRenderHint(QPainter.SmoothPixmapTransform)
        ############ Draw grids #############################
        grid_painter.setPen(self.grid_pen)
        polygons = [
            Plotter.create_polygon(
                np.array(t.tile_poly.exterior.coords) * scale + translation)
            for t in self.complete_graph.tiles
        ]
        for p in polygons:
            grid_painter.drawPolygon(p)

        self.need_draw_grid = False
예제 #5
0
import os
from inputs import config
from solver.ml_solver.trainer import Trainer
import torch
from solver.ml_solver.ml_solver import ML_Solver
import numpy as np
from graph_networks.networks.TilinGNN import TilinGNN

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

if __name__ == "__main__":
    MyDebugger.pre_fix = os.path.join(MyDebugger.pre_fix, "debug")
    debugger = MyDebugger(f"training_{config.experiment_id}",
                          fix_rand_seed=config.rand_seed,
                          save_print_to_file=False)
    plotter = Plotter()
    data_env = config.environment
    data_env.load_complete_graph(config.complete_graph_size)

    #### Network
    network = TilinGNN(
        adj_edge_features_dim=data_env.complete_graph.total_feature_dim,
        network_depth=config.network_depth,
        network_width=config.network_width).to(device)

    ## solver
    ml_solver = ML_Solver(debugger,
                          device,
                          data_env.complete_graph,
                          network,
                          num_prob_maps=1)