src/misc/espresso/solution.c File Reference

#include "mincov_int.h"
Include dependency graph for solution.c:

Go to the source code of this file.

Functions

solution_tsolution_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 59 of file solution.c.

00064 {
00065     register sm_element *p, *pnext;
00066     sm_col *pcol;
00067 
00068     solution_add(sol, weight, col);
00069 
00070     /* delete rows covered by this column */
00071     pcol = sm_get_col(A, col);
00072     for(p = pcol->first_row; p != 0; p = pnext) {
00073         pnext = p->next_row;            /* grab it before it disappears */
00074         sm_delrow(A, p->row_num);
00075     }
00076 }

void solution_add ( solution_t sol,
int *  weight,
int  col 
)

Definition at line 48 of file solution.c.

00052 {
00053     (void) sm_row_insert(sol->row, col);
00054     sol->cost += WEIGHT(weight, col);
00055 }

solution_t* solution_alloc (  ) 

Definition at line 14 of file solution.c.

00015 {
00016     solution_t *sol;
00017 
00018     sol = ALLOC(solution_t, 1);
00019     sol->cost = 0;
00020     sol->row = sm_row_alloc();
00021     return sol;
00022 }

solution_t* solution_choose_best ( solution_t best1,
solution_t best2 
)

Definition at line 92 of file solution.c.

00094 {
00095     if (best1 != NIL(solution_t)) {
00096         if (best2 != NIL(solution_t)) {
00097             if (best1->cost <= best2->cost) {
00098                 solution_free(best2);
00099                 return best1;
00100             } else {
00101                 solution_free(best1);
00102                 return best2;
00103             }
00104         } else {
00105             return best1;
00106         }
00107     } else {
00108         if (best2 != NIL(solution_t)) {
00109             return best2;
00110         } else {
00111             return NIL(solution_t);
00112         }
00113     }
00114 }

solution_t* solution_dup ( solution_t sol  ) 

Definition at line 35 of file solution.c.

00037 {
00038     solution_t *new_sol;
00039 
00040     new_sol = ALLOC(solution_t, 1);
00041     new_sol->cost = sol->cost;
00042     new_sol->row = sm_row_dup(sol->row);
00043     return new_sol;
00044 }

void solution_free ( solution_t sol  ) 

Definition at line 26 of file solution.c.

00028 {
00029     sm_row_free(sol->row);
00030     FREE(sol);
00031 }

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

Definition at line 81 of file solution.c.

00086 {
00087     sm_delcol(A, col);
00088 }


Generated on Tue Jan 5 12:19:12 2010 for abc70930 by  doxygen 1.6.1