(file) Return to acm2.cpp CVS log (file) (dir) Up to [RizwankCVS] / acm

Diff for /acm/acm2.cpp between version 1.6 and 1.7

version 1.6, 2005/02/16 07:49:34 version 1.7, 2005/02/16 08:15:50
Line 175 
Line 175 
         }         }
         else {         else {
                 temp = (float)((this->myBackpack->get_maxWeight()) - cur_weight);                 temp = (float)((this->myBackpack->get_maxWeight()) - cur_weight);
                 temp = temp * (this->myBackpack->get_Item(this->nextitem)).getRatio();  //              temp = temp * (this->myBackpack->get_Item(this->nextitem)).getRatio(); (ratio = 1!)
         }         }
         this->upper_bound = cur_value + temp;         this->upper_bound = cur_value + temp;
  
Line 249 
Line 249 
 void item::setData(unsigned short weightage, unsigned short costage, unsigned short numerage){ void item::setData(unsigned short weightage, unsigned short costage, unsigned short numerage){
         this->cost = costage;         this->cost = costage;
         this->weight = weightage;         this->weight = weightage;
         this->ratio = ( (float)(cost)/(float)(weight) );  //      this->ratio = ( (float)(cost)/(float)(weight) );
           this->ratio = 1; //ratio = 1
         this->number = numerage;         this->number = numerage;
 } }
  
Line 7476 
Line 7477 
 user    0m0.062s user    0m0.062s
 sys     0m0.000s sys     0m0.000s
  
   
 Now, lets really ramp it up so that we can see optimzation effects Now, lets really ramp it up so that we can see optimzation effects
 n=2500! won't even care to list the numbers, no point! n=2500! won't even care to list the numbers, no point!
  
Line 7494 
Line 7496 
  
 Given that this is about the largest we can hope to achieve before INTMAX because a massive issue (we should really typedefine the container class), lets see what optimizations we can make to this code! Given that this is about the largest we can hope to achieve before INTMAX because a massive issue (we should really typedefine the container class), lets see what optimizations we can make to this code!
  
   must do 1 -
   move all the unsigned shorts to (other)
   the unsigned shorts are now ITEM_TYPE, a def earlier on (we could have done typedef here too, of course)
   real    0m2.928s
   user    0m1.999s
   sys     0m0.061s
   Slight increase.
   
   Bad things happen when we try to make it into floats, I just tired. floats can't be [] contents for an array ;p
   Doing unsigned long for now.
   goal 1 = stop ratio calculation and comparisons if at all possible!
   real time shot up!
   real    0m3.994s
   user    0m2.390s
   sys     0m0.046s
   
   
   goal 1 - lets remove the double call to the creator function, weight=value ratio=1
  
  
                 */                 */


Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Rizwan Kassim
Powered by
ViewCVS 0.9.2