Remove warnings and dead code
This commit is contained in:
@@ -200,8 +200,6 @@ static int BNC_branch_node(struct BNC *bnc, double *x, int depth)
|
||||
|
||||
static int BNC_is_integral(double *x, int num_cols)
|
||||
{
|
||||
return 1;
|
||||
|
||||
for (int i = 0; i < num_cols; i++)
|
||||
if (x[i] > LP_EPSILON && x[i] < 1.0 - LP_EPSILON)
|
||||
return 0;
|
||||
|
||||
15
src/flow.c
15
src/flow.c
@@ -13,7 +13,7 @@ int flow_mark_reachable_nodes(
|
||||
|
||||
struct Node **stack;
|
||||
int stack_top = 0;
|
||||
int *parents;
|
||||
int *parents = 0;
|
||||
|
||||
stack = (struct Node **) malloc(graph->node_count * sizeof(struct Node *));
|
||||
abort_if(!stack, "could not allocate stack");
|
||||
@@ -69,8 +69,11 @@ int flow_find_max_flow(
|
||||
for (int i = 0; i < digraph->node_count; i++)
|
||||
digraph->nodes[i].mark = 0;
|
||||
|
||||
// log_verbose()("Input graph:\n");
|
||||
// graph_dump(digraph);
|
||||
log_verbose("Input graph:\n");
|
||||
|
||||
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
|
||||
graph_dump(digraph);
|
||||
#endif
|
||||
|
||||
log_verbose("Solving flow problem:\n");
|
||||
|
||||
@@ -135,7 +138,10 @@ int flow_find_max_flow(
|
||||
log_verbose("New residual capacities:\n");
|
||||
for (int i = 0; i < digraph->edge_count; i++)
|
||||
{
|
||||
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
|
||||
struct Edge *e = &digraph->edges[i];
|
||||
#endif
|
||||
|
||||
if (residual_caps[i] < LP_EPSILON) continue;
|
||||
|
||||
log_verbose("%d %d %.4lf (%d)\n", e->from->index, e->to->index, e->index,
|
||||
@@ -245,6 +251,9 @@ int flow_find_augmenting_path(
|
||||
|
||||
int flow_main(int argc, char **argv)
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
int rval = 0;
|
||||
|
||||
int *edges = 0;
|
||||
|
||||
46
src/graph.c
46
src/graph.c
@@ -126,38 +126,6 @@ void graph_dfs(
|
||||
}
|
||||
}
|
||||
|
||||
int graph_build_directed_from_undirected(
|
||||
const struct Graph *graph, struct Graph *digraph)
|
||||
{
|
||||
int rval = 0;
|
||||
|
||||
int *edges = 0;
|
||||
|
||||
edges = (int *) malloc(4 * graph->edge_count * sizeof(int));
|
||||
abort_if(!edges, "could not allocate edges");
|
||||
|
||||
for (int i = 0; i < graph->edge_count; i++)
|
||||
{
|
||||
struct Edge *e = &graph->edges[i];
|
||||
edges[4 * i] = edges[4 * i + 3] = e->from->index;
|
||||
edges[4 * i + 1] = edges[4 * i + 2] = e->to->index;
|
||||
}
|
||||
|
||||
rval = graph_build(graph->node_count, 2 * graph->edge_count, edges, 1,
|
||||
digraph);
|
||||
abort_if(rval, "graph_build failed");
|
||||
|
||||
for (int i = 0; i < graph->edge_count; i++)
|
||||
{
|
||||
digraph->edges[2 * i].reverse = &digraph->edges[i * 2 + 1];
|
||||
digraph->edges[2 * i + 1].reverse = &digraph->edges[i * 2];
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
if (!edges) free(edges);
|
||||
return rval;
|
||||
}
|
||||
|
||||
void get_delta(
|
||||
int island_node_count,
|
||||
int *island_nodes,
|
||||
@@ -198,10 +166,10 @@ int get_cut_edges_from_marks(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graph_dump(struct Graph *graph)
|
||||
int graph_dump(const struct Graph *graph)
|
||||
{
|
||||
int rval = 0;
|
||||
|
||||
(void) graph;
|
||||
#if LOG_LEVEL >= LOG_LEVEL_DEBUG
|
||||
log_debug("node_count: %d edge_count: %d\n", graph->node_count,
|
||||
graph->edge_count);
|
||||
|
||||
@@ -216,12 +184,10 @@ int graph_dump(struct Graph *graph)
|
||||
struct Edge *e = &graph->edges[i];
|
||||
log_debug("%3d (%d, %d) weight: %d ", e->index, e->from->index,
|
||||
e->to->index, e->weight);
|
||||
#if LOG_LEVEL >= LOG_LEVEL_DEBUG
|
||||
if (e->reverse) printf("reverse: %d ", e->reverse->index);
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
return rval;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,12 +67,9 @@ void get_delta(
|
||||
int *delta,
|
||||
int *marks);
|
||||
|
||||
int graph_build_directed_from_undirected
|
||||
(const struct Graph *graph, struct Graph *digraph);
|
||||
|
||||
int get_cut_edges_from_marks(
|
||||
struct Graph *graph, int *cut_edges_count, struct Edge **cut_edges);
|
||||
|
||||
int graph_dump(struct Graph *graph);
|
||||
int graph_dump(const struct Graph *graph);
|
||||
|
||||
#endif
|
||||
|
||||
45
src/gtsp.c
45
src/gtsp.c
@@ -346,9 +346,7 @@ static int build_flow_digraph(
|
||||
}
|
||||
|
||||
static int map_cut_edges_from_digraph_to_graph(
|
||||
struct Edge **edge_map,
|
||||
int *cut_edges_count,
|
||||
struct Edge **cut_edges)
|
||||
struct Edge **edge_map, int *cut_edges_count, struct Edge **cut_edges)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
@@ -636,9 +634,11 @@ int find_exact_subtour_cuts(
|
||||
rval = LP_get_x(lp, x);
|
||||
abort_if(rval, "LP_get_x failed");
|
||||
|
||||
#if LOG_LEVEL >= LOG_LEVEL_DEBUG
|
||||
log_debug("Writing fractional solution to gtsp-frac.out\n");
|
||||
rval = GTSP_write_solution(data, "gtsp-frac.out", x);
|
||||
abort_if(rval, "GTSP_write_solution failed");
|
||||
#endif
|
||||
|
||||
struct Graph digraph;
|
||||
graph_init(&digraph);
|
||||
@@ -846,13 +846,20 @@ static const struct option options_tab[] = {{"help", no_argument, 0, 'h'},
|
||||
{"seed", required_argument, 0, 's'},
|
||||
{(char *) 0, (int) 0, (int *) 0, (int) 0}};
|
||||
|
||||
static int input_node_count = 20;
|
||||
static int input_cluster_count = 5;
|
||||
static int input_node_count = -1;
|
||||
static int input_cluster_count = -1;
|
||||
static int grid_size = 100;
|
||||
|
||||
static void GTSP_print_usage(char **argv)
|
||||
static void GTSP_print_usage()
|
||||
{
|
||||
printf("wrong usage\n");
|
||||
printf("Parameters:\n");
|
||||
printf("%4s %-13s %s\n", "-n", "--nodes", "number of nodes");
|
||||
printf("%4s %-13s %s\n", "-m", "--clusters", "number of clusters");
|
||||
printf("%4s %-13s %s\n", "-s", "--seed", "random seed");
|
||||
printf("%4s %-13s %s\n", "-g", "--grid-size",
|
||||
"size of the box used for generating random points");
|
||||
printf("%4s %-13s %s\n", "-x", "--optimal",
|
||||
"file containg valid solution (used to assert validity of cuts)");
|
||||
}
|
||||
|
||||
static int GTSP_parse_args(int argc, char **argv)
|
||||
@@ -904,6 +911,30 @@ static int GTSP_parse_args(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (input_cluster_count < 0)
|
||||
{
|
||||
printf("You must specify the number of clusters.\n");
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
if (input_node_count < 0)
|
||||
{
|
||||
printf("You must specify the number of nodes.\n");
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
if(input_cluster_count > input_node_count)
|
||||
{
|
||||
printf("Number of clusters must be at most number of nodes.\n");
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
if (rval)
|
||||
{
|
||||
GTSP_print_usage();
|
||||
rval = 1;
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
return rval;
|
||||
}
|
||||
|
||||
13
src/main.c
13
src/main.c
@@ -16,7 +16,7 @@ static const struct option options_tab[] = {
|
||||
{(char *) 0, (int) 0, (int *) 0, (int) 0}
|
||||
};
|
||||
|
||||
void GTSP_print_usage(char **argv)
|
||||
void GTSP_print_usage()
|
||||
{
|
||||
printf("wrong usage\n");
|
||||
}
|
||||
@@ -30,16 +30,12 @@ int main(int argc, char **argv)
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
GTSP_print_usage(argv);
|
||||
GTSP_print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
GTSP_print_usage(argv);
|
||||
return 1;
|
||||
|
||||
case 'f':
|
||||
return flow_main(argc, argv);
|
||||
|
||||
@@ -48,6 +44,11 @@ int main(int argc, char **argv)
|
||||
|
||||
case 'g':
|
||||
return GTSP_main(argc, argv);
|
||||
|
||||
default:
|
||||
case 'h':
|
||||
GTSP_print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -111,7 +111,10 @@ int TSP_find_violated_subtour_elimination_cut(
|
||||
rval = LP_get_x(lp, x);
|
||||
abort_if(rval, "LP_get_x failed");
|
||||
|
||||
int round = 0;
|
||||
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
|
||||
int current_round = 0;
|
||||
#endif
|
||||
|
||||
int delta_count = 0;
|
||||
int island_count = 0;
|
||||
|
||||
@@ -127,7 +130,7 @@ int TSP_find_violated_subtour_elimination_cut(
|
||||
rval = TSP_add_subtour_elimination_cut(lp, delta_count, delta);
|
||||
}
|
||||
|
||||
log_verbose("Reoptimizing (round %d)...\n", ++round);
|
||||
log_verbose("Reoptimizing (round %d)...\n", ++current_round);
|
||||
abort_if(rval, "TSP_add_subtour_elimination_cut failed");
|
||||
|
||||
rval = LP_optimize(lp, &is_infeasible);
|
||||
@@ -277,7 +280,7 @@ int TSP_read_problem(char *filename, struct TSPData *data)
|
||||
|
||||
struct _IO_FILE *f = (struct _IO_FILE *) NULL;
|
||||
int i, j, end1, end2, w, rval = 0, node_count, edge_count;
|
||||
int *edge_list = (int *) NULL, *edge_weights = (int *) NULL;
|
||||
int *edge_list = 0, *edge_weights = 0;
|
||||
double *x = (double *) NULL, *y = (double *) NULL;
|
||||
|
||||
if (filename)
|
||||
|
||||
@@ -35,10 +35,3 @@ void time_printf(const char *fmt, ...)
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void next_set(int sz, int *set)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < sz - 1 && set[i] + 1 == set[i + 1]; i++) set[i] = i;
|
||||
set[i] = set[i] + 1;
|
||||
}
|
||||
@@ -52,12 +52,12 @@
|
||||
memcpy(&x,swap_temp,sizeof(x)); \
|
||||
} while(0)
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void time_printf(const char *fmt, ...);
|
||||
|
||||
double get_current_time(void);
|
||||
|
||||
double get_real_time();
|
||||
|
||||
void next_set(int sz, int *set);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user