Changeset 648


Ignore:
Timestamp:
Jul 3, 2005 12:40:47 PM (16 years ago)
Author:
forrest
Message:

stuff

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpMessage.cpp

    r618 r648  
    114114  language_=language;
    115115  strcpy(source_,"Clp");
     116  class_ = 1; //solver
    116117  Clp_message * message = us_english;
    117118
  • trunk/ClpModel.cpp

    r647 r648  
    10231023  }
    10241024  numberColumns_ = newNumberColumns;
    1025   // for now gets rid of names
    1026   lengthNames_ = 0;
    1027   rowNames_ = std::vector<std::string> ();
    1028   columnNames_ = std::vector<std::string> ();
     1025  if (lengthNames_) {
     1026    // reduce row and column names vectors only if necessary
     1027    if (rowNames_.size() < (unsigned int)numberRows_)
     1028      rowNames_.resize(numberRows_);
     1029    if (columnNames_.size() < (unsigned int)numberColumns_)
     1030      columnNames_.resize(numberColumns_);
     1031  }
    10291032}
    10301033// Deletes rows
     
    10681071  }
    10691072#if 1
     1073  // Now works if which out of order
    10701074  if (lengthNames_) {
    1071     int i, j, k;
    1072     for (k = 0, j = 0, i = 0; j < number && i < numberRows_; ++i) {
    1073       if (which[j] == i) {
    1074         ++j;
    1075       } else {
     1075    char * mark = new char [numberRows_];
     1076    memset(mark,0,numberRows_);
     1077    int i;
     1078    for (i=0;i<number;i++)
     1079      mark[which[i]]=1;
     1080    int k=0;
     1081    for ( i = 0; i < numberRows_; ++i) {
     1082      if (!mark[i])
    10761083        rowNames_[k++] = rowNames_[i];
    1077       }
    1078     }
    1079     for ( ; i < numberRows_; ++i) {
    1080       rowNames_[k++] = rowNames_[i];
    10811084    }
    10821085    rowNames_.erase(rowNames_.begin()+k, rowNames_.end());
     1086    delete [] mark;
    10831087  }
    10841088#else
     
    11531157                            number, which, newSize,true);
    11541158#if 1
     1159  // Now works if which out of order
    11551160  if (lengthNames_) {
    1156     int i, j, k;
    1157     for (k = 0, j = 0, i = 0; j < number && i < numberColumns_; ++i) {
    1158       if (which[j] == i) {
    1159         ++j;
    1160       } else {
     1161    printf("size of names %d\n",columnNames_.size());
     1162    char * mark = new char [numberColumns_];
     1163    memset(mark,0,numberColumns_);
     1164    int i;
     1165    for (i=0;i<number;i++)
     1166      mark[which[i]]=1;
     1167    int k=0;
     1168    for ( i = 0; i < numberColumns_; ++i) {
     1169      if (!mark[i])
    11611170        columnNames_[k++] = columnNames_[i];
    1162       }
    1163     }
    1164     for ( ; i < numberColumns_; ++i) {
    1165       columnNames_[k++] = columnNames_[i];
    11661171    }
    11671172    columnNames_.erase(columnNames_.begin()+k, columnNames_.end());
     1173    delete [] mark;
    11681174  }
    11691175#else
     
    12961302  delete [] columnScale_;
    12971303  columnScale_ = NULL;
     1304  if (lengthNames_) {
     1305    rowNames_.resize(numberRows_);
     1306  }
    12981307}
    12991308// Add rows from a build object
     
    13011310ClpModel::addRows(const CoinBuild & buildObject,bool tryPlusMinusOne,bool checkDuplicates)
    13021311{
    1303   if (buildObject.numberElements()==0)
    1304     return 0;
    13051312  CoinAssertHint (buildObject.type()==0,"Looks as if both addRows and addCols being used"); // check correct
    13061313  int number = buildObject.numberRows();
     
    17481755  delete [] columnScale_;
    17491756  columnScale_ = NULL;
     1757  if (lengthNames_) {
     1758    columnNames_.resize(numberColumns_);
     1759  }
    17501760}
    17511761// Add columns from a build object
     
    17531763ClpModel::addColumns(const CoinBuild & buildObject,bool tryPlusMinusOne,bool checkDuplicates)
    17541764{
    1755   if (buildObject.numberElements()==0)
    1756     return 0;
    17571765  CoinAssertHint (buildObject.type()==1,"Looks as if both addRows and addCols being used"); // check correct
    17581766  int number = buildObject.numberColumns();
  • trunk/ClpSimplexOther.cpp

    r636 r648  
    205205                                 double & costDecrease, int & sequenceDecrease, double & alphaDecrease)
    206206{
    207   double acceptablePivot = 1.0e-7;
     207  double acceptablePivot = 1.0e-9;
    208208  double * work;
    209209  int number;
     
    20232023  int returnCode = -1;
    20242024  double saveSumDual = sumDualInfeasibilities_; // so we know to be careful
    2025   //double useTheta = startingTheta;
     2025  double useTheta = startingTheta;
    20262026  double * primalChange = new double[numberRows_];
    20272027  double * dualChange = new double[numberColumns_];
    20282028  int numberTotal = numberColumns_+numberRows_;
    2029 
     2029  int iSequence;
     2030  // See if bounds
     2031  int type=0;
     2032  for (iSequence=0;iSequence<numberTotal;iSequence++) {
     2033    if (changeLower[iSequence]||changeUpper[iSequence]) {
     2034      type=1;
     2035      break;
     2036    }
     2037  }
     2038  // See if objective
     2039  for (iSequence=0;iSequence<numberTotal;iSequence++) {
     2040    if (changeObjective[iSequence]) {
     2041      type |= 2;
     2042      break;
     2043    }
     2044  }
     2045  assert (type);
    20302046  while (problemStatus_==-1) {
    2031 
     2047    double increaseTheta = CoinMin(endingTheta-useTheta,1.0e50);
     2048   
    20322049    // Get theta for bounds - we know can't crossover
    2033     // get change
    2034     int iSequence;
    2035     for (iSequence=0;iSequence<numberTotal;iSequence++) {
    2036       primalChange[iSequence]=0.0;
    2037       switch(getStatus(iSequence)) {
    2038        
    2039       case basic:
    2040       case isFree:
    2041       case superBasic:
    2042         break;
    2043       case isFixed:
    2044       case atUpperBound:
    2045         primalChange[iSequence]=changeUpper[iSequence];
    2046         break;
    2047       case atLowerBound:
    2048         primalChange[iSequence]=changeLower[iSequence];
    2049         break;
    2050       }
    2051     }
    2052     // use rowActivity
    2053     memset(rowActivity_,0,numberRows_*sizeof(double));
    2054     times(1.0,primalChange,rowActivity_);
    2055    
     2050    int pivotType = nextTheta(type,increaseTheta,primalChange,dualChange,
     2051                              changeLower,changeUpper,changeObjective);
     2052    if (pivotType)
     2053      abort();
    20562054    // choose row to go out
    20572055    // dualRow will go to virtual row pivot choice algorithm
     
    24972495  return returnCode;
    24982496}
     2497// Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none)
     2498int
     2499ClpSimplexOther::nextTheta(int type, double maxTheta, double * primalChange, double * dualChange,
     2500                           const double * changeLower, const double * changeUpper,
     2501                           const double * changeObjective)
     2502{
     2503  int numberTotal = numberColumns_+numberRows_;
     2504  int iSequence;
     2505  int iRow;
     2506  theta_=maxTheta;
     2507  bool toLower=false;
     2508  if ((type&1)!=0) {
     2509    // get change
     2510    for (iSequence=0;iSequence<numberTotal;iSequence++) {
     2511      primalChange[iSequence]=0.0;
     2512      switch(getStatus(iSequence)) {
     2513       
     2514      case basic:
     2515      case isFree:
     2516      case superBasic:
     2517        break;
     2518      case isFixed:
     2519      case atUpperBound:
     2520        primalChange[iSequence]=changeUpper[iSequence];
     2521        break;
     2522      case atLowerBound:
     2523        primalChange[iSequence]=changeLower[iSequence];
     2524        break;
     2525      }
     2526    }
     2527    // use array
     2528    double * array = rowArray_[1]->denseVector();
     2529    times(1.0,primalChange,array);
     2530    int * index = rowArray_[1]->getIndices();
     2531    int number=0;
     2532    for (iRow=0;iRow<numberRows_;iRow++) {
     2533      double value = array[iRow];
     2534      if (value) {
     2535        array[iRow]=value;
     2536        index[number++]=iRow;
     2537      }
     2538    }
     2539    // ftran it
     2540    rowArray_[1]->setNumElements(number);
     2541    factorization_->updateColumn(rowArray_[0],rowArray_[1]);
     2542    number=rowArray_[1]->getNumElements();
     2543    pivotRow_=-1;
     2544    for (iRow=0;iRow<number;iRow++) {
     2545      int iPivot = index[iRow];
     2546      iSequence = pivotVariable_[iPivot];
     2547      // solution value will be sol - theta*alpha
     2548      // bounds will be bounds + change *theta
     2549      double currentSolution = solution_[iSequence];
     2550      double currentLower = lower_[iSequence];
     2551      double currentUpper = upper_[iSequence];
     2552      double alpha = array[iPivot];
     2553      assert (currentSolution>=currentLower-primalTolerance_);
     2554      assert (currentSolution<=currentUpper+primalTolerance_);
     2555      double thetaCoefficient;
     2556      double hitsLower = COIN_DBL_MAX;
     2557      thetaCoefficient = changeLower[iSequence]+alpha;
     2558      if (fabs(thetaCoefficient)>1.0e-8)
     2559        hitsLower = (currentSolution-currentLower)/thetaCoefficient;
     2560      if (hitsLower<0.0) {
     2561        // does not hit - but should we check further
     2562        hitsLower=COIN_DBL_MAX;
     2563      }
     2564      double hitsUpper = COIN_DBL_MAX;
     2565      thetaCoefficient = changeUpper[iSequence]+alpha;
     2566      if (fabs(thetaCoefficient)>1.0e-8)
     2567        hitsUpper = (currentSolution-currentUpper)/thetaCoefficient;
     2568      if (hitsUpper<0.0) {
     2569        // does not hit - but should we check further
     2570        hitsUpper=COIN_DBL_MAX;
     2571      }
     2572      if (CoinMin(hitsLower,hitsUpper)<theta_) {
     2573        theta_ = CoinMin(hitsLower,hitsUpper);
     2574        toLower = hitsLower<hitsUpper;
     2575        pivotRow_=iPivot;
     2576      }
     2577    }
     2578  }
     2579  if ((type&2)!=0) {
     2580    abort();
     2581  }
     2582  if (pivotRow_>=0) {
     2583    sequenceOut_ = pivotVariable_[pivotRow_];
     2584    valueOut_ = solution_[sequenceOut_];
     2585    lowerOut_ = lower_[sequenceOut_];
     2586    upperOut_ = upper_[sequenceOut_];
     2587    if (!toLower) {
     2588      directionOut_ = -1;
     2589      dualOut_ = valueOut_ - upperOut_;
     2590    } else if (valueOut_<lowerOut_) {
     2591      directionOut_ = 1;
     2592      dualOut_ = lowerOut_ - valueOut_;
     2593    }
     2594    return 0;
     2595  } else {
     2596    return -1;
     2597  }
     2598}
  • trunk/ClpSolve.cpp

    r618 r648  
    376376    saveSignal = signal(SIGINT,signal_handler);
    377377  }
     378  // If no status array - set up basis
     379  if (!status_)
     380    allSlackBasis();
    378381  ClpPresolve pinfo;
    379382  pinfo.setSubstitution(options.substitution());
  • trunk/Makefile.Clp

    r599 r648  
    77# between then specify the exact level you want, e.g., -O1 or -O2
    88OptLevel := -g
    9 OptLevel := -O1
     9#OptLevel := -O1
    1010
    1111LIBNAME := Clp
  • trunk/include/ClpSimplex.hpp

    r645 r648  
    210210  */
    211211  int dual(int ifValuesPass=0, int startFinishOptions=0);
    212   /// For debug
     212  // If using Debug
    213213  int dualDebug(int ifValuesPass=0, int startFinishOptions=0);
    214214  /** Primal algorithm - see ClpSimplexPrimal.hpp for method.
  • trunk/include/ClpSimplexOther.hpp

    r636 r648  
    102102                      const double * changeLower, const double * changeUpper,
    103103                      const double * changeObjective);
     104  /** Computes next theta and says if objective or bounds (0= bounds, 1 objective, -1 none).
     105      theta is in theta_.
     106      type 1 bounds, 2 objective, 3 both.
     107  */
     108  int nextTheta(int type, double maxTheta, double * primalChange, double * dualChange,
     109                      const double * changeLower, const double * changeUpper,
     110                      const double * changeObjective);
    104111  /**
    105112      Row array has row part of pivot row
Note: See TracChangeset for help on using the changeset viewer.