Changeset 1525


Ignore:
Timestamp:
Jan 1, 2010 9:30:24 AM (10 years ago)
Author:
pbonami
Message:

Fix of_current

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/1.1/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r1524 r1525  
    808808  warmstart_ = NULL;
    809809 
    810   double * of_current = new double[numsolve];
     810  double * of_current = (numsolve > 0) ? new double[numsolve]: NULL;
    811811  int num_failed, num_infeas;
    812812  double mean, std_dev, var_coeff;
     
    892892      <<CoinMessageEol;
    893893
    894 
    895   if(isProvenOptimal())
    896   {
    897     of_current[f] = getObjValue();
    898     mean=mean+of_current[f];
    899     if (of_current[f] < min)
    900        min = of_current[f];
    901     else if (of_current[f] > max)
    902        max = of_current[f];
    903   }
    904   else
    905   {
    906     of_current[f] = 0;
    907   }
    908 
    909 }
    910 
    911 
    912 //calculate the mean
    913 mean=mean/(numsolve-num_failed-num_infeas);
    914 
    915 std_dev = 0;
    916 
    917 //calculate the std deviation
    918 for(int i=0; i<numsolve; i++)
    919 {
    920   if(of_current[i]!=0)
    921     std_dev=std_dev+pow(of_current[i]-mean,2);
    922 }
    923 std_dev=pow((std_dev/(numsolve-num_failed-num_infeas)),0.5);
    924 
    925 //calculate coeff of variation
    926 var_coeff=std_dev/mean;
    927 
     894  if(of_current != NULL){
     895    if(isProvenOptimal())
     896    {
     897      of_current[f] = getObjValue();
     898      mean=mean+of_current[f];
     899      if (of_current[f] < min)
     900         min = of_current[f];
     901      else if (of_current[f] > max)
     902         max = of_current[f];
     903    }
     904    else
     905    {
     906      of_current[f] = 0;
     907    }
     908  }
     909}
     910
     911
     912  if(of_current != NULL){
     913     //calculate the mean
     914     mean=mean/(numsolve-num_failed-num_infeas);
     915     
     916     std_dev = 0;
     917     
     918     //calculate the std deviation
     919     for(int i=0; i<numsolve; i++)
     920     {
     921       if(of_current[i]!=0)
     922         std_dev=std_dev+pow(of_current[i]-mean,2);
     923     }
     924     std_dev=pow((std_dev/(numsolve-num_failed-num_infeas)),0.5);
     925     
     926     //calculate coeff of variation
     927     var_coeff=std_dev/mean;
     928  }
    928929
    929930
Note: See TracChangeset for help on using the changeset viewer.