abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
solution.c File Reference
#include "mincov_int.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
solution_t
solution_alloc ()
 
void solution_free (solution_t *sol)
 
solution_tsolution_dup (solution_t *sol)
 
void solution_add (solution_t *sol, int *weight, int col)
 
void solution_accept (solution_t *sol, sm_matrix *A, int *weight, int col)
 
void solution_reject (solution_t *sol, sm_matrix *A, int *weight, int col)
 
solution_tsolution_choose_best (solution_t *best1, solution_t *best2)
 

Function Documentation

void solution_accept ( solution_t sol,
sm_matrix A,
int *  weight,
int  col 
)

Definition at line 62 of file solution.c.

67 {
68  register sm_element *p, *pnext;
69  sm_col *pcol;
70 
71  solution_add(sol, weight, col);
72 
73  /* delete rows covered by this column */
74  pcol = sm_get_col(A, col);
75  for(p = pcol->first_row; p != 0; p = pnext) {
76  pnext = p->next_row; /* grab it before it disappears */
77  sm_delrow(A, p->row_num);
78  }
79 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sm_delrow(sm_matrix *A, int i)
Definition: matrix.c:273
sm_element * first_row
Definition: sparse.h:63
#define sm_get_col(A, colnum)
Definition: sparse.h:89
typedefABC_NAMESPACE_HEADER_START struct sm_element_struct sm_element
Definition: sparse.h:21
void solution_add(solution_t *sol, int *weight, int col)
Definition: solution.c:51
void solution_add ( solution_t sol,
int *  weight,
int  col 
)

Definition at line 51 of file solution.c.

55 {
56  (void) sm_row_insert(sol->row, col);
57  sol->cost += WEIGHT(weight, col);
58 }
sm_element * sm_row_insert(sm_row *prow, int col)
Definition: rows.c:100
#define WEIGHT(weight, col)
Definition: cuddSat.c:112
sm_row * row
Definition: mincov_int.h:37
ABC_NAMESPACE_IMPL_START solution_t* solution_alloc ( )

Definition at line 17 of file solution.c.

18 {
19  solution_t *sol;
20 
21  sol = ALLOC(solution_t, 1);
22  sol->cost = 0;
23  sol->row = sm_row_alloc();
24  return sol;
25 }
#define ALLOC(type, num)
Definition: avl.h:27
sm_row * row
Definition: mincov_int.h:37
ABC_NAMESPACE_IMPL_START sm_row * sm_row_alloc()
Definition: rows.c:21
solution_t* solution_choose_best ( solution_t best1,
solution_t best2 
)

Definition at line 95 of file solution.c.

97 {
98  if (best1 != NIL(solution_t)) {
99  if (best2 != NIL(solution_t)) {
100  if (best1->cost <= best2->cost) {
101  solution_free(best2);
102  return best1;
103  } else {
104  solution_free(best1);
105  return best2;
106  }
107  } else {
108  return best1;
109  }
110  } else {
111  if (best2 != NIL(solution_t)) {
112  return best2;
113  } else {
114  return NIL(solution_t);
115  }
116  }
117 }
#define NIL(type)
Definition: avl.h:25
void solution_free(solution_t *sol)
Definition: solution.c:29
solution_t* solution_dup ( solution_t sol)

Definition at line 38 of file solution.c.

40 {
41  solution_t *new_sol;
42 
43  new_sol = ALLOC(solution_t, 1);
44  new_sol->cost = sol->cost;
45  new_sol->row = sm_row_dup(sol->row);
46  return new_sol;
47 }
sm_row * sm_row_dup(sm_row *prow)
Definition: rows.c:82
#define ALLOC(type, num)
Definition: avl.h:27
sm_row * row
Definition: mincov_int.h:37
void solution_free ( solution_t sol)

Definition at line 29 of file solution.c.

31 {
32  sm_row_free(sol->row);
33  FREE(sol);
34 }
#define FREE(obj)
Definition: avl.h:31
sm_row * row
Definition: mincov_int.h:37
void sm_row_free(sm_row *prow)
Definition: rows.c:53
void solution_reject ( solution_t sol,
sm_matrix A,
int *  weight,
int  col 
)

Definition at line 84 of file solution.c.

89 {
90  sm_delcol(A, col);
91 }
void sm_delcol(sm_matrix *A, int i)
Definition: matrix.c:307