//Bo Zhang //Homwork 12 //Optimization Function B #include "header.h" int main(void) { clock_t start, stop; start=clock(); CountSpecs CSpecs, ResultSpecs; InputSpecs ISpecs; Vector Vect; //declares Vect as a structure in the form of Vector int i; ISpecs.f=0; //initializes the specs to 0 ISpecs.Df=0; ISpecs.DDf=0; CSpecs.f=0; CSpecs.Df=0; CSpecs.DDf=0; //This program will loop as long as ReadVect keeps scanning new things from the data file. If ReadVect cannot find anything else to scan, a -1 will be put in Vect.n, and the loop will exit. scanf("%d",&(ISpecs.f)); scanf("%d",&(ISpecs.Df)); scanf("%d",&(ISpecs.DDf)); //Scans the Initial Specs Vect=ReadVect(); //this is the first initial ReadVect for(i=0;i<3;i++) { Function(Vect,ISpecs,CSpecs); //calls the function to evalue the Function. The measure is set of 0 for the function to run and to 1 to return how many times the function has been evaluated. DestroyVect(Vect); //frees the vector from memory scanf("%d",&(ISpecs.f)); scanf("%d",&(ISpecs.Df)); scanf("%d",&(ISpecs.DDf)); Vect=ReadVect(); //scans the next vector } CSpecs.f=1; //initilizes the values for CSpec to return the count for all 3 CSpecs.Df=1; CSpecs.DDf=1; ResultSpecs=Function(Vect,ISpecs,CSpecs); //stores the counts in ResultSpecs printf("f has run %d times\t",ResultSpecs.f); printf("Df has run %d times\t",ResultSpecs.Df); printf("DDf has run %d times\t",ResultSpecs.DDf); //prints out the counts stop=clock(); printf("\nElapsed time = %g milliseconds\n", MILLISEC_PER_SEC*(stop-start)/((float) CLOCKS_PER_SEC)); return 0; }