Graph Convolutional Branch and Bound v1.0.0
A TSP solver that combines a graph convolutional network with a 1-Tree branch-and-bound.
Loading...
Searching...
No Matches
b_and_b_data.h
Go to the documentation of this file.
1
16#ifndef BRANCHANDBOUND1TREE_B_AND_B_DATA_H
17#define BRANCHANDBOUND1TREE_B_AND_B_DATA_H
18
19#include "mst.h"
20
22typedef enum BBNodeType{
31
32
34typedef enum ConstraintType{
39
40
42typedef struct SubProblem{
44 unsigned int id;
45 unsigned int fatherId;
46 double value;
47 unsigned short treeLevel;
50 unsigned short num_edges_in_cycle;
51 double prob;
52 ConstrainedEdge cycleEdges [MAX_VERTEX_NUM];
53 unsigned short num_forbidden_edges;
54 unsigned short num_mandatory_edges;
57 ConstraintType constraints [MAX_VERTEX_NUM][MAX_VERTEX_NUM];
59
60
62typedef struct Problem{
65 unsigned short candidateNodeId;
66 unsigned short totTreeLevels;
68 double bestValue;
69 unsigned int generatedBBNodes;
70 unsigned int exploredBBNodes;
71 unsigned int num_fixed_edges;
73 clock_t start;
74 clock_t end;
76
77
79typedef struct SubProblemElem{
84
85
87typedef struct SubProblemsList{
90 size_t size;
92
93
95typedef struct {
98 size_t index;
100
101
107
108
114
115
122
123
130
131
138
139
146void add_elem_SubProblemList_index(SubProblemsList *list, SubProblem *element, size_t index);
147
148
154void delete_SubProblemList_elem_index(SubProblemsList *list, size_t index);
155
156
164
165
172
173
175
181
182
189
190
196
197#endif //BRANCHANDBOUND1TREE_B_AND_B_DATA_H
void add_elem_SubProblemList_index(SubProblemsList *list, SubProblem *element, size_t index)
Add a SubProblem at a specific index of a SubProblem List.
Definition: b_and_b_data.c:75
bool is_SubProblemList_iterator_valid(SubProblemsListIterator *iterator)
Check if a SubProblem List iterator is valid.
Definition: b_and_b_data.c:170
SubProblem * get_SubProblemList_elem_index(SubProblemsList *list, size_t index)
Get a SubProblem from a specific index of a SubProblem List.
Definition: b_and_b_data.c:146
ConstraintType
The enum used to identify the type of Edge constraints.
Definition: b_and_b_data.h:34
@ FORBIDDEN
The Edge is forbidden.
Definition: b_and_b_data.h:37
@ MANDATORY
The Edge is mandatory.
Definition: b_and_b_data.h:36
@ NOTHING
The Edge has no constraints.
Definition: b_and_b_data.h:35
void delete_SubProblemList_iterator(SubProblemsListIterator *iterator)
Delete a SubProblem List iterator.
Definition: b_and_b_data.c:198
BBNodeType
The labels used to identify the type of a SubProblem.
Definition: b_and_b_data.h:22
@ OPEN
The SubProblem is a feasible 1Tree, with a value lower than the best solution found so far.
Definition: b_and_b_data.h:23
@ CLOSED_NN
The SubProblem is a feasible 1Tree founded with the Nearest Neighbor algorithm, it is the first feasi...
Definition: b_and_b_data.h:24
@ CLOSED_1TREE
The SubProblem is closed by calculating the 1Tree.
Definition: b_and_b_data.h:28
@ CLOSED_NN_HYBRID
The SubProblem is a feasible 1Tree founded with the Hybrid version of Nearest Neighbor algorithm,...
Definition: b_and_b_data.h:25
@ CLOSED_BOUND
The SubProblem is a feasible 1Tree, with a value greater than the best solution found so far.
Definition: b_and_b_data.h:26
@ CLOSED_UNFEASIBLE
The SubProblem is not a feasible 1Tree, and so discarded.
Definition: b_and_b_data.h:27
@ CLOSED_SUBGRADIENT
The SubProblem is closed in the subgradient algorithm, the ascending dual.
Definition: b_and_b_data.h:29
size_t get_SubProblemList_size(SubProblemsList *list)
Get the size of a SubProblem List.
Definition: b_and_b_data.c:54
void delete_SubProblemList_elem_index(SubProblemsList *list, size_t index)
Remove a SubProblem from a specific index of a SubProblem List.
Definition: b_and_b_data.c:113
void add_elem_SubProblemList_bottom(SubProblemsList *list, SubProblem *element)
Add a SubProblem to the bottom of a SubProblem List.
Definition: b_and_b_data.c:59
SubProblemsListIterator * create_SubProblemList_iterator(SubProblemsList *list)
Create a new SubProblem List iterator on a SubProblem List.
Definition: b_and_b_data.c:159
void new_SubProblemList(SubProblemsList *list)
Create a new SubProblem List.
Definition: b_and_b_data.c:17
bool is_SubProblemList_empty(SubProblemsList *list)
Check if a SubProblem List is empty.
Definition: b_and_b_data.c:39
void delete_SubProblemList(SubProblemsList *list)
Delete a SubProblem List.
Definition: b_and_b_data.c:23
SubProblem * SubProblemList_iterator_get_next(SubProblemsListIterator *iterator)
Get the next element of a SubProblem List iterator.
Definition: b_and_b_data.c:188
This file contains the declaration of the Minimum Spanning Tree datastructure.
A reduced form of an Edge in the Graph, with only the source and destination Nodes.
Definition: mst.h:21
Structure of a Graph.
Definition: graph.h:51
Minimum Spanning Tree, or MST, and also a 1-Tree.
Definition: mst.h:28
The struct used to represent the overall problem.
Definition: b_and_b_data.h:62
Graph reformulationGraph
The Graph used to perform the dual reformulation of Edge weights.
Definition: b_and_b_data.h:64
bool interrupted
True if the algorithm has been interrupted by timeout.
Definition: b_and_b_data.h:72
SubProblem bestSolution
The best solution found so far.
Definition: b_and_b_data.h:67
clock_t end
The time when the algorithm ended.
Definition: b_and_b_data.h:74
clock_t start
The time when the algorithm started.
Definition: b_and_b_data.h:73
Graph graph
The Graph of the problem.
Definition: b_and_b_data.h:63
unsigned short candidateNodeId
The id of the candidate node.
Definition: b_and_b_data.h:65
unsigned int num_fixed_edges
The number of fixed edges in the Branch and Bound tree.
Definition: b_and_b_data.h:71
unsigned int generatedBBNodes
The number of nodes generated in the Branch and Bound tree.
Definition: b_and_b_data.h:69
unsigned short totTreeLevels
The total number of levels in the Branch and Bound tree.
Definition: b_and_b_data.h:66
double bestValue
The cost of the best solution found so far.
Definition: b_and_b_data.h:68
unsigned int exploredBBNodes
The number of nodes explored in the Branch and Bound tree.
Definition: b_and_b_data.h:70
The element of the list of SubProblems.
Definition: b_and_b_data.h:79
SubProblem subProblem
The SubProblem.
Definition: b_and_b_data.h:80
struct SubProblemElem * next
The next element of the list.
Definition: b_and_b_data.h:81
struct SubProblemElem * prev
The previous element of the list.
Definition: b_and_b_data.h:82
The struct used to represent a SubProblem or node of the Branch and Bound tree.
Definition: b_and_b_data.h:42
ConstraintType constraints[MAX_VERTEX_NUM][MAX_VERTEX_NUM]
The constraints of the edges in the SubProblem.
Definition: b_and_b_data.h:57
ConstrainedEdge mandatoryEdges[MAX_VERTEX_NUM]
The mandatory edges in the SubProblem.
Definition: b_and_b_data.h:56
float timeToReach
The time needed to reach the SubProblem, in seconds.
Definition: b_and_b_data.h:48
ConstrainedEdge cycleEdges[MAX_VERTEX_NUM]
The edges in the cycle of the SubProblem.
Definition: b_and_b_data.h:52
unsigned short num_forbidden_edges
The number of forbidden edges in the SubProblem.
Definition: b_and_b_data.h:53
double prob
The probability of the SubProblem to be the best tour.
Definition: b_and_b_data.h:51
unsigned int id
The id of the SubProblem, an incremental number.
Definition: b_and_b_data.h:44
double value
The cost of the SubProblem.
Definition: b_and_b_data.h:46
unsigned int fatherId
The id of the father of the SubProblem.
Definition: b_and_b_data.h:45
int edge_to_branch
The id of the edge to branch in the SubProblem.
Definition: b_and_b_data.h:55
BBNodeType type
The label of the SubProblem.
Definition: b_and_b_data.h:43
MST oneTree
The 1Tree of the SubProblem.
Definition: b_and_b_data.h:49
unsigned short treeLevel
The level of the SubProblem in the Branch and Bound tree.
Definition: b_and_b_data.h:47
unsigned short num_mandatory_edges
The number of mandatory edges in the SubProblem.
Definition: b_and_b_data.h:54
unsigned short num_edges_in_cycle
The number of edges in the cycle of the SubProblem.
Definition: b_and_b_data.h:50
The iterator of the list of SubProblems.
Definition: b_and_b_data.h:95
size_t index
The index of the current element of the list.
Definition: b_and_b_data.h:98
SubProblemsList * list
The list to iterate.
Definition: b_and_b_data.h:96
SubProblemElem * curr
The current element of the list.
Definition: b_and_b_data.h:97
The list of open SubProblems.
Definition: b_and_b_data.h:87
SubProblemElem * tail
The tail of the list.
Definition: b_and_b_data.h:89
SubProblemElem * head
The head of the list.
Definition: b_and_b_data.h:88
size_t size
The size of the list.
Definition: b_and_b_data.h:90