27 (void) fprintf(stderr, "Fatal error: file %s, line %d\n%s\n",\
28 __FILE__, __LINE__, why);\
29 (void) fflush(stdout);\
55 stats.debug = debug_level > 0;
56 stats.max_print_depth = debug_level;
59 stats.component = stats.comp_count = 0;
60 stats.gimpel = stats.gimpel_count = 0;
61 stats.no_branching = heuristic != 0;
62 stats.lower_bound = -1;
69 sparsity = (double) nelem / (
double) (A->nrows * A->ncols);
80 best =
sm_mincov(dup_A, select, weight, 0, bound, 0, &stats);
85 if (stats.no_branching) {
86 (void) printf(
"**** heuristic covering ...\n");
87 (void) printf(
"lower bound = %d\n", stats.lower_bound);
89 (void) printf(
"matrix = %d by %d with %d elements (%4.3f%%)\n",
90 A->nrows, A->ncols, nelem, sparsity * 100.0);
91 (void) printf(
"cover size = %d elements\n", best->
row->
length);
92 (void) printf(
"cover cost = %d\n", best->
cost);
93 (void) printf(
"time = %s\n",
95 (void) printf(
"components = %d\n", stats.comp_count);
96 (void) printf(
"gimpel = %d\n", stats.gimpel_count);
97 (void) printf(
"nodes = %d\n", stats.nodes);
98 (void) printf(
"max_depth = %d\n", stats.max_depth);
103 fail(
"mincov: internal error -- cover verification failed\n");
131 int pick, lb_new,
debug;
135 if (depth > stats->max_depth) stats->max_depth = depth;
136 debug = stats->debug && (depth <= stats->max_print_depth);
140 if (select->
cost >= bound) {
146 if ( weight ==
NIL(
int)) {
147 if (
gimpel_reduce(A, select, weight, lb, bound, depth, stats, &best)) {
162 lb_new = select->
cost + (A->nrows > 0);
167 stats->lower_bound = lb_new + stats->gimpel;
171 (void) printf(
"ABSMIN[%2d]%s", depth, stats->component ?
"*" :
" ");
172 (void) printf(
" %3dx%3d sel=%3d bnd=%3d lb=%3d %12s ",
173 A->nrows, A->ncols, select->
cost + stats->gimpel,
174 bound + stats->gimpel, lb_new + stats->gimpel,
179 if (lb_new >= bound) {
180 if (debug) (void) printf(
"bounded\n");
185 }
else if (A->nrows == 0) {
187 if (debug) (void) printf(
"BEST\n");
188 if (stats->debug && stats->component == 0) {
189 (void) printf(
"new 'best' solution %d at level %d (time is %s)\n",
190 best->
cost + stats->gimpel, depth,
203 if (debug) (void) printf(
"comp %d %d\n", L->
nrows, R->
nrows);
210 bound-select->
cost, depth+1, stats);
219 for(p = best1->
row->
first_col; p != 0; p = p->next_col) {
225 best =
sm_mincov(R, select, weight, lb_new, bound, depth+1, stats);
231 if (debug) (void) printf(
"pick=%d\n", pick);
237 best1 =
sm_mincov(A1, select1, weight, lb_new, bound, depth+1, stats);
247 if (stats->no_branching) {
260 best2 =
sm_mincov(A2, select2, weight, lb_new, bound, depth+1, stats);
277 register sm_row *prow, *indep_cols;
285 for(p = indep->
row->
first_col; p != 0; p = p->next_col) {
287 for(p1 = prow->
first_col; p1 != 0; p1 = p1->next_col) {
308 for(p = pcol->
first_row; p != 0; p = p->next_row) {
310 w += 1.0 / ((double) prow->
length - 1.0);
335 register sm_row *prow, *essen;
336 int delcols, delrows, essen_count;
354 if (select->
cost >= bound) {
359 essen_count = essen->
length;
365 }
while (delcols > 0 || delrows > 0 || essen_count > 0);
int sm_block_partition(sm_matrix *A, sm_matrix **L, sm_matrix **R)
int sm_col_dominance(sm_matrix *A, int *weight)
static void select_essential()
ABC_NAMESPACE_IMPL_START int gimpel_reduce(sm_matrix *A, solution_t *select, int *weight, int lb, int bound, int depth, stats_t *stats, solution_t **best)
solution_t * solution_dup()
solution_t * sm_maximal_independent_set(sm_matrix *A, int *weight)
sm_matrix * sm_dup(sm_matrix *A)
#define sm_foreach_row(A, prow)
#define sm_foreach_col(A, pcol)
solution_t * solution_alloc()
sm_element * sm_row_insert(sm_row *prow, int col)
sm_row * sm_row_dup(sm_row *prow)
#define sm_foreach_row_element(prow, p)
#define sm_get_row(A, rownum)
#define ABC_NAMESPACE_IMPL_END
#define sm_get_col(A, colnum)
void sm_free(sm_matrix *A)
ABC_NAMESPACE_IMPL_START int sm_row_dominance(sm_matrix *A)
#define WEIGHT(weight, col)
sm_row * sm_minimum_cover(sm_matrix *A, int *weight, int heuristic, int debug_level)
#define ABC_NAMESPACE_IMPL_START
static int verify_cover()
solution_t * sm_mincov(sm_matrix *A, solution_t *select, int *weight, int lb, int bound, int depth, stats_t *stats)
static int select_column()
solution_t * solution_choose_best()
typedefABC_NAMESPACE_HEADER_START struct sm_element_struct sm_element
ABC_NAMESPACE_IMPL_START sm_row * sm_row_alloc()
void sm_row_free(sm_row *prow)
int sm_row_intersects(sm_row *p1, sm_row *p2)