Changeset 1073 for branches


Ignore:
Timestamp:
Aug 9, 2007 4:14:03 PM (12 years ago)
Author:
ladanyi
Message:

Got rid of dependency on Data/Netlib?

Location:
branches/BSP/trunk/Clp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/BSP/trunk/Clp/README

    r797 r1073  
    55To use Clp you need the Clp and Coin libraries
    66
    7 To make the unitTest and standalone executable do
     7To make standalone executable do 'make Clp' in the Clp directory.
     8This creates an executable clp in Clp/src.
    89
    9 make unitTest in the Clp directory (or make in Clp/test).  This creates an executable clp.in Clp
     10To run unitTest do 'make unitTest' in the Clp directory. This will
     11do some minimal testing.
     12
     13To run clp on all netlib problems do 'make unitTest NETLIBDIR=<dirname>'
     14dirname should be the path to the directory containing all the
     15netlib files. If you have compiled Clp without zlib support then the
     16files must be uncompressed.
    1017
    1118Running clp gives you some hints.  It can do a unit test (clp -unitTest) and solve netlib
  • branches/BSP/trunk/Clp/src/CbcOrClpParam.cpp

    r1061 r1073  
    14131413    (
    14141414     "This sets the directory which import, export, saveModel, restoreModel etc will use.\
     1415  This is also the directory where the netlib problems are read from when unitTest\
     1416  is invoked with -netlib or -netlibp.\
    14151417  It is initialized to './'"
    14161418     );
  • branches/BSP/trunk/Clp/src/ClpMain.cpp

    r1070 r1073  
    9797    models->messageHandler()->setPrefix(false);
    9898    const char dirsep =  CoinFindDirSeparator();
    99     std::string directory = (dirsep == '/' ? "./" : ".\\");
     99    std::string directory = ".";
    100100    std::string defaultDirectory = directory;
    101101    std::string importFile ="";
     
    13731373              // create fields for unitTest
    13741374              const char * fields[4];
    1375               int nFields=2;
    13761375              fields[0]="fake main from unitTest";
    13771376              fields[1]="-netlib";
    1378               if (directory!=defaultDirectory) {
    1379                 fields[2]="-netlibDir";
    1380                 fields[3]=directory.c_str();
    1381                 nFields=4;
    1382               }
     1377              fields[2]="-directory";
     1378              fields[3]=directory.c_str();
     1379              int nFields=4;
    13831380              int algorithm;
    13841381              if (type==NETLIB_DUAL) {
     
    14091406            {
    14101407              // create fields for unitTest
    1411               const char * fields[3];
    1412               int nFields=1;
     1408              const char * fields[4];
    14131409              fields[0]="fake main from unitTest";
    1414               if (directory!=defaultDirectory) {
    1415                 fields[1]="-mpsDir";
    1416                 fields[2]=directory.c_str();
    1417                 nFields=3;
    1418               }
     1410              fields[1]="-unitTest";
     1411              fields[2]="-directory";
     1412              fields[3]=directory.c_str();
     1413              int nFields=4;
    14191414              int specialOptions = models[iModel].specialOptions();
    14201415              models[iModel].setSpecialOptions(0);
  • branches/BSP/trunk/Clp/src/ClpSimplex.hpp

    r1055 r1073  
    5050
    5151class ClpSimplex : public ClpModel {
    52    friend void ClpSimplexUnitTest(const std::string & mpsDir,
    53                                   const std::string & netlibDir);
     52  friend void ClpSimplexUnitTest(const std::string & directory);
    5453
    5554public:
     
    12811280 */
    12821281void
    1283 ClpSimplexUnitTest(const std::string & mpsDir,
    1284                    const std::string & netlibDir);
     1282ClpSimplexUnitTest(const std::string & directory);
    12851283
    12861284
  • branches/BSP/trunk/Clp/src/unitTest.cpp

    r1056 r1073  
    227227  printf("Computed objective %g\n",objValue);
    228228}
    229 //----------------------------------------------------------------
    230 // unitTest [-mpsDir=V1] [-netlibDir=V2] [-test]
    231 //
    232 // where:
    233 //   -mpsDir: directory containing mps test files
    234 //       Default value V1="../../Data/Sample"   
    235 //   -netlibDir: directory containing netlib files
    236 //       Default value V2="../../Data/Netlib"
    237 //   -test
    238 //       If specified, then netlib test set run
    239 //
    240 // All parameters are optional.
     229
     230static void usage()
     231{
     232  std::cerr <<"Correct usage for running clp in testing mode: \n"
     233            <<"  clp -directory DIR  <-unitTest|-netlib> "
     234            <<"    where:\n"
     235            <<"      -directory: directory containing mps test files\n"
     236            <<"                  Must be specified.\n"
     237            <<"      -unitTest or -netlib specifies whether a small sample should be run\n"
     238            <<"          or the full set pf netlib problems.\n"
     239            <<"          One of them must be specified.\n";
     240}
     241
    241242//----------------------------------------------------------------
    242243int mainTest (int argc, const char *argv[],int algorithm,
    243244              ClpSimplex empty, bool doPresolve, int switchOffValue,bool doVector)
    244245{
    245   int i;
    246 
    247246  if (switchOffValue>0) {
    248247    // switch off some
     
    256255  }
    257256
    258   // define valid parameter keywords
    259   std::set<std::string> definedKeyWords;
    260   definedKeyWords.insert("-mpsDir");
    261   definedKeyWords.insert("-netlibDir");
    262   definedKeyWords.insert("-netlib");
    263 
    264   // Create a map of parameter keys and associated data
    265   std::map<std::string,std::string> parms;
    266   for ( i=1; i<argc; i++ ) {
    267     std::string parm(argv[i]);
    268     std::string key,value;
    269     std::string::size_type  eqPos = parm.find('=');
    270 
    271     // Does parm contain and '='
    272     if ( eqPos==std::string::npos ) {
    273       //Parm does not contain '='
    274       key = parm;
    275     }
    276     else {
    277       key=parm.substr(0,eqPos);
    278       value=parm.substr(eqPos+1);
    279     }
    280 
    281     // Is specifed key valid?
    282     if ( definedKeyWords.find(key) == definedKeyWords.end() ) {
    283       // invalid key word.
    284       // Write help text
    285       std::cerr <<"Undefined parameter \"" <<key <<"\".\n";
    286       std::cerr <<"Correct usage: \n";
    287       std::cerr <<"  unitTest [-mpsDir=V1] [-netlibDir=V2] [-test[=V3]]\n";
    288       std::cerr <<"  where:\n";
    289       std::cerr <<"    -mpsDir: directory containing mps test files\n";
    290       std::cerr <<"        Default value V1=\"../../Data/Sample\"\n";
    291       std::cerr <<"    -netlibDir: directory containing netlib files\n";
    292       std::cerr <<"        Default value V2=\"../../Data/Netlib\"\n";
    293       std::cerr <<"    -test\n";
    294       std::cerr <<"        If specified, then netlib testset run.\n";
    295       std::cerr <<"        If V3 then taken as single file\n";
    296       return 1;
    297     }
    298     parms[key]=value;
     257  bool netlib = false;
     258  bool singleprob = empty.numberRows() > 0;
     259
     260  if (argc != 4) {
     261    usage();
     262    return 1;
    299263  }
    300264 
    301   const char dirsep =  CoinFindDirSeparator();
     265  if (strncmp(argv[1], "-unitTest", 9) == 0) {
     266    netlib = false;
     267  } else if (strncmp(argv[1], "-netlib", 7) == 0) {
     268    netlib = true;
     269  } else {
     270    usage();
     271    return 1;
     272  }
     273 
     274  if (strncmp(argv[2], "-directory", 9) != 0) {
     275    usage();
     276    return 1;
     277  }
    302278  // Set directory containing mps data files.
    303   std::string mpsDir;
    304   if (parms.find("-mpsDir") != parms.end())
    305     mpsDir=parms["-mpsDir"] + dirsep;
    306   else
    307     mpsDir = dirsep == '/' ? "../../Data/Sample/" : "..\\..\\Data\\Sample\\";
    308  
    309   // Set directory containing netlib data files.
    310   std::string netlibDir;
    311   if (parms.find("-netlibDir") != parms.end())
    312     netlibDir=parms["-netlibDir"] + dirsep;
    313   else
    314     netlibDir = dirsep == '/' ? "../../Data/Netlib/" : "..\\..\\Data\\Netlib\\";
    315   if (!empty.numberRows()) {
    316     testingMessage( "Testing ClpSimplex\n" );
    317     ClpSimplexUnitTest(mpsDir,netlibDir);
    318   }
    319   if (parms.find("-netlib") != parms.end()||empty.numberRows())
    320   {
     279  std::string directory(argv[3]);
     280
     281  if (!netlib) {
     282    testingMessage( "Testing clp -unitTest\n" );
     283    ClpSimplexUnitTest(directory);
     284  }
     285
     286  if (netlib) {
    321287    unsigned int m;
    322288   
     
    334300    // 100 added means no presolve
    335301    std::vector<int> bestStrategy;
    336     if(empty.numberRows()) {
     302
     303    if (singleprob) {
     304      testingMessage( "Testing clp on a single netlib problemx\n" );
     305      // Just testing one
     306      mpsName.push_back(empty.problemName());min.push_back(true);nRows.push_back(-1);
     307      nCols.push_back(-1);objValueTol.push_back(1.e-10);
     308      objValue.push_back(0.0);bestStrategy.push_back(0);
     309      int iTest;
    337310      std::string alg;
    338       for (int iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) {
     311      for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) {
    339312        ClpSolve solveOptions=setupForSolve(iTest,alg,0);
    340313        printf("%d %s ",iTest,alg.c_str());
     
    346319          printf("will be tested\n");
    347320      }
    348     }
    349     if (!empty.numberRows()) {
     321    } else {
     322      testingMessage( "Testing clp -netlib\n" );
    350323      mpsName.push_back("25fv47");
    351324      min.push_back(true);
     
    449422      mpsName.push_back("wood1p");min.push_back(true);nRows.push_back(245);nCols.push_back(2594);objValueTol.push_back(5.e-5);objValue.push_back(1.4429024116e+00);bestStrategy.push_back(3);
    450423      mpsName.push_back("woodw");min.push_back(true);nRows.push_back(1099);nCols.push_back(8405);objValueTol.push_back(1.e-10);objValue.push_back(1.3044763331E+00);bestStrategy.push_back(3);
    451     } else {
    452       // Just testing one
    453       mpsName.push_back(empty.problemName());min.push_back(true);nRows.push_back(-1);
    454       nCols.push_back(-1);objValueTol.push_back(1.e-10);
    455       objValue.push_back(0.0);bestStrategy.push_back(0);
    456       int iTest;
    457       std::string alg;
    458       for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) {
    459         ClpSolve solveOptions=setupForSolve(iTest,alg,0);
    460         printf("%d %s ",iTest,alg.c_str());
    461         if (switchOff[iTest])
    462           printf("skipped by user\n");
    463         else if(solveOptions.getSolveType()==ClpSolve::notImplemented)
    464           printf("skipped as not available\n");
    465         else
    466           printf("will be tested\n");
    467       }
    468424    }
    469425
     
    477433
    478434      ClpSimplex solutionBase=empty;
    479       std::string fn = netlibDir+mpsName[m];
     435      std::string fn = directory+mpsName[m];
    480436      if (!empty.numberRows()||algorithm<6) {
    481437        // Read data mps file,
     
    622578    printf("Total time %g seconds\n",timeTaken);
    623579  }
    624   else {
    625     testingMessage( "***Skipped Testing on netlib    ***\n" );
    626     testingMessage( "***use -netlib to test class***\n" );
    627   }
    628580 
    629581  testingMessage( "All tests completed successfully\n" );
     
    643595// test factorization methods and simplex method and simple barrier
    644596void
    645 ClpSimplexUnitTest(const std::string & mpsDir,
    646                    const std::string & netlibDir)
     597ClpSimplexUnitTest(const std::string & directory)
    647598{
    648599 
     
    765716  {   
    766717    CoinMpsIO m;
    767     std::string fn = mpsDir+"exmip1";
     718    std::string fn = directory+"exmip1";
    768719    m.readMps(fn.c_str(),"mps");
    769720    ClpSimplex solution;
     
    785736  {   
    786737    CoinMpsIO m;
    787     std::string fn = mpsDir+"exmip1";
     738    std::string fn = directory+"exmip1";
    788739    //fn = "Test/subGams4";
    789740    m.readMps(fn.c_str(),"mps");
     
    836787  {   
    837788    CoinMpsIO m;
    838     std::string fn = mpsDir+"exmip1";
     789    std::string fn = directory+"exmip1";
    839790    m.readMps(fn.c_str(),"mps");
    840791    ClpSimplex model;
     
    895846  {   
    896847    CoinMpsIO m;
    897     std::string fn = mpsDir+"exmip1";
     848    std::string fn = directory+"exmip1";
    898849    m.readMps(fn.c_str(),"mps");
    899850    ClpSimplex model;
     
    998949  {   
    999950    CoinMpsIO m;
    1000     std::string fn = netlibDir+"finnis";
     951    std::string fn = directory+"finnis";
    1001952    int returnCode = m.readMps(fn.c_str(),"mps");
    1002953    if (returnCode) {
    1003954      // probable cause is that gz not there
    1004       fprintf(stderr,"Unable to open finnis.mps in COIN/Mps/Netlib!\n");
     955      fprintf(stderr,"Unable to open finnis.mps in %s!\n", directory.c_str());
    1005956      fprintf(stderr,"Most probable cause is finnis.mps is gzipped i.e. finnis.mps.gz and libz has not been activated\n");
    1006957      fprintf(stderr,"Either gunzip files or edit Makefiles/Makefile.location to get libz\n");
     
    1028979  {   
    1029980    CoinMpsIO m;
    1030     std::string fn = netlibDir+"afiro";
     981    std::string fn = directory+"afiro";
    1031982    m.readMps(fn.c_str(),"mps");
    1032983    ClpSimplex solution;
     
    11151066  {   
    11161067    CoinMpsIO m;
    1117     std::string fn = netlibDir+"brandy";
     1068    std::string fn = directory+"brandy";
    11181069    m.readMps(fn.c_str(),"mps");
    11191070    ClpSimplex solution;
     
    11871138  {   
    11881139    CoinMpsIO m;
    1189     std::string fn = netlibDir+"brandy";
     1140    std::string fn = directory+"brandy";
    11901141    m.readMps(fn.c_str(),"mps");
    11911142    ClpSimplex solution;
     
    12761227  {   
    12771228    CoinMpsIO m;
    1278     std::string fn = netlibDir+"brandy";
     1229    std::string fn = directory+"brandy";
    12791230    m.readMps(fn.c_str(),"mps");
    12801231    ClpSimplex solution;
     
    14551406  {
    14561407    CoinMpsIO m;
    1457     std::string fn = mpsDir+"exmip1";
     1408    std::string fn = directory+"exmip1";
    14581409    m.readMps(fn.c_str(),"mps");
    14591410    ClpInterior solution;
     
    14671418#define QUADRATIC
    14681419  if (1) {   
    1469     std::string fn = mpsDir+"input.130";
     1420    std::string fn = directory+"input.130";
    14701421    int numberColumns;
    14711422    int numberRows;
     
    14731424    FILE * fp = fopen(fn.c_str(),"r");
    14741425    if (!fp) {
    1475       // Try in Data/Sample
    1476       fn = "Data/Sample/input.130";
    1477       fp = fopen(fn.c_str(),"r");
    1478     }
    1479     if (!fp) {
    1480       fprintf(stderr,"Unable to open file input.130 in mpsDir or Data/Sample directory\n");
     1426      fprintf(stderr,"Unable to open file input.130 in directory %s\n",
     1427              directory.c_str());
    14811428    } else {
    14821429      int problem;
     
    16441591  if (1) {   
    16451592    CoinMpsIO m;
    1646     std::string fn = mpsDir+"exmip1";
     1593    std::string fn = directory+"exmip1";
    16471594    m.readMps(fn.c_str(),"mps");
    16481595    ClpSimplex solution;
     
    16891636  if (1) {   
    16901637    CoinMpsIO m;
    1691     std::string fn = mpsDir+"share2qp";
     1638    std::string fn = directory+"share2qp";
    16921639    //fn = "share2qpb";
    16931640    m.readMps(fn.c_str(),"mps");
  • branches/BSP/trunk/Clp/test/Makefile.am

    r915 r1073  
    1515# We are using the CLP solver executable to do the unit test
    1616test: ../src/clp$(EXEEXT)
    17         cd ../../Data/Netlib; $(MAKE) uncompress
    18         ../src/clp$(EXEEXT) -unitTest -netlib -netlibp
     17        ../src/clp$(EXEEXT) -directory ../../Data/Sample -unitTest
     18        if test x"$(NETLIBDIR)" != x; then \
     19                ../src/clp$(EXEEXT) -directory $(NETLIBDIR) -netlib -netlibp ; \
     20        fi
    1921
    2022.PHONY: test
  • branches/BSP/trunk/Clp/test/Makefile.in

    r915 r1073  
    371371# We are using the CLP solver executable to do the unit test
    372372test: ../src/clp$(EXEEXT)
    373         cd ../../Data/Netlib; $(MAKE) uncompress
    374         ../src/clp$(EXEEXT) -unitTest -netlib -netlibp
     373        ../src/clp$(EXEEXT) -directory ../../Data/Sample -unitTest
     374        if test x"$(NETLIBDIR)" != x; then \
     375                ../src/clp$(EXEEXT) -directory $(NETLIBDIR) -netlib -netlibp ; \
     376        fi
    375377
    376378.PHONY: test
Note: See TracChangeset for help on using the changeset viewer.