Changeset 641


Ignore:
Timestamp:
Jun 26, 2007 5:18:19 AM (12 years ago)
Author:
forrest
Message:

moving devel unit test

Location:
trunk/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/unitTest.cpp

    r325 r641  
    309309// where:
    310310//   -miplibDir: directory containing miplib files
    311 //       Default value V2="./Samples/miplib3"
     311//       Default value V2="./examples/miplib3"
    312312//
    313313// All parameters are optional.
     
    349349      std::cerr <<"  where:\n";
    350350      std::cerr <<"    -miplibDir: directory containing miplib files\n";
    351       std::cerr <<"        Default value V2=\"./Samples/miplib3\"\n";
     351      std::cerr <<"        Default value V2=\"./Data/miplib3\"\n";
    352352      return 1;
    353353    }
     
    362362    miplibDir=parms["-miplibDir"] + dirsep;
    363363  else
    364     miplibDir = dirsep == '/' ? "./Samples/miplib3/" : ".\\Samples\\miplib3\\";
     364    miplibDir = dirsep == '/' ? "./Data/miplib3/" : ".\\Data\\miplib3\\";
    365365#ifdef COIN_HAS_CBC
    366366
  • trunk/Cbc/src/unitTestClp.cpp

    r624 r641  
    1616#include "CoinTime.hpp"
    1717#include "CbcModel.hpp"
     18#include "CbcCutGenerator.hpp"
    1819#include "OsiClpSolverInterface.hpp"
    1920#include "ClpFactorization.hpp"
     
    200201//----------------------------------------------------------------
    201202int mainTest (int argc, const char *argv[],int algorithm,
    202               ClpSimplex empty, bool doPresolve, int switchOffValue)
     203              ClpSimplex empty, bool doPresolve, int switchOffValue,bool doVector)
    203204{
    204205  int i;
     
    462463            if (solution.maximumSeconds()<0.0)
    463464              solution.setMaximumSeconds(120.0);
     465            if (doVector) {
     466              ClpMatrixBase * matrix = solution.clpMatrix();
     467              if (dynamic_cast< ClpPackedMatrix*>(matrix)) {
     468                ClpPackedMatrix * clpMatrix = dynamic_cast< ClpPackedMatrix*>(matrix);
     469                clpMatrix->makeSpecialColumnCopy();
     470              }
     471            }
    464472            solution.initialSolve(solveOptions);
    465473            double time2 = CoinCpuTime()-time1;
     
    549557        if (presolveOff)
    550558          solveOptions.setPresolveType(ClpSolve::presolveOff);
     559      }
     560      if (doVector) {
     561        ClpMatrixBase * matrix = solution.clpMatrix();
     562        if (dynamic_cast< ClpPackedMatrix*>(matrix)) {
     563          ClpPackedMatrix * clpMatrix = dynamic_cast< ClpPackedMatrix*>(matrix);
     564          clpMatrix->makeSpecialColumnCopy();
     565        }
    551566      }
    552567      solution.initialSolve(solveOptions);
     
    857872             i,valueIncrease[i],sequenceIncrease[i],
    858873             valueDecrease[i],sequenceDecrease[i]);
    859     //assert (fabs(valueDecrease[3]-0.642857)<1.0e-4);
    860     //assert (fabs(valueDecrease[8]-2.95113)<1.0e-4);
     874    assert (fabs(valueDecrease[3]-0.642857)<1.0e-4);
     875    assert (fabs(valueDecrease[8]-2.95113)<1.0e-4);
    861876#if 0
    862877    // out until I find optimization bug
     
    14151430    FILE * fp = fopen(fn.c_str(),"r");
    14161431    if (!fp) {
    1417       // Try in Samples
    1418       fn = "Samples/input.130";
     1432      // Try in Data
     1433      fn = "Data/Sample/input.130";
    14191434      fp = fopen(fn.c_str(),"r");
    14201435    }
    14211436    if (!fp) {
    1422       fprintf(stderr,"Unable to open file input.130 in mpsDir or Samples directory\n");
     1437      fprintf(stderr,"Unable to open file input.130 in mpsDir or Data/Sample directory\n");
    14231438    } else {
    14241439      int problem;
     
    19371952
    19381953    double startTime = CoinCpuTime();
    1939     model->setMaximumNodes(100000);
     1954    model->setMaximumNodes(200000);
    19401955    OsiClpSolverInterface * si =
    19411956      dynamic_cast<OsiClpSolverInterface *>(model->solver()) ;
     
    19451960    modelC->tightenPrimalBounds();
    19461961    model->initialSolve();
     1962    if (modelC->dualBound()==1.0e10) {
     1963      // user did not set - so modify
     1964      // get largest scaled away from bound
     1965      double largest=1.0e-12;
     1966      int numberRows = modelC->numberRows();
     1967      const double * rowPrimal = modelC->primalRowSolution();
     1968      const double * rowLower = modelC->rowLower();
     1969      const double * rowUpper = modelC->rowUpper();
     1970      const double * rowScale = modelC->rowScale();
     1971      int iRow;
     1972      for (iRow=0;iRow<numberRows;iRow++) {
     1973        double value = rowPrimal[iRow];
     1974        double above = value-rowLower[iRow];
     1975        double below = rowUpper[iRow]-value;
     1976        if (rowScale) {
     1977          double multiplier = rowScale[iRow];
     1978          above *= multiplier;
     1979          below *= multiplier;
     1980        }
     1981        if (above<1.0e12)
     1982          largest = CoinMax(largest,above);
     1983        if (below<1.0e12)
     1984          largest = CoinMax(largest,below);
     1985      }
     1986     
     1987      int numberColumns = modelC->numberColumns();
     1988      const double * columnPrimal = modelC->primalColumnSolution();
     1989      const double * columnLower = modelC->columnLower();
     1990      const double * columnUpper = modelC->columnUpper();
     1991      const double * columnScale = modelC->columnScale();
     1992      int iColumn;
     1993      for (iColumn=0;iColumn<numberColumns;iColumn++) {
     1994        double value = columnPrimal[iColumn];
     1995        double above = value-columnLower[iColumn];
     1996        double below = columnUpper[iColumn]-value;
     1997        if (columnScale) {
     1998          double multiplier = 1.0/columnScale[iColumn];
     1999          above *= multiplier;
     2000          below *= multiplier;
     2001        }
     2002        if (above<1.0e12)
     2003          largest = CoinMax(largest,above);
     2004        if (below<1.0e12)
     2005          largest = CoinMax(largest,below);
     2006      }
     2007      //std::cout<<"Largest (scaled) away from bound "<<largest<<std::endl;
     2008      modelC->setDualBound(CoinMax(1.0001e8,CoinMin(1000.0*largest,1.00001e10)));
     2009    }
    19472010    model->setMinimumDrop(min(5.0e-2,
    19482011                                 fabs(model->getMinimizationObjValue())*1.0e-3+1.0e-4));
     
    19562019     
    19572020    double timeOfSolution = CoinCpuTime()-startTime;
     2021    // Print more statistics
     2022    std::cout<<"Cuts at root node changed objective from "<<model->getContinuousObjective()
     2023             <<" to "<<model->rootObjectiveAfterCuts()<<std::endl;
     2024    int numberGenerators = model->numberCutGenerators();
     2025    for (int iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     2026      CbcCutGenerator * generator = model->cutGenerator(iGenerator);
     2027      std::cout<<generator->cutGeneratorName()<<" was tried "
     2028               <<generator->numberTimesEntered()<<" times and created "
     2029               <<generator->numberCutsInTotal()<<" cuts of which "
     2030               <<generator->numberCutsActive()<<" were active after adding rounds of cuts";
     2031      if (generator->timing())
     2032        std::cout<<" ( "<<generator->timeInCutGenerator()<<" seconds)"<<std::endl;
     2033      else
     2034        std::cout<<std::endl;
     2035    }
    19582036    if (!model->status()) {
    19592037      double soln = model->getObjValue();       
Note: See TracChangeset for help on using the changeset viewer.