gap.c
/* It recomputes the vdata->cost and vdata->penal.
   This function is called whenever a new best solution is found.
*/
It recomputes the vdata->cost and vdata->penal.
This function is called whenever a new best solution is found.
It recomputes the vdata - > cost and vdata - > penal . This function is called whenever a new best solution is found .
void cost_total(Vdata *vdata, GAPdata *gapdata)
{
  int	i,j;		
  int	*rest_b;	
  int	cost, penal;	
  int	temp;		
  rest_b = (int *) malloc_e(gapdata->m * sizeof(int));
  cost = penal = 0;
  for(i=0; i<gapdata->m; i++){rest_b[i] = gapdata->b[i];}
  for(j=0; j<gapdata->n; j++){
    rest_b[vdata->bestsol[j]] -= gapdata->a[vdata->bestsol[j]][j];
    cost += gapdata->c[vdata->bestsol[j]][j];
  }
  for(i=0; i<gapdata->m; i++){
    temp = rest_b[i];
    if(temp<0){
      penal -= temp;
    }
  }
  vdata->penal = penal;
  vdata->cost = cost;
  free((void *) rest_b);
}
void cost_total ( Vdata * vdata , GAPdata * gapdata ) { int i , j ; int * rest_b ; int cost , penal ; int temp ; rest_b = ( int * ) malloc_e ( gapdata -> m * sizeof ( int ) ) ; cost = penal = 0 ; for ( i = 0 ; i < gapdata -> m ; i ++ ) { rest_b [ i ] = gapdata -> b [ i ] ; } for ( j = 0 ; j < gapdata -> n ; j ++ ) { rest_b [ vdata -> bestsol [ j ] ] -= gapdata -> a [ vdata -> bestsol [ j ] ] [ j ] ; cost += gapdata -> c [ vdata -> bestsol [ j ] ] [ j ] ; } for ( i = 0 ; i < gapdata -> m ; i ++ ) { temp = rest_b [ i ] ; if ( temp < 0 ) { penal -= temp ; } } vdata -> penal = penal ; vdata -> cost = cost ; free ( ( void * ) rest_b ) ; }
It recomputes the vdata->cost and vdata->penal.
It recomputes the vdata - > cost and vdata - > penal .
/* indices of agents and jobs */ /* the amount of resource available at each agent */ /* the cost; the penalty = the total capacity excess */ /* temporary variable */