Changeset 1005 for branches


Ignore:
Timestamp:
May 10, 2007 5:33:06 AM (12 years ago)
Author:
forrest
Message:

quadratic constraints

Location:
branches/devel/Clp/src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Clp/src/ClpConstraint.cpp

    r997 r1005  
    1616  lastGradient_(NULL),
    1717  functionValue_(0.0),
     18  offset_(0.0),
    1819  type_(-1),
    1920  rowNumber_(-1)
     
    2829  lastGradient_(NULL),
    2930  functionValue_(source.functionValue_),
     31  offset_(source.offset_),
    3032  type_(source.type_),
    3133  rowNumber_(source.rowNumber_)
     
    5153  if (this != &rhs) {
    5254    functionValue_ = rhs.functionValue_;
     55    offset_ = rhs.offset_;
    5356    type_ = rhs.type_;
    5457    rowNumber_= rhs.rowNumber_;
  • branches/devel/Clp/src/ClpConstraint.hpp

    r998 r1005  
    3232                       double & functionValue ,
    3333                       double & offset,
     34                       bool useScaling=false,
    3435                       bool refresh=true) const =0;
    3536  /// Resize constraint
     
    7879  {return rowNumber_;};
    7980 
     81  /// Number of possible coefficients in gradient
     82  virtual int numberCoefficients() const = 0;
     83 
    8084  /// Constraint function value
    8185  inline double functionValue () const
    8286  { return functionValue_;};
     87
     88  /// Constraint offset
     89  inline double offset () const
     90  { return offset_;};
    8391  //@}
    8492
     
    92100  /// Value of non-linear part of constraint
    93101  mutable double functionValue_;
     102  /// Value of offset for constraint
     103  mutable double offset_;
    94104  /// Type of constraint - linear is 1
    95105  int type_;
  • branches/devel/Clp/src/ClpConstraintLinear.cpp

    r998 r1005  
    9595                              double & functionValue,
    9696                              double & offset,
     97                              bool useScaling,
    9798                              bool refresh) const
    9899{
     
    102103      lastGradient_ = new double[numberColumns_];
    103104    CoinZeroN(lastGradient_,numberColumns_);
    104     bool scaling=(model&&model->rowScale());
     105    bool scaling=(model&&model->rowScale()&&useScaling);
    105106    if (!scaling) {
    106107      for (int i=0;i<numberCoefficients_;i++) {
     
    194195  return numberCoefficients_;
    195196}
     197// Number of coefficients
     198int
     199ClpConstraintLinear::numberCoefficients() const
     200{
     201  return numberCoefficients_;
     202}
  • branches/devel/Clp/src/ClpConstraintLinear.hpp

    r998 r1005  
    3131                       double & functionValue ,
    3232                       double & offset,
     33                       bool useScaling=false,
    3334                       bool refresh=true) const ;
    3435  /// Resize constraint
     
    7475  //@{
    7576  /// Number of coefficients
    76   inline int numberCoefficients() const
    77   {return numberCoefficients_;};
     77  virtual int numberCoefficients() const;
    7878  /// Number of columns in linear constraint
    7979  inline int numberColumns() const
  • branches/devel/Clp/src/ClpSimplexNonlinear.cpp

    r998 r1005  
    34193419  // build row copy of matrix with space for nonzeros
    34203420  // Get column copy
    3421   columnCopy = matrix();
     3421  columnCopy = newModel.matrix();
    34223422  copy.reverseOrderedCopyOf(*columnCopy);
    34233423  // get matrix data pointers
     
    34653465          newElement[numberExtra++] = 1.0;
    34663466        }
     3467      }
     3468      // copy artificials
     3469      for (CoinBigIndex j=rowStart[iRow];j<rowStart[iRow]+rowLength[iRow];
     3470           j++) {
     3471        newColumn[numberExtra]=column[j];
     3472        newElement[numberExtra++] = elementByRow[j];
    34673473      }
    34683474    }
     
    35103516  char * saveStatus = new char [numberColumns2+numberRows];
    35113517  double targetDrop=1.0e31;
    3512   //double objectiveOffset2 = objectiveOffset;
    35133518  // 1 bound up, 2 up, -1 bound down, -2 down, 0 no change
    35143519  for (iPass=0;iPass<3;iPass++) {
     
    35223527#define SMALL_FIX 0.0
    35233528  for (iPass=0;iPass<numberPasses;iPass++) {
     3529    objectiveOffset2 = objectiveOffset;
    35243530    for (jNon=0;jNon<numberNonLinearColumns;jNon++) {
    35253531      iColumn=listNonLinearColumn[jNon];
     
    35493555        }
    35503556      } else {
    3551 #if 1
     3557#if 0
    35523558        // fix nonlinear variables
    35533559        columnLower[iColumn]=solution[iColumn];
     
    35723578      if (iRow>=0) {
    35733579        if (numberRows<50)
    3574           printf("For row %d current value is %g (activity %g) , dual is %g\n",iRow,offset,
     3580          printf("For row %d current value is %g (activity %g) , dual is %g\n",iRow,functionValue,
    35753581                 newModel.primalRowSolution()[iRow],
    35763582                 newModel.dualRowSolution()[iRow]);
    3577         for (CoinBigIndex j=rowStart[iRow];j<rowStart[iRow]+rowLength[iRow];
    3578              j++) {
     3583        int numberCoefficients = constraint->numberCoefficients();
     3584        for (CoinBigIndex j=rowStart[iRow];j<rowStart[iRow]+numberCoefficients;j++) {
    35793585          int iColumn = column[j];
    35803586          changeableElement[j] = gradient[iColumn];
     
    36613667    if (objectiveOffset2)
    36623668      printf("offset2 %g\n",objectiveOffset2);
    3663     objValue = objValue + infValue -objectiveOffset2;
     3669    objValue -= objectiveOffset2;
    36643670    printf("True objective %g\n",objValue);
     3671    objValue += infValue;
    36653672    if (iPass) {
    36663673      double drop = lastObjective-objValue;
     
    38533860    writer.writeMps("xx.mps");
    38543861#endif
    3855     if (iPass<3) {
    3856       newModel.primal(1);
    3857       abort();
    3858     } else {
    3859       abort();
    3860     }
     3862    // solve
     3863    newModel.primal(1);
    38613864    if (newModel.status()==1) {
    38623865      // Infeasible!
    38633866      newModel.allSlackBasis();
    38643867      newModel.primal();
     3868      newModel.writeMps("infeas.mps");
    38653869      assert(!newModel.status());
    38663870    }
     
    38753879    printf("%d infeasibilities - summing to %g\n",
    38763880           numberInfeas,sumInfeas);
    3877     //model.writeMps("xx");
    38783881  }
    38793882  delete [] saveSolution;
     
    39063909    }
    39073910  }
    3908   delete [] saveSolution;
    3909   delete [] saveStatus;
    3910   for (iPass=0;iPass<3;iPass++)
    3911     delete [] last[iPass];
    3912   for (jNon=0;jNon<numberNonLinearColumns;jNon++) {
    3913     iColumn=listNonLinearColumn[jNon];
    3914     columnLower[iColumn]=trueLower[jNon];
    3915     columnUpper[iColumn]=trueUpper[jNon];
    3916   }
    3917   delete [] trust;
    3918   delete [] trueUpper;
    3919   delete [] trueLower;
    39203911  delete [] listNonLinearColumn;
    39213912  delete [] gradient;
     
    39293920  CoinZeroN(rowActivity_,numberRows_);
    39303921  matrix_->times(1.0,columnActivity_,rowActivity_);
    3931   abort();
    39323922  return 0;
    39333923}
  • branches/devel/Clp/src/Makefile.am

    r996 r1005  
    2525        ClpConstraint.cpp ClpConstraint.hpp \
    2626        ClpConstraintLinear.cpp ClpConstraintLinear.hpp \
     27        ClpConstraintQuadratic.cpp ClpConstraintQuadratic.hpp \
    2728        Clp_C_Interface.cpp Clp_C_Interface.h \
    2829        ClpDualRowDantzig.cpp ClpDualRowDantzig.hpp \
     
    123124        ClpConstraint.hpp \
    124125        ClpConstraintLinear.hpp \
     126        ClpConstraintQuadratic.hpp \
    125127        ClpDualRowDantzig.hpp \
    126128        ClpDualRowPivot.hpp \
  • branches/devel/Clp/src/Makefile.in

    r998 r1005  
    7070am_libClp_la_OBJECTS = ClpCholeskyBase.lo ClpCholeskyDense.lo \
    7171        ClpCholeskyUfl.lo ClpConstraint.lo ClpConstraintLinear.lo \
    72         Clp_C_Interface.lo ClpDualRowDantzig.lo ClpDualRowPivot.lo \
    73         ClpDualRowSteepest.lo ClpDummyMatrix.lo \
    74         ClpDynamicExampleMatrix.lo ClpDynamicMatrix.lo \
    75         ClpEventHandler.lo ClpFactorization.lo ClpGubDynamicMatrix.lo \
    76         ClpGubMatrix.lo ClpHelperFunctions.lo ClpInterior.lo \
    77         ClpLinearObjective.lo ClpMatrixBase.lo ClpMessage.lo \
    78         ClpModel.lo ClpNetworkBasis.lo ClpNetworkMatrix.lo \
    79         ClpNonLinearCost.lo ClpObjective.lo ClpPackedMatrix.lo \
    80         ClpPlusMinusOneMatrix.lo ClpPredictorCorrector.lo \
    81         ClpPresolve.lo ClpPrimalColumnDantzig.lo \
    82         ClpPrimalColumnPivot.lo ClpPrimalColumnSteepest.lo \
    83         ClpQuadraticObjective.lo ClpSimplex.lo ClpSimplexDual.lo \
    84         ClpSimplexNonlinear.lo ClpSimplexOther.lo ClpSimplexPrimal.lo \
    85         ClpSolve.lo Idiot.lo IdiSolve.lo
     72        ClpConstraintQuadratic.lo Clp_C_Interface.lo \
     73        ClpDualRowDantzig.lo ClpDualRowPivot.lo ClpDualRowSteepest.lo \
     74        ClpDummyMatrix.lo ClpDynamicExampleMatrix.lo \
     75        ClpDynamicMatrix.lo ClpEventHandler.lo ClpFactorization.lo \
     76        ClpGubDynamicMatrix.lo ClpGubMatrix.lo ClpHelperFunctions.lo \
     77        ClpInterior.lo ClpLinearObjective.lo ClpMatrixBase.lo \
     78        ClpMessage.lo ClpModel.lo ClpNetworkBasis.lo \
     79        ClpNetworkMatrix.lo ClpNonLinearCost.lo ClpObjective.lo \
     80        ClpPackedMatrix.lo ClpPlusMinusOneMatrix.lo \
     81        ClpPredictorCorrector.lo ClpPresolve.lo \
     82        ClpPrimalColumnDantzig.lo ClpPrimalColumnPivot.lo \
     83        ClpPrimalColumnSteepest.lo ClpQuadraticObjective.lo \
     84        ClpSimplex.lo ClpSimplexDual.lo ClpSimplexNonlinear.lo \
     85        ClpSimplexOther.lo ClpSimplexPrimal.lo ClpSolve.lo Idiot.lo \
     86        IdiSolve.lo
    8687libClp_la_OBJECTS = $(am_libClp_la_OBJECTS)
    8788binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
     
    277278        ClpConstraint.cpp ClpConstraint.hpp \
    278279        ClpConstraintLinear.cpp ClpConstraintLinear.hpp \
     280        ClpConstraintQuadratic.cpp ClpConstraintQuadratic.hpp \
    279281        Clp_C_Interface.cpp Clp_C_Interface.h \
    280282        ClpDualRowDantzig.cpp ClpDualRowDantzig.hpp \
     
    368370        ClpConstraint.hpp \
    369371        ClpConstraintLinear.hpp \
     372        ClpConstraintQuadratic.hpp \
    370373        ClpDualRowDantzig.hpp \
    371374        ClpDualRowPivot.hpp \
     
    513516@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpConstraint.Plo@am__quote@
    514517@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpConstraintLinear.Plo@am__quote@
     518@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpConstraintQuadratic.Plo@am__quote@
    515519@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpDualRowDantzig.Plo@am__quote@
    516520@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpDualRowPivot.Plo@am__quote@
Note: See TracChangeset for help on using the changeset viewer.