gap.c
/***** read the instance data ************************************************/
/***** NEVER MODIFY THIS SUBROUTINE! *****************************************/
read the instance data
NEVER MODIFY THIS SUBROUTINE!
read the instance data NEVER MODIFY THIS SUBROUTINE!
void read_instance(GAPdata *gapdata)
{
  int	i, j;		
  int	value_read;	
  FILE	*fp=stdin;	
  fscanf(fp, "%d", &value_read);	
  gapdata->m = value_read;
  fscanf(fp,"%d",&value_read);		
  gapdata->n = value_read;
  gapdata->c    = (int **) malloc_e(gapdata->m * sizeof(int *));
  gapdata->c[0] = (int *)  malloc_e(gapdata->m * gapdata->n * sizeof(int));
  for(i=1; i<gapdata->m; i++){gapdata->c[i] = gapdata->c[i-1] + gapdata->n;}
  gapdata->a    = (int **) malloc_e(gapdata->m * sizeof(int *));
  gapdata->a[0] = (int *)  malloc_e(gapdata->m * gapdata->n * sizeof(int));
  for(i=1; i<gapdata->m; i++){gapdata->a[i] = gapdata->a[i-1] + gapdata->n;}
  gapdata->b    = (int *)  malloc_e(gapdata->m * sizeof(int));
  for(i=0; i<gapdata->m; i++){
    for(j=0; j<gapdata->n; j++){
      fscanf(fp, "%d", &value_read);
      gapdata->c[i][j] = value_read;
    }
  }
  for(i=0; i<gapdata->m; i++){
    for(j=0; j<gapdata->n; j++){
      fscanf(fp, "%d", &value_read);
      gapdata->a[i][j] = value_read;
    }
  }
  for(i=0; i<gapdata->m; i++){
    fscanf(fp,"%d", &value_read);
    gapdata->b[i] = value_read;
  }
}
void read_instance ( GAPdata * gapdata ) { int i , j ; int value_read ; FILE * fp = stdin ; fscanf ( fp , " " , & value_read ) ; gapdata -> m = value_read ; fscanf ( fp , " " , & value_read ) ; gapdata -> n = value_read ; gapdata -> c = ( int * * ) malloc_e ( gapdata -> m * sizeof ( int * ) ) ; gapdata -> c [ 0 ] = ( int * ) malloc_e ( gapdata -> m * gapdata -> n * sizeof ( int ) ) ; for ( i = 1 ; i < gapdata -> m ; i ++ ) { gapdata -> c [ i ] = gapdata -> c [ i - 1 ] + gapdata -> n ; } gapdata -> a = ( int * * ) malloc_e ( gapdata -> m * sizeof ( int * ) ) ; gapdata -> a [ 0 ] = ( int * ) malloc_e ( gapdata -> m * gapdata -> n * sizeof ( int ) ) ; for ( i = 1 ; i < gapdata -> m ; i ++ ) { gapdata -> a [ i ] = gapdata -> a [ i - 1 ] + gapdata -> n ; } gapdata -> b = ( int * ) malloc_e ( gapdata -> m * sizeof ( int ) ) ; for ( i = 0 ; i < gapdata -> m ; i ++ ) { for ( j = 0 ; j < gapdata -> n ; j ++ ) { fscanf ( fp , " " , & value_read ) ; gapdata -> c [ i ] [ j ] = value_read ; } } for ( i = 0 ; i < gapdata -> m ; i ++ ) { for ( j = 0 ; j < gapdata -> n ; j ++ ) { fscanf ( fp , " " , & value_read ) ; gapdata -> a [ i ] [ j ] = value_read ; } } for ( i = 0 ; i < gapdata -> m ; i ++ ) { fscanf ( fp , " " , & value_read ) ; gapdata -> b [ i ] = value_read ; } }
read the instance data
NEVER MODIFY THIS SUBROUTINE!
read the instance data NEVER MODIFY THIS SUBROUTINE!
/* indices of agents and jobs */ /* the value read by fscanf */ /* set fp to the standard input */ /* read the number of agents and jobs */ /* number of agents */ /* number of jobs */ /* initialize memory */ /* read the cost coefficients */ /* read the resource consumption */ /* read the resource capacity */