int sm_col_dominance(sm_matrix *A, int *weight) { register sm_row *prow; register sm_col *pcol, *pcol1; register sm_element *p; sm_row *least_row; sm_col *next_col; int colcnt; colcnt = A->ncols; for(pcol = A->first_col; pcol != 0; pcol = next_col) { next_col = pcol->next_col; least_row = ((( pcol->first_row->row_num) >= 0 && ( pcol->first_row->row_num) < (A)->rows_size) ? (A)->rows[ pcol->first_row->row_num] : (sm_row *) 0); for(p = pcol->first_row->next_row; p != 0; p = p->next_row) { prow = ((( p->row_num) >= 0 && ( p->row_num) < (A)->rows_size) ? (A)->rows[ p->row_num] : (sm_row *) 0); if (prow->length < least_row->length) { least_row = prow; } } for(p = least_row->first_col; p != 0; p = p->next_col) { pcol1 = ((( p->col_num) >= 0 && ( p->col_num) < (A)->cols_size) ? (A)->cols[ p->col_num] : (sm_col *) 0); if (weight != 0 && weight[pcol1->col_num] > weight[pcol->col_num]) continue; if ((pcol1->length > pcol->length) || (pcol1->length == pcol->length && pcol1->col_num > pcol->col_num)) { if (sm_col_contains(pcol, pcol1)) { sm_delcol(A, pcol->col_num); break; } } } } return colcnt - A->ncols; }
int sm_col_dominance(sm_matrix *A, int *weight) { register sm_row *prow; register sm_col *pcol, *pcol1; register sm_element *p; sm_row *least_row; sm_col *next_col; int colcnt; colcnt = A->ncols; /* Check each column against all other columns */ for(pcol = A->first_col; pcol != 0; pcol = next_col) { next_col = pcol->next_col; /* Check all rows to find the one with fewest elements */ least_row = sm_get_row(A, pcol->first_row->row_num); for(p = pcol->first_row->next_row; p != 0; p = p->next_row) { prow = sm_get_row(A, p->row_num); if (prow->length < least_row->length) { least_row = prow; } } /* Only check for containment against columns in this row */ for(p = least_row->first_col; p != 0; p = p->next_col) { pcol1 = sm_get_col(A, p->col_num); if (weight != 0 && weight[pcol1->col_num] > weight[pcol->col_num]) continue; if ((pcol1->length > pcol->length) || (pcol1->length == pcol->length && pcol1->col_num > pcol->col_num)) { if (sm_col_contains(pcol, pcol1)) { sm_delcol(A, pcol->col_num); break; } } } } return colcnt - A->ncols; }
/* ARGSUSED */ void solution_reject(solution_t *sol, sm_matrix *A, int *weight, int col) { sm_delcol(A, col); }