Logo Search packages:      
Sourcecode: tablix2 version File versions  Download package

void table_fitness ( table tab  ) 

Assign a fitness to a table by calling all fitness functions.

Parameters:
tab Pointer to the table to be fitnessd.

Definition at line 407 of file modsup.c.

References table_t::chr, fitnessfunc_t::chr, ext_update(), table_t::fitness, fitnessfunc_t::func, fitnessfunc_t::man, fitnessfunc_t::next, slist_t::next, ext_t::next, table_t::possible, fitnessfunc_t::req_ext, modulelist_t::req_ext, fitnessfunc_t::req_slist, modulelist_t::req_slist, slist_update(), table_t::subtotals, fitnessfunc_t::typeid, and fitnessfunc_t::weight.

Referenced by new_generation().

{
      ext *cur_ext;
      slist *cur_slist;
      fitnessfunc *cur;
      int n,m,x,total;

      assert(tab!=NULL);

      cur_ext=mod_list->req_ext;
      while(cur_ext!=NULL) {
            ext_update(cur_ext, tab);
            cur_ext=cur_ext->next;
      }
      
      cur_slist=mod_list->req_slist;
      while(cur_slist!=NULL) {
            slist_update(cur_slist, tab);
            cur_slist=cur_slist->next;
      }

      cur=mod_fitnessfunc;
      n=0;
      total=0;

      tab->possible=1;
      while(cur!=NULL) {
            m=0;
            while(cur->typeid[m]!=INT_MIN) {
                  cur->chr[m]=&(tab->chr[cur->typeid[m]]);
                  m++;
            }
            cur->chr[m]=NULL;

            x=(*cur->func)(cur->chr, cur->req_ext, cur->req_slist);

            x=x*cur->weight;

            tab->subtotals[n]=x;
            total=total+x;

            if(x>0&&cur->man) tab->possible=0;
            
            cur=cur->next;
            n++;
      }

      tab->fitness=total;
}


Generated by  Doxygen 1.6.0   Back to index