gap.c
/* It performs shifting or swapping of the jobs on a 0.5 porcent of probabilty.
   The third argument (a int random number) must be 0 or 1.
   0 is for swapping and 1 is for shifting jobs. */
It performs shifting or swapping of the jobs on a 0.5 porcent of probabilty.
The third argument (a int random number) must be 0 or 1.
0 is for swapping and 1 is for shifting jobs.
It performs shifting or swapping of the jobs on a 0 . 5 porcent of probabilty . The third argument ( a int random number ) must be 0 or 1 . 0 is for swapping and 1 is for shifting jobs .
void swap_shift(Vdata *vdata, GAPdata *gapdata, int random){ 
  int temp, a_random_job, another_random_job, a_random_worker;
  if (random == 0){ 
    a_random_job = rand () % gapdata->n;
    while((another_random_job = rand() % gapdata->n) == a_random_job) 
      ;
    temp = vdata->bestsol[a_random_job];
    vdata->bestsol[a_random_job] = vdata->bestsol[another_random_job];
    vdata->bestsol[another_random_job] = temp;
  }
  if (random == 1){ 
    a_random_job = rand() % gapdata->n;
    a_random_worker = rand() % gapdata->m;
    vdata->bestsol[a_random_job] = a_random_worker;
  }
  cost_total(vdata,gapdata);
}
void swap_shift ( Vdata * vdata , GAPdata * gapdata , int random ) { int temp , a_random_job , another_random_job , a_random_worker ; if ( random == 0 ) { a_random_job = rand ( ) % gapdata -> n ; while ( ( another_random_job = rand ( ) % gapdata -> n ) == a_random_job ) ; temp = vdata -> bestsol [ a_random_job ] ; vdata -> bestsol [ a_random_job ] = vdata -> bestsol [ another_random_job ] ; vdata -> bestsol [ another_random_job ] = temp ; } if ( random == 1 ) { a_random_job = rand ( ) % gapdata -> n ; a_random_worker = rand ( ) % gapdata -> m ; vdata -> bestsol [ a_random_job ] = a_random_worker ; } cost_total ( vdata , gapdata ) ; }
It performs shifting or swapping of the jobs on a 0.5 porcent of probabilty.
It performs shifting or swapping of the jobs on a 0 . 5 porcent of probabilty .
//random = 0 or 1 //swap //avoid swapping between the same job //simple swap //shift