Esempio n. 1
0
int main(){
/***********clock************************/
/*clock_t start, end;

  start = clock();
  printf("***********************************************************************\n");
  printf( "star time:%d\n", start );
/***********clock************************/

 T newtask[]={
   {1,0,10,3,3,1.0,0,0,1},
   {2,0,10,4,4,1.0,0,0,1},
   {3,0,10,5,5,1.0,0,0,1},
   {4,0,9,8,8,1.0,0,0,1},
   {5,0,8,6,6,1.0,0,0,1},
 
 
 }; 

int size =sizeof(newtask)/sizeof(T); //size=Numbers of Task ,last task--> task[size-1]
int timer=0;
int CompletesTure=0;
int cnt=0;
 int i;
int total_job=0;
		/****TOTALJOBS**/
		for(i=0;i<size;i++){
		  total_job+=maxtime/newtask[i].deadline;
		}

		printf("TOTAL JOBS :%d\n",total_job);
/***************AcO loop***********/
while(timer<maxtime){
if(TaskRelease(newtask,timer,size)||CompletesTure){
ExeProb(newtask,timer,size);//#1figure out Exe.Probability.##first
FixSequence(newtask,timer,size);
SuccessRate(newtask,timer,size);//include ##UPdate Pheromon
ExeProb(newtask,timer,size);//#1figure out Exe.Probability.##second
FixSequence(newtask,timer,size);
if(printout)
PrintOut(newtask,timer,size);
}
CompletesTure=ExeTask(newtask,timer,size);//## Exe Task
if(CompletesTure)
cnt++;
timer++;
}

printf("\n");
printf("\n");
printf("             RESULT   ACO Shah                         \n");
 printf("     maxtime=%d\n     apha=%d beat=%d \n     SuccessJob=%d(%4.1f%%)\n      \n",maxtime,apha,beta,cnt,(float)cnt/total_job*100);
/***********clock************************/
/* end = clock();
  printf("***********************************************************************\n");
  printf( "end time:%d\n", end );
  printf( "exetime :%d[ms]\n", end - start );
    printf("***********************************************************************\n");
	
/***********clock************************/
return 0;
}
Esempio n. 2
0
/*>int main(int argc, char **argv)
   -------------------------------
   Main program for PDB to PIR conversion

   10.05.94 Original    By: ACRM
   22.08.97 Various new flags to handle SEQRES
   26.08.97 Option to ignore nucleic acids
   02.10.00 Added -x
   18.10.00 Added -f
   08.02.01 Added -n
   07.03.07 Calls ReadWholePDBAtoms()
*/
int old_main(int argc, char **argv)
{
   int  filecount = 0,
        len1;
   FILE *in       = stdin,
        *out      = stdout;
   char *sequence,
        *fixedsequence,
        *seqres,
        seqchains[MAXCHAINS],
        atomchains[MAXCHAINS],
        outchains[MAXCHAINS],
        title[MAXTITLE];
   PDB  *pdb;
   WHOLEPDB *wpdb;
   BOOL ByChain     = FALSE,
        UseSEQRES   = FALSE,
        SkipX       = FALSE,
        DoNumbering = FALSE;
   MODRES *modres = NULL;
   

   gLabel[0] = gLabel[MAXLAB-1]  = '\0';
   title[0]  = title[MAXTITLE-1] = '\0';
   
   argv++;
   argc--;
   
   /* Parse command line and open files                                 */
   while(argc)
   {
      if(argv[0][0] == '-')    /* Handle switches                       */
      {
         switch(argv[0][1])
         {
         case 'h':
         case 'H':
         case '?':
            pdb2pir_Usage();
            return(0);
            break;
         case 'l':
         case 'L':
            argc--;
            argv++;
            strncpy(gLabel,argv[0],MAXLAB-1);
            break;
         case 't':
         case 'T':
            argc--;
            argv++;
            strncpy(title,argv[0],MAXTITLE-1);
            break;
         case 'q':
         case 'Q':
            gQuiet = TRUE;
            break;
         case 'c':
         case 'C':
            ByChain = TRUE;
            break;
         case 'x':
         case 'X':
            SkipX = TRUE;
            break;
         case 'u':
         case 'U':
            gUpper = TRUE;
            break;
         case 's':
         case 'S':
            UseSEQRES = TRUE;
            break;
         case 'p':
         case 'P':
            gDoNucleic = FALSE;
            break;
         case 'f':
         case 'F':
            gFASTA = TRUE;
            ByChain = TRUE;
            break;
         case 'n':
         case 'N':
            DoNumbering = TRUE;
            break;
         default:
            pdb2pir_Usage();
            return(1);
         }
      }
      else                     /* Filenames                             */
      {
         switch(++filecount)
         {
         case 1:
            if((in = fopen(argv[0],"r"))==NULL)
            {
               fprintf(stderr,"Error: Unable to open input file: %s\n",
                       argv[0]);
               return(1);
            }
            break;
         case 2:
            if((out = fopen(argv[0],"w"))==NULL)
            {
               fprintf(stderr,"Error: Unable to open output file: %s\n",
                       argv[0]);
               return(1);
            }
            break;
         default:
            pdb2pir_Usage();
            return(1);
         }
      }
      argc--;
      argv++;
   }

   /* Read PDB file                                                     */
   if((wpdb = ReadWholePDBAtoms(in)) == NULL)
   {
      fprintf(stderr,"Error: Unable to read atoms from input file%s%s\n",
              ((gLabel[0])?" Label: ":""),
              ((gLabel[0])?gLabel:""));
      return(1);
   }
   pdb = wpdb->pdb;

   if(UseSEQRES)
   {
      /* Read MODRES and SEQRES records                                 */
      modres = ReadMODRES(wpdb);
      seqres = ReadSEQRES(wpdb, seqchains, modres);
   }

   /* Extract sequence from PDB linked list                             */
   GetPDBChains(pdb, atomchains);

   /* Convert PDB linked list to a sequence                             */
   if(SkipX)
   {
      if(gDoNucleic)
      {
         if((sequence = PDB2SeqXNoX(pdb))==NULL)
         {
            fprintf(stderr,"Error: No memory for sequence data\n");
            return(1);
         }
      }
      else
      {
         if((sequence = PDBProt2SeqXNoX(pdb))==NULL)
         {
            fprintf(stderr,"Error: No memory for sequence data\n");
            return(1);
         }
      }
   }
   else
   {
      if(gDoNucleic)
      {
         if((sequence = PDB2SeqX(pdb))==NULL)
         {
            fprintf(stderr,"Error: No memory for sequence data\n");
            return(1);
         }
      }
      else
      {
         if((sequence = PDBProt2SeqX(pdb))==NULL)
         {
            fprintf(stderr,"Error: No memory for sequence data\n");
            return(1);
         }
      }
   }
      
   /* Append a * since PDB2Seq() doesn't do this; note that this will
      have to change if we fix PDB2Seq() in future
   */
   len1 = strlen(sequence);
   if((sequence=(char *)realloc((void *)sequence,
                                (len1+1)*sizeof(char)))==NULL)
   {
      fprintf(stderr,"Error: No memory to expand sequence data\n");
      return(1);
   }
   strcat(sequence,"*");

   if(UseSEQRES)
   {
      /* Fiddle with sequences to combine information from SEQRES and ATOM
         records
      */
      if((fixedsequence = FixSequence(seqres,sequence,seqchains,
                                      atomchains,outchains))
         ==NULL)
         return(1);

      /* Write out the PIR file                                         */
      WritePIR(out,gLabel,title,fixedsequence,outchains,ByChain);
   }
   else
   {
      WritePIR(out,gLabel,title,sequence,atomchains,ByChain);
   }

   if(DoNumbering)
   {
      PrintNumbering(out, pdb, modres);
   }

   return(0);
}