Changeset 926 for branches


Ignore:
Timestamp:
Feb 27, 2007 3:25:03 PM (13 years ago)
Author:
forrest
Message:

correct example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Clp/examples/sprintGub.cpp

    r925 r926  
    1111                   const int * whichColumn,  const int * startSet,
    1212                   const char * rowType,
    13                    int numberGub,double smallFactor)
     13                   int numberGub,double smallFactor,int * sort, int numberSort)
    1414{
    1515  int numberColumns = model.numberColumns();
     
    1717
    1818  // We will need an array to choose variables.
    19   int * sort = new int [numberColumns];
    2019  float * weight = new float [numberColumns];
    2120  const int * ordRow = setToRow+numberGub;
    22   int numberSort=0;
    23   // Set up initial list
    24   numberSort=numberRows;
    25   int i;
    26   for (i=0;i<numberSort;i++)
    27     sort[i] = i;
    2821  // and basic
    2922  int nOrd=numberColumns - startSet[numberGub];
    30   int iRow,iColumn;
     23  int i,iRow,iColumn;
    3124  const double * columnLower = model.columnLower();
    3225  const double * columnUpper = model.columnUpper();
    3326  double * fullSolution = model.primalColumnSolution();
    34   CoinPackedMatrix * matrix = model.matrix();
    35   const int * columnStart = matrix->getVectorStarts();
    36   for (iColumn=numberRows;iColumn<numberColumns;iColumn++) {
    37     if(model.getColumnStatus(iColumn)==ClpSimplex::basic||
    38        columnStart[iColumn+1]==columnStart[iColumn]+1) {
    39       sort[numberSort++]=iColumn;
    40     } else if (fullSolution[iColumn]>columnLower[iColumn]+1.0e-7&&
    41                fullSolution[iColumn]<columnUpper[iColumn]-1.0e-7) {
    42       sort[numberSort++]=iColumn;
    43     }
    44     if (fullSolution[iColumn]>columnLower[iColumn]-1.0e-7&&
    45         fullSolution[iColumn]<columnUpper[iColumn]+1.0e-7) {
    46     } else {
    47       printf("bad %d %g %g %g\n",iColumn,columnLower[iColumn],
    48              fullSolution[iColumn],columnUpper[iColumn]);
    49     }
    50     if (fullSolution[iColumn]<columnLower[iColumn])
    51       fullSolution[iColumn]=columnLower[iColumn];
    52     if (fullSolution[iColumn]>columnUpper[iColumn])
    53       fullSolution[iColumn]=columnUpper[iColumn];
    54   }
    5527  double time1 = CoinCpuTime();
    5628
     
    7446  // Basic counts for each set
    7547  int * counts = new int[numberGub];
    76   memset(counts,0,numberGub*sizeof(int));
     48  // For first pass - say all have counts
     49  for (i=0;i<numberGub;i++)
     50    counts[i]=1;
    7751  // Negative dj counts
    7852  int * negCounts = new int[numberGub];
     
    154128      model.setColumnStatus(kColumn,small.getColumnStatus(iColumn));
    155129      fullSolution[kColumn]=solution[iColumn];
    156       if (fullSolution[iColumn]>columnLower[iColumn]-1.0e-7&&
    157           fullSolution[iColumn]<columnUpper[iColumn]+1.0e-7) {
     130      if (fullSolution[kColumn]>columnLower[kColumn]-1.0e-7&&
     131          fullSolution[kColumn]<columnUpper[kColumn]+1.0e-7) {
    158132      } else {
    159133        printf("bad2 %d\n",iColumn);
     
    162136    model.setObjectiveValue(small.objectiveValue());
    163137    double * rowSol1 = model.primalRowSolution();
    164     double * rowSol2 = small.primalRowSolution();
     138    memset (rowSol1,0,numberRows*sizeof(double));
     139    model.times(1.0,model.primalColumnSolution(),rowSol1);
     140    //double * rowSol2 = small.primalRowSolution();
    165141    double * rowPi1 = model.dualRowSolution();
    166142    double * rowPi2 = small.dualRowSolution();
     
    168144      int jRow = whichRows[iRow];
    169145      model.setRowStatus(jRow,small.getRowStatus(iRow));
    170       rowSol1[jRow] = rowSol2[iRow];
     146      //rowSol1[jRow] = rowSol2[iRow];
    171147      rowPi1[jRow] = rowPi2[iRow];
    172148    }
     
    407383  delete [] negSum;
    408384  delete [] weight;
    409   delete [] sort;
    410385  delete [] whichRows;
    411386  printf("Sprint took %g seconds\n",CoinCpuTime()-time1);
     
    507482    // Get initial list in some magical way
    508483    // Add in your own coding here
    509     abort();
     484    int iColumn;
     485    const double * columnLower = model.columnLower();
     486    const double * columnUpper = model.columnUpper();
     487    double * fullSolution = model.primalColumnSolution();
     488    CoinPackedMatrix * matrix = model.matrix();
     489    const int * columnStart = matrix->getVectorStarts();
     490    int numberColumns = model.numberColumns();
     491    for (iColumn=numberRows;iColumn<numberColumns;iColumn++) {
     492      if(model.getColumnStatus(iColumn)==ClpSimplex::basic||
     493         columnStart[iColumn+1]==columnStart[iColumn]+1) {
     494        sort[numberSort++]=iColumn;
     495      } else if (fullSolution[iColumn]>columnLower[iColumn]+1.0e-7&&
     496                 fullSolution[iColumn]<columnUpper[iColumn]-1.0e-7) {
     497        sort[numberSort++]=iColumn;
     498      }
     499      if (fullSolution[iColumn]>columnLower[iColumn]-1.0e-7&&
     500          fullSolution[iColumn]<columnUpper[iColumn]+1.0e-7) {
     501      } else {
     502        printf("bad %d %g %g %g\n",iColumn,columnLower[iColumn],
     503               fullSolution[iColumn],columnUpper[iColumn]);
     504      }
     505      if (fullSolution[iColumn]<columnLower[iColumn])
     506        fullSolution[iColumn]=columnLower[iColumn];
     507      if (fullSolution[iColumn]>columnUpper[iColumn])
     508        fullSolution[iColumn]=columnUpper[iColumn];
     509    }
    510510  }
    511511  // gub stuff
     
    572572    nOrd=numberColumns-startSet[numberGub];
    573573    printf("%d ordinary columns, %d gub sets\n",nOrd,numberGub);
     574    if (nOrd>numberRows) {
     575      printf("This algorithm only designed for problems with few ordinary columns\n");
     576      exit(77);
     577    }
    574578    assert (numberGub<numberRows); // otherwise array bad
    575579    char * rowType = new char[numberRows];
    576580    memset(rowType,0,numberRows);
    577581    sprint( model, setToRow, whichGub,
    578             whichColumn,  startSet, rowType, numberGub,3);
     582            whichColumn,  startSet, rowType, numberGub,3,sort,numberSort);
    579583    delete [] setToRow;
    580584    delete [] whichGub;
Note: See TracChangeset for help on using the changeset viewer.