Changeset 1902 for stable/2.8/Cbc/examples
- Timestamp:
- Apr 10, 2013 12:58:16 PM (8 years ago)
- Location:
- stable/2.8/Cbc
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
stable/2.8/Cbc
- Property svn:mergeinfo changed
/trunk/Cbc merged: 1889-1901
- Property svn:mergeinfo changed
-
stable/2.8/Cbc/examples/CbcBranchFollow2.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 6 #include <cassert> 11 7 #include <cmath> … … 13 9 //#define CBC_DEBUG 14 10 11 #include "CoinPragma.hpp" 15 12 #include "OsiSolverInterface.hpp" 16 13 #include "CbcModel.hpp" -
stable/2.8/Cbc/examples/CbcBranchLink.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 6 #include <cassert> 11 7 #include <cmath> … … 13 9 //#define CBC_DEBUG 14 10 11 #include "CoinPragma.hpp" 15 12 #include "OsiSolverInterface.hpp" 16 13 #include "CbcModel.hpp" … … 52 49 // weights must be increasing 53 50 int i; 54 double last=-COIN_DBL_MAX; 55 for (i=0;i<numberMembers_;i++) { 56 assert (weights_[i]>last+1.0e-12); 57 last=weights_[i]; 58 } 51 for (i=0;i<numberMembers_;i++) 52 assert (i == 0 || weights_[i]>weights_[i-1]+1.0e-12); 59 53 for (i=0;i<numberMembers_*numberLinks_;i++) { 60 54 which_[i]=first+i; … … 86 80 // weights must be increasing 87 81 int i; 88 double last=-COIN_DBL_MAX; 89 for (i=0;i<numberMembers_;i++) { 90 assert (weights_[i]>last+1.0e-12); 91 last=weights_[i]; 92 } 82 for (i=0;i<numberMembers_;i++) 83 assert (i == 0 || weights_[i]>weights_[i-1]+1.0e-12); 93 84 for (i=0;i<numberMembers_*numberLinks_;i++) { 94 85 which_[i]= which[i]; … … 467 458 // Creates a branching object 468 459 CbcBranchingObject * 469 CbcLink::create Branch(int way)460 CbcLink::createCbcBranch(OsiSolverInterface * /*solver*/, const OsiBranchingInformation * /*info*/, int way) 470 461 { 471 462 int j; -
stable/2.8/Cbc/examples/CbcBranchLink.hpp
r1574 r1902 58 58 virtual void feasibleRegion(); 59 59 /// Creates a branching object 60 virtual CbcBranchingObject * create Branch(int way) ;60 virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; 61 61 62 62 /// Number of members -
stable/2.8/Cbc/examples/CbcBranchUser.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 6 #include <cassert> 11 7 #include <cmath> 12 8 #include <cfloat> 13 9 10 #include "CoinPragma.hpp" 14 11 #include "OsiSolverInterface.hpp" 15 12 #include "CbcModel.hpp" -
stable/2.8/Cbc/examples/CbcCompareUser.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 6 #include <cassert> 11 7 #include <cmath> … … 13 9 //#define CBC_DEBUG 14 10 11 #include "CoinPragma.hpp" 15 12 #include "CbcMessage.hpp" 16 13 #include "CbcModel.hpp" -
stable/2.8/Cbc/examples/CbcSolver3.cpp
r1574 r1902 246 246 assert(!modelPtr_->specialOptions()); 247 247 int saveOptions = modelPtr_->specialOptions(); 248 int startFinishOptions;249 248 bool takeHint; 250 249 OsiHintStrength strength; 251 bool gotHint = (getHintParam(OsiDoInBranchAndCut,takeHint,strength)); 252 assert (gotHint); 250 getHintParam(OsiDoInBranchAndCut,takeHint,strength); 253 251 if (strength!=OsiHintIgnore&&takeHint) { 254 252 // could do something - think about it … … 256 254 } 257 255 if((specialOptions_&1)==0) { 258 startFinishOptions=0;259 256 modelPtr_->setSpecialOptions(saveOptions|(64|1024)); 260 257 } else { 261 startFinishOptions=1+2+4;262 258 if((specialOptions_&4)==0) 263 259 modelPtr_->setSpecialOptions(saveOptions|(64|128|512|1024|4096)); -
stable/2.8/Cbc/examples/CbcSolverLongThin.cpp
r1793 r1902 473 473 assert(!modelPtr_->specialOptions()); 474 474 int saveOptions = modelPtr_->specialOptions(); 475 int startFinishOptions;476 475 bool takeHint; 477 476 OsiHintStrength strength; 478 bool gotHint = (getHintParam(OsiDoInBranchAndCut,takeHint,strength)); 479 assert (gotHint); 477 getHintParam(OsiDoInBranchAndCut,takeHint,strength); 480 478 if (strength!=OsiHintIgnore&&takeHint) { 481 479 // could do something - think about it … … 483 481 } 484 482 if((specialOptions_&1)==0) { 485 startFinishOptions=0;486 483 modelPtr_->setSpecialOptions(saveOptions|(64|1024)); 487 484 } else { 488 startFinishOptions=1+2+4;489 485 if((specialOptions_&4)==0) 490 486 modelPtr_->setSpecialOptions(saveOptions|(64|128|512|1024|4096)); -
stable/2.8/Cbc/examples/Makefile.in
r1854 r1902 21 21 OBJS = $(DRIVER).@OBJEXT@ 22 22 23 # CbcCompareUser.@OBJEXT@ \ 24 # CbcSolver2.@OBJEXT@ \ 25 # CbcSolver3.@OBJEXT@ \ 26 # ClpQuadInterface.@OBJEXT@ \ 27 # CbcBranchFollow2.@OBJEXT@ \ 28 # CbcBranchUser.@OBJEXT@ \ 29 # CbcBranchLink.@OBJEXT@ 23 # extra object files that are required by some examples (we just link them into each one) 24 EXTRAOBJS = \ 25 CbcCompareUser.@OBJEXT@ \ 26 CbcSolver2.@OBJEXT@ \ 27 CbcSolver3.@OBJEXT@ \ 28 CbcSolverLongThin.@OBJEXT@ \ 29 ClpQuadInterface.@OBJEXT@ \ 30 CbcBranchFollow2.@OBJEXT@ \ 31 CbcBranchUser.@OBJEXT@ \ 32 CbcBranchLink.@OBJEXT@ 30 33 31 34 # CHANGEME: Additional libraries 35 # e.g., for driver2, put -lOsiCbc here 32 36 ADDLIBS = 33 37 … … 89 93 INCL = @CBCLIB_CFLAGS_INSTALLED@ 90 94 endif 91 INCL += $(ADDINCFLAGS)95 INCL += -I@srcdir@ $(ADDINCFLAGS) 92 96 93 97 # Linker flags … … 106 110 107 111 # Here we list all possible generated objects or executables to delete them 108 CLEANFILES = \ 112 CLEANFILES = $(EXTRAOBJS) \ 113 allCuts.@OBJEXT@ allCuts@EXEEXT@ \ 114 barrier.@OBJEXT@ barrier@EXEEXT@ \ 115 cbc_driverC_sos.@OBJEXT@ cbc_driverC_sos@EXEEXT@ \ 109 116 crew.@OBJEXT@ crew@EXEEXT@ \ 110 barrier.@OBJEXT@ barrier@EXEEXT@ \117 driver.@OBJEXT@ driver@EXEEXT@ \ 111 118 driver2.@OBJEXT@ driver2@EXEEXT@ \ 112 driver .@OBJEXT@ driver@EXEEXT@ \113 d ynamic.@OBJEXT@ dynamic@EXEEXT@ \119 driver3.@OBJEXT@ driver3@EXEEXT@ \ 120 driver4.@OBJEXT@ driver4@EXEEXT@ \ 114 121 fast0507b.@OBJEXT@ fast0507b@EXEEXT@ \ 115 122 fast0507.@OBJEXT@ fast0507@EXEEXT@ \ 116 123 gear.@OBJEXT@ gear@EXEEXT@ \ 117 124 hotstart.@OBJEXT@ hotstart@EXEEXT@ \ 125 interrupt.@OBJEXT@ interrupt@EXEEXT@ \ 118 126 link.@OBJEXT@ link@EXEEXT@ \ 119 127 longthin.@OBJEXT@ longthin@EXEEXT@ \ 120 128 lotsize.@OBJEXT@ lotsize@EXEEXT@ \ 121 129 minimum.@OBJEXT@ minimum@EXEEXT@ \ 130 modify.@OBJEXT@ modify@EXEEXT@ \ 122 131 nway.@OBJEXT@ nway@EXEEXT@ \ 123 132 qmip.@OBJEXT@ qmip@EXEEXT@ \ … … 129 138 sample4.@OBJEXT@ sample4@EXEEXT@ \ 130 139 sample5.@OBJEXT@ sample5@EXEEXT@ \ 140 simpleBAB.@OBJEXT@ simpleBAB@EXEEXT@ \ 131 141 sos.@OBJEXT@ sos@EXEEXT@ \ 132 142 sudoku.@OBJEXT@ sudoku@EXEEXT@ … … 136 146 .SUFFIXES: .cpp .c .o .obj 137 147 138 $(EXE): $(OBJS) 148 $(EXE): $(OBJS) $(EXTRAOBJS) 139 149 bla=;\ 140 for file in $(OBJS) ; do bla="$$bla `$(CYGPATH_W) $$file`"; done; \150 for file in $(OBJS) $(EXTRAOBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \ 141 151 $(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(LIBS) $(ADDLIBS) 142 152 -
stable/2.8/Cbc/examples/allCuts.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 // For Branch and bound 16 12 #include "OsiSolverInterface.hpp" … … 42 38 #include "CbcHeuristic.hpp" 43 39 44 #include 40 #include "CoinTime.hpp" 45 41 // Need stored cuts 46 42 … … 254 250 if (argc>=2) mpsFileName = argv[1]; 255 251 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 256 assert(numMpsReadErrors==0); 252 if( numMpsReadErrors != 0 ) 253 { 254 printf("%d errors reading MPS file\n", numMpsReadErrors); 255 return numMpsReadErrors; 256 } 257 257 double time1 = CoinCpuTime(); 258 258 OsiClpSolverInterface solverSave = solver1; -
stable/2.8/Cbc/examples/barrier.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 #include "OsiClpSolverInterface.hpp" 16 #include 12 #include "CoinTime.hpp" 17 13 18 14 //############################################################################# … … 72 68 if (argc>=2) mpsFileName = argv[1]; 73 69 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 74 assert(numMpsReadErrors==0); 70 if( numMpsReadErrors != 0 ) 71 { 72 printf("%d errors reading MPS file\n", numMpsReadErrors); 73 return numMpsReadErrors; 74 } 75 75 double time1 = CoinCpuTime(); 76 76 -
stable/2.8/Cbc/examples/cbc_driverC_sos.c
r1854 r1902 4 4 This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 $Id #6 $Id$ 7 7 */ 8 8 … … 77 77 #if defined(SAMPLEDIR) 78 78 /* 79 SAMPLEDIR should be something like "path/to/mps/directory /", including the80 quotes and final directory separator. Don't forget to properly escape79 SAMPLEDIR should be something like "path/to/mps/directory", including the 80 quotes and excluding the final directory separator. Don't forget to properly escape 81 81 '\' when using native Windows path syntax. 82 82 */ 83 status=Cbc_readMps(model, SAMPLEDIR "p0033.mps") ;83 status=Cbc_readMps(model, SAMPLEDIR "/p0033.mps") ; 84 84 #else 85 85 fprintf(stderr, "Please specify the full path to an MPS file on the command line\n"); … … 397 397 } else { 398 398 int numObjects = numberSets; /* cannot pass const int */ 399 Cbc_addSOS_Dense(model, numObjects, len, (const int* *)which, (const double*)weights, 2);399 Cbc_addSOS_Dense(model, numObjects, len, (const int* const *)which, (const double*)weights, 2); 400 400 } 401 401 } -
stable/2.8/Cbc/examples/crew.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 #include "CoinPragma.hpp" 15 10 // For Branch and bound 16 11 #include "OsiClpSolverInterface.hpp" … … 19 14 #include "CbcCompareUser.hpp" 20 15 21 #include 16 #include "CoinTime.hpp" 22 17 23 18 /************************************************************************ … … 49 44 if (argc>=2) mpsFileName = argv[1]; 50 45 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 51 assert(numMpsReadErrors==0); 46 if( numMpsReadErrors != 0 ) 47 { 48 printf("%d errors reading MPS file\n", numMpsReadErrors); 49 return numMpsReadErrors; 50 } 52 51 double time1 = CoinCpuTime(); 53 52 … … 60 59 // Point to solver 61 60 OsiSolverInterface * solver3 = model.solver(); 62 OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (solver3); 63 assert (osiclp); 61 assert (dynamic_cast< OsiClpSolverInterface*> (solver3)); 64 62 65 63 // Definition of node choice -
stable/2.8/Cbc/examples/driver.cpp
r1574 r1902 3 3 // Corporation and others. All Rights Reserved. 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 5 11 6 #include <cassert> … … 14 9 15 10 // For Branch and bound 11 #include "CoinPragma.hpp" 16 12 #include "CbcModel.hpp" 17 13 #include "CbcStrategy.hpp" … … 20 16 #include "CglPreProcess.hpp" 21 17 22 #include 18 #include "CoinTime.hpp" 23 19 24 20 //############################################################################# … … 50 46 if (argc>=2) mpsFileName = argv[1]; 51 47 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 52 assert(numMpsReadErrors==0); 48 if( numMpsReadErrors != 0 ) 49 { 50 printf("%d errors reading MPS file\n", numMpsReadErrors); 51 return numMpsReadErrors; 52 } 53 53 double time1 = CoinCpuTime(); 54 54 -
stable/2.8/Cbc/examples/driver2.cpp
r1574 r1902 3 3 // Corporation and others. All Rights Reserved. 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 5 11 6 #include <cassert> … … 15 10 // For Branch and bound 16 11 //#include "CbcStrategy.hpp" 12 #include "CoinPragma.hpp" 17 13 #include "OsiCbcSolverInterface.hpp" 18 14 19 #include 15 #include "CoinTime.hpp" 20 16 21 17 //############################################################################# … … 50 46 if (argc>=2) mpsFileName = argv[1]; 51 47 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 52 assert(numMpsReadErrors==0); 48 if( numMpsReadErrors != 0 ) 49 { 50 printf("%d errors reading MPS file\n", numMpsReadErrors); 51 return numMpsReadErrors; 52 } 53 53 double time1 = CoinCpuTime(); 54 54 // Do complete search -
stable/2.8/Cbc/examples/driver3.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 #include "CoinPragma.hpp" 14 10 #include "CbcModel.hpp" 15 11 #include "OsiClpSolverInterface.hpp" 16 12 #include "CbcBranchDynamic.hpp" 17 13 18 #include 14 #include "CoinTime.hpp" 19 15 20 16 //############################################################################# … … 55 51 if (argc>=2) mpsFileName = argv[1]; 56 52 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 57 assert(numMpsReadErrors==0); 53 if( numMpsReadErrors != 0 ) 54 { 55 printf("%d errors reading MPS file\n", numMpsReadErrors); 56 return numMpsReadErrors; 57 } 58 58 59 59 // Strip off integer information and save -
stable/2.8/Cbc/examples/driver4.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 #include "CbcModel.hpp" 16 12 #include "OsiClpSolverInterface.hpp" 17 13 #include "CbcSolver.hpp" 18 14 19 #include 15 #include "CoinTime.hpp" 20 16 21 17 //############################################################################# … … 221 217 if (argc>=2) mpsFileName = argv[1]; 222 218 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 223 assert(numMpsReadErrors==0); 219 if( numMpsReadErrors != 0 ) 220 { 221 printf("%d errors reading MPS file\n", numMpsReadErrors); 222 return numMpsReadErrors; 223 } 224 224 // Tell solver to return fast if presolve or initial solve infeasible 225 225 solver1.getModelPtr()->setMoreSpecialOptions(3); -
stable/2.8/Cbc/examples/fast0507.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 #include "CoinPragma.hpp" 14 10 15 11 // For Branch and bound … … 39 35 #include "CglPreProcess.hpp" 40 36 41 #include 37 #include "CoinTime.hpp" 42 38 43 39 //############################################################################# … … 77 73 if (argc>=2) mpsFileName = argv[1]; 78 74 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 79 assert(numMpsReadErrors==0); 75 if( numMpsReadErrors != 0 ) 76 { 77 printf("%d errors reading MPS file\n", numMpsReadErrors); 78 return numMpsReadErrors; 79 } 80 80 double time1 = CoinCpuTime(); 81 81 -
stable/2.8/Cbc/examples/fast0507b.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include "CbcConfig.h" 12 7 … … 14 9 #include <iomanip> 15 10 11 #include "CoinPragma.hpp" 16 12 17 13 // For Branch and bound … … 39 35 #include "CglPreProcess.hpp" 40 36 41 #include 37 #include "CoinTime.hpp" 42 38 43 39 //############################################################################# … … 83 79 if (argc>=2) mpsFileName = argv[1]; 84 80 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 85 assert(numMpsReadErrors==0); 81 if( numMpsReadErrors != 0 ) 82 { 83 printf("%d errors reading MPS file\n", numMpsReadErrors); 84 return numMpsReadErrors; 85 } 86 86 double time1 = CoinCpuTime(); 87 87 /* Options are: -
stable/2.8/Cbc/examples/gear.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 #include "CoinPragma.hpp" 14 10 15 11 // For Branch and bound … … 21 17 #include "OsiClpSolverInterface.hpp" 22 18 23 #include 19 #include "CoinTime.hpp" 24 20 25 21 -
stable/2.8/Cbc/examples/hotstart.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 #include "CoinPragma.hpp" 14 10 15 11 // For Branch and bound … … 38 34 #include "CbcHeuristic.hpp" 39 35 40 #include 36 #include "CoinTime.hpp" 41 37 42 38 //############################################################################# … … 74 70 if (argc>=2) mpsFileName = argv[1]; 75 71 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 76 assert(numMpsReadErrors==0); 72 if( numMpsReadErrors != 0 ) 73 { 74 printf("%d errors reading MPS file\n", numMpsReadErrors); 75 return numMpsReadErrors; 76 } 77 77 double time1 = CoinCpuTime(); 78 78 -
stable/2.8/Cbc/examples/interrupt.cpp
- Property svn:keywords set to Author Date Id Revision
r1873 r1902 1 // $Id : interrupt.cpp 1854 2013-01-28 00:02:55Z stefan$1 // $Id$ 2 2 // Copyright (C) 2007, International Business Machines 3 3 // Corporation and others. All Rights Reserved. 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 #include "CbcModel.hpp" 16 12 #include "OsiClpSolverInterface.hpp" 17 13 #include "CbcSolver.hpp" 18 14 19 #include 15 #include "CoinTime.hpp" 20 16 21 17 //############################################################################# … … 359 355 if (argc>=2) mpsFileName = argv[1]; 360 356 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 361 assert(numMpsReadErrors==0); 357 if( numMpsReadErrors != 0 ) 358 { 359 printf("%d errors reading MPS file\n", numMpsReadErrors); 360 return numMpsReadErrors; 361 } 362 362 // Tell solver to return fast if presolve or initial solve infeasible 363 363 solver1.getModelPtr()->setMoreSpecialOptions(3); -
stable/2.8/Cbc/examples/link.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 #include "CoinPragma.hpp" 15 10 // For Branch and bound 16 11 #include "OsiSolverInterface.hpp" … … 21 16 #include "OsiClpSolverInterface.hpp" 22 17 23 #include 18 #include "CoinTime.hpp" 24 19 25 20 -
stable/2.8/Cbc/examples/longthin.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 // For Branch and bound 16 12 #include "OsiSolverInterface.hpp" … … 28 24 #include "CglProbing.hpp" 29 25 30 #include 26 #include "CoinTime.hpp" 31 27 32 28 /************************************************************************ … … 58 54 if (argc>=2) mpsFileName = argv[1]; 59 55 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 60 assert(numMpsReadErrors==0); 56 if( numMpsReadErrors != 0 ) 57 { 58 printf("%d errors reading MPS file\n", numMpsReadErrors); 59 return numMpsReadErrors; 60 } 61 61 double time1 = CoinCpuTime(); 62 62 -
stable/2.8/Cbc/examples/lotsize.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 #include "CoinPragma.hpp" 15 10 // For Branch and bound 16 11 #include "CbcModel.hpp" … … 50 45 if (argc>=2) mpsFileName = argv[1]; 51 46 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 52 assert(numMpsReadErrors==0); 47 if( numMpsReadErrors != 0 ) 48 { 49 printf("%d errors reading MPS file\n", numMpsReadErrors); 50 return numMpsReadErrors; 51 } 53 52 54 53 int iColumn; -
stable/2.8/Cbc/examples/minimum.cpp
r1574 r1902 16 16 #if defined(SAMPLEDIR) 17 17 int numMpsReadErrors = solver1.readMps(SAMPLEDIR "/p0033.mps",""); 18 assert(numMpsReadErrors==0); 18 if( numMpsReadErrors != 0 ) 19 { 20 printf("%d errors reading MPS file\n", numMpsReadErrors); 21 return numMpsReadErrors; 22 } 19 23 #else 20 24 fprintf(stderr, "Do not know where to find sample MPS files.\n"); -
stable/2.8/Cbc/examples/nway.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 // For Branch and bound 16 12 #include "CbcModel.hpp" … … 49 45 if (argc>=2) mpsFileName = argv[1]; 50 46 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 51 assert(numMpsReadErrors==0); 47 if( numMpsReadErrors != 0 ) 48 { 49 printf("%d errors reading MPS file\n", numMpsReadErrors); 50 return numMpsReadErrors; 51 } 52 52 53 53 int iRow, iColumn; -
stable/2.8/Cbc/examples/qmip.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 10 #include "CoinPragma.hpp" 14 11 15 12 // For Branch and bound … … 67 64 68 65 // Read in model using argv[1] 66 if (argc <= 1) { 67 printf("using %s <modelfile>\n", argv[0]); 68 return 1; 69 } 69 70 // must use clp to get a quadratic model 70 71 ClpSimplex * clp = solver1.getModelPtr(); 71 72 int numMpsReadErrors = clp->readMps(argv[1]); 72 73 // and assert that it is a clean model 73 assert(numMpsReadErrors==0); 74 if( numMpsReadErrors != 0 ) 75 { 76 printf("%d errors reading MPS file\n", numMpsReadErrors); 77 return numMpsReadErrors; 78 } 74 79 75 80 // This clones solver -
stable/2.8/Cbc/examples/qmip2.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 7 8 #include "CoinPragma.hpp" 12 9 13 10 // For Branch and bound -
stable/2.8/Cbc/examples/repeat.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 #include "CoinPragma.hpp" 14 10 15 11 // For Branch and bound … … 39 35 #include "CbcHeuristic.hpp" 40 36 41 #include 37 #include "CoinTime.hpp" 42 38 43 39 //############################################################################# … … 79 75 if (argc>=2) mpsFileName = argv[1]; 80 76 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 81 assert(numMpsReadErrors==0); 77 if( numMpsReadErrors != 0 ) 78 { 79 printf("%d errors reading MPS file\n", numMpsReadErrors); 80 return numMpsReadErrors; 81 } 82 82 double time1 = CoinCpuTime(); 83 83 … … 301 301 OsiSolverInterface * refSolver = model.referenceSolver(); 302 302 const double * bestSolution = model.bestSolution(); 303 #ifndef NDEBUG 303 304 const double * originalLower = refSolver->getColLower(); 304 305 const double * originalUpper = refSolver->getColUpper(); 306 #endif 305 307 CoinPackedVector cut; 306 308 double rhs = 1.0; -
stable/2.8/Cbc/examples/sample1.cpp
r1660 r1902 43 43 struct rusage usage; 44 44 getrusage(RUSAGE_SELF,&usage); 45 cpu_temp = usage.ru_utime.tv_sec;45 cpu_temp = (double)usage.ru_utime.tv_sec; 46 46 cpu_temp += 1.0e-6*((double) usage.ru_utime.tv_usec); 47 47 #endif … … 87 87 // and assert that it is a clean model 88 88 89 assert(!simplex.readMps(argv[1],"")); 89 if (argc <= 1) { 90 printf("using %s <modelfile>\n", argv[0]); 91 return 1; 92 } 93 int numMpsReadErrors = simplex.readMps(argv[1],""); 94 if( numMpsReadErrors != 0 ) 95 { 96 printf("%d errors reading MPS file\n", numMpsReadErrors); 97 return numMpsReadErrors; 98 } 90 99 time2 = cpuTime(); 91 100 std::cout<<"Input took "<<time2-time1<<" seconds"<<std::endl;; -
stable/2.8/Cbc/examples/sample2.cpp
r1660 r1902 35 35 #include "CbcHeuristic.hpp" 36 36 37 #include 37 #include "CoinTime.hpp" 38 38 39 39 //############################################################################# … … 85 85 if (argc>=2) mpsFileName = argv[1]; 86 86 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 87 assert(numMpsReadErrors==0); 87 if( numMpsReadErrors != 0 ) 88 { 89 printf("%d errors reading MPS file\n", numMpsReadErrors); 90 return numMpsReadErrors; 91 } 88 92 double time1 = CoinCpuTime(); 89 93 -
stable/2.8/Cbc/examples/sample3.cpp
r1660 r1902 91 91 solver1.getModelPtr()->setDualBound(1.0e10); 92 92 93 if (argc <= 1) { 94 printf("using %s <modelfile>\n", argv[0]); 95 return 1; 96 } 97 93 98 // Read in model using argv[1] 94 99 // and assert that it is a clean model 95 100 int numMpsReadErrors = solver1.readMps(argv[1],""); 96 assert(numMpsReadErrors==0); 101 if( numMpsReadErrors != 0 ) 102 { 103 printf("%d errors reading MPS file\n", numMpsReadErrors); 104 return numMpsReadErrors; 105 } 97 106 // do here so integers correct 98 107 CbcModel model(solver1); -
stable/2.8/Cbc/examples/sample4.cpp
r1660 r1902 26 26 /************************************************************************ 27 27 28 This main program reads in an SOS r model (ltw) from an mps file.28 This main program reads in an SOS model (rgn) from an mps file. 29 29 30 30 It then solves it three ways :- … … 32 32 a) As normal 33 33 b) SOS 1 34 c) SOS 2 (so answer will be different)34 c) SOS 2 (so answer will be different) 35 35 36 36 ************************************************************************/ … … 46 46 model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); 47 47 48 // Read in ltw.mps 49 // and assert that it is a clean model 50 int numMpsReadErrors = model.solver()->readMps("./ltw.mps",""); 51 assert(numMpsReadErrors==0); 48 // Read in rgn.mps 49 std::string mpsFileName; 50 #if defined(MIPLIB3DIR) 51 mpsFileName = MIPLIB3DIR "/rgn"; 52 #else 53 if (argc < 2) { 54 fprintf(stderr, "Do not know where to find miplib3 MPS files.\n"); 55 exit(1); 56 } 57 #endif 58 if (argc>=2) mpsFileName = argv[1]; 59 int numMpsReadErrors = model.solver()->readMps(mpsFileName.c_str(),""); 60 if( numMpsReadErrors != 0 ) 61 { 62 printf("%d errors reading MPS file\n", numMpsReadErrors); 63 return numMpsReadErrors; 64 } 52 65 53 66 // Definition of node choice … … 75 88 } 76 89 77 90 if (numberColumns!=180 || numberIntegers!=100) { 91 printf("Incorrect model for example\n"); 92 exit(1); 93 } 94 78 95 double time1 = CoinCpuTime() ; 79 96 80 97 model.branchAndBound(); 81 98 82 std::cout<<" ltw.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, "99 std::cout<<"rgn.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, " 83 100 <<model.getNodeCount()<<" nodes with objective " 84 101 <<model.getObjValue() … … 104 121 model = model2; 105 122 123 // Convert slacks to variables 124 CoinBigIndex start[5]={0,1,2,3,4}; 125 int row[4]={0,1,2,3}; 126 double element[4]={1.0,1.0,1.0,1.0}; 127 double up[4]={1.0,1.0,1.0,1.0}; 128 model.solver()->addCols(4,start,row,element,NULL,up,NULL); 106 129 // Now use SOS1 107 int numberSets=8; 108 int which[28]={20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, 109 39,40,41,42,43,44,45,46,47}; 110 double weights[]={1.0,2.0,3.0,4.0,5.0}; 111 int starts[]={0,2,4,6,8,13,18,23,28}; 112 CbcObject ** objects = new CbcObject * [numberSets]; 130 int numberSets=4; 131 int which[104]; 132 double weights[104]; 133 int starts[5]; 134 // load 135 int n=0; 136 starts[0]=0; 137 for (int iSet=0;iSet<4;iSet++) { 138 for (int i=0;i<25;i++) { 139 weights[n]=i+1.0; 140 which[n]=iSet*25+i; 141 n++; 142 } 143 // slack - make sure first branch is on slack 144 weights[n]=1000.0; 145 which[n]=180+iSet; 146 n++; 147 starts[iSet+1]=n; 148 } 113 149 for (i=0;i<numberIntegers;i++) { 114 150 int iColumn = integerVariable[i]; … … 116 152 model.solver()->setContinuous(iColumn); 117 153 } 154 // save model in this state 155 CbcModel modelSOS = model; 156 CbcObject ** objects = new CbcObject * [numberSets]; 118 157 for (i=0;i<numberSets;i++) { 119 158 objects[i]= new CbcSOS(&model,starts[i+1]-starts[i],which+starts[i], … … 129 168 model.branchAndBound(); 130 169 131 std::cout<<" ltw.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, "170 std::cout<<"rgn.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, " 132 171 <<model.getNodeCount()<<" nodes with objective " 133 172 <<model.getObjValue() … … 151 190 152 191 153 // Restore model154 model = model 2;192 // Restore SOS model 193 model = modelSOS; 155 194 156 195 // Now use SOS2 157 196 objects = new CbcObject * [numberSets]; 158 for (i=0;i<numberIntegers;i++) {159 int iColumn = integerVariable[i];160 // Stop being integer161 model.solver()->setContinuous(iColumn);162 }163 197 for (i=0;i<numberSets;i++) { 164 198 objects[i]= new CbcSOS(&model,starts[i+1]-starts[i],which+starts[i], … … 174 208 model.branchAndBound(); 175 209 176 std::cout<<" ltw.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, "210 std::cout<<"rgn.mps"<<" took "<<CoinCpuTime()-time1<<" seconds, " 177 211 <<model.getNodeCount()<<" nodes with objective " 178 212 <<model.getObjValue() -
stable/2.8/Cbc/examples/sample5.cpp
r1660 r1902 40 40 #include "CoinModel.hpp" 41 41 42 #include 42 #include "CoinTime.hpp" 43 43 44 44 -
stable/2.8/Cbc/examples/simpleBAB.cpp
r1854 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 #include "OsiClpSolverInterface.hpp" 16 12 #include "CoinPackedVector.hpp" … … 41 37 model.setInteger(0); 42 38 model.setObjSense(-1.0); 43 bool optimal;39 //bool optimal; 44 40 45 41 #ifndef USE_CBC … … 54 50 model.getDblParam(OsiDualObjectiveLimit,objLimit); 55 51 model.branchAndBound(); 56 optimal = model.isProvenOptimal();52 //optimal = model.isProvenOptimal(); 57 53 const double *val = model.getColSolution(); // x0 = 3, x1 = 0.45 58 54 printf("Solution %g %g\n",val[0],val[1]); … … 65 61 CbcModel model2(model); 66 62 model2.branchAndBound(); 67 optimal = model2.isProvenOptimal();63 //optimal = model2.isProvenOptimal(); 68 64 const double *val = model2.getColSolution(); // x0 = 3, x1 = 0.45 69 65 printf("Solution %g %g\n",val[0],val[1]); … … 79 75 #ifndef USE_CBC 80 76 model.branchAndBound(); 81 optimal = model.isProvenOptimal(); // should be x0 = 2, x1 = 0.9577 //optimal = model.isProvenOptimal(); // should be x0 = 2, x1 = 0.95 82 78 // Address of solution will be same as only adding rows - but be safe 83 79 val = model.getColSolution(); … … 87 83 CbcModel model2(model); 88 84 model2.branchAndBound(); 89 optimal = model2.isProvenOptimal(); // should be x0 = 2, x1 = 0.9585 //optimal = model2.isProvenOptimal(); // should be x0 = 2, x1 = 0.95 90 86 const double *val = model2.getColSolution(); 91 87 printf("Solution %g %g\n",val[0],val[1]); -
stable/2.8/Cbc/examples/sos.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 9 10 #include "CoinPragma.hpp" 14 11 15 12 // For Branch and bound … … 49 46 if (argc>=2) mpsFileName = argv[1]; 50 47 int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); 51 assert(numMpsReadErrors==0); 48 if( numMpsReadErrors != 0 ) 49 { 50 printf("%d errors reading MPS file\n", numMpsReadErrors); 51 return numMpsReadErrors; 52 } 52 53 53 54 int iRow, iColumn; -
stable/2.8/Cbc/examples/sudoku.cpp
r1574 r1902 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 5 6 #if defined(_MSC_VER)7 // Turn off compiler warning about long names8 # pragma warning(disable:4786)9 #endif10 11 6 #include <cassert> 12 7 #include <iomanip> 13 8 14 9 10 #include "CoinPragma.hpp" 15 11 // For Branch and bound 16 12 #include "OsiSolverInterface.hpp" … … 26 22 #include "CglStored.hpp" 27 23 28 #include 24 #include "CoinTime.hpp" 29 25 30 26
Note: See TracChangeset
for help on using the changeset viewer.