Changeset 1095 for trunk


Ignore:
Timestamp:
Sep 3, 2007 12:23:11 PM (13 years ago)
Author:
forrest
Message:

event handling and nonlinear

Location:
trunk/Clp/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpSimplexNonlinear.cpp

    r1094 r1095  
    33643364  // Both these should be modified depending on problem
    33653365  // Possibly start with big bounds
    3366   double penalties[]={1.0e-2,1.0e3,1.0e9};
     3366  double penalties[]={1.0e-3,1.0e7,1.0e9};
    33673367  //double bounds[] = {1.0e-2,1.0,COIN_DBL_MAX};
    3368   double bounds[] = {1.0e-1,1.0e2,COIN_DBL_MAX};
     3368  double bounds[] = {1.0e-2,1.0e2,COIN_DBL_MAX};
    33693369  // see how many extra we need
    33703370  CoinBigIndex numberExtra=0;
     
    34003400  }
    34013401  int numberColumns2 = numberColumns_;
     3402  int numberSmallGap = numberArtificials;
    34023403  if (numberArtificials) {
    34033404    numberArtificials *= SEGMENTS;
     
    34443445  }
    34453446  // find nonlinear columns
    3446   int * listNonLinearColumn = new int [numberColumns_];
     3447  int * listNonLinearColumn = new int [numberColumns_+numberSmallGap];
    34473448  char * mark = new char[numberColumns_];
    34483449  memset(mark,0,numberColumns_);
     
    34583459    if (mark[iColumn])
    34593460      listNonLinearColumn[numberNonLinearColumns++]=iColumn;
     3461  }
     3462  // and small gap artificials
     3463  for (iColumn=numberColumns_;iColumn<numberColumns2;iColumn+=SEGMENTS) {
     3464    listNonLinearColumn[numberNonLinearColumns++]=iColumn;
    34603465  }
    34613466  // build row copy of matrix with space for nonzeros
     
    36013606  int iPass;
    36023607  double lastObjective=1.0e31;
     3608  double lastGoodObjective=1.0e31;
     3609  double * bestSolution = NULL;
    36033610  double * saveSolution = new double [numberColumns2+numberRows];
    36043611  char * saveStatus = new char [numberColumns2+numberRows];
     
    37223729      sumArt[jNon]=sumArt[jNon+1];
    37233730    sumArt[KEEP_SUM-1]=sumInfeas;
    3724     if (sumInfeas>0.01&&sumInfeas*1.1>sumArt[0]&&objective[numberColumns_+1]<1.0e5) {
     3731    if (sumInfeas>0.01&&sumInfeas*1.1>sumArt[0]&&penalties[1]<1.0e7) {
    37253732      // not doing very well - increase - be more sophisticated later
    37263733      lastObjective=COIN_DBL_MAX;
    37273734      for (jNon=0;jNon<KEEP_SUM;jNon++)
    37283735        sumArt[jNon]=COIN_DBL_MAX;
    3729       for (iColumn=numberColumns_;iColumn<numberColumns2;iColumn+=SEGMENTS) {
    3730         objective[iColumn+1] *= 1.5;
    3731       }
     3736      //for (iColumn=numberColumns_;iColumn<numberColumns2;iColumn+=SEGMENTS) {
     3737      //objective[iColumn+1] *= 1.5;
     3738      //}
     3739      penalties[1] *= 1.5;
    37323740      for (jNon=0;jNon<numberNonLinearColumns;jNon++)
    37333741        if (trust[jNon]>0.1)
     
    38583866      printf("offset2 %g ",objectiveOffset2);
    38593867    objValue -= objectiveOffset2;
    3860     printf("True objective %g or maybe %g\n",objValue,objValue+objectiveOffset2);
     3868    printf("True objective %g or maybe %g (with penalty %g) -pen2 %g %g\n",objValue,
     3869           objValue+objectiveOffset2,objValue+objectiveOffset2+infPenalty,infPenalty2,penalties[1]);
     3870    double useObjValue = objValue+objectiveOffset2+infPenalty;
    38613871    objValue += infPenalty+infPenalty2;
     3872    objValue = useObjValue;
    38623873    if (iPass) {
    38633874      double drop = lastObjective-objValue;
     
    39543965               <<", smallest nonlinear gap is "<<smallestNonLinearGap
    39553966               <<std::endl;
     3967      if (iPass>200) {
     3968        //double useObjValue = objValue+objectiveOffset2+infPenalty;
     3969        if (useObjValue+1.0e-4> lastGoodObjective&&iPass>250) {
     3970          std::cout<<"Exiting as objective not changing much"<<std::endl;
     3971          break;
     3972        } else if (useObjValue<lastGoodObjective) {
     3973          lastGoodObjective = useObjValue;
     3974          if (!bestSolution)
     3975            bestSolution = new double [numberColumns2];
     3976          memcpy(bestSolution,solution,numberColumns2*sizeof(double));
     3977        }
     3978      }
    39563979      if (maxDelta<deltaTolerance&&!increasing&&iPass>100) {
    39573980        numberZeroPasses++;
     
    40634086  delete [] trueUpper;
    40644087  delete [] trueLower;
     4088  objectiveValue_=newModel.objectiveValue();
     4089  if (bestSolution) {
     4090    memcpy(solution,bestSolution,numberColumns2*sizeof(double));
     4091    delete [] bestSolution;
     4092    printf("restoring objective of %g\n",lastGoodObjective);
     4093    objectiveValue_=lastGoodObjective;
     4094  }
    40654095  // Simplest way to get true row activity ?
    40664096  double * rowActivity = newModel.primalRowSolution();
     
    40834113  delete [] gradient;
    40844114  printf("solution still in newModel - do objective etc!\n");
    4085   objectiveValue_=newModel.objectiveValue();
    40864115  numberIterations_ =newModel.numberIterations();
    40874116  problemStatus_ =newModel.problemStatus();
  • trunk/Clp/src/ClpSimplexPrimal.cpp

    r1088 r1095  
    662662      } else if (returnCode!=-1) {
    663663        assert(returnCode==3);
    664         problemStatus_=3;
     664        if (problemStatus_!=5)
     665          problemStatus_=3;
    665666      }
    666667    } else {
     
    28882889        problemStatus_=5;
    28892890        secondaryStatus_=ClpEventHandler::endOfIteration;
    2890         returnCode=4;
     2891        returnCode=3;
    28912892      }
    28922893    }
Note: See TracChangeset for help on using the changeset viewer.