Changeset 1073
- Timestamp:
- Aug 9, 2007 4:14:03 PM (14 years ago)
- Location:
- branches/BSP/trunk/Clp
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BSP/trunk/Clp/README
r797 r1073 5 5 To use Clp you need the Clp and Coin libraries 6 6 7 To make the unitTest and standalone executable do 7 To make standalone executable do 'make Clp' in the Clp directory. 8 This creates an executable clp in Clp/src. 8 9 9 make unitTest in the Clp directory (or make in Clp/test). This creates an executable clp.in Clp 10 To run unitTest do 'make unitTest' in the Clp directory. This will 11 do some minimal testing. 12 13 To run clp on all netlib problems do 'make unitTest NETLIBDIR=<dirname>' 14 dirname should be the path to the directory containing all the 15 netlib files. If you have compiled Clp without zlib support then the 16 files must be uncompressed. 10 17 11 18 Running 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 1413 1413 ( 1414 1414 "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.\ 1415 1417 It is initialized to './'" 1416 1418 ); -
branches/BSP/trunk/Clp/src/ClpMain.cpp
r1070 r1073 97 97 models->messageHandler()->setPrefix(false); 98 98 const char dirsep = CoinFindDirSeparator(); 99 std::string directory = (dirsep == '/' ? "./" : ".\\");99 std::string directory = "."; 100 100 std::string defaultDirectory = directory; 101 101 std::string importFile =""; … … 1373 1373 // create fields for unitTest 1374 1374 const char * fields[4]; 1375 int nFields=2;1376 1375 fields[0]="fake main from unitTest"; 1377 1376 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; 1383 1380 int algorithm; 1384 1381 if (type==NETLIB_DUAL) { … … 1409 1406 { 1410 1407 // create fields for unitTest 1411 const char * fields[3]; 1412 int nFields=1; 1408 const char * fields[4]; 1413 1409 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; 1419 1414 int specialOptions = models[iModel].specialOptions(); 1420 1415 models[iModel].setSpecialOptions(0); -
branches/BSP/trunk/Clp/src/ClpSimplex.hpp
r1055 r1073 50 50 51 51 class ClpSimplex : public ClpModel { 52 friend void ClpSimplexUnitTest(const std::string & mpsDir, 53 const std::string & netlibDir); 52 friend void ClpSimplexUnitTest(const std::string & directory); 54 53 55 54 public: … … 1281 1280 */ 1282 1281 void 1283 ClpSimplexUnitTest(const std::string & mpsDir, 1284 const std::string & netlibDir); 1282 ClpSimplexUnitTest(const std::string & directory); 1285 1283 1286 1284 -
branches/BSP/trunk/Clp/src/unitTest.cpp
r1056 r1073 227 227 printf("Computed objective %g\n",objValue); 228 228 } 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 230 static 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 241 242 //---------------------------------------------------------------- 242 243 int mainTest (int argc, const char *argv[],int algorithm, 243 244 ClpSimplex empty, bool doPresolve, int switchOffValue,bool doVector) 244 245 { 245 int i;246 247 246 if (switchOffValue>0) { 248 247 // switch off some … … 256 255 } 257 256 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; 299 263 } 300 264 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 } 302 278 // 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) { 321 287 unsigned int m; 322 288 … … 334 300 // 100 added means no presolve 335 301 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; 337 310 std::string alg; 338 for (i nt iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) {311 for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 339 312 ClpSolve solveOptions=setupForSolve(iTest,alg,0); 340 313 printf("%d %s ",iTest,alg.c_str()); … … 346 319 printf("will be tested\n"); 347 320 } 348 } 349 if (!empty.numberRows()) {321 } else { 322 testingMessage( "Testing clp -netlib\n" ); 350 323 mpsName.push_back("25fv47"); 351 324 min.push_back(true); … … 449 422 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); 450 423 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 one453 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 else466 printf("will be tested\n");467 }468 424 } 469 425 … … 477 433 478 434 ClpSimplex solutionBase=empty; 479 std::string fn = netlibDir+mpsName[m];435 std::string fn = directory+mpsName[m]; 480 436 if (!empty.numberRows()||algorithm<6) { 481 437 // Read data mps file, … … 622 578 printf("Total time %g seconds\n",timeTaken); 623 579 } 624 else {625 testingMessage( "***Skipped Testing on netlib ***\n" );626 testingMessage( "***use -netlib to test class***\n" );627 }628 580 629 581 testingMessage( "All tests completed successfully\n" ); … … 643 595 // test factorization methods and simplex method and simple barrier 644 596 void 645 ClpSimplexUnitTest(const std::string & mpsDir, 646 const std::string & netlibDir) 597 ClpSimplexUnitTest(const std::string & directory) 647 598 { 648 599 … … 765 716 { 766 717 CoinMpsIO m; 767 std::string fn = mpsDir+"exmip1";718 std::string fn = directory+"exmip1"; 768 719 m.readMps(fn.c_str(),"mps"); 769 720 ClpSimplex solution; … … 785 736 { 786 737 CoinMpsIO m; 787 std::string fn = mpsDir+"exmip1";738 std::string fn = directory+"exmip1"; 788 739 //fn = "Test/subGams4"; 789 740 m.readMps(fn.c_str(),"mps"); … … 836 787 { 837 788 CoinMpsIO m; 838 std::string fn = mpsDir+"exmip1";789 std::string fn = directory+"exmip1"; 839 790 m.readMps(fn.c_str(),"mps"); 840 791 ClpSimplex model; … … 895 846 { 896 847 CoinMpsIO m; 897 std::string fn = mpsDir+"exmip1";848 std::string fn = directory+"exmip1"; 898 849 m.readMps(fn.c_str(),"mps"); 899 850 ClpSimplex model; … … 998 949 { 999 950 CoinMpsIO m; 1000 std::string fn = netlibDir+"finnis";951 std::string fn = directory+"finnis"; 1001 952 int returnCode = m.readMps(fn.c_str(),"mps"); 1002 953 if (returnCode) { 1003 954 // 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()); 1005 956 fprintf(stderr,"Most probable cause is finnis.mps is gzipped i.e. finnis.mps.gz and libz has not been activated\n"); 1006 957 fprintf(stderr,"Either gunzip files or edit Makefiles/Makefile.location to get libz\n"); … … 1028 979 { 1029 980 CoinMpsIO m; 1030 std::string fn = netlibDir+"afiro";981 std::string fn = directory+"afiro"; 1031 982 m.readMps(fn.c_str(),"mps"); 1032 983 ClpSimplex solution; … … 1115 1066 { 1116 1067 CoinMpsIO m; 1117 std::string fn = netlibDir+"brandy";1068 std::string fn = directory+"brandy"; 1118 1069 m.readMps(fn.c_str(),"mps"); 1119 1070 ClpSimplex solution; … … 1187 1138 { 1188 1139 CoinMpsIO m; 1189 std::string fn = netlibDir+"brandy";1140 std::string fn = directory+"brandy"; 1190 1141 m.readMps(fn.c_str(),"mps"); 1191 1142 ClpSimplex solution; … … 1276 1227 { 1277 1228 CoinMpsIO m; 1278 std::string fn = netlibDir+"brandy";1229 std::string fn = directory+"brandy"; 1279 1230 m.readMps(fn.c_str(),"mps"); 1280 1231 ClpSimplex solution; … … 1455 1406 { 1456 1407 CoinMpsIO m; 1457 std::string fn = mpsDir+"exmip1";1408 std::string fn = directory+"exmip1"; 1458 1409 m.readMps(fn.c_str(),"mps"); 1459 1410 ClpInterior solution; … … 1467 1418 #define QUADRATIC 1468 1419 if (1) { 1469 std::string fn = mpsDir+"input.130";1420 std::string fn = directory+"input.130"; 1470 1421 int numberColumns; 1471 1422 int numberRows; … … 1473 1424 FILE * fp = fopen(fn.c_str(),"r"); 1474 1425 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()); 1481 1428 } else { 1482 1429 int problem; … … 1644 1591 if (1) { 1645 1592 CoinMpsIO m; 1646 std::string fn = mpsDir+"exmip1";1593 std::string fn = directory+"exmip1"; 1647 1594 m.readMps(fn.c_str(),"mps"); 1648 1595 ClpSimplex solution; … … 1689 1636 if (1) { 1690 1637 CoinMpsIO m; 1691 std::string fn = mpsDir+"share2qp";1638 std::string fn = directory+"share2qp"; 1692 1639 //fn = "share2qpb"; 1693 1640 m.readMps(fn.c_str(),"mps"); -
branches/BSP/trunk/Clp/test/Makefile.am
r915 r1073 15 15 # We are using the CLP solver executable to do the unit test 16 16 test: ../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 19 21 20 22 .PHONY: test -
branches/BSP/trunk/Clp/test/Makefile.in
r915 r1073 371 371 # We are using the CLP solver executable to do the unit test 372 372 test: ../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 375 377 376 378 .PHONY: test
Note: See TracChangeset
for help on using the changeset viewer.