Changeset 20


Ignore:
Timestamp:
Sep 17, 2002 9:15:14 AM (17 years ago)
Author:
forrest
Message:

Synchronizing

Location:
branches/devel-1
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-1/ClpSimplex.cpp

    r19 r20  
    7373  largestDualError_(0.0),
    7474  largestSolutionError_(0.0),
    75   dualBound_(1.0e7),
     75  dualBound_(1.0e6),
    7676  lower_(NULL),
    7777  rowLowerWork_(NULL),
     
    118118  savedSolution_(NULL),
    119119  columnScale_(NULL),
    120   scalingFlag_(0),
     120  scalingFlag_(1),
    121121  numberTimesOptimal_(0),
    122122  changeMade_(1),
     
    128128  specialOptions_(0),
    129129  lastBadIteration_(-999999),
    130   numberFake_(0)
     130  numberFake_(0),
     131  progressFlag_(0),
     132  sumOfRelaxedDualInfeasibilities_(0.0),
     133  sumOfRelaxedPrimalInfeasibilities_(0.0)
    131134
    132135{
     
    546549            rowActivityWork_[iRow]=rowUpperWork_[iRow];
    547550            if (rowActivityWork_[iRow]>largeValue_) {
    548               assert(rowLowerWork_[iRow]>-largeValue_);
    549               rowActivityWork_[iRow]=rowLowerWork_[iRow];
    550               setRowStatus(iRow,ClpSimplex::atLowerBound);
     551              if (rowLowerWork_[iRow]>-largeValue_) {
     552                rowActivityWork_[iRow]=rowLowerWork_[iRow];
     553                setRowStatus(iRow,ClpSimplex::atLowerBound);
     554              } else {
     555                // say free
     556                setRowStatus(iRow,ClpSimplex::isFree);
     557                rowActivityWork_[iRow]=0.0;
     558              }
    551559            }
    552560            break;
     
    554562            rowActivityWork_[iRow]=rowLowerWork_[iRow];
    555563            if (rowActivityWork_[iRow]<-largeValue_) {
    556               assert(rowUpperWork_[iRow]<largeValue_);
    557               rowActivityWork_[iRow]=rowUpperWork_[iRow];
    558               setRowStatus(iRow,ClpSimplex::atUpperBound);
     564              if (rowUpperWork_[iRow]<largeValue_) {
     565                rowActivityWork_[iRow]=rowUpperWork_[iRow];
     566                setRowStatus(iRow,ClpSimplex::atUpperBound);
     567              } else {
     568                // say free
     569                setRowStatus(iRow,ClpSimplex::isFree);
     570                rowActivityWork_[iRow]=0.0;
     571              }
    559572            }
    560573            break;
     
    930943  if (sequenceIn_!=sequenceOut_) {
    931944    assert( getStatus(sequenceOut_)== ClpSimplex::basic);
     945    if (upper_[sequenceOut_]-lower_[sequenceOut_]<1.0e-12)
     946      progressFlag_ |= 1; // making real progress
    932947    if (algorithm_<0) {
    933948      if (directionOut_>0) {
     
    10751090  specialOptions_(0),
    10761091  lastBadIteration_(-999999),
    1077   numberFake_(0)
     1092  numberFake_(0),
     1093  progressFlag_(0),
     1094  sumOfRelaxedDualInfeasibilities_(0.0),
     1095  sumOfRelaxedPrimalInfeasibilities_(0.0)
    10781096{
    10791097  int i;
     
    11611179  specialOptions_(0),
    11621180  lastBadIteration_(-999999),
    1163   numberFake_(0)
     1181  numberFake_(0),
     1182  progressFlag_(0),
     1183  sumOfRelaxedDualInfeasibilities_(0.0),
     1184  sumOfRelaxedPrimalInfeasibilities_(0.0)
    11641185{
    11651186  int i;
     
    12901311  lastBadIteration_ = rhs.lastBadIteration_;
    12911312  numberFake_ = rhs.numberFake_;
     1313  progressFlag_ = rhs.progressFlag_;
     1314  sumOfRelaxedDualInfeasibilities_ = rhs.sumOfRelaxedDualInfeasibilities_;
     1315  sumOfRelaxedPrimalInfeasibilities_ = rhs.sumOfRelaxedPrimalInfeasibilities_;
    12921316  if (rhs.nonLinearCost_!=NULL)
    12931317    nonLinearCost_ = new ClpNonLinearCost(*rhs.nonLinearCost_);
     
    13681392  sumPrimalInfeasibilities_=0.0;
    13691393  numberPrimalInfeasibilities_=0;
     1394  double primalTolerance = primalTolerance_;
     1395  double relaxedTolerance=dualTolerance_;
     1396  // we can't really trust infeasibilities if there is primal error
     1397  double error = min(1.0e-3,largestPrimalError_);
     1398  relaxedTolerance = max(relaxedTolerance, error);
     1399  sumOfRelaxedPrimalInfeasibilities_ = 0.0;
     1400
    13701401  for (iRow=0;iRow<numberRows_;iRow++) {
    13711402    double infeasibility=0.0;
     
    13761407      infeasibility=rowLowerWork_[iRow]-solution[iRow];
    13771408    }
    1378     if (infeasibility>primalTolerance_) {
     1409    if (infeasibility>primalTolerance) {
    13791410      sumPrimalInfeasibilities_ += infeasibility-primalTolerance_;
     1411      if (infeasibility>relaxedTolerance)
     1412        sumOfRelaxedPrimalInfeasibilities_ += infeasibility-relaxedTolerance;
    13801413      numberPrimalInfeasibilities_ ++;
    13811414    }
     
    14051438      columnPrimalSequence_=iColumn;
    14061439    }
    1407     if (infeasibility>primalTolerance_) {
     1440    if (infeasibility>primalTolerance) {
    14081441      sumPrimalInfeasibilities_ += infeasibility-primalTolerance_;
     1442      if (infeasibility>relaxedTolerance)
     1443        sumOfRelaxedPrimalInfeasibilities_ += infeasibility-relaxedTolerance;
    14091444      numberPrimalInfeasibilities_ ++;
    14101445    }
     
    14351470  remainingDualInfeasibility_=0.0;
    14361471  solution = rowActivityWork_;
    1437   double dualTolerance=dualTolerance_;
    1438   if (algorithm_>0) {
    1439     // primal
    1440     // we can't really trust infeasibilities if there is dual error
    1441     if (largestDualError_>1.0e-6)
    1442       dualTolerance *= largestDualError_/1.0e-6;
    1443   }
     1472  double relaxedTolerance=dualTolerance_;
     1473  // we can't really trust infeasibilities if there is dual error
     1474  double error = min(1.0e-3,largestDualError_);
     1475  relaxedTolerance = max(relaxedTolerance, error);
     1476  sumOfRelaxedDualInfeasibilities_ = 0.0;
     1477
    14441478  for (iRow=0;iRow<numberRows_;iRow++) {
    14451479    if (getRowStatus(iRow) != ClpSimplex::basic) {
     
    14561490            rowDualSequence_=iRow;
    14571491          }
    1458           if (value>dualTolerance) {
    1459             sumDualInfeasibilities_ += value-dualTolerance;
     1492          if (value>dualTolerance_) {
     1493            sumDualInfeasibilities_ += value-dualTolerance_;
     1494            if (value>relaxedTolerance)
     1495              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
    14601496            numberDualInfeasibilities_ ++;
    14611497            if (getRowStatus(iRow) != ClpSimplex::isFree)
     
    14811517            rowDualSequence_=iRow;
    14821518          }
    1483           if (value>dualTolerance) {
    1484             sumDualInfeasibilities_ += value-dualTolerance;
     1519          if (value>dualTolerance_) {
     1520            sumDualInfeasibilities_ += value-dualTolerance_;
     1521            if (value>relaxedTolerance)
     1522              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
    14851523            numberDualInfeasibilities_ ++;
    14861524            if (getRowStatus(iRow) != ClpSimplex::isFree)
     
    15101548            columnDualSequence_=iColumn;
    15111549          }
    1512           if (value>dualTolerance) {
    1513             sumDualInfeasibilities_ += value-dualTolerance;
     1550          if (value>dualTolerance_) {
     1551            sumDualInfeasibilities_ += value-dualTolerance_;
     1552            if (value>relaxedTolerance)
     1553              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
    15141554            numberDualInfeasibilities_ ++;
    15151555            if (getColumnStatus(iColumn) != ClpSimplex::isFree)
     
    15351575            columnDualSequence_=iColumn;
    15361576          }
    1537           if (value>dualTolerance) {
    1538             sumDualInfeasibilities_ += value-dualTolerance;
     1577          if (value>dualTolerance_) {
     1578            sumDualInfeasibilities_ += value-dualTolerance_;
     1579            if (value>relaxedTolerance)
     1580              sumOfRelaxedDualInfeasibilities_ += value-relaxedTolerance;
    15391581            numberDualInfeasibilities_ ++;
    15401582            if (getColumnStatus(iColumn) != ClpSimplex::isFree)
     
    16321674    // clean up any mismatches on infinity
    16331675    for (i=0;i<numberColumns_;i++) {
    1634       if (columnLowerWork_[i]<-CLP_INFINITY)
     1676      if (columnLowerWork_[i]<-1.0e30)
    16351677        columnLowerWork_[i] = -DBL_MAX;
    1636       if (columnUpperWork_[i]>CLP_INFINITY)
     1678      if (columnUpperWork_[i]>1.0e30)
    16371679        columnUpperWork_[i] = DBL_MAX;
    16381680    }
     
    26332675  return valueIncoming;
    26342676}
     2677//#############################################################################
     2678
     2679ClpSimplexProgress::ClpSimplexProgress ()
     2680{
     2681  int i;
     2682  for (i=0;i<CLP_PROGRESS;i++) {
     2683    objective_[i] = 0.0;
     2684    infeasibility_[i] = -1.0; // set to an impossible value
     2685    numberInfeasibilities_[i]=-1;
     2686  }
     2687  numberTimes_ = 0;
     2688  numberBadTimes_ = 0;
     2689  model_ = NULL;
     2690}
     2691
     2692
     2693//-----------------------------------------------------------------------------
     2694
     2695ClpSimplexProgress::~ClpSimplexProgress ()
     2696{
     2697}
     2698// Copy constructor.
     2699ClpSimplexProgress::ClpSimplexProgress(const ClpSimplexProgress &rhs)
     2700{
     2701  int i;
     2702  for (i=0;i<CLP_PROGRESS;i++) {
     2703    objective_[i] = rhs.objective_[i];
     2704    infeasibility_[i] = rhs.infeasibility_[i];
     2705    numberInfeasibilities_[i]=rhs.numberInfeasibilities_[i];
     2706  }
     2707  numberTimes_ = rhs.numberTimes_;
     2708  numberBadTimes_ = rhs.numberBadTimes_;
     2709  model_ = rhs.model_;
     2710}
     2711// Copy constructor.from model
     2712ClpSimplexProgress::ClpSimplexProgress(ClpSimplex * model)
     2713{
     2714  int i;
     2715  for (i=0;i<CLP_PROGRESS;i++) {
     2716    objective_[i] = 0.0;
     2717    infeasibility_[i] = -1.0; // set to an impossible value
     2718    numberInfeasibilities_[i]=-1;
     2719  }
     2720  numberTimes_ = 0;
     2721  numberBadTimes_ = 0;
     2722  model_ = model;
     2723}
     2724// Assignment operator. This copies the data
     2725ClpSimplexProgress &
     2726ClpSimplexProgress::operator=(const ClpSimplexProgress & rhs)
     2727{
     2728  if (this != &rhs) {
     2729    int i;
     2730    for (i=0;i<CLP_PROGRESS;i++) {
     2731      objective_[i] = rhs.objective_[i];
     2732      infeasibility_[i] = rhs.infeasibility_[i];
     2733      numberInfeasibilities_[i]=rhs.numberInfeasibilities_[i];
     2734    }
     2735    numberTimes_ = rhs.numberTimes_;
     2736    numberBadTimes_ = rhs.numberBadTimes_;
     2737    model_ = rhs.model_;
     2738  }
     2739  return *this;
     2740}
     2741int
     2742ClpSimplexProgress::looping()
     2743{
     2744  assert(model_);
     2745  double objective = model_->objectiveValue();
     2746  double infeasibility;
     2747  int numberInfeasibilities;
     2748  if (model_->algorithm()<0) {
     2749    // dual
     2750    infeasibility = model_->sumPrimalInfeasibilities();
     2751    numberInfeasibilities = model_->numberPrimalInfeasibilities();
     2752  } else {
     2753    //primal
     2754    infeasibility = model_->sumDualInfeasibilities();
     2755    numberInfeasibilities = model_->numberDualInfeasibilities();
     2756  }
     2757  int i;
     2758  int numberMatched=0;
     2759  int matched=0;
     2760
     2761  for (i=0;i<CLP_PROGRESS;i++) {
     2762    if (objective==objective_[i]&&
     2763        infeasibility==infeasibility_[i]&&
     2764        numberInfeasibilities==numberInfeasibilities_[i]) {
     2765      matched |= (1<<i);
     2766      numberMatched++;
     2767    }
     2768    if (i) {
     2769      objective_[i-1] = objective_[i];
     2770      infeasibility_[i-1] = infeasibility_[i];
     2771      numberInfeasibilities_[i-1]=numberInfeasibilities_[i];
     2772    }
     2773  }
     2774  objective_[CLP_PROGRESS-1] = objective;
     2775  infeasibility_[CLP_PROGRESS-1] = infeasibility;
     2776  numberInfeasibilities_[CLP_PROGRESS-1]=numberInfeasibilities;
     2777  if (model_->progressFlag())
     2778    numberMatched=0;
     2779  numberTimes_++;
     2780  if (numberTimes_<10)
     2781    numberMatched=0;
     2782  // skip if just last time as may be checking something
     2783  if (matched==(1<<(CLP_PROGRESS-1)))
     2784    numberMatched=0;
     2785  if (numberMatched) {
     2786    printf("Possible loop - %d matches (%x) after %d checks\n",
     2787           numberMatched,matched,numberTimes_);
     2788    numberBadTimes_++;
     2789    if (numberBadTimes_<10) {
     2790      if (model_->algorithm()<0) {
     2791        // dual - change tolerance
     2792        model_->setCurrentDualTolerance(model_->currentDualTolerance()*1.05);
     2793      } else {
     2794        // primal - change tolerance
     2795        model_->setCurrentPrimalTolerance(model_->currentPrimalTolerance()*1.05);
     2796      }
     2797    } else {
     2798      // look at solution and maybe declare victory
     2799      if (infeasibility<1.0e-4)
     2800        return 0;
     2801      else
     2802        return 3;
     2803    }
     2804  }
     2805  return -1;
     2806}
  • branches/devel-1/ClpSimplexDual.cpp

    r19 r20  
    290290  numberTimesOptimal_=0;
    291291
     292  // Progress indicator
     293  ClpSimplexProgress progress(this);
     294
    292295  // This says whether to restore things etc
    293296  int factorType=0;
     
    322325#endif
    323326    // may factorize, checks if problem finished
    324     statusOfProblemInDual(lastCleaned,factorType);
     327    statusOfProblemInDual(lastCleaned,factorType,progress);
    325328
    326329    // Say good factorization
     
    336339  }
    337340
    338   assert(!numberFake_||problemStatus_); // all bounds should be okay
     341  //assert(!numberFake_||problemStatus_); // all bounds should be okay
    339342  // at present we are leaving factorization around
    340343  // maybe we should empty it
     
    15261529      oldValue = dj_[sequenceIn_];
    15271530      theta_ = oldValue/alpha;
     1531#if 0
     1532      if (numberIterations_>2000)
     1533        exit(99);
     1534      if (numberIterations_>2000-20)
     1535        handler_->setLogLevel(63);
     1536      if (numberIterations_>2000-20)
     1537        printf("theta %g oldValue %g tol %g %g\n",theta_,oldValue,dualTolerance_,
     1538               newTolerance);
     1539#endif
    15281540      if (theta_<MINIMUMTHETA) {
    15291541        // can't pivot to zero
     
    15521564            alpha=workColumn[iSequence];
    15531565          double value = dj_[iSequence]-theta_*alpha;
     1566#if 0
     1567          if (numberIterations_>2000-20)
     1568            printf("%d alpha %g value %g\n",iSequence,alpha,value);
     1569#endif
    15541570           
    15551571          // can't be free here
     
    15681584              dj_[iSequence] += modification;
    15691585              cost_[iSequence] +=  modification;
     1586#if 0
     1587              if (numberIterations_>2000-20)
     1588                printf("%d acost %g mod %g\n",iSequence,cost_[iSequence],
     1589                       modification);
     1590#endif
    15701591#endif
    15711592            }
     
    15821603              dj_[iSequence] += modification;
    15831604              cost_[iSequence] +=  modification;
     1605#if 0
     1606              if (numberIterations_>2000-20)
     1607                printf("%d bcost %g mod %g\n",iSequence,cost_[iSequence],
     1608                       modification);
     1609#endif
    15841610#endif
    15851611            }
     
    17081734/* Checks if finished.  Updates status */
    17091735void
    1710 ClpSimplexDual::statusOfProblemInDual(int & lastCleaned,int type)
     1736ClpSimplexDual::statusOfProblemInDual(int & lastCleaned,int type,
     1737                               ClpSimplexProgress &progress)
    17111738{
    17121739  if (type==2) {
     
    17551782  // get primal and dual solutions
    17561783  gutsOfSolution(rowActivityWork_,columnActivityWork_);
     1784  // Check if looping
     1785  int loop = progress.looping();
     1786  bool situationChanged=false;
     1787  if (loop>=0) {
     1788    problemStatus_ = loop; //exit if in loop
     1789    return;
     1790  } else if (loop<-1) {
     1791    // something may have changed
     1792    gutsOfSolution(rowActivityWork_,columnActivityWork_);
     1793    situationChanged=true;
     1794  }
     1795  progressFlag_ = 0; //reset progress flag
    17571796#ifdef CLP_DEBUG
    17581797  if (!rowScale_&&(handler_->logLevel()&32)) {
     
    17931832    numberDualInfeasibilitiesWithoutFree_;
    17941833  handler_->message()<<CoinMessageEol;
     1834
    17951835  while (problemStatus_<=-3) {
    17961836    bool cleanDuals=false;
     
    18001840      doOriginalTolerance=1;
    18011841    // check optimal
     1842    // give code benefit of doubt
     1843    if (sumOfRelaxedDualInfeasibilities_ == 0.0&&
     1844        sumOfRelaxedPrimalInfeasibilities_ == 0.0) {
     1845      // say optimal (with these bounds etc)
     1846      numberDualInfeasibilities_ = 0;
     1847      sumDualInfeasibilities_ = 0.0;
     1848      numberPrimalInfeasibilities_ = 0;
     1849      sumPrimalInfeasibilities_ = 0.0;
     1850    }
    18021851    if (dualFeasible()||problemStatus_==-4) {
    18031852      if (primalFeasible()) {
     
    18231872              factorization_->zeroTolerance(1.0e-15);
    18241873            }
     1874            cleanDuals=true;
    18251875          } else {
    18261876            problemStatus_=0; // optimal
     
    18571907        CoinFillN(columnArray_[0]->denseVector(),numberColumns_,0.0);
    18581908        CoinFillN(rowArray_[2]->denseVector(),numberRows_,0.0);
    1859       }
     1909      } 
    18601910      if (problemStatus_==-4) {
    18611911        // may be infeasible - or may be bounds are wrong
     
    21672217  int i;
    21682218  int returnCode=0;
    2169   double saveObjective = objectiveValue_;
     2219  double saveObjectiveValue = objectiveValue_;
    21702220#if 1
    21712221  algorithm_ = -1;
     
    22202270  memcpy(saveUpper,upper_,
    22212271         (numberRows_+numberColumns_)*sizeof(double));
     2272  double * saveObjective = new double[numberRows_+numberColumns_];
     2273  memcpy(saveObjective,cost_,
     2274         (numberRows_+numberColumns_)*sizeof(double));
    22222275  int * savePivot = new int [numberRows_];
    22232276  memcpy(savePivot, pivotVariable_, numberRows_*sizeof(int));
     
    22492302    memcpy(upper_,saveUpper,
    22502303           (numberRows_+numberColumns_)*sizeof(double));
     2304    memcpy(cost_,saveObjective,
     2305         (numberRows_+numberColumns_)*sizeof(double));
    22512306    columnUpper_[iColumn] = saveBound;
    22522307    memcpy(pivotVariable_, savePivot, numberRows_*sizeof(int));
     
    22552310
    22562311    if (status||(problemStatus_==0&&!isDualObjectiveLimitReached())) {
    2257       objectiveChange = objectiveValue_-saveObjective;
     2312      objectiveChange = objectiveValue_-saveObjectiveValue;
    22582313    } else {
    22592314      objectiveChange = 1.0e100;
     
    22842339    memcpy(upper_,saveUpper,
    22852340           (numberRows_+numberColumns_)*sizeof(double));
     2341    memcpy(cost_,saveObjective,
     2342         (numberRows_+numberColumns_)*sizeof(double));
    22862343    columnLower_[iColumn] = saveBound;
    22872344    memcpy(pivotVariable_, savePivot, numberRows_*sizeof(int));
     
    22902347
    22912348    if (status||(problemStatus_==0&&!isDualObjectiveLimitReached())) {
    2292       objectiveChange = objectiveValue_-saveObjective;
     2349      objectiveChange = objectiveValue_-saveObjectiveValue;
    22932350    } else {
    22942351      objectiveChange = 1.0e100;
     
    23292386  delete [] saveLower;
    23302387  delete [] saveUpper;
     2388  delete [] saveObjective;
    23312389  delete [] saveStatus;
    23322390  delete [] savePivot;
     
    23672425
    23682426    if (problemStatus_==0&&!isDualObjectiveLimitReached()) {
    2369       objectiveChange = objectiveValue_-saveObjective;
     2427      objectiveChange = objectiveValue_-saveObjectiveValue;
    23702428    } else {
    23712429      objectiveChange = 1.0e100;
     
    23892447
    23902448    if (problemStatus_==0&&!isDualObjectiveLimitReached()) {
    2391       objectiveChange = objectiveValue_-saveObjective;
     2449      objectiveChange = objectiveValue_-saveObjectiveValue;
    23922450    } else {
    23932451      objectiveChange = 1.0e100;
     
    24292487  delete [] saveStatus;
    24302488#endif
    2431   objectiveValue_ = saveObjective;
     2489  objectiveValue_ = saveObjectiveValue;
    24322490  return returnCode;
    24332491}
     
    24562514  // number of times we have declared optimality
    24572515  numberTimesOptimal_=0;
     2516
     2517  // Progress indicator
     2518  ClpSimplexProgress progress(this);
    24582519
    24592520  // This says whether to restore things etc
     
    24982559    // may factorize, checks if problem finished
    24992560    // should be able to speed this up on first time
    2500     statusOfProblemInDual(lastCleaned,factorType);
     2561    statusOfProblemInDual(lastCleaned,factorType,progress);
    25012562
    25022563    // Say good factorization
     
    25052566    // Do iterations
    25062567    if (problemStatus_<0) {
    2507 #if 1
    25082568      returnCode = whileIterating();
    25092569      if (!alwaysFinish&&returnCode<1) {
     
    25222582      }
    25232583      returnCode=0;
    2524 #else
    2525       whileIterating();
    2526 #endif
    25272584    }
    25282585  }
     
    25592616    }
    25602617  }
     2618  numberFake_ = numberFake;
    25612619  return numberFake;
    25622620}
  • branches/devel-1/ClpSimplexPrimal.cpp

    r19 r20  
    293293  numberTimesOptimal_=0;
    294294
     295  // Progress indicator
     296  ClpSimplexProgress progress(this);
     297
    295298  // Say no pivot has occurred (for steepest edge and updates)
    296299  pivotRow_=-2;
     
    334337      factorType=3;
    335338    // may factorize, checks if problem finished
    336     statusOfProblemInPrimal(lastCleaned,factorType);
     339    statusOfProblemInPrimal(lastCleaned,factorType,progress);
    337340
    338341    // Say good factorization
     
    664667/* Checks if finished.  Updates status */
    665668void
    666 ClpSimplexPrimal::statusOfProblemInPrimal(int & lastCleaned,int type)
     669ClpSimplexPrimal::statusOfProblemInPrimal(int & lastCleaned,int type,
     670                               ClpSimplexProgress &progress)
    667671{
    668672  if (type==2) {
     
    710714  createRim(7);
    711715  gutsOfSolution(rowActivityWork_, columnActivityWork_);
     716  // Check if looping
     717  int loop = progress.looping();
     718  if (loop>=0) {
     719    problemStatus_ = loop; //exit if in loop
     720    return ;
     721  } else if (loop<-1) {
     722    // something may have changed
     723    gutsOfSolution(rowActivityWork_, columnActivityWork_);
     724  }
     725  progressFlag_ = 0; //reset progress flag
     726
    712727  handler_->message(CLP_SIMPLEX_STATUS,messages_)
    713728    <<numberIterations_<<objectiveValue();
     
    724739  // we may wish to say it is optimal even if infeasible
    725740  bool alwaysOptimal = (specialOptions_&1)!=0;
     741  // give code benefit of doubt
     742  if (sumOfRelaxedDualInfeasibilities_ == 0.0&&
     743      sumOfRelaxedPrimalInfeasibilities_ == 0.0) {
     744    // say optimal (with these bounds etc)
     745    numberDualInfeasibilities_ = 0;
     746    sumDualInfeasibilities_ = 0.0;
     747    numberPrimalInfeasibilities_ = 0;
     748    sumPrimalInfeasibilities_ = 0.0;
     749  }
    726750  if (dualFeasible()||problemStatus_==-4||(type==3&&problemStatus_!=-5)) {
    727751    if (nonLinearCost_->numberInfeasibilities()&&!alwaysOptimal) {
  • branches/devel-1/Test/unitTest.cpp

    r19 r20  
    364364    solution.setLogLevel(3+4+8+16+32);
    365365    solution.primal();
     366    // intricate stuff does not work with scaling
     367    solution.scaling(0);
    366368    solution.setBasis(warm);
    367369    assert(!solution.factorize ( ));
     
    378380    solution2.setFactorization(factorization2);
    379381    solution2.setBasis(warm);
     382    // intricate stuff does not work with scaling
     383    solution2.scaling(0);
    380384    solution2.getSolution(rowsol,colsol);
    381385    colsol = solution2.primalColumnSolution();
  • branches/devel-1/include/ClpSimplex.hpp

    r19 r20  
    3737    There is an algorithm data member.  + for primal variations
    3838    and - for dual variations
     39
     40    This file also includes (at end) a very simple class ClpSimplexProgress
     41    which is where anti-looping stuff should migrate to
    3942
    4043*/
     
    309312  inline double currentDualTolerance() const
    310313          { return dualTolerance_;} ;
     314  inline void setCurrentDualTolerance(double value)
     315          { dualTolerance_ = value;} ;
    311316  /// Current primal tolerance
    312317  inline double currentPrimalTolerance() const
    313318          { return primalTolerance_;} ;
     319  inline void setCurrentPrimalTolerance(double value)
     320          { primalTolerance_ = value;} ;
    314321  /// How many iterative refinements to do
    315322  inline int numberRefinements() const
     
    475482  inline int lastBadIteration() const
    476483  {return lastBadIteration_;};
     484  /// Progress flag - at present 0 bit says artificials out
     485  inline int progressFlag() const
     486  {return progressFlag_;};
    477487  //@}
    478488
     
    648658  /// Can be used for count of fake bounds (dual) or fake costs (primal)
    649659  int numberFake_;
     660  /// Progress flag - at present 0 bit says artificials out
     661  int progressFlag_;
     662  /// Sum of Dual infeasibilities using tolerance based on error in duals
     663  double sumOfRelaxedDualInfeasibilities_;
     664  /// Sum of Primal infeasibilities using tolerance based on error in primals
     665  double sumOfRelaxedPrimalInfeasibilities_;
    650666  //@}
    651667};
     
    662678ClpSimplexUnitTest(const std::string & mpsDir,
    663679                   const std::string & netlibDir);
     680
     681
     682/// For saving extra information to see if looping. not worth a Class
     683class ClpSimplexProgress {
     684
     685public:
     686
     687
     688  /**@name Constructors and destructor and copy */
     689  //@{
     690  /// Default constructor
     691    ClpSimplexProgress (  );
     692
     693  /// Constructor from model
     694    ClpSimplexProgress ( ClpSimplex * model );
     695
     696  /// Copy constructor.
     697  ClpSimplexProgress(const ClpSimplexProgress &);
     698
     699  /// Assignment operator. This copies the data
     700    ClpSimplexProgress & operator=(const ClpSimplexProgress & rhs);
     701  /// Destructor
     702   ~ClpSimplexProgress (  );
     703  //@}
     704
     705  /**@name Check progress */
     706  //@{
     707  /** Returns -1 if okay, -n+1 (n number of times bad) if bad but action taken,
     708      >=0 if give up and use as problem status
     709  */
     710    int looping (  );
     711
     712  //@}
     713  /**@name Data  */
     714#define CLP_PROGRESS 4
     715  //@{
     716  /// Objective values
     717  double objective_[CLP_PROGRESS];
     718  /// Sum of infeasibilities for algorithm
     719  double infeasibility_[CLP_PROGRESS];
     720  /// Number of infeasibilities
     721  int numberInfeasibilities_[CLP_PROGRESS];
     722  /// Number of times checked (so won't stop too early)
     723  int numberTimes_;
     724  /// Number of times it looked like loop
     725  int numberBadTimes_;
     726  /// Pointer back to model so we can get information
     727  ClpSimplex * model_;
     728  //@}
     729};
    664730#endif
  • branches/devel-1/include/ClpSimplexDual.hpp

    r19 r20  
    209209            - 2 restoring from saved
    210210  */
    211   void statusOfProblemInDual(int & lastCleaned, int type);
     211  void statusOfProblemInDual(int & lastCleaned, int type,
     212                             ClpSimplexProgress & progress);
    212213  /// Perturbs problem (method depends on perturbation())
    213214  void perturb();
  • branches/devel-1/include/ClpSimplexPrimal.hpp

    r19 r20  
    183183            - 2 restoring from saved
    184184  */
    185   void statusOfProblemInPrimal(int & lastCleaned, int type);
     185  void statusOfProblemInPrimal(int & lastCleaned, int type,
     186                             ClpSimplexProgress & progress);
    186187  /// Perturbs problem (method depends on perturbation())
    187188  void perturb();
Note: See TracChangeset for help on using the changeset viewer.