Changeset 712


Ignore:
Timestamp:
Jan 30, 2006 5:06:14 PM (14 years ago)
Author:
forrest
Message:

for AMPL

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpLinearObjective.cpp

    r399 r712  
    3333  type_=1;
    3434  numberColumns_=numberColumns;
    35   if (objective) {
    36     objective_ = new double [numberColumns_];
    37     memcpy(objective_,objective,numberColumns_*sizeof(double));
    38   } else {
    39     objective_ = new double [numberColumns_];
    40     memset(objective_,0,numberColumns_*sizeof(double));
    41   }
     35  objective_ = CoinCopyOfArray(objective,numberColumns_,0.0);
    4236}
    4337
     
    4943
    5044  numberColumns_=rhs.numberColumns_;
    51   if (rhs.objective_) {
    52     objective_ = new double [numberColumns_];
    53     memcpy(objective_,rhs.objective_,numberColumns_*sizeof(double));
    54   } else {
    55     objective_=NULL;
    56   }
     45  objective_ = CoinCopyOfArray(rhs.objective_,numberColumns_);
    5746}
    5847/* Subset constructor.  Duplicates are allowed
     
    10190    ClpObjective::operator=(rhs);
    10291    numberColumns_=rhs.numberColumns_;
    103     if (rhs.objective_) {
    104       objective_ = new double [numberColumns_];
    105       memcpy(objective_,rhs.objective_,numberColumns_*sizeof(double));
    106     } else {
    107       objective_=NULL;
    108     }
     92    delete [] objective_;
     93    objective_ = CoinCopyOfArray(rhs.objective_,numberColumns_);
    10994  }
    11095  return *this;
     
    238223    double * newArray = new double[newNumberColumns];
    239224    if (objective_)
    240       memcpy(newArray,objective_,
    241              CoinMin(newNumberColumns,numberColumns_)*sizeof(double));
     225      CoinMemcpyN(objective_,CoinMin(newNumberColumns,numberColumns_),newArray);
    242226    delete [] objective_;
    243227    objective_ = newArray;
     
    256240    char * deleted = new char[numberColumns_];
    257241    int numberDeleted=0;
    258     memset(deleted,0,numberColumns_*sizeof(char));
     242    CoinZeroN(deleted,numberColumns_);
    259243    for (i=0;i<numberToDelete;i++) {
    260244      int j = which[i];
  • trunk/ClpPrimalColumnSteepest.cpp

    r618 r712  
    7171      ClpDisjointCopyN(rhs.savedWeights_,number,savedWeights_);
    7272      if (mode_!=1) {
    73         reference_ = new unsigned int[(number+31)>>5];
    74         memcpy(reference_,rhs.reference_,((number+31)>>5)*sizeof(unsigned int));
     73        reference_ = CoinCopyOfArray(rhs.reference_,(number+31)>>5);
    7574      }
    7675    } else {
     
    142141      ClpDisjointCopyN(rhs.savedWeights_,number,savedWeights_);
    143142      if (mode_!=1) {
    144         reference_ = new unsigned int[(number+31)>>5];
    145         memcpy(reference_,rhs.reference_,
    146                ((number+31)>>5)*sizeof(unsigned int));
     143        reference_ = CoinCopyOfArray(rhs.reference_,(number+31)>>5);
    147144      }
    148145    } else {
     
    28002797        if (pivotSequence_>=0) {
    28012798          // save pivot order
    2802           memcpy(alternateWeights_->getIndices(),pivotVariable,
    2803                  numberRows*sizeof(int));
     2799          CoinMemcpyN(pivotVariable,
     2800                 numberRows,alternateWeights_->getIndices());
    28042801          // change from pivot row number to sequence number
    28052802          pivotSequence_=pivotVariable[pivotSequence_];
     
    28402837        // create saved weights
    28412838        delete [] savedWeights_;
    2842         savedWeights_ = new double[numberRows+numberColumns];
    2843         memcpy(savedWeights_,weights_,(numberRows+numberColumns)*
    2844                sizeof(double));
     2839        savedWeights_ = CoinCopyOfArray(weights_,numberRows+numberColumns);
    28452840      } else {
    28462841        // Partial pricing
     
    28702865      if (mode!=4) {
    28712866        // save
    2872         memcpy(savedWeights_,weights_,(numberRows+numberColumns)*
    2873                sizeof(double));
     2867        CoinMemcpyN(weights_,(numberRows+numberColumns),savedWeights_);
    28742868        savedPivotSequence_= pivotSequence_;
    28752869        savedSequenceOut_ = model_->sequenceOut();
    28762870      } else {
    28772871        // restore
    2878         memcpy(weights_,savedWeights_,(numberRows+numberColumns)*
    2879                sizeof(double));
     2872        CoinMemcpyN(savedWeights_,(numberRows+numberColumns),weights_);
    28802873        // was - but I think should not be
    28812874        //pivotSequence_= savedPivotSequence_;
     
    30923085        devex_+=ADD_ONE;
    30933086        weights_[sequenceOut]=1.0+ADD_ONE;
    3094         memcpy(newWhich,which,number*sizeof(int));
     3087        CoinMemcpyN(which,number,newWhich);
    30953088        alternateWeights_->setNumElements(number);
    30963089      } else {
     
    31583151        devex_+=ADD_ONE;
    31593152        weights_[sequenceOut]=1.0+ADD_ONE;
    3160         memcpy(newWhich,which,number*sizeof(int));
     3153        CoinMemcpyN(which,number,newWhich);
    31613154        alternateWeights_->setNumElements(number);
    31623155      } else {
     
    33113304      int nWords = (number+31)>>5;
    33123305      reference_ = new unsigned int[nWords];
    3313       // tiny overhead to zero out (stops valgrind complaining)
    3314       memset(reference_,0,nWords*sizeof(int));
     3306      CoinZeroN(reference_,nWords);
    33153307    }
    33163308   
  • trunk/ClpSimplex.cpp

    r702 r712  
    85608560    objectiveValue_ += value*obj[iSequence];
    85618561  }
     8562  // But remember direction
     8563  objectiveValue_ *= optimizationDirection_;
    85628564  //if (fabs(objectiveValue_-oldObj)>1.0e-1) {
    85638565  //if(problemStatus_!=3) printf("XX ");;
  • trunk/ClpSimplexDual.cpp

    r710 r712  
    235235        }
    236236      } else {
    237         memcpy(dual_,saveDuals,numberRows_*sizeof(double));
     237        CoinMemcpyN(saveDuals,numberRows_,dual_);
    238238      }
    239239      // now create my duals
     
    244244        saveDuals[i+numberColumns_]=value;
    245245      }
    246       ClpDisjointCopyN(objectiveWork_,numberColumns_,saveDuals);
     246      CoinMemcpyN(objectiveWork_,numberColumns_,saveDuals);
    247247      transposeTimes(-1.0,dual_,saveDuals);
    248248      // make reduced costs okay
     
    262262        }
    263263      }
    264       memcpy(dj_,saveDuals,(numberColumns_+numberRows_)*sizeof(double));
     264      CoinMemcpyN(saveDuals,(numberColumns_+numberRows_),dj_);
    265265      // set up possible ones
    266266      for (i=0;i<numberRows_+numberColumns_;i++)
     
    443443  if (ifValuesPass) {
    444444    saveDuals = new double [numberRows_+numberColumns_];
    445     memcpy(saveDuals,dual_,numberRows_*sizeof(double));
     445    CoinMemcpyN(dual_,numberRows_,saveDuals);
    446446  }
    447447  int returnCode = startupSolve(ifValuesPass,saveDuals,startFinishOptions);
     
    475475  if (ifValuesPass) {
    476476    saveDuals = new double [numberRows_+numberColumns_];
    477     memcpy(saveDuals,dual_,numberRows_*sizeof(double));
     477    CoinMemcpyN(dual_,numberRows_,saveDuals);
    478478  }
    479479  // sanity check
     
    497497        }
    498498      } else {
    499         memcpy(dual_,saveDuals,numberRows_*sizeof(double));
     499        CoinMemcpyN(saveDuals,numberRows_,dual_);
    500500      }
    501501      // now create my duals
     
    506506        saveDuals[i+numberColumns_]=value;
    507507      }
    508       ClpDisjointCopyN(objectiveWork_,numberColumns_,saveDuals);
     508      CoinMemcpyN(objectiveWork_,numberColumns_,saveDuals);
    509509      transposeTimes(-1.0,dual_,saveDuals);
    510510      // make reduced costs okay
     
    524524        }
    525525      }
    526       memcpy(dj_,saveDuals,(numberColumns_+numberRows_)*sizeof(double));
     526      CoinMemcpyN(saveDuals,numberColumns_+numberRows_,dj_);
    527527      // set up possible ones
    528528      for (i=0;i<numberRows_+numberColumns_;i++)
     
    706706ClpSimplexDual::whileIterating(double * & givenDuals,int ifValuesPass)
    707707{
     708#if 0
     709  if (!numberIterations_&&auxiliaryModel_) {
     710    for (int i=0;i<numberColumns_;i++) {
     711      if (!columnLower_[i]==auxiliaryModel_->lowerRegion()[i+numberRows_+numberColumns_])
     712        {printf("%d a\n",i);break;}
     713      if (!columnUpper_[i]==auxiliaryModel_->upperRegion()[i+numberRows_+numberColumns_])
     714        {printf("%d b %g\n",i,auxiliaryModel_->upperRegion()[i+numberRows_+numberColumns_]);break;}
     715    }
     716    for (int i=0 ;i<numberRows_;i++) {
     717      if (!rowLower_[i]==auxiliaryModel_->lowerRegion()[i+numberRows_+2*numberColumns_])
     718        {printf("%d c\n",i);break;}
     719      if (!rowUpper_[i]==auxiliaryModel_->upperRegion()[i+numberRows_+2*numberColumns_])
     720        {printf("%d d\n",i);break;}
     721    }
     722  }
     723#endif
    708724#ifdef CLP_DEBUG
    709725  int debugIteration=-1;
     
    752768    candidateList = new int[numberRows_];
    753769    // move reduced costs across
    754     memcpy(dj_,givenDuals,(numberRows_+numberColumns_)*sizeof(double));
     770    CoinMemcpyN(givenDuals,numberRows_+numberColumns_,dj_);
    755771    int iRow;
    756772    for (iRow=0;iRow<numberRows_;iRow++) {
     
    809825#endif
    810826  while (problemStatus_==-1) {
    811 
    812827#ifdef CLP_DEBUG
    813828    if (givenDuals) {
     
    11671182        else
    11681183          updateDualsInValuesPass(rowArray_[0],columnArray_[0],theta_);
    1169 
     1184        double oldDualOut = dualOut_;
    11701185        // which will change basic solution
    11711186        if (nswapped) {
     
    12051220        // amount primal will move
    12061221        double movement = -dualOut_*directionOut_/alpha_;
     1222        double movementOld = oldDualOut*directionOut_/alpha_;
    12071223        // so objective should increase by fabs(dj)*movement
    12081224        // but we already have objective change - so check will be good
    1209         if (objectiveChange+fabs(movement*dualIn_)<-1.0e-5) {
     1225        if (objectiveChange+fabs(movementOld*dualIn_)<-CoinMax(1.0e-5,1.0e-12*fabs(objectiveValue_))) {
    12101226#ifdef CLP_DEBUG
    12111227          if (handler_->logLevel()&32)
     
    14231439            ray_ = new double [ numberRows_];
    14241440            rowArray_[0]->expand(); // in case packed
    1425             ClpDisjointCopyN(rowArray_[0]->denseVector(),numberRows_,ray_);
     1441            CoinMemcpyN(rowArray_[0]->denseVector(),numberRows_,ray_);
    14261442          }
    14271443          // If we have just factorized and infeasibility reasonable say infeas
     
    16411657  }
    16421658  if (givenDuals) {
    1643     memcpy(givenDuals,dj_,(numberRows_+numberColumns_)*sizeof(double));
     1659    CoinMemcpyN(dj_,numberRows_+numberColumns_,givenDuals);
    16441660    // get rid of any values pass array
    16451661    delete [] candidateList;
     
    29292945        } else {
    29302946          // keep old swapped
    2931           memcpy(array[1-iFlip]+swapped[iFlip],
    2932                  array[iFlip]+swapped[iFlip],
    2933                  (numberColumns_-swapped[iFlip])*sizeof(double));
    2934           memcpy(indices[1-iFlip]+swapped[iFlip],
    2935                  indices[iFlip]+swapped[iFlip],
    2936                  (numberColumns_-swapped[iFlip])*sizeof(int));
     2947          CoinMemcpyN(array[iFlip]+swapped[iFlip],
     2948                 numberColumns_-swapped[iFlip],array[1-iFlip]+swapped[iFlip]);
     2949          CoinMemcpyN(indices[iFlip]+swapped[iFlip],
     2950                 numberColumns_-swapped[iFlip],indices[1-iFlip]+swapped[iFlip]);
    29372951          marker[1-iFlip][1] = CoinMin(marker[1-iFlip][1],swapped[iFlip]);
    29382952          swapped[1-iFlip]=swapped[iFlip];
     
    30823096    double modification = theta_*alpha_-dualIn_;
    30833097    if ((specialOptions_&(2048+4096))!=0) {
    3084       if ((specialOptions_&2048)!=0) {
     3098      if ((specialOptions_&16384)!=0) {
     3099        // in fast dual
     3100        if (fabs(modification)<1.0e-7)
     3101          modification=0.0;
     3102      } else if ((specialOptions_&2048)!=0) {
    30853103        if (fabs(modification)<1.0e-10)
    30863104          modification=0.0;
     
    31213139
    31223140  for (i=0;i<2;i++) {
    3123     memset(array[i],0,marker[i][0]*sizeof(double));
    3124     memset(array[i]+marker[i][1],0,
    3125            (numberColumns_-marker[i][1])*sizeof(double));
     3141    CoinZeroN(array[i],marker[i][0]);
     3142    CoinZeroN(array[i]+marker[i][1],numberColumns_-marker[i][1]);
    31263143  }
    31273144  return bestPossible;
     
    31803197    delete [] ray_;
    31813198    ray_ = new double [numberColumns_];
    3182     ClpFillN(ray_,numberColumns_,0.0);
     3199    CoinZeroN(ray_,numberColumns_);
    31833200    for (i=0;i<number;i++) {
    31843201      int iRow=index[i];
     
    32033220  if (type==2) {
    32043221    // trouble - restore solution
    3205     memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3206     memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3207            numberRows_*sizeof(double));
    3208     memcpy(columnActivityWork_,savedSolution_ ,
    3209            numberColumns_*sizeof(double));
     3222    CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3223    CoinMemcpyN(savedSolution_+numberColumns_ ,
     3224           numberRows_,rowActivityWork_);
     3225    CoinMemcpyN(savedSolution_ ,
     3226           numberColumns_,columnActivityWork_);
    32103227    // restore extra stuff
    32113228    int dummy;
     
    32363253            saveStatus_[i] |= 64; //say flagged
    32373254        }
    3238         memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3239         memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3240                numberRows_*sizeof(double));
    3241         memcpy(columnActivityWork_,savedSolution_ ,
    3242                numberColumns_*sizeof(double));
     3255        CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3256        CoinMemcpyN(savedSolution_+numberColumns_ ,
     3257               numberRows_,rowActivityWork_);
     3258        CoinMemcpyN(savedSolution_ ,
     3259               numberColumns_,columnActivityWork_);
    32433260        // restore extra stuff
    32443261        int dummy;
     
    32643281        //assert (internalFactorize(1)==0);
    32653282        if (internalFactorize(1)) {
    3266           memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3267           memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3268                  numberRows_*sizeof(double));
    3269           memcpy(columnActivityWork_,savedSolution_ ,
    3270                  numberColumns_*sizeof(double));
     3283          CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3284          CoinMemcpyN(savedSolution_+numberColumns_ ,
     3285                 numberRows_,rowActivityWork_);
     3286          CoinMemcpyN(savedSolution_ ,
     3287                 numberColumns_,columnActivityWork_);
    32713288          // restore extra stuff
    32723289          int dummy;
     
    33063323        saveStatus_[i] |= 64; //say flagged
    33073324    }
    3308     //memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3309     for (int j=0;j<numberRows_+numberColumns_;j++) {
    3310       status_[j]=saveStatus_[j];
    3311     }
    3312     memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3313            numberRows_*sizeof(double));
    3314     memcpy(columnActivityWork_,savedSolution_ ,
    3315            numberColumns_*sizeof(double));
     3325    CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3326    CoinMemcpyN(savedSolution_+numberColumns_ ,
     3327           numberRows_,rowActivityWork_);
     3328    CoinMemcpyN(savedSolution_ ,
     3329           numberColumns_,columnActivityWork_);
    33163330    // restore extra stuff
    33173331    int dummy;
     
    33383352    //assert (internalFactorize(1)==0);
    33393353    if (internalFactorize(1)) {
    3340       memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3341       memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3342              numberRows_*sizeof(double));
    3343       memcpy(columnActivityWork_,savedSolution_ ,
    3344              numberColumns_*sizeof(double));
     3354      CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3355      CoinMemcpyN(savedSolution_+numberColumns_ ,
     3356              numberRows_,rowActivityWork_);
     3357      CoinMemcpyN(savedSolution_ ,
     3358           numberColumns_,columnActivityWork_);
    33453359      // restore extra stuff
    33463360      int dummy;
     
    33903404        unflagVariables = false;
    33913405        changeMade_++; // say something changed
    3392         memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3393         memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3394                numberRows_*sizeof(double));
    3395         memcpy(columnActivityWork_,savedSolution_ ,
    3396                numberColumns_*sizeof(double));
     3406        CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3407        CoinMemcpyN(savedSolution_+numberColumns_ ,
     3408                numberRows_,rowActivityWork_);
     3409        CoinMemcpyN(savedSolution_ ,
     3410                numberColumns_,columnActivityWork_);
    33973411        // restore extra stuff
    33983412        int dummy;
     
    34073421          factorization_->pivotTolerance(0.2);
    34083422        if (internalFactorize(1)) {
    3409           memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    3410           memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    3411                  numberRows_*sizeof(double));
    3412           memcpy(columnActivityWork_,savedSolution_ ,
    3413                  numberColumns_*sizeof(double));
     3423          CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     3424          CoinMemcpyN(savedSolution_+numberColumns_ ,
     3425                  numberRows_,rowActivityWork_);
     3426          CoinMemcpyN(savedSolution_ ,
     3427                  numberColumns_,columnActivityWork_);
    34143428          // restore extra stuff
    34153429          int dummy;
     
    35413555          <<CoinMessageEol;
    35423556        // save solution in case unbounded
    3543         ClpDisjointCopyN(columnActivityWork_,numberColumns_,
     3557        CoinMemcpyN(columnActivityWork_,numberColumns_,
    35443558                          columnArray_[0]->denseVector());
    3545         ClpDisjointCopyN(rowActivityWork_,numberRows_,
     3559        CoinMemcpyN(rowActivityWork_,numberRows_,
    35463560                          rowArray_[2]->denseVector());
    35473561        numberChangedBounds=changeBounds(false,rowArray_[3],changeCost);
     
    35513565            perturbation_=102; // stop any perturbations
    35523566            cleanDuals=1;
    3553             createRim(4);
    35543567            // make sure fake bounds are back
    35553568            changeBounds(true,NULL,changeCost);
    3556             numberChanged_=1; // force something to happen
     3569            createRim(4);
     3570            // make sure duals are current
     3571            //computeDuals(givenDuals);
     3572            //checkDualSolution();
     3573            //if (numberDualInfeasibilities_)
     3574              numberChanged_=1; // force something to happen
     3575              //else
     3576              computeObjectiveValue();
    35573577          }
    35583578          if (lastCleaned<numberIterations_&&numberTimesOptimal_<4&&
     
    36403660                columnActivityWork_[iColumn] = original[iColumn];
    36413661              }
    3642               ClpDisjointCopyN(rowArray_[2]->denseVector(),numberRows_,
     3662              CoinMemcpyN(rowArray_[2]->denseVector(),numberRows_,
    36433663                                rowActivityWork_);
    36443664            }
     
    36483668          }
    36493669        }
    3650         ClpFillN(columnArray_[0]->denseVector(),numberColumns_,0.0);
    3651         ClpFillN(rowArray_[2]->denseVector(),numberRows_,0.0);
     3670        CoinZeroN(columnArray_[0]->denseVector(),numberColumns_);
     3671        CoinZeroN(rowArray_[2]->denseVector(),numberRows_);
    36523672      }
    36533673      if (problemStatus_==-4||problemStatus_==-5) {
     
    38553875    }
    38563876    // save arrays
    3857     memcpy(saveStatus_,status_,(numberColumns_+numberRows_)*sizeof(char));
    3858     memcpy(savedSolution_+numberColumns_ ,rowActivityWork_,
    3859            numberRows_*sizeof(double));
    3860     memcpy(savedSolution_ ,columnActivityWork_,numberColumns_*sizeof(double));
     3877    CoinMemcpyN(status_,numberColumns_+numberRows_,saveStatus_);
     3878    CoinMemcpyN(rowActivityWork_,
     3879           numberRows_,savedSolution_+numberColumns_);
     3880    CoinMemcpyN(columnActivityWork_,numberColumns_,savedSolution_);
    38613881    // save extra stuff
    38623882    int dummy;
     
    39143934  if ((specialOptions_&1024)!=0) {
    39153935    int looksBad=0;
    3916     if (numberIterations_>10000&&largestPrimalError_*largestDualError_>1.0e2) {
     3936    if (largestPrimalError_*largestDualError_>1.0e2) {
    39173937      looksBad=1;
    3918     } else if (numberIterations_>10000&&largestPrimalError_>1.0e-2
    3919         &&objectiveValue_>CoinMin(1.0e15,limit)) {
     3938    } else if (largestPrimalError_>1.0e-2
     3939        &&objectiveValue_>CoinMin(1.0e15,1.0e3*limit)) {
    39203940      looksBad=2;
    39213941    }
     
    39243944        // up tolerance
    39253945        factorization_->pivotTolerance(CoinMin(factorization_->pivotTolerance()*1.05+0.02,0.91));
    3926       } else {
     3946      } else if (numberIterations_>10000) {
    39273947        if (handler_->logLevel()>0)
    39283948          printf("bad dual - saying infeasible %d\n",looksBad);
    39293949        problemStatus_=1;
    39303950        secondaryStatus_ = 1; // and say was on cutoff
     3951      } else if (largestPrimalError_>1.0e5) {
     3952        allSlackBasis();
     3953        problemStatus_=10;
     3954        //if (handler_->logLevel()>0)
     3955          printf("bad dual - going to primal %d %g\n",looksBad,largestPrimalError_);
    39313956      }
    39323957    }
     
    44324457  // and zero changes
    44334458  //int nTotal = numberRows_+numberColumns_;
    4434   //memset(cost_+nTotal,0,nTotal*sizeof(double));
     4459  //CoinZeroN(cost_+nTotal,nTotal);
    44354460  // say perturbed
    44364461  perturbation_=101;
     
    45014526  // save basis and solution
    45024527  double * saveSolution = new double[numberRows_+numberColumns_];
    4503   memcpy(saveSolution,solution_,
    4504          (numberRows_+numberColumns_)*sizeof(double));
     4528  CoinMemcpyN(solution_,
     4529         numberRows_+numberColumns_,saveSolution);
    45054530  unsigned char * saveStatus =
    45064531    new unsigned char [numberRows_+numberColumns_];
    4507   memcpy(saveStatus,status_,(numberColumns_+numberRows_)*sizeof(char));
     4532  CoinMemcpyN(status_,numberColumns_+numberRows_,saveStatus);
    45084533  // save bounds as createRim makes clean copies
    45094534  double * saveLower = new double[numberRows_+numberColumns_];
    4510   memcpy(saveLower,lower_,
    4511          (numberRows_+numberColumns_)*sizeof(double));
     4535  CoinMemcpyN(lower_,
     4536         numberRows_+numberColumns_,saveLower);
    45124537  double * saveUpper = new double[numberRows_+numberColumns_];
    4513   memcpy(saveUpper,upper_,
    4514          (numberRows_+numberColumns_)*sizeof(double));
     4538  CoinMemcpyN(upper_,
     4539         numberRows_+numberColumns_,saveUpper);
    45154540  double * saveObjective = new double[numberRows_+numberColumns_];
    4516   memcpy(saveObjective,cost_,
    4517          (numberRows_+numberColumns_)*sizeof(double));
     4541  CoinMemcpyN(cost_,
     4542         numberRows_+numberColumns_,saveObjective);
    45184543  int * savePivot = new int [numberRows_];
    4519   memcpy(savePivot, pivotVariable_, numberRows_*sizeof(int));
     4544  CoinMemcpyN(pivotVariable_, numberRows_,savePivot);
    45204545  // need to save/restore weights.
    45214546
     
    45604585
    45614586    if (scalingFlag_<=0) {
    4562       memcpy(outputSolution[iSolution],solution_,numberColumns_*sizeof(double));
     4587      CoinMemcpyN(solution_,numberColumns_,outputSolution[iSolution]);
    45634588    } else {
    45644589      int j;
     
    45714596    iSolution++;
    45724597    // restore
    4573     memcpy(solution_,saveSolution,
    4574            (numberRows_+numberColumns_)*sizeof(double));
    4575     memcpy(status_,saveStatus,(numberColumns_+numberRows_)*sizeof(char));
    4576     memcpy(lower_,saveLower,
    4577            (numberRows_+numberColumns_)*sizeof(double));
    4578     memcpy(upper_,saveUpper,
    4579            (numberRows_+numberColumns_)*sizeof(double));
    4580     memcpy(cost_,saveObjective,
    4581          (numberRows_+numberColumns_)*sizeof(double));
     4598    CoinMemcpyN(saveSolution,
     4599            numberRows_+numberColumns_,solution_);
     4600    CoinMemcpyN(saveStatus,numberColumns_+numberRows_,status_);
     4601    CoinMemcpyN(saveLower,
     4602            numberRows_+numberColumns_,lower_);
     4603    CoinMemcpyN(saveUpper,
     4604            numberRows_+numberColumns_,upper_);
     4605    CoinMemcpyN(saveObjective,
     4606            numberRows_+numberColumns_,cost_);
    45824607    columnUpper_[iColumn] = saveBound;
    4583     memcpy(pivotVariable_, savePivot, numberRows_*sizeof(int));
     4608    CoinMemcpyN(savePivot, numberRows_,pivotVariable_);
    45844609    delete factorization_;
    45854610    factorization_ = new ClpFactorization(saveFactorization);
     
    46224647      status=2;
    46234648    if (scalingFlag_<=0) {
    4624       memcpy(outputSolution[iSolution],solution_,numberColumns_*sizeof(double));
     4649      CoinMemcpyN(solution_,numberColumns_,outputSolution[iSolution]);
    46254650    } else {
    46264651      int j;
     
    46344659
    46354660    // restore
    4636     memcpy(solution_,saveSolution,
    4637            (numberRows_+numberColumns_)*sizeof(double));
    4638     memcpy(status_,saveStatus,(numberColumns_+numberRows_)*sizeof(char));
    4639     memcpy(lower_,saveLower,
    4640            (numberRows_+numberColumns_)*sizeof(double));
    4641     memcpy(upper_,saveUpper,
    4642            (numberRows_+numberColumns_)*sizeof(double));
    4643     memcpy(cost_,saveObjective,
    4644          (numberRows_+numberColumns_)*sizeof(double));
     4661    CoinMemcpyN(saveSolution,
     4662            numberRows_+numberColumns_,solution_);
     4663    CoinMemcpyN(saveStatus,numberColumns_+numberRows_,status_);
     4664    CoinMemcpyN(saveLower,
     4665            numberRows_+numberColumns_,lower_);
     4666    CoinMemcpyN(saveUpper,
     4667            numberRows_+numberColumns_,upper_);
     4668    CoinMemcpyN(saveObjective,
     4669            numberRows_+numberColumns_,cost_);
    46454670    columnLower_[iColumn] = saveBound;
    4646     memcpy(pivotVariable_, savePivot, numberRows_*sizeof(int));
     4671    CoinMemcpyN(savePivot, numberRows_,pivotVariable_);
    46474672    delete factorization_;
    46484673    factorization_ = new ClpFactorization(saveFactorization);
     
    48254850  // create modifiable copies of model rim and do optional scaling
    48264851  int startFinishOptions;
    4827   if((specialOptions_&4096)==0||auxiliaryModel_) {
     4852  /*  COIN_CLP_VETTED
     4853      Looks safe for Cbc
     4854  */
     4855  bool safeOption = ((specialOptions_&COIN_CBC_USING_CLP)!=0);
     4856  if((specialOptions_&4096)==0||(auxiliaryModel_&&!safeOption)) {
    48284857    startFinishOptions=0;
    48294858  } else {
     
    48784907  // save stuff
    48794908  // save basis and solution
    4880   memcpy(saveSolution,solution_,
    4881          (numberRows_+numberColumns_)*sizeof(double));
    4882   memcpy(saveStatus,status_,(numberColumns_+numberRows_)*sizeof(char));
    4883   memcpy(saveLower,lower_,
    4884          (numberRows_+numberColumns_)*sizeof(double));
    4885   memcpy(saveUpper,upper_,
    4886          (numberRows_+numberColumns_)*sizeof(double));
    4887   memcpy(saveObjective,cost_,
    4888          (numberRows_+numberColumns_)*sizeof(double));
    4889   memcpy(savePivot, pivotVariable_, numberRows_*sizeof(int));
     4909  CoinMemcpyN(solution_,
     4910          numberRows_+numberColumns_,saveSolution);
     4911  CoinMemcpyN(status_,numberColumns_+numberRows_,saveStatus);
     4912  CoinMemcpyN(lower_,
     4913          numberRows_+numberColumns_,saveLower);
     4914  CoinMemcpyN(upper_,
     4915          numberRows_+numberColumns_,saveUpper);
     4916  CoinMemcpyN(cost_,
     4917          numberRows_+numberColumns_,saveObjective);
     4918  CoinMemcpyN(pivotVariable_, numberRows_,savePivot);
    48904919  return new ClpFactorization(*factorization_);
    48914920}
     
    48954924{
    48964925  int startFinishOptions;
    4897   if((specialOptions_&4096)==0||auxiliaryModel_) {
     4926  /*  COIN_CLP_VETTED
     4927      Looks safe for Cbc
     4928  */
     4929  bool safeOption = ((specialOptions_&COIN_CBC_USING_CLP)!=0);
     4930  if((specialOptions_&4096)==0||(auxiliaryModel_&&!safeOption)) {
    48984931    startFinishOptions=0;
    48994932  } else {
  • trunk/ClpSimplexOther.cpp

    r705 r712  
    10141014        int iRow = row[j];
    10151015        int n=whichRow[iRow];
    1016         if (n==0)
     1016        if (n==0&&element[j])
    10171017          whichRow[iRow]=-iColumn-1;
    1018         else if (n<0)
     1018        else if (n<0) 
    10191019          whichRow[iRow]=2;
    10201020      }
  • trunk/ClpSimplexPrimal.cpp

    r688 r712  
    642642  if (type==2) {
    643643    // trouble - restore solution
    644     memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
    645     memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    646            numberRows_*sizeof(double));
    647     memcpy(columnActivityWork_,savedSolution_ ,
    648            numberColumns_*sizeof(double));
     644    CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
     645    CoinMemcpyN(savedSolution_+numberColumns_ ,
     646           numberRows_,rowActivityWork_);
     647    CoinMemcpyN(savedSolution_ ,
     648           numberColumns_,columnActivityWork_);
    649649    // restore extra stuff
    650650    matrix_->generalExpanded(this,6,dummy);
     
    699699                saveStatus_[i] |= 64; //say flagged
    700700            }
    701             memcpy(status_ ,saveStatus_,(numberColumns_+numberRows_)*sizeof(char));
     701            CoinMemcpyN(saveStatus_,numberColumns_+numberRows_,status_);
    702702            if (numberPivots<=1) {
    703703              // throw out something
     
    713713              factorization_->pivotTolerance(0.99);
    714714            }
    715             memcpy(rowActivityWork_,savedSolution_+numberColumns_ ,
    716                    numberRows_*sizeof(double));
    717             memcpy(columnActivityWork_,savedSolution_ ,
    718                    numberColumns_*sizeof(double));
     715            CoinMemcpyN(savedSolution_+numberColumns_ ,
     716                   numberRows_,rowActivityWork_);
     717            CoinMemcpyN(savedSolution_ ,
     718                   numberColumns_,columnActivityWork_);
    719719            // restore extra stuff
    720720            matrix_->generalExpanded(this,6,dummy);
     
    905905          delete [] ray_;
    906906          ray_ = new double [numberRows_];
    907           memcpy(ray_,dual_,numberRows_*sizeof(double));
     907          CoinMemcpyN(dual_,numberRows_,ray_);
    908908          // and get feasible duals
    909909          infeasibilityCost_=0.0;
     
    10591059        //bool unflagged =
    10601060        unflag();
    1061         if (sumDualInfeasibilities_<1.0e-3&&!numberPrimalInfeasibilities_) {
    1062           if (numberTimesOptimal_<4) {
    1063             numberTimesOptimal_++;
    1064             changeMade_++; // say change made
    1065           } else {
    1066             problemStatus_=0;
    1067             secondaryStatus_=5;
    1068           }
     1061        if (sumDualInfeasibilities_<1.0e-3||
     1062            (sumDualInfeasibilities_/(double) numberDualInfeasibilities_)<1.0e-5||
     1063            progress->lastIterationNumber(0)==numberIterations_) {
     1064          if (!numberPrimalInfeasibilities_) {
     1065            if (numberTimesOptimal_<4) {
     1066              numberTimesOptimal_++;
     1067              changeMade_++; // say change made
     1068            } else {
     1069              problemStatus_=0;
     1070              secondaryStatus_=5;
     1071            }
     1072          }
    10691073        }
    10701074      }
     
    10821086    }
    10831087    // save arrays
    1084     memcpy(saveStatus_,status_,(numberColumns_+numberRows_)*sizeof(char));
    1085     memcpy(savedSolution_+numberColumns_ ,rowActivityWork_,
    1086            numberRows_*sizeof(double));
    1087     memcpy(savedSolution_ ,columnActivityWork_,numberColumns_*sizeof(double));
     1088    CoinMemcpyN(status_,numberColumns_+numberRows_,saveStatus_);
     1089    CoinMemcpyN(rowActivityWork_,
     1090           numberRows_,savedSolution_+numberColumns_);
     1091    CoinMemcpyN(columnActivityWork_,numberColumns_,savedSolution_);
    10881092  }
    10891093  if (doFactorization) {
     
    15751579  // clear arrays
    15761580
    1577   memset(spare,0,numberRemaining*sizeof(double));
     1581  CoinZeroN(spare,numberRemaining);
    15781582
    15791583  // put back original bounds etc
    1580   memcpy(rhsArray->getIndices(),index,numberRemaining*sizeof(int));
     1584  CoinMemcpyN(index,numberRemaining,rhsArray->getIndices());
    15811585  rhsArray->setNumElements(numberRemaining);
    15821586  rhsArray->setPacked();
     
    26392643  delete [] ray_;
    26402644  ray_ = new double [numberColumns_];
    2641   ClpFillN(ray_,numberColumns_,0.0);
     2645  CoinZeroN(ray_,numberColumns_);
    26422646  int number=rowArray->getNumElements();
    26432647  int * index = rowArray->getIndices();
     
    27112715          CoinSort_2(work,work+number,which);
    27122716          columnArray->setNumElements(number);
    2713           memset(work,0,number*sizeof(double));
     2717          CoinZeroN(work,number);
    27142718        }
    27152719        int * which=columnArray->getIndices();
Note: See TracChangeset for help on using the changeset viewer.