Graph Convolutional Branch and Bound v1.0.0
A TSP solver that combines a graph convolutional network with a 1-Tree branch-and-bound.
|
Functions | |
def | adjacency_matrix (orig_graph) |
def | create_temp_file (num_nodes, str_grap) |
def | get_nodes (graph) |
def | get_instance (instance, num_nodes) |
def | build_c_program (build_directory, num_nodes, hyb_mode) |
def | hybrid_solver (num_instances, num_nodes, hyb_mode, gen_matrix) |
Variables | |
argparse | parser = argparse.ArgumentParser() |
type | |
str | |
default | |
int | |
action | |
argparse | opts = parser.parse_args() |
argparse | gen_matrix = False |
@file: HybridSolver.py @author Lorenzo Sciandra @brief First it builds the program in C, specifying the number of nodes to use and whether it is in hybrid mode or not. Then it runs the graph conv net on the instance, and finally it runs the Branch and Bound. It can be run on a single instance or a range of instances. The input matrix is generated by the neural network and stored in the data folder. The output is stored in the results folder. @version 1.0.0 @data 2024-05-1 @copyright Copyright (c) 2024, license MIT Repo: https://github.com/LorenzoSciandra/GraphConvolutionalBranchandBound
def HybridSolver.adjacency_matrix | ( | orig_graph | ) |
Calculates the adjacency matrix of the graph. Args: orig_graph: The original graph. Returns: The adjacency matrix of the graph.
Definition at line 22 of file HybridSolver.py.
def HybridSolver.build_c_program | ( | build_directory, | |
num_nodes, | |||
hyb_mode | |||
) |
Builds the C program with the specified number of nodes and whether it is in hybrid mode or not. Args: build_directory: The directory where the CMakeLists.txt file is located and where the executable will be built. num_nodes: The number of nodes to use in the C program. hyb_mode: 1 if the program is in hybrid mode, 0 otherwise.
Definition at line 115 of file HybridSolver.py.
def HybridSolver.create_temp_file | ( | num_nodes, | |
str_grap | |||
) |
Creates a temporary file to store the current instance of the TSP for the neural network. Args: num_nodes: The number of nodes in the TSP instance. str_grap: The string representation of the graph.
Definition at line 41 of file HybridSolver.py.
def HybridSolver.get_instance | ( | instance, | |
num_nodes | |||
) |
Gets the instance of the TSP from the file. Args: instance: The instance to get. num_nodes: The number of nodes in the TSP instance. Returns: The graph in a list and string format.
Definition at line 81 of file HybridSolver.py.
def HybridSolver.get_nodes | ( | graph | ) |
From a graph, it returns the nodes in a string format. Args: graph: The graph to get the nodes from. Returns: The nodes in a string format.
Definition at line 63 of file HybridSolver.py.
def HybridSolver.hybrid_solver | ( | num_instances, | |
num_nodes, | |||
hyb_mode, | |||
gen_matrix | |||
) |
The Graph Convolutional Branch-and-Bound Solver. Args: num_instances: The range of instances to run on the Solver. num_nodes: The number of nodes in each TSP instance. hyb_mode: True if the program is in hybrid mode, False otherwise. gen_matrix: True if the adjacency matrix is already generated, False otherwise.
Definition at line 147 of file HybridSolver.py.
HybridSolver.action |
Definition at line 263 of file HybridSolver.py.
HybridSolver.default |
Definition at line 261 of file HybridSolver.py.
argparse HybridSolver.gen_matrix = False |
Definition at line 268 of file HybridSolver.py.
HybridSolver.int |
Definition at line 262 of file HybridSolver.py.
argparse HybridSolver.opts = parser.parse_args() |
Definition at line 264 of file HybridSolver.py.
argparse HybridSolver.parser = argparse.ArgumentParser() |
Definition at line 260 of file HybridSolver.py.
HybridSolver.str |
Definition at line 261 of file HybridSolver.py.
HybridSolver.type |
Definition at line 261 of file HybridSolver.py.