Changeset 1059 for trunk/Clp


Ignore:
Timestamp:
Aug 3, 2007 8:47:45 AM (13 years ago)
Author:
forrest
Message:

add defaulthandler and stuff for nonlinear

Location:
trunk/Clp/src
Files:
3 edited

Legend:

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

    r1035 r1059  
    164164        }
    165165      }
    166       functionValue_ += offset_;
     166      functionValue_ -= offset_;
    167167    } else {
    168168      abort();
  • trunk/Clp/src/ClpModel.hpp

    r1056 r1059  
    670670   inline void setLogLevel(int value)    { handler_->setLogLevel(value); }
    671671   inline int logLevel() const           { return handler_->logLevel(); }
     672   /// Return true if default handler
     673   inline bool defaultHandler() const
     674   { return defaultHandler_;}
    672675   /// Pass in Event handler (cloned and deleted at end)
    673676   void passInEventHandler(const ClpEventHandler * eventHandler);
  • trunk/Clp/src/ClpSimplexNonlinear.cpp

    r1057 r1059  
    37123712    // This penalty is for target drop
    37133713    double infPenalty2=0.0;
     3714    //const int * row = columnCopy->getIndices();
     3715    //const CoinBigIndex * columnStart = columnCopy->getVectorStarts();
     3716    //const int * columnLength = columnCopy->getVectorLengths();
     3717    //const double * element = columnCopy->getElements();
     3718    double * cost = newModel.objective();
     3719    column = newMatrix.getIndices();
     3720    rowStart = newMatrix.getVectorStarts();
     3721    rowLength = newMatrix.getVectorLengths();
     3722    elementByRow = newMatrix.getElements();
     3723    int jColumn = numberColumns_;
     3724    double objectiveAdjustment=0.0;
    37143725    for (iConstraint=0;iConstraint<numberConstraints;iConstraint++) {
    37153726      ClpConstraint * constraint = constraints[iConstraint];
     
    37183729      double dualValue = newModel.dualRowSolution()[iRow];
    37193730      if (numberConstraints<50)
    3720         printf("For row %d current value is %g (activity %g) , dual is %g - offset %g\n",iRow,functionValue,
     3731        printf("For row %d current value is %g (row activity %g) , dual is %g\n",iRow,functionValue,
    37213732               newModel.primalRowSolution()[iRow],
    3722                dualValue,offset);
     3733               dualValue);
    37233734      double movement = newModel.primalRowSolution()[iRow];
    37243735      movement = fabs((movement-functionValue)*dualValue);
    37253736      infPenalty2 += movement;
    3726       double infeasibility=0.0;
    3727       if (functionValue<rowLower_[iRow]-1.0e-5) {
    3728         infeasibility = rowLower_[iRow]-functionValue;
    3729       } else if (functionValue>rowUpper_[iRow]+1.0e-5) {
    3730         infeasibility = functionValue-rowUpper_[iRow];
    3731       }
    3732       infValue += infeasibility;
    3733       for (int k=0;k<SEGMENTS;k++) {
    3734         if (infeasibility<=0)
    3735           break;
    3736         double thisPart = CoinMin(infeasibility,bounds[k]);
    3737         infPenalty += thisPart*penalties[k];
    3738         infeasibility -= thisPart;
    3739       }
    3740     }
     3737      double sumOfActivities=0.0;
     3738      for (CoinBigIndex j=rowStart[iRow];j<rowStart[iRow]+rowLength[iRow];j++) {
     3739        int iColumn = column[j];
     3740        sumOfActivities += fabs(solution[iColumn]*elementByRow[j]);
     3741      }
     3742      if (rowLower_[iRow]>-1.0e20) {
     3743        if (functionValue<rowLower_[iRow]-1.0e-5) {
     3744          double infeasibility = rowLower_[iRow]-functionValue;
     3745          double thisPenalty=0.0;
     3746          infValue += infeasibility;
     3747          double boundMultiplier = 1.0;
     3748          if (sumOfActivities<0.001)
     3749            boundMultiplier = 0.1;
     3750          else if (sumOfActivities>100.0)
     3751            boundMultiplier=10.0;
     3752          int k;
     3753          for ( k=0;k<SEGMENTS;k++) {
     3754            if (infeasibility<=0)
     3755              break;
     3756            double thisPart = CoinMin(infeasibility,bounds[k]);
     3757            thisPenalty += thisPart*cost[jColumn+k];
     3758            infeasibility -= thisPart;
     3759          }
     3760          infPenalty += thisPenalty;
     3761        }
     3762        jColumn += SEGMENTS;
     3763      }
     3764      if (rowUpper_[iRow]<1.0e20) {
     3765        if (functionValue>rowUpper_[iRow]+1.0e-5) {
     3766          double infeasibility = functionValue-rowUpper_[iRow];
     3767          double thisPenalty=0.0;
     3768          infValue += infeasibility;
     3769          double boundMultiplier = 1.0;
     3770          if (sumOfActivities<0.001)
     3771            boundMultiplier = 0.1;
     3772          else if (sumOfActivities>100.0)
     3773            boundMultiplier=10.0;
     3774          int k;
     3775          dualValue = -dualValue;
     3776          assert (dualValue>=-1.0e-5);
     3777          dualValue = CoinMax(dualValue,0.0);
     3778          for ( k=0;k<SEGMENTS;k++) {
     3779            if (infeasibility<=0)
     3780              break;
     3781            double thisPart = CoinMin(infeasibility,bounds[k]);
     3782            thisPenalty += thisPart*cost[jColumn+k];
     3783            infeasibility -= thisPart;
     3784          }
     3785          infeasibility = functionValue-rowUpper_[iRow];
     3786          double newPenalty=0.0;
     3787          for ( k=0;k<SEGMENTS;k++) {
     3788            double thisPart = CoinMin(infeasibility,bounds[k]);
     3789            cost[jColumn+k] = CoinMax(penalties[k],dualValue+1.0e-3);
     3790            newPenalty += thisPart*cost[jColumn+k];
     3791            infeasibility -= thisPart;
     3792          }
     3793          infPenalty += thisPenalty;
     3794          objectiveAdjustment += CoinMax(0.0,newPenalty-thisPenalty);
     3795        }
     3796        jColumn += SEGMENTS;
     3797      }
     3798    }
     3799    // adjust last objective value
     3800    lastObjective += objectiveAdjustment;
    37413801    if (infValue)
    37423802      printf("Sum infeasibilities %g - penalty %g",infValue,infPenalty);
Note: See TracChangeset for help on using the changeset viewer.