solution_t * solution_alloc() { solution_t *sol; sol = ALLOC(solution_t, 1); sol->cost = 0; sol->row = sm_row_alloc(); return sol; }
ABC_NAMESPACE_IMPL_START solution_t * solution_alloc() { solution_t *sol; sol = ALLOC(solution_t, 1); sol->cost = 0; sol->row = sm_row_alloc(); return sol; }
sm_row * sm_minimum_cover(sm_matrix *A, int *weight, int heuristic, int debug_level) /* set to 1 for a heuristic covering */ /* how deep in the recursion to provide info */ { stats_t stats; solution_t *best, *select; sm_row *prow, *sol; sm_col *pcol; sm_matrix *dup_A; int nelem, bound; double sparsity; /* Avoid sillyness */ if (A->nrows <= 0) { return sm_row_alloc(); /* easy to cover */ } /* Initialize debugging structure */ stats.start_time = util_cpu_time(); stats.debug = debug_level > 0; stats.max_print_depth = debug_level; stats.max_depth = -1; stats.nodes = 0; stats.component = stats.comp_count = 0; stats.gimpel = stats.gimpel_count = 0; stats.no_branching = heuristic != 0; stats.lower_bound = -1; /* Check the matrix sparsity */ nelem = 0; sm_foreach_row(A, prow) { nelem += prow->length; } sparsity = (double) nelem / (double) (A->nrows * A->ncols); /* Determine an upper bound on the solution */ bound = 1; sm_foreach_col(A, pcol) { bound += WEIGHT(weight, pcol->col_num); }