Changeset 869


Ignore:
Timestamp:
Oct 12, 2006 2:50:14 PM (13 years ago)
Author:
forrest
Message:

for restorefromdual

Location:
trunk/Clp/src
Files:
2 edited

Legend:

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

    r754 r869  
    790790}
    791791// Restores solution from dualized problem
    792 void 
     792void
    793793ClpSimplexOther::restoreFromDual(const ClpSimplex * dualProblem)
    794794{
     795  int returnCode=0;;
    795796  createStatus();
    796797  // Number of rows in dual problem was original number of columns
     
    886887        setColumnStatus(iColumn,basic);
    887888        numberBasic++;
    888         columnActivity_[iColumn]=-dualDual[iColumn];
     889        if (columnLower_[iColumn]>-1.0e20) {
     890          columnActivity_[iColumn]=-dualDual[iColumn] + columnLower_[iColumn];
     891        } else if (columnUpper_[iColumn]<1.0e20) {
     892          columnActivity_[iColumn]=-dualDual[iColumn] + columnUpper_[iColumn];
     893        }
    889894        reducedCost_[iColumn]=0.0;
    890895      } else {
     
    914919  // now rows
    915920  int kRow=0;
     921  int numberRanges=0;
    916922  for (iRow=0;iRow<numberRows_;iRow++) {
    917923    Status status = dualProblem->getColumnStatus(kRow);
     
    950956      } else {
    951957        // range
    952         abort();
     958        numberRanges++;
     959        Status statusL = dualProblem->getColumnStatus(kRow+1);
     960        if (status==basic) {
     961          assert (statusL!=basic);
     962          rowActivity_[iRow]=rowUpper_[iRow];
     963          setRowStatus(iRow,atUpperBound);
     964        } else if (statusL==basic) {
     965          rowActivity_[iRow]=rowLower_[iRow];
     966          setRowStatus(iRow,atLowerBound);
     967        } else {
     968          rowActivity_[iRow]=rowLower_[iRow]+dualSol[kRow];
     969          // row basic
     970          setRowStatus(iRow,basic);
     971          numberBasic++;
     972          dual_[iRow]=0.0;
     973        }
    953974        kRow++;
    954975        kRow++;
     
    956977    }
    957978  }
    958   assert (numberBasic==numberRows_);
     979  if (numberRanges) {
     980    printf("%d ranges - coding needed\n",numberRanges);
     981    returnCode=1;
     982  }
     983  if (numberBasic!=numberRows_) {
     984    printf("Bad basis - ranges?\n");
     985    assert (numberRanges);
     986  }
    959987  if (optimizationDirection_<0.0) {
    960988    for (iRow=0;iRow<numberRows_;iRow++) {
     
    965993    }
    966994  }
     995  // redo row activities
     996  memset(rowActivity_,0,numberRows_*sizeof(double));
     997  matrix_->times(-1.0,columnActivity_,rowActivity_);
    967998  checkSolutionInternal();
     999  //return returnCode;
    9681000}
    9691001/* Does very cursory presolve.
     
    20022034      numberDualInfeasibilities_=1;
    20032035  }
     2036  // Allow matrices to be sorted etc
     2037  int fake=-999; // signal sort
     2038  matrix_->correctSequence(fake,fake);
    20042039}
    20052040/* This has the flow between re-factorizations
  • trunk/Clp/src/ClpSimplexPrimal.cpp

    r845 r869  
    915915      numberDualInfeasibilities_ = -776;
    916916    }
    917   }
     917    // But if real primal infeasibilities nonzero carry on
     918    if (nonLinearCost_->numberInfeasibilities()) {
     919      // most likely to happen if infeasible
     920      double relaxedToleranceP=primalTolerance_;
     921      // we can't really trust infeasibilities if there is primal error
     922      double error = CoinMin(1.0e-2,largestPrimalError_);
     923      // allow tolerance at least slightly bigger than standard
     924      relaxedToleranceP = relaxedToleranceP +  error;
     925      int ninfeas = nonLinearCost_->numberInfeasibilities();
     926      double sum = nonLinearCost_->sumInfeasibilities();
     927      double average = sum/ ((double) ninfeas);
     928#ifdef COIN_DEVELOP
     929      printf("nonLinearCost says infeasible %d summing to %g\n",
     930             ninfeas,sum);
     931#endif
     932      if (average>relaxedToleranceP) {
     933        sumOfRelaxedPrimalInfeasibilities_ = sum;
     934        numberPrimalInfeasibilities_ = ninfeas;
     935        sumPrimalInfeasibilities_ = sum;
     936      }
     937    }
     938  }
    918939  // had ||(type==3&&problemStatus_!=-5) -- ??? why ????
    919940  if ((dualFeasible()||problemStatus_==-4)&&!ifValuesPass) {
Note: See TracChangeset for help on using the changeset viewer.