Changeset 765
- Timestamp:
- Aug 20, 2007 12:03:23 AM (13 years ago)
- Location:
- trunk/Cbc
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/MSVisualStudio/v8/cbcCSosDllSample/cbcCSosDllSample.vcproj
r713 r765 64 64 <Tool 65 65 Name="VCLinkerTool" 66 AdditionalDependencies=" cbcCInterfaceDll.lib"66 AdditionalDependencies="$(InputDir)..\cbcCInterfaceDll\debug\cbcCInterfaceDll.lib" 67 67 LinkIncremental="2" 68 68 AdditionalLibraryDirectories="$(SolutionDir)cbcCInterfaceDll\Debug" … … 145 145 <Tool 146 146 Name="VCLinkerTool" 147 AdditionalDependencies=" cbcCInterfaceDll.lib"147 AdditionalDependencies="$(InputDir)..\cbcCInterfaceDll\release\cbcCInterfaceDll.lib" 148 148 LinkIncremental="1" 149 149 AdditionalLibraryDirectories="$(SolutionDir)cbcCInterfaceDll\Release" -
trunk/Cbc/configure
r721 r765 1 1 #! /bin/sh 2 2 # Guess values for system-dependent variables and create Makefiles. 3 # Generated by GNU Autoconf 2.59 for Cbc 0.1.3 # Generated by GNU Autoconf 2.59 for Cbc 1.2trunk. 4 4 # 5 5 # Report bugs to <coin-cbc@list.coin-or.org>. … … 430 430 PACKAGE_NAME='Cbc' 431 431 PACKAGE_TARNAME='cbc' 432 PACKAGE_VERSION=' 0.1'433 PACKAGE_STRING='Cbc 0.1'432 PACKAGE_VERSION='1.2trunk' 433 PACKAGE_STRING='Cbc 1.2trunk' 434 434 PACKAGE_BUGREPORT='coin-cbc@list.coin-or.org' 435 435 … … 1002 1002 # This message is too long to be a string in the A/UX 3.1 sh. 1003 1003 cat <<_ACEOF 1004 \`configure' configures Cbc 0.1to adapt to many kinds of systems.1004 \`configure' configures Cbc 1.2trunk to adapt to many kinds of systems. 1005 1005 1006 1006 Usage: $0 [OPTION]... [VAR=VALUE]... … … 1068 1068 if test -n "$ac_init_help"; then 1069 1069 case $ac_init_help in 1070 short | recursive ) echo "Configuration of Cbc 0.1:";;1070 short | recursive ) echo "Configuration of Cbc 1.2trunk:";; 1071 1071 esac 1072 1072 cat <<\_ACEOF … … 1269 1269 if $ac_init_version; then 1270 1270 cat <<\_ACEOF 1271 Cbc configure 0.11271 Cbc configure 1.2trunk 1272 1272 generated by GNU Autoconf 2.59 1273 1273 … … 1289 1289 running configure, to aid debugging if configure makes a mistake. 1290 1290 1291 It was created by Cbc $as_me 0.1, which was1291 It was created by Cbc $as_me 1.2trunk, which was 1292 1292 generated by GNU Autoconf 2.59. Invocation command line was 1293 1293 … … 1849 1849 if test "$enable_doscompile" != no; then 1850 1850 case $build in 1851 *-cygwin* ) ;;1852 *) { { echo "$as_me:$LINENO: error: --enable-doscompile option makes sense only under Cygwin " >&51853 echo "$as_me: error: --enable-doscompile option makes sense only under Cygwin " >&2;}1851 *-cygwin* | *-mingw*) ;; 1852 *) { { echo "$as_me:$LINENO: error: --enable-doscompile option makes sense only under Cygwin or MinGW" >&5 1853 echo "$as_me: error: --enable-doscompile option makes sense only under Cygwin or MinGW" >&2;} 1854 1854 { (exit 1); exit 1; }; } ;; 1855 1855 esac … … 1859 1859 fi; 1860 1860 case "$enable_doscompile" in 1861 msvc|mingw|no) ;; 1861 mingw) 1862 case $build in 1863 *-mingw*) enable_doscompile=no ;; 1864 esac 1865 ;; 1866 msvc|no) ;; 1862 1867 yes) enable_doscompile=mingw ;; 1863 1868 *) { { echo "$as_me:$LINENO: error: Invalid value $enable_doscompile for --enable-doscompile. … … 2809 2814 xlc* | */xlc* | mpxlc* | */mpxlc*) 2810 2815 coin_opt_cflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1" 2811 coin_add_cflags="-bmaxdata:0x80000000 "2816 coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029" 2812 2817 coin_dbg_cflags="-g" 2813 2818 ;; … … 3650 3655 xlC* | */xlC* | mpxlC* | */mpxlC*) 3651 3656 coin_opt_cxxflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1" 3652 coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna "3657 coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029" 3653 3658 coin_dbg_cxxflags="-g" 3654 3659 ;; … … 4346 4351 # Define the identity of the package. 4347 4352 PACKAGE='cbc' 4348 VERSION=' 0.1'4353 VERSION='1.2trunk' 4349 4354 4350 4355 … … 5648 5653 *-*-irix6*) 5649 5654 # Find out which ABI we are using. 5650 echo '#line 565 0"configure"' > conftest.$ac_ext5655 echo '#line 5655 "configure"' > conftest.$ac_ext 5651 5656 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 5652 5657 (eval $ac_compile) 2>&5 … … 6782 6787 6783 6788 # Provide some information about the compiler. 6784 echo "$as_me:678 4:" \6789 echo "$as_me:6789:" \ 6785 6790 "checking for Fortran 77 compiler version" >&5 6786 6791 ac_compiler=`set X $ac_compile; echo $2` … … 7849 7854 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 7850 7855 -e 's:$: $lt_compiler_flag:'` 7851 (eval echo "\"\$as_me:785 1: $lt_compile\"" >&5)7856 (eval echo "\"\$as_me:7856: $lt_compile\"" >&5) 7852 7857 (eval "$lt_compile" 2>conftest.err) 7853 7858 ac_status=$? 7854 7859 cat conftest.err >&5 7855 echo "$as_me:78 55: \$? = $ac_status" >&57860 echo "$as_me:7860: \$? = $ac_status" >&5 7856 7861 if (exit $ac_status) && test -s "$ac_outfile"; then 7857 7862 # The compiler can only warn and ignore the option if not recognized … … 8117 8122 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 8118 8123 -e 's:$: $lt_compiler_flag:'` 8119 (eval echo "\"\$as_me:81 19: $lt_compile\"" >&5)8124 (eval echo "\"\$as_me:8124: $lt_compile\"" >&5) 8120 8125 (eval "$lt_compile" 2>conftest.err) 8121 8126 ac_status=$? 8122 8127 cat conftest.err >&5 8123 echo "$as_me:812 3: \$? = $ac_status" >&58128 echo "$as_me:8128: \$? = $ac_status" >&5 8124 8129 if (exit $ac_status) && test -s "$ac_outfile"; then 8125 8130 # The compiler can only warn and ignore the option if not recognized … … 8221 8226 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 8222 8227 -e 's:$: $lt_compiler_flag:'` 8223 (eval echo "\"\$as_me:822 3: $lt_compile\"" >&5)8228 (eval echo "\"\$as_me:8228: $lt_compile\"" >&5) 8224 8229 (eval "$lt_compile" 2>out/conftest.err) 8225 8230 ac_status=$? 8226 8231 cat out/conftest.err >&5 8227 echo "$as_me:82 27: \$? = $ac_status" >&58232 echo "$as_me:8232: \$? = $ac_status" >&5 8228 8233 if (exit $ac_status) && test -s out/conftest2.$ac_objext 8229 8234 then … … 10566 10571 lt_status=$lt_dlunknown 10567 10572 cat > conftest.$ac_ext <<EOF 10568 #line 105 68"configure"10573 #line 10573 "configure" 10569 10574 #include "confdefs.h" 10570 10575 … … 10666 10671 lt_status=$lt_dlunknown 10667 10672 cat > conftest.$ac_ext <<EOF 10668 #line 106 68"configure"10673 #line 10673 "configure" 10669 10674 #include "confdefs.h" 10670 10675 … … 13010 13015 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 13011 13016 -e 's:$: $lt_compiler_flag:'` 13012 (eval echo "\"\$as_me:1301 2: $lt_compile\"" >&5)13017 (eval echo "\"\$as_me:13017: $lt_compile\"" >&5) 13013 13018 (eval "$lt_compile" 2>conftest.err) 13014 13019 ac_status=$? 13015 13020 cat conftest.err >&5 13016 echo "$as_me:130 16: \$? = $ac_status" >&513021 echo "$as_me:13021: \$? = $ac_status" >&5 13017 13022 if (exit $ac_status) && test -s "$ac_outfile"; then 13018 13023 # The compiler can only warn and ignore the option if not recognized … … 13114 13119 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 13115 13120 -e 's:$: $lt_compiler_flag:'` 13116 (eval echo "\"\$as_me:131 16: $lt_compile\"" >&5)13121 (eval echo "\"\$as_me:13121: $lt_compile\"" >&5) 13117 13122 (eval "$lt_compile" 2>out/conftest.err) 13118 13123 ac_status=$? 13119 13124 cat out/conftest.err >&5 13120 echo "$as_me:1312 0: \$? = $ac_status" >&513125 echo "$as_me:13125: \$? = $ac_status" >&5 13121 13126 if (exit $ac_status) && test -s out/conftest2.$ac_objext 13122 13127 then … … 14684 14689 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 14685 14690 -e 's:$: $lt_compiler_flag:'` 14686 (eval echo "\"\$as_me:146 86: $lt_compile\"" >&5)14691 (eval echo "\"\$as_me:14691: $lt_compile\"" >&5) 14687 14692 (eval "$lt_compile" 2>conftest.err) 14688 14693 ac_status=$? 14689 14694 cat conftest.err >&5 14690 echo "$as_me:1469 0: \$? = $ac_status" >&514695 echo "$as_me:14695: \$? = $ac_status" >&5 14691 14696 if (exit $ac_status) && test -s "$ac_outfile"; then 14692 14697 # The compiler can only warn and ignore the option if not recognized … … 14788 14793 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 14789 14794 -e 's:$: $lt_compiler_flag:'` 14790 (eval echo "\"\$as_me:1479 0: $lt_compile\"" >&5)14795 (eval echo "\"\$as_me:14795: $lt_compile\"" >&5) 14791 14796 (eval "$lt_compile" 2>out/conftest.err) 14792 14797 ac_status=$? 14793 14798 cat out/conftest.err >&5 14794 echo "$as_me:1479 4: \$? = $ac_status" >&514799 echo "$as_me:14799: \$? = $ac_status" >&5 14795 14800 if (exit $ac_status) && test -s out/conftest2.$ac_objext 14796 14801 then … … 16995 17000 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 16996 17001 -e 's:$: $lt_compiler_flag:'` 16997 (eval echo "\"\$as_me:1 6997: $lt_compile\"" >&5)17002 (eval echo "\"\$as_me:17002: $lt_compile\"" >&5) 16998 17003 (eval "$lt_compile" 2>conftest.err) 16999 17004 ac_status=$? 17000 17005 cat conftest.err >&5 17001 echo "$as_me:1700 1: \$? = $ac_status" >&517006 echo "$as_me:17006: \$? = $ac_status" >&5 17002 17007 if (exit $ac_status) && test -s "$ac_outfile"; then 17003 17008 # The compiler can only warn and ignore the option if not recognized … … 17263 17268 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 17264 17269 -e 's:$: $lt_compiler_flag:'` 17265 (eval echo "\"\$as_me:172 65: $lt_compile\"" >&5)17270 (eval echo "\"\$as_me:17270: $lt_compile\"" >&5) 17266 17271 (eval "$lt_compile" 2>conftest.err) 17267 17272 ac_status=$? 17268 17273 cat conftest.err >&5 17269 echo "$as_me:172 69: \$? = $ac_status" >&517274 echo "$as_me:17274: \$? = $ac_status" >&5 17270 17275 if (exit $ac_status) && test -s "$ac_outfile"; then 17271 17276 # The compiler can only warn and ignore the option if not recognized … … 17367 17372 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ 17368 17373 -e 's:$: $lt_compiler_flag:'` 17369 (eval echo "\"\$as_me:173 69: $lt_compile\"" >&5)17374 (eval echo "\"\$as_me:17374: $lt_compile\"" >&5) 17370 17375 (eval "$lt_compile" 2>out/conftest.err) 17371 17376 ac_status=$? 17372 17377 cat out/conftest.err >&5 17373 echo "$as_me:1737 3: \$? = $ac_status" >&517378 echo "$as_me:17378: \$? = $ac_status" >&5 17374 17379 if (exit $ac_status) && test -s out/conftest2.$ac_objext 17375 17380 then … … 22959 22964 cat >&5 <<_CSEOF 22960 22965 22961 This file was extended by Cbc $as_me 0.1, which was22966 This file was extended by Cbc $as_me 1.2trunk, which was 22962 22967 generated by GNU Autoconf 2.59. Invocation command line was 22963 22968 … … 23022 23027 cat >>$CONFIG_STATUS <<_ACEOF 23023 23028 ac_cs_version="\\ 23024 Cbc config.status 0.123029 Cbc config.status 1.2trunk 23025 23030 configured by $0, generated by GNU Autoconf 2.59, 23026 23031 with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -
trunk/Cbc/configure.ac
r711 r765 13 13 AC_PREREQ(2.59) 14 14 15 AC_INIT([Cbc],[ 0.1],[coin-cbc@list.coin-or.org])15 AC_INIT([Cbc],[1.2trunk],[coin-cbc@list.coin-or.org]) 16 16 17 17 AC_COPYRIGHT([ -
trunk/Cbc/src/CbcBranchActual.hpp
r720 r765 37 37 ~CbcClique (); 38 38 39 using CbcObject::infeasibility ; 39 40 /// Infeasibility - large is 0.5 40 41 virtual double infeasibility(int & preferredWay) const; 41 42 43 using CbcObject::feasibleRegion ; 42 44 /// This looks at solution and sets bounds to contain solution 43 45 virtual void feasibleRegion(); 46 47 using CbcObject::createBranch ; 44 48 /// Creates a branching object 45 49 virtual CbcBranchingObject * createBranch(int way) ; … … 122 126 ~CbcSOS (); 123 127 128 using CbcObject::infeasibility ; 124 129 /// Infeasibility - large is 0.5 125 130 virtual double infeasibility(int & preferredWay) const; 126 131 132 using CbcObject::feasibleRegion ; 127 133 /// This looks at solution and sets bounds to contain solution 128 134 virtual void feasibleRegion(); 135 136 using CbcObject::createBranch ; 129 137 /// Creates a branching object 130 138 virtual CbcBranchingObject * createBranch(int way) ; 131 139 140 using CbcObject::solverBranch ; 132 141 /** Create an OsiSolverBranch object 133 142 … … 220 229 /// Construct an OsiSimpleInteger object 221 230 OsiSimpleInteger * osiObject() const; 231 using CbcObject::infeasibility ; 222 232 /// Infeasibility - large is 0.5 223 233 virtual double infeasibility(const OsiSolverInterface * solver, 224 234 const OsiBranchingInformation * info, int & preferredWay) const; 225 235 236 using CbcObject::feasibleRegion ; 226 237 /** Set bounds to fix the variable at the current (integer) value. 227 238 … … 231 242 virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const; 232 243 244 using CbcObject::createBranch ; 233 245 /** Create a branching object and indicate which way to branch first. 234 246 … … 238 250 virtual CbcBranchingObject * createBranch(OsiSolverInterface * solver, 239 251 const OsiBranchingInformation * info, int way) ; 252 253 using CbcObject::solverBranch ; 240 254 /** Create an OsiSolverBranch object 241 255 … … 343 357 void applyConsequence(int iSequence, int state) const; 344 358 359 using CbcObject::infeasibility ; 345 360 /// Infeasibility - large is 0.5 (and 0.5 will give this) 346 361 virtual double infeasibility(int & preferredWay) const; 347 362 363 using CbcObject::feasibleRegion ; 348 364 /// This looks at solution and sets bounds to contain solution 349 365 virtual void feasibleRegion(); 366 367 using CbcObject::createBranch ; 350 368 /// Creates a branching object 351 369 virtual CbcBranchingObject * createBranch(int way) ; 370 352 371 /// Number of members 353 372 inline int numberMembers() const … … 420 439 virtual ~CbcIntegerBranchingObject (); 421 440 441 using CbcBranchingObject::branch ; 422 442 /** \brief Sets the bounds for the variable according to the current arm 423 443 of the branch and advances the object state to the next arm. … … 426 446 virtual double branch(); 427 447 448 using CbcBranchingObject::print ; 428 449 /** \brief Print something about branch - only if log level high 429 450 */ … … 470 491 ~CbcSimpleIntegerPseudoCost (); 471 492 493 using CbcObject::infeasibility ; 472 494 /// Infeasibility - large is 0.5 473 495 virtual double infeasibility(int & preferredWay) const; 474 496 497 using CbcObject::createBranch ; 475 498 /// Creates a branching object 476 499 virtual CbcBranchingObject * createBranch(int way) ; … … 580 603 virtual ~CbcIntegerPseudoCostBranchingObject (); 581 604 605 using CbcBranchingObject::branch ; 582 606 /** \brief Sets the bounds for the variable according to the current arm 583 607 of the branch and advances the object state to the next arm. … … 631 655 virtual ~CbcCliqueBranchingObject (); 632 656 657 using CbcBranchingObject::branch ; 633 658 /// Does next branch and updates state 634 659 virtual double branch(); 635 660 661 using CbcBranchingObject::print ; 636 662 /** \brief Print something about branch - only if log level high 637 663 */ … … 676 702 virtual ~CbcLongCliqueBranchingObject (); 677 703 704 using CbcBranchingObject::branch ; 678 705 /// Does next branch and updates state 679 706 virtual double branch(); 680 707 708 using CbcBranchingObject::print ; 681 709 /** \brief Print something about branch - only if log level high 682 710 */ … … 720 748 virtual ~CbcSOSBranchingObject (); 721 749 750 using CbcBranchingObject::branch ; 722 751 /// Does next branch and updates state 723 752 virtual double branch(); 724 753 754 using CbcBranchingObject::print ; 725 755 /** \brief Print something about branch - only if log level high 726 756 */ … … 762 792 virtual ~CbcNWayBranchingObject (); 763 793 794 using CbcBranchingObject::branch ; 764 795 /// Does next branch and updates state 765 796 virtual double branch(); 766 797 798 using CbcBranchingObject::print ; 767 799 /** \brief Print something about branch - only if log level high 768 800 */ … … 905 937 ~CbcFollowOn (); 906 938 939 using CbcObject::infeasibility ; 907 940 /// Infeasibility - large is 0.5 908 941 virtual double infeasibility(int & preferredWay) const; 909 942 943 using CbcObject::feasibleRegion ; 910 944 /// This looks at solution and sets bounds to contain solution 911 945 virtual void feasibleRegion(); 946 947 using CbcObject::createBranch ; 912 948 /// Creates a branching object 913 949 virtual CbcBranchingObject * createBranch(int way) ; … … 952 988 virtual ~CbcFixingBranchingObject (); 953 989 990 using CbcBranchingObject::branch ; 954 991 /// Does next branch and updates state 955 992 virtual double branch(); 956 993 994 using CbcBranchingObject::print ; 957 995 /** \brief Print something about branch - only if log level high 958 996 */ … … 1047 1085 virtual ~CbcDummyBranchingObject (); 1048 1086 1087 using CbcBranchingObject::branch ; 1049 1088 /** \brief Dummy branch 1050 1089 */ 1051 1090 virtual double branch(); 1052 1091 1092 using CbcBranchingObject::print ; 1053 1093 /** \brief Print something about branch - only if log level high 1054 1094 */ -
trunk/Cbc/src/CbcBranchBase.hpp
r706 r765 299 299 { return branch();} 300 300 301 using OsiBranchingObject::print ; 301 302 /** \brief Print something about branch - only if log level high 302 303 */ -
trunk/Cbc/src/CbcBranchCut.hpp
r640 r765 34 34 ~CbcBranchCut (); 35 35 36 using CbcObject::infeasibility ; 36 37 /// Infeasibility 37 38 virtual double infeasibility(int & preferredWay) const; 38 39 40 using CbcObject::feasibleRegion ; 39 41 /** Set bounds to contain the current solution. 40 42 … … 51 53 */ 52 54 virtual bool boundBranch() const ; 55 56 using CbcObject::createBranch ; 53 57 /// Creates a branching object 54 58 virtual CbcBranchingObject * createBranch(int way) ; … … 82 86 virtual CbcBranchingObject * notPreferredNewFeasible() const ; 83 87 88 using CbcObject::resetBounds ; 84 89 /** Reset original upper and lower bound values from the solver. 85 90 … … 127 132 virtual ~CbcCutBranchingObject (); 128 133 134 using CbcBranchingObject::branch ; 129 135 /** \brief Sets the bounds for variables or adds a cut depending on the 130 136 current arm of the branch and advances the object state to the next arm. … … 133 139 virtual double branch(); 134 140 141 using CbcBranchingObject::print ; 135 142 /** \brief Print something about branch - only if log level high 136 143 */ … … 193 200 */ 194 201 int shallWe() const; 202 203 using CbcObject::infeasibility ; 195 204 /// Infeasibility - large is 0.5 196 205 virtual double infeasibility(int & preferredWay) const; 197 206 207 using CbcObject::createBranch ; 198 208 /// Creates a branching object 199 209 virtual CbcBranchingObject * createBranch(int way); … … 248 258 ~CbcBranchAllDifferent (); 249 259 260 using CbcObject::infeasibility ; 250 261 /// Infeasibility - large is 0.5 251 262 virtual double infeasibility(int & preferredWay) const; 252 263 264 using CbcObject::createBranch ; 253 265 /// Creates a branching object 254 266 virtual CbcBranchingObject * createBranch(int way); -
trunk/Cbc/src/CbcBranchDynamic.hpp
r706 r765 47 47 ~CbcSimpleIntegerDynamicPseudoCost (); 48 48 49 using CbcObject::infeasibility ; 49 50 /// Infeasibility - large is 0.5 50 51 virtual double infeasibility(int & preferredWay) const; 51 52 53 using CbcObject::createBranch ; 52 54 /// Creates a branching object 53 55 virtual CbcBranchingObject * createBranch(int way) ; 56 54 57 /// Infeasibility - large is 0.5 55 58 virtual double infeasibility(const OsiSolverInterface * solver, … … 76 79 void copySome(CbcSimpleIntegerDynamicPseudoCost * otherObject); 77 80 81 using CbcSimpleInteger::solverBranch ; 78 82 /** Create an OsiSolverBranch object 79 83 … … 345 349 virtual ~CbcDynamicPseudoCostBranchingObject (); 346 350 351 using CbcBranchingObject::branch ; 347 352 /** \brief Sets the bounds for the variable according to the current arm 348 353 of the branch and advances the object state to the next arm. … … 350 355 */ 351 356 virtual double branch(); 357 352 358 /** Some branchingObjects may claim to be able to skip 353 359 strong branching. If so they have to fill in CbcStrongInfo. -
trunk/Cbc/src/CbcBranchLotsize.hpp
r706 r765 34 34 ~CbcLotsize (); 35 35 36 using CbcObject::infeasibility ; 36 37 /// Infeasibility - large is 0.5 37 38 virtual double infeasibility(int & preferredWay) const; 38 39 40 using CbcObject::feasibleRegion ; 39 41 /** Set bounds to contain the current solution. 40 42 … … 46 48 virtual void feasibleRegion(); 47 49 50 using CbcObject::createBranch ; 48 51 /// Creates a branching object 49 52 virtual CbcBranchingObject * createBranch(int way) ; … … 188 191 virtual ~CbcLotsizeBranchingObject (); 189 192 193 using CbcBranchingObject::branch ; 190 194 /** \brief Sets the bounds for the variable according to the current arm 191 195 of the branch and advances the object state to the next arm. … … 193 197 virtual double branch(); 194 198 199 using CbcBranchingObject::print ; 195 200 /** \brief Print something about branch - only if log level high 196 201 */ -
trunk/Cbc/src/CbcCompareActual.hpp
r706 r765 85 85 weighted value of node x */ 86 86 virtual bool test (CbcNode * x, CbcNode * y) ; 87 88 using CbcCompareBase::newSolution ; 87 89 // This allows method to change behavior as it is called 88 90 // after each solution -
trunk/Cbc/src/CbcFathomDynamicProgramming.cpp
r702 r765 259 259 numberActive_=numberActive; 260 260 indices_ = new int [numberActive_]; 261 cost_ = new float[size_];262 CoinFillN(cost_,size_, FLT_MAX);261 cost_ = new double [size_]; 262 CoinFillN(cost_,size_,DBL_MAX); 263 263 // but do nothing is okay 264 264 cost_[0]=0.0; … … 475 475 int i; 476 476 // may be possible 477 double bestAtTarget = FLT_MAX;477 double bestAtTarget = DBL_MAX; 478 478 for (i=0;i<numberColumns;i++) { 479 479 if (size_>10000000&&(i%100)==0) … … 481 481 double lowerValue = lower[i]; 482 482 assert (lowerValue==floor(lowerValue)); 483 floatcost = direction * objective[i];483 double cost = direction * objective[i]; 484 484 fixedObj += lowerValue*cost; 485 485 int gap = (int) (upper[i]-lowerValue); … … 494 494 returnCode=1; 495 495 int needed=0; 496 float bestValue=FLT_MAX;496 double bestValue=DBL_MAX; 497 497 int iBest=-1; 498 498 if (algorithm_==0) { … … 554 554 delete [] lower; 555 555 } 556 if (bestValue< FLT_MAX) {556 if (bestValue<DBL_MAX) { 557 557 bestValue += fixedObj; 558 558 if (model_->messageHandler()->logLevel()>1) … … 565 565 int n=decodeBitPattern(iBest-back_[iBest],indices_,numberRows); 566 566 // Search for cheapest 567 float bestCost=FLT_MAX;567 double bestCost=DBL_MAX; 568 568 int iColumn=-1; 569 569 for (i=0;i<numberColumns;i++) { … … 632 632 bool 633 633 CbcFathomDynamicProgramming::tryColumn(int numberElements, const int * rows, 634 const double * coefficients, floatcost,634 const double * coefficients, double cost, 635 635 int upper) 636 636 { … … 693 693 bool 694 694 CbcFathomDynamicProgramming::addOneColumn0(int numberElements, const int * rows, 695 floatcost)695 double cost) 696 696 { 697 697 // build up mask … … 708 708 int kMask = i&mask; 709 709 if (kMask==0) { 710 floatthisCost = cost_[i];711 if (thisCost!= FLT_MAX) {710 double thisCost = cost_[i]; 711 if (thisCost!=DBL_MAX) { 712 712 // possible 713 floatnewCost=thisCost+cost;713 double newCost=thisCost+cost; 714 714 int next = i + mask; 715 715 if (cost_[next]>newCost) { … … 740 740 bool 741 741 CbcFathomDynamicProgramming::addOneColumn1(int numberElements, const int * rows, 742 const int * coefficients, floatcost)742 const int * coefficients, double cost) 743 743 { 744 744 /* build up masks. … … 824 824 if (good) { 825 825 double thisCost = cost_[i]; 826 if (thisCost!= FLT_MAX) {826 if (thisCost!=DBL_MAX) { 827 827 // possible 828 828 double newCost=thisCost+cost; … … 858 858 bool 859 859 CbcFathomDynamicProgramming::addOneColumn1A(int numberElements, const int * rows, 860 const int * coefficients, floatcost)860 const int * coefficients, double cost) 861 861 { 862 862 /* build up masks. … … 899 899 int kMask = i&maskA; 900 900 if (kMask==0) { 901 floatthisCost = cost_[i];902 if (thisCost!= FLT_MAX) {901 double thisCost = cost_[i]; 902 if (thisCost!=DBL_MAX) { 903 903 // possible 904 floatnewCost=thisCost+cost;904 double newCost=thisCost+cost; 905 905 int next = i + maskAdd; 906 906 if (cost_[next]>newCost) { … … 926 926 added &= (~maskD); 927 927 if (added == 0) { 928 floatthisCost = cost_[i];929 if (thisCost!= FLT_MAX) {928 double thisCost = cost_[i]; 929 if (thisCost!=DBL_MAX) { 930 930 // possible 931 floatnewCost=thisCost+cost;931 double newCost=thisCost+cost; 932 932 int next = i + maskAdd; 933 933 if (cost_[next]>newCost) { -
trunk/Cbc/src/CbcFathomDynamicProgramming.hpp
r706 r765 68 68 */ 69 69 bool tryColumn(int numberElements, const int * rows, 70 const double * coefficients, floatcost,70 const double * coefficients, double cost, 71 71 int upper=COIN_INT_MAX); 72 72 /// Returns cost array 73 inline const float* cost() const73 inline const double * cost() const 74 74 { return cost_;} 75 75 /// Returns back array … … 90 90 */ 91 91 bool addOneColumn0(int numberElements, const int * rows, 92 floatcost);92 double cost); 93 93 /** Adds one attempt of one column of type 1, 94 94 returns true if was used in making any changes. … … 96 96 */ 97 97 bool addOneColumn1(int numberElements, const int * rows, 98 const int * coefficients, floatcost);98 const int * coefficients, double cost); 99 99 /** Adds one attempt of one column of type 1, 100 100 returns true if was used in making any changes. … … 103 103 */ 104 104 bool addOneColumn1A(int numberElements, const int * rows, 105 const int * coefficients, floatcost);105 const int * coefficients, double cost); 106 106 /// Gets bit pattern from original column 107 107 int bitPattern(int numberElements, const int * rows, … … 121 121 */ 122 122 int type_; 123 /// Space for states (float as who cares)124 float* cost_;123 /// Space for states 124 double * cost_; 125 125 /// Which state produced this cheapest one 126 126 int * back_; -
trunk/Cbc/src/CbcGeneric.cpp
r640 r765 107 107 108 108 return ; } 109 110 109 111 110 } // end unnamed namespace -
trunk/Cbc/src/CbcHeuristic.cpp
r759 r765 679 679 lastChange=0; 680 680 for (iColumn=0;iColumn<numberColumns;iColumn++) { 681 bool isInteger = integerType[iColumn];681 bool isInteger = (integerType[iColumn]!=0); 682 682 double currentValue = newSolution[iColumn]; 683 683 double lowerValue = lower[iColumn]; -
trunk/Cbc/src/CbcHeuristic.hpp
r706 r765 161 161 virtual void setModel(CbcModel * model); 162 162 163 using CbcHeuristic::solution ; 163 164 /** returns 0 if no solution, 1 if valid solution 164 165 with better objective value than one passed in … … 220 221 virtual void setModel(CbcModel * model); 221 222 223 using CbcHeuristic::solution ; 222 224 /** returns 0 if no solution, 1 if valid solution. 223 225 Sets solution values if good, sets objective value (only if good) -
trunk/Cbc/src/CbcHeuristicFPump.hpp
r758 r765 38 38 virtual void setModel(CbcModel * model); 39 39 40 using CbcHeuristic::solution ; 40 41 /** returns 0 if no solution, 1 if valid solution 41 42 with better objective value than one passed in -
trunk/Cbc/src/CbcHeuristicGreedy.hpp
r706 r765 35 35 virtual void setModel(CbcModel * model); 36 36 37 using CbcHeuristic::solution ; 37 38 /** returns 0 if no solution, 1 if valid solution. 38 39 Sets solution values if good, sets objective value (only if good) … … 113 114 virtual void setModel(CbcModel * model); 114 115 116 using CbcHeuristic::solution ; 115 117 /** returns 0 if no solution, 1 if valid solution. 116 118 Sets solution values if good, sets objective value (only if good) -
trunk/Cbc/src/CbcHeuristicLocal.hpp
r706 r765 40 40 virtual void setModel(CbcModel * model); 41 41 42 using CbcHeuristic::solution ; 42 43 /** returns 0 if no solution, 1 if valid solution. 43 44 Sets solution values if good, sets objective value (only if good) -
trunk/Cbc/src/CbcHeuristicRINS.hpp
r706 r765 41 41 virtual void setModel(CbcModel * model); 42 42 43 using CbcHeuristic::solution ; 43 44 /** returns 0 if no solution, 1 if valid solution. 44 45 Sets solution values if good, sets objective value (only if good) -
trunk/Cbc/src/CbcLinked.hpp
r706 r765 334 334 unsigned int type:4; // type of computation 335 335 unsigned int affected:25; // variable or element affected 336 floatmultiplier; // to use in computation336 double multiplier; // to use in computation 337 337 } boundElementAction; 338 338 … … 377 377 virtual void setModel(CbcModel * model); 378 378 379 using CbcHeuristic::solution ; 379 380 /** returns 0 if no solution, 1 if valid solution. 380 381 Sets solution values if good, sets objective value (only if good) … … 446 447 virtual ~OsiOldLink (); 447 448 449 using OsiObject::infeasibility ; 448 450 /// Infeasibility - large is 0.5 449 451 virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const; 450 452 453 using OsiObject::feasibleRegion ; 451 454 /** Set bounds to fix the variable at the current (integer) value. 452 455 … … 511 514 virtual ~OsiOldLinkBranchingObject (); 512 515 516 using OsiBranchingObject::branch ; 513 517 /// Does next branch and updates state 514 518 virtual double branch(OsiSolverInterface * solver); 515 519 520 using OsiBranchingObject::print ; 516 521 /** \brief Print something about branch - only if log level high 517 522 */ … … 592 597 virtual ~OsiLink (); 593 598 599 using OsiObject::infeasibility ; 594 600 /// Infeasibility - large is 0.5 595 601 virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const; 596 602 603 using OsiObject::feasibleRegion ; 597 604 /** Set bounds to fix the variable at the current (integer) value. 598 605 … … 664 671 virtual ~OsiLinkBranchingObject (); 665 672 673 using OsiBranchingObject::branch ; 666 674 /// Does next branch and updates state 667 675 virtual double branch(OsiSolverInterface * solver); 668 676 677 using OsiBranchingObject::print ; 669 678 /** \brief Print something about branch - only if log level high 670 679 */ … … 719 728 virtual ~OsiBiLinear (); 720 729 730 using OsiObject::infeasibility ; 721 731 /// Infeasibility - large is 0.5 722 732 virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const; 723 733 734 using OsiObject::feasibleRegion ; 724 735 /** Set bounds to fix the variable at the current (integer) value. 725 736 … … 943 954 virtual ~OsiBiLinearBranchingObject (); 944 955 956 using OsiBranchingObject::branch ; 945 957 /// Does next branch and updates state 946 958 virtual double branch(OsiSolverInterface * solver); 947 959 960 using OsiBranchingObject::print ; 948 961 /** \brief Print something about branch - only if log level high 949 962 */ … … 1041 1054 virtual ~OsiSimpleFixedInteger (); 1042 1055 1056 using OsiObject::infeasibility ; 1043 1057 /// Infeasibility - large is 0.5 1044 1058 virtual double infeasibility(const OsiBranchingInformation * info, int & whichWay) const; 1059 1045 1060 /** Creates a branching object 1046 1061 … … 1089 1104 virtual ~OsiUsesBiLinear (); 1090 1105 1106 using OsiObject::infeasibility ; 1091 1107 /// Infeasibility - large is 0.5 1092 1108 virtual double infeasibility(const OsiBranchingInformation * info, int & whichWay) const; 1109 1093 1110 /** Creates a branching object 1094 1111 … … 1096 1113 */ 1097 1114 virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const; 1115 1116 using OsiObject::feasibleRegion ; 1098 1117 /** Set bounds to fix the variable at the current value. 1099 1118 … … 1102 1121 */ 1103 1122 virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const; 1123 1104 1124 /// Add all bi-linear objects 1105 1125 void addBiLinearObjects(OsiSolverLink * solver); -
trunk/Cbc/src/CbcMain.cpp
r759 r765 304 304 CbcParam("directory","Set Default import directory", 305 305 DIRECTORY); 306 parameters[numberParameters++]= 307 CbcParam("dirSample","Set directory where the COIN-OR sample problems are.", 308 DIRSAMPLE); 309 parameters[numberParameters++]= 310 CbcParam("dirNetlib","Set directory where the netlib problems are.", 311 DIRNETLIB); 312 parameters[numberParameters++]= 313 CbcOrClpParam("dirMiplib","Set directory where the miplib 2003 problems are.", 314 DIRMIPLIB); 306 315 parameters[numberParameters++]= 307 316 CbcParam("solver!","Set the solver used by cbc", … … 726 735 727 736 const char dirsep = CoinFindDirSeparator(); 728 std::string directory = (dirsep == '/' ? "./" : ".\\"); 737 std::string directory; 738 std::string dirSample; 739 std::string dirNetlib; 740 std::string dirMiplib; 741 if (dirsep == '/') { 742 directory = "./"; 743 dirSample = "../../Data/Sample/"; 744 dirNetlib = "../../Data/Netlib/"; 745 dirMiplib = "../../Data/miplib3/"; 746 } else { 747 directory = ".\\"; 748 dirSample = "..\\..\\Data\\Sample\\"; 749 dirNetlib = "..\\..\\Data\\Netlib\\"; 750 dirMiplib = "..\\..\\Data\\miplib3\\"; 751 } 729 752 std::string field; 730 753 /* … … 1419 1442 directory += '/' ; 1420 1443 break ; } 1444 case DIRSAMPLE: 1445 { dirSample = getString(argc,argv); 1446 if (dirSample[dirSample.length()-1] != '/') 1447 dirSample += '/' ; 1448 break ; } 1449 case DIRNETLIB: 1450 { dirNetlib = getString(argc,argv); 1451 if (dirNetlib[dirNetlib.length()-1] != '/') 1452 dirNetlib += '/' ; 1453 break ; } 1454 case DIRMIPLIB: 1455 { dirMiplib = getString(argc,argv); 1456 if (dirMiplib[dirMiplib.length()-1] != '/') 1457 dirMiplib += '/' ; 1458 break ; } 1421 1459 case STDIN: 1422 1460 read_mode=-1; … … 1478 1516 // create fields for test 1479 1517 const char * fields[3]; 1480 int nFields= 1;1518 int nFields=3; 1481 1519 fields[0]="fake main for miplib"; 1482 if (directory!="./") { 1483 fields[1]=("-miplibDir="+directory).c_str(); 1484 nFields=2; 1485 } 1520 std::string mpsfield = "-mpsDir="; 1521 mpsfield += dirSample.c_str(); 1522 fields[1]=mpsfield.c_str(); 1523 std::string mipfield = "-miplibDir="; 1524 mipfield += dirMiplib.c_str(); 1525 fields[2]=mipfield.c_str(); 1486 1526 mainTest(nFields,fields); 1487 1527 } -
trunk/Cbc/src/CbcModel.cpp
r758 r765 5382 5382 delete basis; 5383 5383 } 5384 feasible = resolve(node ? node->nodeInfo() : NULL,2) ;5384 feasible = ( resolve(node ? node->nodeInfo() : NULL,2) != 0) ; 5385 5385 if ( getCurrentSeconds() > dblParam_[CbcMaximumSeconds] ) 5386 5386 numberTries=0; // exit … … 8271 8271 // solve LP 8272 8272 //solver_->writeMps("bad"); 8273 bool feasible = resolve(NULL,3);8273 bool feasible = (resolve(NULL,3)!=0); 8274 8274 8275 8275 CbcModel * newModel = NULL; … … 8304 8304 status_ = 0; 8305 8305 // solve LP 8306 bool feasible = resolve(NULL,3);8306 bool feasible = (resolve(NULL,3)!=0); 8307 8307 8308 8308 bestObjective_=1.0e50; … … 8499 8499 // just point to solver_ 8500 8500 continuousSolver_ = solver_; 8501 feasible= resolve(NULL,3);8501 feasible=(resolve(NULL,3)!=0); 8502 8502 if (!feasible||!doIntegerPresolve||weak) break; 8503 8503 // see if we can get solution by heuristics -
trunk/Cbc/src/CbcModel.hpp
r758 r765 2093 2093 // When we want to load up CbcModel with options first 2094 2094 void CbcMain0 (CbcModel & babSolver); 2095 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver); 2095 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, 2096 int call_CbcClpUnitTest_on_777 = 0); 2096 2097 // two ways of calling 2097 2098 int callCbc(const char * input2, CbcModel & babSolver); … … 2103 2104 int callCbc1(const char * input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom)); 2104 2105 int callCbc1(const std::string input2, CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom)); 2105 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom) );2106 int CbcMain1 (int argc, const char *argv[],CbcModel & babSolver, int (CbcModel * currentSolver, int whereFrom), int call_CbcClpUnitTest_on_777 = 0); 2106 2107 #endif -
trunk/Cbc/src/CbcSolver.cpp
r760 r765 1662 1662 } 1663 1663 int CbcMain1 (int argc, const char *argv[], 1664 CbcModel & model)1664 CbcModel & model, int call_CbcClpUnitTest_on_777) 1665 1665 { 1666 return CbcMain1(argc,argv,model,dummyCallBack );1666 return CbcMain1(argc,argv,model,dummyCallBack, call_CbcClpUnitTest_on_777); 1667 1667 } 1668 1668 int callCbc1(const std::string input2, CbcModel & babSolver, int callBack(CbcModel * currentSolver, int whereFrom)) … … 1699 1699 establishParams(numberParameters,parameters) ; 1700 1700 const char dirsep = CoinFindDirSeparator(); 1701 std::string directory = (dirsep == '/' ? "./" : ".\\"); 1701 std::string directory; 1702 std::string dirSample; 1703 std::string dirNetlib; 1704 std::string dirMiplib; 1705 if (dirsep == '/') { 1706 directory = "./"; 1707 dirSample = "../../Data/Sample/"; 1708 dirNetlib = "../../Data/Netlib/"; 1709 dirMiplib = "../../Data/miplib3/"; 1710 } else { 1711 directory = ".\\"; 1712 dirSample = "..\\..\\Data\\Sample\\"; 1713 dirNetlib = "..\\..\\Data\\Netlib\\"; 1714 dirMiplib = "..\\..\\Data\\miplib3\\"; 1715 } 1702 1716 std::string defaultDirectory = directory; 1703 1717 std::string importFile =""; … … 1725 1739 parameters[whichParam(PRINTMASK,numberParameters,parameters)].setStringValue(printMask); 1726 1740 parameters[whichParam(DIRECTORY,numberParameters,parameters)].setStringValue(directory); 1741 parameters[whichParam(DIRSAMPLE,numberParameters,parameters)].setStringValue(dirSample); 1742 parameters[whichParam(DIRNETLIB,numberParameters,parameters)].setStringValue(dirNetlib); 1743 parameters[whichParam(DIRMIPLIB,numberParameters,parameters)].setStringValue(dirMiplib); 1727 1744 parameters[whichParam(DUALBOUND,numberParameters,parameters)].setDoubleValue(lpSolver->dualBound()); 1728 1745 parameters[whichParam(DUALTOLERANCE,numberParameters,parameters)].setDoubleValue(lpSolver->dualTolerance()); … … 1795 1812 parameters[whichParam(COSTSTRATEGY,numberParameters,parameters)].setCurrentOption("off"); 1796 1813 } 1814 1797 1815 /* 1 - add heuristics to model 1798 1816 2 - do heuristics (and set cutoff and best solution) … … 1981 1999 } 1982 2000 } 2001 2002 void CbcClpUnitTest (const CbcModel & saveModel, 2003 std::string& dirMiplib, bool unitTestOnly); 2004 1983 2005 /* Meaning of whereFrom: 1984 2006 1 after initial solve by dualsimplex etc … … 1989 2011 6 after a user called heuristic phase 1990 2012 */ 2013 1991 2014 int CbcMain1 (int argc, const char *argv[], 1992 CbcModel & model, int callBack(CbcModel * currentSolver, int whereFrom)) 2015 CbcModel & model, 2016 int callBack(CbcModel * currentSolver, int whereFrom), 2017 int call_CbcClpUnitTest_on_777) 1993 2018 { 1994 2019 /* Note … … 2272 2297 double tightenFactor=0.0; 2273 2298 const char dirsep = CoinFindDirSeparator(); 2274 std::string directory = (dirsep == '/' ? "./" : ".\\"); 2299 std::string directory; 2300 std::string dirSample; 2301 std::string dirNetlib; 2302 std::string dirMiplib; 2303 if (dirsep == '/') { 2304 directory = "./"; 2305 dirSample = "../../Data/Sample/"; 2306 dirNetlib = "../../Data/Netlib/"; 2307 dirMiplib = "../../Data/miplib3/"; 2308 } else { 2309 directory = ".\\"; 2310 dirSample = "..\\..\\Data\\Sample\\"; 2311 dirNetlib = "..\\..\\Data\\Netlib\\"; 2312 dirMiplib = "..\\..\\Data\\miplib3\\"; 2313 } 2275 2314 std::string defaultDirectory = directory; 2276 2315 std::string importFile =""; … … 5309 5348 } 5310 5349 model = *babModel; 5350 /* LL: this was done in CoinSolve.cpp: main(argc, argv). 5351 I have moved it here so that the miplib directory location 5352 could be passed to CbcClpUnitTest. */ 5353 if (call_CbcClpUnitTest_on_777 == 777) { 5354 CbcClpUnitTest(model, dirMiplib, false); 5355 } 5311 5356 return 777; 5312 5357 } else { … … 6571 6616 } 6572 6617 break; 6618 case DIRSAMPLE: 6619 { 6620 std::string name = CoinReadGetString(argc,argv); 6621 if (name!="EOL") { 6622 int length=name.length(); 6623 if (name[length-1]=='/'||name[length-1]=='\\') 6624 dirSample=name; 6625 else 6626 dirSample = name+"/"; 6627 parameters[iParam].setStringValue(dirSample); 6628 } else { 6629 parameters[iParam].printString(); 6630 } 6631 } 6632 break; 6633 case DIRNETLIB: 6634 { 6635 std::string name = CoinReadGetString(argc,argv); 6636 if (name!="EOL") { 6637 int length=name.length(); 6638 if (name[length-1]=='/'||name[length-1]=='\\') 6639 dirNetlib=name; 6640 else 6641 dirNetlib = name+"/"; 6642 parameters[iParam].setStringValue(dirNetlib); 6643 } else { 6644 parameters[iParam].printString(); 6645 } 6646 } 6647 break; 6648 case DIRMIPLIB: 6649 { 6650 std::string name = CoinReadGetString(argc,argv); 6651 if (name!="EOL") { 6652 int length=name.length(); 6653 if (name[length-1]=='/'||name[length-1]=='\\') 6654 dirMiplib=name; 6655 else 6656 dirMiplib = name+"/"; 6657 parameters[iParam].setStringValue(dirMiplib); 6658 } else { 6659 parameters[iParam].printString(); 6660 } 6661 } 6662 break; 6573 6663 case STDIN: 6574 6664 CbcOrClpRead_mode=-1; … … 6586 6676 case UNITTEST: 6587 6677 { 6588 printf("unit test is now only from clp - does same thing\n"); 6589 //return(22); 6678 CbcClpUnitTest(model, dirSample, true); 6590 6679 } 6591 6680 break; -
trunk/Cbc/src/CbcTree.cpp
r724 r765 41 41 { 42 42 comparison_.test_ = &compare; 43 make_heap(nodes_.begin(), nodes_.end(), comparison_);43 std::make_heap(nodes_.begin(), nodes_.end(), comparison_); 44 44 } 45 45 … … 59 59 assert(x->objectiveValue()!=COIN_DBL_MAX&&x->nodeInfo()); 60 60 nodes_.push_back(x); 61 push_heap(nodes_.begin(), nodes_.end(), comparison_);61 std::push_heap(nodes_.begin(), nodes_.end(), comparison_); 62 62 } 63 63 … … 65 65 void 66 66 CbcTree::pop() { 67 pop_heap(nodes_.begin(), nodes_.end(), comparison_);67 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 68 68 nodes_.pop_back(); 69 69 } … … 89 89 #if 0 90 90 // take off 91 pop_heap(nodes_.begin(), nodes_.end(), comparison_);91 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 92 92 nodes_.pop_back(); 93 93 delete best; … … 119 119 // can pop 120 120 // take off 121 pop_heap(nodes_.begin(), nodes_.end(), comparison_);121 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 122 122 nodes_.pop_back(); 123 123 } else { … … 127 127 } else if (best) { 128 128 // take off 129 pop_heap(nodes_.begin(), nodes_.end(), comparison_);129 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 130 130 nodes_.pop_back(); 131 131 } … … 330 330 CbcTree::pop() { 331 331 #if 0 332 pop_heap(nodes_.begin(), nodes_.end(), comparison_);332 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 333 333 nodes_.pop_back(); 334 334 #else … … 362 362 #if 0 363 363 // take off 364 pop_heap(nodes_.begin(), nodes_.end(), comparison_);364 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 365 365 nodes_.pop_back(); 366 366 delete best; … … 392 392 // can pop 393 393 // take off 394 pop_heap(nodes_.begin(), nodes_.end(), comparison_);394 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 395 395 nodes_.pop_back(); 396 396 } else { … … 401 401 // take off 402 402 #if 0 403 pop_heap(nodes_.begin(), nodes_.end(), comparison_);403 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 404 404 nodes_.pop_back(); 405 405 #else -
trunk/Cbc/src/CbcTree.hpp
r724 r765 3 3 #ifndef CbcTree_H 4 4 #define CbcTree_H 5 using namespace std;6 7 5 8 6 #include <vector> -
trunk/Cbc/src/CbcTreeLocal.cpp
r511 r765 384 384 x->nodeInfo()->nodeNumber(),x,x->nodeInfo()); 385 385 #endif 386 push_heap(nodes_.begin(), nodes_.end(), comparison_);386 std::push_heap(nodes_.begin(), nodes_.end(), comparison_); 387 387 } 388 388 … … 390 390 void 391 391 CbcTreeLocal::pop() { 392 pop_heap(nodes_.begin(), nodes_.end(), comparison_);392 std::pop_heap(nodes_.begin(), nodes_.end(), comparison_); 393 393 nodes_.pop_back(); 394 394 } … … 660 660 nodes_.push_back(localNode_); 661 661 localNode_=localNode2; 662 make_heap(nodes_.begin(), nodes_.end(), comparison_);662 std::make_heap(nodes_.begin(), nodes_.end(), comparison_); 663 663 } 664 664 } -
trunk/Cbc/src/CoinSolve.cpp
r755 r765 190 190 // End any fake main program 191 191 //############################################################################# 192 void CbcClpUnitTest (const CbcModel & saveModel);192 // void CbcClpUnitTest (const CbcModel & saveModel); 193 193 int main (int argc, const char *argv[]) 194 194 { … … 215 215 setCbcOrClpPrinting(false); 216 216 #endif 217 int returnCode = CbcMain1 (argc, argv,model); 217 int returnCode = CbcMain1 (argc, argv,model, 777); 218 #if 0 219 /* The call to CbcClpUnitTest was moved into CbcMain1. To make sure 220 CbcMain1 behaves as it did before for any other call, I have added one more 221 argument to indicate that it was called from here. */ 218 222 if (returnCode!=777) { 219 223 //const CoinWarmStartBasis* debugws = … … 227 231 return 0; 228 232 } 229 } 233 #else 234 if (returnCode!=777) { 235 return returnCode; 236 } else { 237 return 0; 238 } 239 #endif 240 } 241 230 242 /* 231 243 Version 1.00.00 November 16 2005. -
trunk/Cbc/src/Makefile.am
r710 r765 1 # Copyright (C) 2006 International Business Machines and others.1 # Copyright (C) 2006, 2007 International Business Machines and others. 2 2 # All Rights Reserved. 3 3 # This file is distributed under the Common Public License. … … 15 15 # Name of the library compiled in this directory. We want it to be installed 16 16 # in the 'lib' directory 17 lib_LTLIBRARIES = libCbc.la 17 lib_LTLIBRARIES = libCbc.la libCbcSolver.la 18 18 19 19 # List all source files for this library, including headers … … 42 42 CbcModel.cpp CbcModel.hpp \ 43 43 CbcNode.cpp CbcNode.hpp \ 44 CbcSolver.cpp CbcCbcParam.cpp \45 44 CbcStatistics.cpp CbcStatistics.hpp \ 46 45 CbcStrategy.cpp CbcStrategy.hpp \ 47 46 CbcTree.cpp CbcTree.hpp \ 47 CbcTreeLocal.cpp CbcTreeLocal.hpp 48 49 libCbcSolver_la_SOURCES = \ 50 CbcCbcParam.cpp \ 51 Cbc_ampl.cpp Cbc_ampl.h \ 52 ClpConstraintAmpl.hpp ClpAmplObjective.hpp ClpAmplStuff.cpp \ 48 53 CbcLinked.cpp CbcLinked.hpp \ 49 CbcTreeLocal.cpp CbcTreeLocal.hpp \ 50 ClpConstraintAmpl.hpp ClpAmplObjective.hpp ClpAmplStuff.cpp 54 unitTestClp.cpp CbcSolver.cpp 55 56 #Stefan: added unitTestClp.cpp because CbcSolver defines reference to it 51 57 52 58 ## If we have the Ampl solver library, we need to add additional things 53 59 ## also see lower down 54 60 ## new idea is to add in source code anyway 55 libCbc_la_SOURCES += Cbc_ampl.cpp Cbc_ampl.h61 ##libCbc_la_SOURCES += Cbc_ampl.cpp Cbc_ampl.h 56 62 57 63 … … 59 65 60 66 libCbc_la_LDFLAGS = $(LT_LDFLAGS) 67 libCbcSolver_la_LDFLAGS = $(LT_LDFLAGS) 61 68 62 69 # Some common setup for cbc and cbc-generic. … … 82 89 # List all source files for this executable, including headers 83 90 cbc_SOURCES = \ 84 CoinSolve.cpp \ 85 unitTestClp.cpp 91 CoinSolve.cpp 86 92 87 93 # Additional COIN libraries 88 cbc_LDADD = libCbc.la \ 94 cbc_LDADD = libCbcSolver.la \ 95 libCbc.la \ 89 96 $(CGLOBJDIR)/src/libCgl.la \ 90 97 $(OSIOBJDIR)/src/OsiClp/libOsiClp.la \ … … 139 146 CbcGenSolvers.cpp 140 147 141 cbc_generic_LDADD = libCbc.la \ 148 cbc_generic_LDADD = libCbcSolver.la \ 149 libCbc.la \ 142 150 $(CGLOBJDIR)/src/libCgl.la 143 151 … … 218 226 -I`$(CYGPATH_W) $(OSISRCDIR)/src/OsiXpr` 219 227 cbc_generic_LDADD += $(OSIOBJDIR)/src/OsiXpr/libOsiXpr.la 228 endif 229 230 if COIN_HAS_ASL 231 cbc_generic_LDADD += $(ASLLIB) 232 AM_CPPFLAGS += $(ASL_CPPFLAGS) -DCOIN_HAS_ASL 220 233 endif 221 234 -
trunk/Cbc/src/Makefile.in
r710 r765 15 15 @SET_MAKE@ 16 16 17 # Copyright (C) 2006 International Business Machines and others.17 # Copyright (C) 2006, 2007 International Business Machines and others. 18 18 # All Rights Reserved. 19 19 # This file is distributed under the Common Public License. … … 133 133 134 134 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_XPR_TRUE@am__append_32 = $(OSIOBJDIR)/src/OsiXpr/libOsiXpr.la 135 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_ASL_TRUE@am__append_33 = $(ASLLIB) 136 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_ASL_TRUE@am__append_34 = $(ASL_CPPFLAGS) -DCOIN_HAS_ASL 135 137 subdir = src 136 138 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ … … 162 164 CbcHeuristicFPump.lo CbcHeuristicGreedy.lo \ 163 165 CbcHeuristicLocal.lo CbcHeuristicRINS.lo CbcMessage.lo \ 164 CbcModel.lo CbcNode.lo CbcSolver.lo CbcCbcParam.lo \ 165 CbcStatistics.lo CbcStrategy.lo CbcTree.lo CbcLinked.lo \ 166 CbcTreeLocal.lo ClpAmplStuff.lo Cbc_ampl.lo 166 CbcModel.lo CbcNode.lo CbcStatistics.lo CbcStrategy.lo \ 167 CbcTree.lo CbcTreeLocal.lo 167 168 libCbc_la_OBJECTS = $(am_libCbc_la_OBJECTS) 169 libCbcSolver_la_LIBADD = 170 am_libCbcSolver_la_OBJECTS = CbcCbcParam.lo Cbc_ampl.lo \ 171 ClpAmplStuff.lo CbcLinked.lo unitTestClp.lo CbcSolver.lo 172 libCbcSolver_la_OBJECTS = $(am_libCbcSolver_la_OBJECTS) 168 173 @COIN_HAS_CLP_TRUE@am__EXEEXT_1 = cbc$(EXEEXT) 169 174 @CBC_BUILD_CBC_GENERIC_TRUE@am__EXEEXT_2 = cbc-generic$(EXEEXT) 170 175 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 171 176 PROGRAMS = $(bin_PROGRAMS) 172 am__cbc_SOURCES_DIST = CoinSolve.cpp unitTestClp.cpp 173 @COIN_HAS_CLP_TRUE@am_cbc_OBJECTS = CoinSolve.$(OBJEXT) \ 174 @COIN_HAS_CLP_TRUE@ unitTestClp.$(OBJEXT) 177 am__cbc_SOURCES_DIST = CoinSolve.cpp 178 @COIN_HAS_CLP_TRUE@am_cbc_OBJECTS = CoinSolve.$(OBJEXT) 175 179 cbc_OBJECTS = $(am_cbc_OBJECTS) 176 180 am__DEPENDENCIES_1 = 177 181 @COIN_HAS_ASL_TRUE@@COIN_HAS_CLP_TRUE@am__DEPENDENCIES_2 = \ 178 182 @COIN_HAS_ASL_TRUE@@COIN_HAS_CLP_TRUE@ $(am__DEPENDENCIES_1) 179 @COIN_HAS_CLP_TRUE@cbc_DEPENDENCIES = libCbc .la \183 @COIN_HAS_CLP_TRUE@cbc_DEPENDENCIES = libCbcSolver.la libCbc.la \ 180 184 @COIN_HAS_CLP_TRUE@ $(CGLOBJDIR)/src/libCgl.la \ 181 185 @COIN_HAS_CLP_TRUE@ $(OSIOBJDIR)/src/OsiClp/libOsiClp.la \ … … 219 223 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_VOL_TRUE@ $(VOLOBJDIR)/src/libVol.la 220 224 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_XPR_TRUE@am__DEPENDENCIES_13 = $(OSIOBJDIR)/src/OsiXpr/libOsiXpr.la 221 @CBC_BUILD_CBC_GENERIC_TRUE@cbc_generic_DEPENDENCIES = libCbc.la \ 225 @CBC_BUILD_CBC_GENERIC_TRUE@@COIN_HAS_ASL_TRUE@am__DEPENDENCIES_14 = $(am__DEPENDENCIES_1) 226 @CBC_BUILD_CBC_GENERIC_TRUE@cbc_generic_DEPENDENCIES = \ 227 @CBC_BUILD_CBC_GENERIC_TRUE@ libCbcSolver.la libCbc.la \ 222 228 @CBC_BUILD_CBC_GENERIC_TRUE@ $(CGLOBJDIR)/src/libCgl.la \ 223 229 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__DEPENDENCIES_3) \ … … 232 238 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__DEPENDENCIES_12) \ 233 239 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__DEPENDENCIES_13) \ 240 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__DEPENDENCIES_14) \ 234 241 @CBC_BUILD_CBC_GENERIC_TRUE@ $(OSIOBJDIR)/src/libOsi.la \ 235 242 @CBC_BUILD_CBC_GENERIC_TRUE@ $(COINUTILSOBJDIR)/src/libCoinUtils.la … … 252 259 LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ 253 260 $(AM_LDFLAGS) $(LDFLAGS) -o $@ 254 SOURCES = $(libCbc_la_SOURCES) $(cbc_SOURCES) $(cbc_generic_SOURCES) 255 DIST_SOURCES = $(libCbc_la_SOURCES) $(am__cbc_SOURCES_DIST) \ 256 $(am__cbc_generic_SOURCES_DIST) 261 SOURCES = $(libCbc_la_SOURCES) $(libCbcSolver_la_SOURCES) \ 262 $(cbc_SOURCES) $(cbc_generic_SOURCES) 263 DIST_SOURCES = $(libCbc_la_SOURCES) $(libCbcSolver_la_SOURCES) \ 264 $(am__cbc_SOURCES_DIST) $(am__cbc_generic_SOURCES_DIST) 257 265 includeHEADERS_INSTALL = $(INSTALL_HEADER) 258 266 HEADERS = $(include_HEADERS) … … 471 479 # Name of the library compiled in this directory. We want it to be installed 472 480 # in the 'lib' directory 473 lib_LTLIBRARIES = libCbc.la 481 lib_LTLIBRARIES = libCbc.la libCbcSolver.la 474 482 475 483 # List all source files for this library, including headers 476 libCbc_la_SOURCES = Cbc_C_Interface.cpp Cbc_C_Interface.h CbcConfig.h \ 477 CbcBranchActual.cpp CbcBranchActual.hpp CbcBranchBase.cpp \ 478 CbcBranchBase.hpp CbcBranchCut.cpp CbcBranchCut.hpp \ 479 CbcBranchDynamic.cpp CbcBranchDynamic.hpp CbcBranchLotsize.cpp \ 480 CbcBranchLotsize.hpp CbcCompareActual.cpp CbcCompareActual.hpp \ 481 CbcCompareBase.hpp CbcCountRowCut.cpp CbcCountRowCut.hpp \ 482 CbcCutGenerator.cpp CbcCutGenerator.hpp CbcEventHandler.cpp \ 483 CbcEventHandler.hpp CbcFathom.cpp CbcFathom.hpp \ 484 CbcFathomDynamicProgramming.cpp \ 485 CbcFathomDynamicProgramming.hpp CbcFeasibilityBase.hpp \ 486 CbcHeuristic.cpp CbcHeuristic.hpp CbcHeuristicFPump.cpp \ 487 CbcHeuristicFPump.hpp CbcHeuristicGreedy.cpp \ 488 CbcHeuristicGreedy.hpp CbcHeuristicLocal.cpp \ 489 CbcHeuristicLocal.hpp CbcHeuristicRINS.cpp \ 490 CbcHeuristicRINS.hpp CbcMessage.cpp CbcMessage.hpp \ 491 CbcModel.cpp CbcModel.hpp CbcNode.cpp CbcNode.hpp \ 492 CbcSolver.cpp CbcCbcParam.cpp CbcStatistics.cpp \ 493 CbcStatistics.hpp CbcStrategy.cpp CbcStrategy.hpp CbcTree.cpp \ 494 CbcTree.hpp CbcLinked.cpp CbcLinked.hpp CbcTreeLocal.cpp \ 495 CbcTreeLocal.hpp ClpConstraintAmpl.hpp ClpAmplObjective.hpp \ 496 ClpAmplStuff.cpp Cbc_ampl.cpp Cbc_ampl.h 484 libCbc_la_SOURCES = \ 485 Cbc_C_Interface.cpp Cbc_C_Interface.h \ 486 CbcConfig.h \ 487 CbcBranchActual.cpp CbcBranchActual.hpp \ 488 CbcBranchBase.cpp CbcBranchBase.hpp \ 489 CbcBranchCut.cpp CbcBranchCut.hpp \ 490 CbcBranchDynamic.cpp CbcBranchDynamic.hpp \ 491 CbcBranchLotsize.cpp CbcBranchLotsize.hpp \ 492 CbcCompareActual.cpp CbcCompareActual.hpp \ 493 CbcCompareBase.hpp \ 494 CbcCountRowCut.cpp CbcCountRowCut.hpp \ 495 CbcCutGenerator.cpp CbcCutGenerator.hpp \ 496 CbcEventHandler.cpp CbcEventHandler.hpp \ 497 CbcFathom.cpp CbcFathom.hpp \ 498 CbcFathomDynamicProgramming.cpp CbcFathomDynamicProgramming.hpp \ 499 CbcFeasibilityBase.hpp \ 500 CbcHeuristic.cpp CbcHeuristic.hpp \ 501 CbcHeuristicFPump.cpp CbcHeuristicFPump.hpp \ 502 CbcHeuristicGreedy.cpp CbcHeuristicGreedy.hpp \ 503 CbcHeuristicLocal.cpp CbcHeuristicLocal.hpp \ 504 CbcHeuristicRINS.cpp CbcHeuristicRINS.hpp \ 505 CbcMessage.cpp CbcMessage.hpp \ 506 CbcModel.cpp CbcModel.hpp \ 507 CbcNode.cpp CbcNode.hpp \ 508 CbcStatistics.cpp CbcStatistics.hpp \ 509 CbcStrategy.cpp CbcStrategy.hpp \ 510 CbcTree.cpp CbcTree.hpp \ 511 CbcTreeLocal.cpp CbcTreeLocal.hpp 512 513 libCbcSolver_la_SOURCES = \ 514 CbcCbcParam.cpp \ 515 Cbc_ampl.cpp Cbc_ampl.h \ 516 ClpConstraintAmpl.hpp ClpAmplObjective.hpp ClpAmplStuff.cpp \ 517 CbcLinked.cpp CbcLinked.hpp \ 518 unitTestClp.cpp CbcSolver.cpp 519 520 521 #Stefan: added unitTestClp.cpp because CbcSolver defines reference to it 497 522 498 523 # This is for libtool (on Windows) 499 524 libCbc_la_LDFLAGS = $(LT_LDFLAGS) 525 libCbcSolver_la_LDFLAGS = $(LT_LDFLAGS) 500 526 501 527 ######################################################################## … … 513 539 $(am__append_17) $(am__append_19) $(am__append_21) \ 514 540 $(am__append_23) $(am__append_25) $(am__append_28) \ 515 $(am__append_31) -I`$(CYGPATH_W) $(CGLSRCDIR)/src`\516 -I`$(CYGPATH_W) $(CGLSRCDIR)/src/CglClique` -I`$(CYGPATH_W)\517 $(CGLSRCDIR)/src/CglDuplicateRow` -I`$(CYGPATH_W)\518 $(CGLSRCDIR)/src/CglFlowCover` -I`$(CYGPATH_W) \541 $(am__append_31) $(am__append_34) -I`$(CYGPATH_W) \ 542 $(CGLSRCDIR)/src` -I`$(CYGPATH_W) $(CGLSRCDIR)/src/CglClique` \ 543 -I`$(CYGPATH_W) $(CGLSRCDIR)/src/CglDuplicateRow` \ 544 -I`$(CYGPATH_W) $(CGLSRCDIR)/src/CglFlowCover` -I`$(CYGPATH_W) \ 519 545 $(CGLSRCDIR)/src/CglGomory` -I`$(CYGPATH_W) \ 520 546 $(CGLSRCDIR)/src/CglKnapsackCover` -I`$(CYGPATH_W) \ … … 535 561 # List all source files for this executable, including headers 536 562 @COIN_HAS_CLP_TRUE@cbc_SOURCES = \ 537 @COIN_HAS_CLP_TRUE@ CoinSolve.cpp \ 538 @COIN_HAS_CLP_TRUE@ unitTestClp.cpp 563 @COIN_HAS_CLP_TRUE@ CoinSolve.cpp 539 564 540 565 541 566 # Additional COIN libraries 542 @COIN_HAS_CLP_TRUE@cbc_LDADD = libCbc.la $(CGLOBJDIR)/src/libCgl.la \ 567 @COIN_HAS_CLP_TRUE@cbc_LDADD = libCbcSolver.la libCbc.la \ 568 @COIN_HAS_CLP_TRUE@ $(CGLOBJDIR)/src/libCgl.la \ 543 569 @COIN_HAS_CLP_TRUE@ $(OSIOBJDIR)/src/OsiClp/libOsiClp.la \ 544 570 @COIN_HAS_CLP_TRUE@ $(OSIOBJDIR)/src/libOsi.la \ … … 566 592 567 593 # Finally the Osi Coin library (many of the above need it) 568 @CBC_BUILD_CBC_GENERIC_TRUE@cbc_generic_LDADD = libCbc.la \ 594 @CBC_BUILD_CBC_GENERIC_TRUE@cbc_generic_LDADD = libCbcSolver.la \ 595 @CBC_BUILD_CBC_GENERIC_TRUE@ libCbc.la \ 569 596 @CBC_BUILD_CBC_GENERIC_TRUE@ $(CGLOBJDIR)/src/libCgl.la \ 570 597 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__append_8) $(am__append_11) \ … … 573 600 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__append_22) $(am__append_24) \ 574 601 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__append_26) $(am__append_29) \ 575 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__append_32) \602 @CBC_BUILD_CBC_GENERIC_TRUE@ $(am__append_32) $(am__append_33) \ 576 603 @CBC_BUILD_CBC_GENERIC_TRUE@ $(OSIOBJDIR)/src/libOsi.la \ 577 604 @CBC_BUILD_CBC_GENERIC_TRUE@ $(COINUTILSOBJDIR)/src/libCoinUtils.la … … 690 717 libCbc.la: $(libCbc_la_OBJECTS) $(libCbc_la_DEPENDENCIES) 691 718 $(CXXLINK) -rpath $(libdir) $(libCbc_la_LDFLAGS) $(libCbc_la_OBJECTS) $(libCbc_la_LIBADD) $(LIBS) 719 libCbcSolver.la: $(libCbcSolver_la_OBJECTS) $(libCbcSolver_la_DEPENDENCIES) 720 $(CXXLINK) -rpath $(libdir) $(libCbcSolver_la_LDFLAGS) $(libCbcSolver_la_OBJECTS) $(libCbcSolver_la_LIBADD) $(LIBS) 692 721 install-binPROGRAMS: $(bin_PROGRAMS) 693 722 @$(NORMAL_INSTALL) … … 773 802 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClpAmplStuff.Plo@am__quote@ 774 803 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoinSolve.Po@am__quote@ 775 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unitTestClp.P o@am__quote@804 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unitTestClp.Plo@am__quote@ 776 805 777 806 .cpp.o: -
trunk/Cbc/src/unitTestClp.cpp
r708 r765 2 2 // Corporation and others. All Rights Reserved. 3 3 4 #include "CoinPragma.hpp"5 #include <cassert>6 4 #include <cstdio> 7 #include <cmath>8 #include <cfloat>9 5 #include <string> 10 6 #include <iostream> 11 7 12 #include "CoinMpsIO.hpp"13 #include "CoinPackedMatrix.hpp"14 #include "CoinPackedVector.hpp"15 #include "CoinHelperFunctions.hpp"16 8 #include "CoinTime.hpp" 17 9 #include "CbcModel.hpp" 18 10 #include "CbcCutGenerator.hpp" 19 11 #include "OsiClpSolverInterface.hpp" 20 #include "ClpFactorization.hpp"21 #include "ClpSimplex.hpp"22 #include "ClpSimplexOther.hpp"23 #include "ClpInterior.hpp"24 #include "ClpLinearObjective.hpp"25 #include "ClpDualRowSteepest.hpp"26 #include "ClpDualRowDantzig.hpp"27 #include "ClpPrimalColumnSteepest.hpp"28 #include "ClpPrimalColumnDantzig.hpp"29 #include "ClpParameters.hpp"30 #include "ClpNetworkMatrix.hpp"31 #include "ClpPlusMinusOneMatrix.hpp"32 #include "MyMessageHandler.hpp"33 #include "MyEventHandler.hpp"34 35 #include "ClpPresolve.hpp"36 #include "Idiot.hpp"37 38 12 39 13 //############################################################################# … … 43 17 #endif 44 18 45 // Function Prototypes. Function definitions is in this file. 46 void testingMessage( const char * const msg ); 47 #if UFL_BARRIER 48 static int barrierAvailable=1; 49 static std::string nameBarrier="barrier-UFL"; 50 #elif WSSMP_BARRIER 51 static int barrierAvailable=2; 52 static std::string nameBarrier="barrier-WSSMP"; 53 #else 54 static int barrierAvailable=0; 55 static std::string nameBarrier="barrier-slow"; 56 #endif 57 #define NUMBER_ALGORITHMS 12 58 // If you just want a subset then set some to 1 59 static int switchOff[NUMBER_ALGORITHMS]={0,0,0,0,0,0,0,0,0,0,0,0}; 60 // shortName - 0 no , 1 yes 61 ClpSolve setupForSolve(int algorithm, std::string & nameAlgorithm, 62 int shortName) 63 { 64 ClpSolve solveOptions; 65 /* algorithms are 66 0 barrier 67 1 dual with volumne crash 68 2,3 dual with and without crash 69 4,5 primal with and without 70 6,7 automatic with and without 71 8,9 primal with idiot 1 and 5 72 10,11 primal with 70, dual with volume 73 */ 74 switch (algorithm) { 75 case 0: 76 if (shortName) 77 nameAlgorithm="ba"; 78 else 79 nameAlgorithm="nameBarrier"; 80 solveOptions.setSolveType(ClpSolve::useBarrier); 81 if (barrierAvailable==1) 82 solveOptions.setSpecialOption(4,4); 83 else if (barrierAvailable==2) 84 solveOptions.setSpecialOption(4,2); 85 break; 86 case 1: 87 #ifdef COIN_HAS_VOL 88 if (shortName) 89 nameAlgorithm="du-vol-50"; 90 else 91 nameAlgorithm="dual-volume-50"; 92 solveOptions.setSolveType(ClpSolve::useDual); 93 solveOptions.setSpecialOption(0,2,50); // volume 94 #else 95 solveOptions.setSolveType(ClpSolve::notImplemented); 96 #endif 97 break; 98 case 2: 99 if (shortName) 100 nameAlgorithm="du-cr"; 101 else 102 nameAlgorithm="dual-crash"; 103 solveOptions.setSolveType(ClpSolve::useDual); 104 solveOptions.setSpecialOption(0,1); 105 break; 106 case 3: 107 if (shortName) 108 nameAlgorithm="du"; 109 else 110 nameAlgorithm="dual"; 111 solveOptions.setSolveType(ClpSolve::useDual); 112 break; 113 case 4: 114 if (shortName) 115 nameAlgorithm="pr-cr"; 116 else 117 nameAlgorithm="primal-crash"; 118 solveOptions.setSolveType(ClpSolve::usePrimal); 119 solveOptions.setSpecialOption(1,1); 120 break; 121 case 5: 122 if (shortName) 123 nameAlgorithm="pr"; 124 else 125 nameAlgorithm="primal"; 126 solveOptions.setSolveType(ClpSolve::usePrimal); 127 break; 128 case 6: 129 if (shortName) 130 nameAlgorithm="au-cr"; 131 else 132 nameAlgorithm="either-crash"; 133 solveOptions.setSolveType(ClpSolve::automatic); 134 solveOptions.setSpecialOption(1,1); 135 break; 136 case 7: 137 if (shortName) 138 nameAlgorithm="au"; 139 else 140 nameAlgorithm="either"; 141 solveOptions.setSolveType(ClpSolve::automatic); 142 break; 143 case 8: 144 if (shortName) 145 nameAlgorithm="pr-id-1"; 146 else 147 nameAlgorithm="primal-idiot-1"; 148 solveOptions.setSolveType(ClpSolve::usePrimalorSprint); 149 solveOptions.setSpecialOption(1,2,1); // idiot 150 break; 151 case 9: 152 if (shortName) 153 nameAlgorithm="pr-id-5"; 154 else 155 nameAlgorithm="primal-idiot-5"; 156 solveOptions.setSolveType(ClpSolve::usePrimalorSprint); 157 solveOptions.setSpecialOption(1,2,5); // idiot 158 break; 159 case 10: 160 if (shortName) 161 nameAlgorithm="pr-id-70"; 162 else 163 nameAlgorithm="primal-idiot-70"; 164 solveOptions.setSolveType(ClpSolve::usePrimalorSprint); 165 solveOptions.setSpecialOption(1,2,70); // idiot 166 break; 167 case 11: 168 #ifdef COIN_HAS_VOL 169 if (shortName) 170 nameAlgorithm="du-vol"; 171 else 172 nameAlgorithm="dual-volume"; 173 solveOptions.setSolveType(ClpSolve::useDual); 174 solveOptions.setSpecialOption(0,2,3000); // volume 175 #else 176 solveOptions.setSolveType(ClpSolve::notImplemented); 177 #endif 178 break; 179 default: 180 abort(); 181 } 182 if (shortName) { 183 // can switch off 184 if (switchOff[algorithm]) 185 solveOptions.setSolveType(ClpSolve::notImplemented); 186 } 187 return solveOptions; 188 } 189 //---------------------------------------------------------------- 190 // unitTest [-mpsDir=V1] [-netlibDir=V2] [-test] 191 // 192 // where: 193 // -mpsDir: directory containing mps test files 194 // Default value V1="../../Data/Sample" 195 // -netlibDir: directory containing netlib files 196 // Default value V2="../../Data/Netlib" 197 // -test 198 // If specified, then netlib test set run 199 // 200 // All parameters are optional. 201 //---------------------------------------------------------------- 202 int mainTest (int argc, const char *argv[],int algorithm, 203 ClpSimplex empty, bool doPresolve, int switchOffValue,bool doVector) 204 { 205 int i; 206 207 if (switchOffValue>0) { 208 // switch off some 209 int iTest; 210 for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 211 int bottom = switchOffValue%10; 212 assert (bottom==0||bottom==1); 213 switchOffValue/= 10; 214 switchOff[iTest]=0; 215 } 216 } 217 218 // define valid parameter keywords 219 std::set<std::string> definedKeyWords; 220 definedKeyWords.insert("-mpsDir"); 221 definedKeyWords.insert("-netlibDir"); 222 definedKeyWords.insert("-netlib"); 223 224 // Create a map of parameter keys and associated data 225 std::map<std::string,std::string> parms; 226 for ( i=1; i<argc; i++ ) { 227 std::string parm(argv[i]); 228 std::string key,value; 229 unsigned int eqPos = parm.find('='); 230 231 // Does parm contain and '=' 232 if ( eqPos==std::string::npos ) { 233 //Parm does not contain '=' 234 key = parm; 235 } 236 else { 237 key=parm.substr(0,eqPos); 238 value=parm.substr(eqPos+1); 239 } 240 241 // Is specifed key valid? 242 if ( definedKeyWords.find(key) == definedKeyWords.end() ) { 243 // invalid key word. 244 // Write help text 245 std::cerr <<"Undefined parameter \"" <<key <<"\".\n"; 246 std::cerr <<"Correct usage: \n"; 247 std::cerr <<" unitTest [-mpsDir=V1] [-netlibDir=V2] [-test[=V3]]\n"; 248 std::cerr <<" where:\n"; 249 std::cerr <<" -mpsDir: directory containing mps test files\n"; 250 std::cerr <<" Default value V1=\"../../Data/Sample\"\n"; 251 std::cerr <<" -netlibDir: directory containing netlib files\n"; 252 std::cerr <<" Default value V2=\"../../Data/Netlib\"\n"; 253 std::cerr <<" -test\n"; 254 std::cerr <<" If specified, then netlib testset run.\n"; 255 std::cerr <<" If V3 then taken as single file\n"; 256 return 1; 257 } 258 parms[key]=value; 259 } 260 261 const char dirsep = CoinFindDirSeparator(); 262 // Set directory containing mps data files. 263 std::string mpsDir; 264 if (parms.find("-mpsDir") != parms.end()) 265 mpsDir=parms["-mpsDir"] + dirsep; 266 else 267 mpsDir = dirsep == '/' ? "../../Data/Sample/" : "..\\..\\Data\\Sample\\"; 268 269 // Set directory containing netlib data files. 270 std::string netlibDir; 271 if (parms.find("-netlibDir") != parms.end()) 272 netlibDir=parms["-netlibDir"] + dirsep; 273 else 274 netlibDir = dirsep == '/' ? "../../Data/Netlib/" : "..\\..\\Data\\Netlib\\"; 275 if (!empty.numberRows()) { 276 testingMessage( "Testing ClpSimplex\n" ); 277 ClpSimplexUnitTest(mpsDir,netlibDir); 278 } 279 if (parms.find("-netlib") != parms.end()||empty.numberRows()) 280 { 281 unsigned int m; 282 283 // Define test problems: 284 // mps names, 285 // maximization or minimization, 286 // Number of rows and columns in problem, and 287 // objective function value 288 std::vector<std::string> mpsName; 289 std::vector<bool> min; 290 std::vector<int> nRows; 291 std::vector<int> nCols; 292 std::vector<double> objValue; 293 std::vector<double> objValueTol; 294 // 100 added means no presolve 295 std::vector<int> bestStrategy; 296 if(empty.numberRows()) { 297 std::string alg; 298 for (int iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 299 ClpSolve solveOptions=setupForSolve(iTest,alg,0); 300 printf("%d %s ",iTest,alg.c_str()); 301 if (switchOff[iTest]) 302 printf("skipped by user\n"); 303 else if(solveOptions.getSolveType()==ClpSolve::notImplemented) 304 printf("skipped as not available\n"); 305 else 306 printf("will be tested\n"); 307 } 308 } 309 if (!empty.numberRows()) { 310 mpsName.push_back("25fv47"); 311 min.push_back(true); 312 nRows.push_back(822); 313 nCols.push_back(1571); 314 objValueTol.push_back(1.E-10); 315 objValue.push_back(5.5018458883E+03); 316 bestStrategy.push_back(0); 317 mpsName.push_back("80bau3b");min.push_back(true);nRows.push_back(2263);nCols.push_back(9799);objValueTol.push_back(1.e-10);objValue.push_back(9.8722419241E+05);bestStrategy.push_back(3); 318 mpsName.push_back("blend");min.push_back(true);nRows.push_back(75);nCols.push_back(83);objValueTol.push_back(1.e-10);objValue.push_back(-3.0812149846e+01);bestStrategy.push_back(3); 319 mpsName.push_back("pilotnov");min.push_back(true);nRows.push_back(976);nCols.push_back(2172);objValueTol.push_back(1.e-10);objValue.push_back(-4.4972761882e+03);bestStrategy.push_back(3); 320 mpsName.push_back("maros-r7");min.push_back(true);nRows.push_back(3137);nCols.push_back(9408);objValueTol.push_back(1.e-10);objValue.push_back(1.4971851665e+06);bestStrategy.push_back(2); 321 mpsName.push_back("pilot");min.push_back(true);nRows.push_back(1442);nCols.push_back(3652);objValueTol.push_back(1.e-5);objValue.push_back(/*-5.5740430007e+02*/-557.48972927292);bestStrategy.push_back(3); 322 mpsName.push_back("pilot4");min.push_back(true);nRows.push_back(411);nCols.push_back(1000);objValueTol.push_back(5.e-5);objValue.push_back(-2.5811392641e+03);bestStrategy.push_back(3); 323 mpsName.push_back("pilot87");min.push_back(true);nRows.push_back(2031);nCols.push_back(4883);objValueTol.push_back(1.e-4);objValue.push_back(3.0171072827e+02);bestStrategy.push_back(0); 324 mpsName.push_back("adlittle");min.push_back(true);nRows.push_back(57);nCols.push_back(97);objValueTol.push_back(1.e-10);objValue.push_back(2.2549496316e+05);bestStrategy.push_back(3); 325 mpsName.push_back("afiro");min.push_back(true);nRows.push_back(28);nCols.push_back(32);objValueTol.push_back(1.e-10);objValue.push_back(-4.6475314286e+02);bestStrategy.push_back(3); 326 mpsName.push_back("agg");min.push_back(true);nRows.push_back(489);nCols.push_back(163);objValueTol.push_back(1.e-10);objValue.push_back(-3.5991767287e+07);bestStrategy.push_back(3); 327 mpsName.push_back("agg2");min.push_back(true);nRows.push_back(517);nCols.push_back(302);objValueTol.push_back(1.e-10);objValue.push_back(-2.0239252356e+07);bestStrategy.push_back(3); 328 mpsName.push_back("agg3");min.push_back(true);nRows.push_back(517);nCols.push_back(302);objValueTol.push_back(1.e-10);objValue.push_back(1.0312115935e+07);bestStrategy.push_back(4); 329 mpsName.push_back("bandm");min.push_back(true);nRows.push_back(306);nCols.push_back(472);objValueTol.push_back(1.e-10);objValue.push_back(-1.5862801845e+02);bestStrategy.push_back(2); 330 mpsName.push_back("beaconfd");min.push_back(true);nRows.push_back(174);nCols.push_back(262);objValueTol.push_back(1.e-10);objValue.push_back(3.3592485807e+04);bestStrategy.push_back(0); 331 mpsName.push_back("bnl1");min.push_back(true);nRows.push_back(644);nCols.push_back(1175);objValueTol.push_back(1.e-10);objValue.push_back(1.9776295615E+03);bestStrategy.push_back(3); 332 mpsName.push_back("bnl2");min.push_back(true);nRows.push_back(2325);nCols.push_back(3489);objValueTol.push_back(1.e-10);objValue.push_back(1.8112365404e+03);bestStrategy.push_back(3); 333 mpsName.push_back("boeing1");min.push_back(true);nRows.push_back(/*351*/352);nCols.push_back(384);objValueTol.push_back(1.e-10);objValue.push_back(-3.3521356751e+02);bestStrategy.push_back(3); 334 mpsName.push_back("boeing2");min.push_back(true);nRows.push_back(167);nCols.push_back(143);objValueTol.push_back(1.e-10);objValue.push_back(-3.1501872802e+02);bestStrategy.push_back(3); 335 mpsName.push_back("bore3d");min.push_back(true);nRows.push_back(234);nCols.push_back(315);objValueTol.push_back(1.e-10);objValue.push_back(1.3730803942e+03);bestStrategy.push_back(3); 336 mpsName.push_back("brandy");min.push_back(true);nRows.push_back(221);nCols.push_back(249);objValueTol.push_back(1.e-10);objValue.push_back(1.5185098965e+03);bestStrategy.push_back(3); 337 mpsName.push_back("capri");min.push_back(true);nRows.push_back(272);nCols.push_back(353);objValueTol.push_back(1.e-10);objValue.push_back(2.6900129138e+03);bestStrategy.push_back(3); 338 mpsName.push_back("cycle");min.push_back(true);nRows.push_back(1904);nCols.push_back(2857);objValueTol.push_back(1.e-9);objValue.push_back(-5.2263930249e+00);bestStrategy.push_back(3); 339 mpsName.push_back("czprob");min.push_back(true);nRows.push_back(930);nCols.push_back(3523);objValueTol.push_back(1.e-10);objValue.push_back(2.1851966989e+06);bestStrategy.push_back(3); 340 mpsName.push_back("d2q06c");min.push_back(true);nRows.push_back(2172);nCols.push_back(5167);objValueTol.push_back(1.e-7);objValue.push_back(122784.21557456);bestStrategy.push_back(0); 341 mpsName.push_back("d6cube");min.push_back(true);nRows.push_back(416);nCols.push_back(6184);objValueTol.push_back(1.e-7);objValue.push_back(3.1549166667e+02);bestStrategy.push_back(3); 342 mpsName.push_back("degen2");min.push_back(true);nRows.push_back(445);nCols.push_back(534);objValueTol.push_back(1.e-10);objValue.push_back(-1.4351780000e+03);bestStrategy.push_back(3); 343 mpsName.push_back("degen3");min.push_back(true);nRows.push_back(1504);nCols.push_back(1818);objValueTol.push_back(1.e-10);objValue.push_back(-9.8729400000e+02);bestStrategy.push_back(2); 344 mpsName.push_back("dfl001");min.push_back(true);nRows.push_back(6072);nCols.push_back(12230);objValueTol.push_back(1.e-5);objValue.push_back(1.1266396047E+07);bestStrategy.push_back(5); 345 mpsName.push_back("e226");min.push_back(true);nRows.push_back(224);nCols.push_back(282);objValueTol.push_back(1.e-10);objValue.push_back(-1.8751929066e+01+7.113);bestStrategy.push_back(3); // The correct answer includes -7.113 term. This is a constant in the objective function. See line 1683 of the mps file. 346 mpsName.push_back("etamacro");min.push_back(true);nRows.push_back(401);nCols.push_back(688);objValueTol.push_back(1.e-6);objValue.push_back(-7.5571521774e+02 );bestStrategy.push_back(3); 347 mpsName.push_back("fffff800");min.push_back(true);nRows.push_back(525);nCols.push_back(854);objValueTol.push_back(1.e-6);objValue.push_back(5.5567961165e+05);bestStrategy.push_back(3); 348 mpsName.push_back("finnis");min.push_back(true);nRows.push_back(498);nCols.push_back(614);objValueTol.push_back(1.e-6);objValue.push_back(1.7279096547e+05);bestStrategy.push_back(3); 349 mpsName.push_back("fit1d");min.push_back(true);nRows.push_back(25);nCols.push_back(1026);objValueTol.push_back(1.e-10);objValue.push_back(-9.1463780924e+03);bestStrategy.push_back(3+100); 350 mpsName.push_back("fit1p");min.push_back(true);nRows.push_back(628);nCols.push_back(1677);objValueTol.push_back(1.e-10);objValue.push_back(9.1463780924e+03);bestStrategy.push_back(5+100); 351 mpsName.push_back("fit2d");min.push_back(true);nRows.push_back(26);nCols.push_back(10500);objValueTol.push_back(1.e-10);objValue.push_back(-6.8464293294e+04);bestStrategy.push_back(3+100); 352 mpsName.push_back("fit2p");min.push_back(true);nRows.push_back(3001);nCols.push_back(13525);objValueTol.push_back(1.e-9);objValue.push_back(6.8464293232e+04);bestStrategy.push_back(5+100); 353 mpsName.push_back("forplan");min.push_back(true);nRows.push_back(162);nCols.push_back(421);objValueTol.push_back(1.e-6);objValue.push_back(-6.6421873953e+02);bestStrategy.push_back(3); 354 mpsName.push_back("ganges");min.push_back(true);nRows.push_back(1310);nCols.push_back(1681);objValueTol.push_back(1.e-5);objValue.push_back(-1.0958636356e+05);bestStrategy.push_back(3); 355 mpsName.push_back("gfrd-pnc");min.push_back(true);nRows.push_back(617);nCols.push_back(1092);objValueTol.push_back(1.e-10);objValue.push_back(6.9022359995e+06);bestStrategy.push_back(3); 356 mpsName.push_back("greenbea");min.push_back(true);nRows.push_back(2393);nCols.push_back(5405);objValueTol.push_back(1.e-10);objValue.push_back(/*-7.2462405908e+07*/-72555248.129846);bestStrategy.push_back(3); 357 mpsName.push_back("greenbeb");min.push_back(true);nRows.push_back(2393);nCols.push_back(5405);objValueTol.push_back(1.e-10);objValue.push_back(/*-4.3021476065e+06*/-4302260.2612066);bestStrategy.push_back(3); 358 mpsName.push_back("grow15");min.push_back(true);nRows.push_back(301);nCols.push_back(645);objValueTol.push_back(1.e-10);objValue.push_back(-1.0687094129e+08);bestStrategy.push_back(4+100); 359 mpsName.push_back("grow22");min.push_back(true);nRows.push_back(441);nCols.push_back(946);objValueTol.push_back(1.e-10);objValue.push_back(-1.6083433648e+08);bestStrategy.push_back(4+100); 360 mpsName.push_back("grow7");min.push_back(true);nRows.push_back(141);nCols.push_back(301);objValueTol.push_back(1.e-10);objValue.push_back(-4.7787811815e+07);bestStrategy.push_back(4+100); 361 mpsName.push_back("israel");min.push_back(true);nRows.push_back(175);nCols.push_back(142);objValueTol.push_back(1.e-10);objValue.push_back(-8.9664482186e+05);bestStrategy.push_back(2); 362 mpsName.push_back("kb2");min.push_back(true);nRows.push_back(44);nCols.push_back(41);objValueTol.push_back(1.e-10);objValue.push_back(-1.7499001299e+03);bestStrategy.push_back(3); 363 mpsName.push_back("lotfi");min.push_back(true);nRows.push_back(154);nCols.push_back(308);objValueTol.push_back(1.e-10);objValue.push_back(-2.5264706062e+01);bestStrategy.push_back(3); 364 mpsName.push_back("maros");min.push_back(true);nRows.push_back(847);nCols.push_back(1443);objValueTol.push_back(1.e-10);objValue.push_back(-5.8063743701e+04);bestStrategy.push_back(3); 365 mpsName.push_back("modszk1");min.push_back(true);nRows.push_back(688);nCols.push_back(1620);objValueTol.push_back(1.e-10);objValue.push_back(3.2061972906e+02);bestStrategy.push_back(3); 366 mpsName.push_back("nesm");min.push_back(true);nRows.push_back(663);nCols.push_back(2923);objValueTol.push_back(1.e-5);objValue.push_back(1.4076073035e+07);bestStrategy.push_back(2); 367 mpsName.push_back("perold");min.push_back(true);nRows.push_back(626);nCols.push_back(1376);objValueTol.push_back(1.e-6);objValue.push_back(-9.3807580773e+03);bestStrategy.push_back(3); 368 //mpsName.push_back("qap12");min.push_back(true);nRows.push_back(3193);nCols.push_back(8856);objValueTol.push_back(1.e-6);objValue.push_back(5.2289435056e+02);bestStrategy.push_back(3); 369 //mpsName.push_back("qap15");min.push_back(true);nRows.push_back(6331);nCols.push_back(22275);objValueTol.push_back(1.e-10);objValue.push_back(1.0409940410e+03);bestStrategy.push_back(3); 370 mpsName.push_back("recipe");min.push_back(true);nRows.push_back(92);nCols.push_back(180);objValueTol.push_back(1.e-10);objValue.push_back(-2.6661600000e+02);bestStrategy.push_back(3); 371 mpsName.push_back("sc105");min.push_back(true);nRows.push_back(106);nCols.push_back(103);objValueTol.push_back(1.e-10);objValue.push_back(-5.2202061212e+01);bestStrategy.push_back(3); 372 mpsName.push_back("sc205");min.push_back(true);nRows.push_back(206);nCols.push_back(203);objValueTol.push_back(1.e-10);objValue.push_back(-5.2202061212e+01);bestStrategy.push_back(3); 373 mpsName.push_back("sc50a");min.push_back(true);nRows.push_back(51);nCols.push_back(48);objValueTol.push_back(1.e-10);objValue.push_back(-6.4575077059e+01);bestStrategy.push_back(3); 374 mpsName.push_back("sc50b");min.push_back(true);nRows.push_back(51);nCols.push_back(48);objValueTol.push_back(1.e-10);objValue.push_back(-7.0000000000e+01);bestStrategy.push_back(3); 375 mpsName.push_back("scagr25");min.push_back(true);nRows.push_back(472);nCols.push_back(500);objValueTol.push_back(1.e-10);objValue.push_back(-1.4753433061e+07);bestStrategy.push_back(3); 376 mpsName.push_back("scagr7");min.push_back(true);nRows.push_back(130);nCols.push_back(140);objValueTol.push_back(1.e-6);objValue.push_back(-2.3313892548e+06);bestStrategy.push_back(3); 377 mpsName.push_back("scfxm1");min.push_back(true);nRows.push_back(331);nCols.push_back(457);objValueTol.push_back(1.e-10);objValue.push_back(1.8416759028e+04);bestStrategy.push_back(3); 378 mpsName.push_back("scfxm2");min.push_back(true);nRows.push_back(661);nCols.push_back(914);objValueTol.push_back(1.e-10);objValue.push_back(3.6660261565e+04);bestStrategy.push_back(3); 379 mpsName.push_back("scfxm3");min.push_back(true);nRows.push_back(991);nCols.push_back(1371);objValueTol.push_back(1.e-10);objValue.push_back(5.4901254550e+04);bestStrategy.push_back(3); 380 mpsName.push_back("scorpion");min.push_back(true);nRows.push_back(389);nCols.push_back(358);objValueTol.push_back(1.e-10);objValue.push_back(1.8781248227e+03);bestStrategy.push_back(3); 381 mpsName.push_back("scrs8");min.push_back(true);nRows.push_back(491);nCols.push_back(1169);objValueTol.push_back(1.e-5);objValue.push_back(9.0429998619e+02);bestStrategy.push_back(2); 382 mpsName.push_back("scsd1");min.push_back(true);nRows.push_back(78);nCols.push_back(760);objValueTol.push_back(1.e-10);objValue.push_back(8.6666666743e+00);bestStrategy.push_back(3+100); 383 mpsName.push_back("scsd6");min.push_back(true);nRows.push_back(148);nCols.push_back(1350);objValueTol.push_back(1.e-10);objValue.push_back(5.0500000078e+01);bestStrategy.push_back(3+100); 384 mpsName.push_back("scsd8");min.push_back(true);nRows.push_back(398);nCols.push_back(2750);objValueTol.push_back(1.e-10);objValue.push_back(9.0499999993e+02);bestStrategy.push_back(1+100); 385 mpsName.push_back("sctap1");min.push_back(true);nRows.push_back(301);nCols.push_back(480);objValueTol.push_back(1.e-10);objValue.push_back(1.4122500000e+03);bestStrategy.push_back(3); 386 mpsName.push_back("sctap2");min.push_back(true);nRows.push_back(1091);nCols.push_back(1880);objValueTol.push_back(1.e-10);objValue.push_back(1.7248071429e+03);bestStrategy.push_back(3); 387 mpsName.push_back("sctap3");min.push_back(true);nRows.push_back(1481);nCols.push_back(2480);objValueTol.push_back(1.e-10);objValue.push_back(1.4240000000e+03);bestStrategy.push_back(3); 388 mpsName.push_back("seba");min.push_back(true);nRows.push_back(516);nCols.push_back(1028);objValueTol.push_back(1.e-10);objValue.push_back(1.5711600000e+04);bestStrategy.push_back(3); 389 mpsName.push_back("share1b");min.push_back(true);nRows.push_back(118);nCols.push_back(225);objValueTol.push_back(1.e-10);objValue.push_back(-7.6589318579e+04);bestStrategy.push_back(3); 390 mpsName.push_back("share2b");min.push_back(true);nRows.push_back(97);nCols.push_back(79);objValueTol.push_back(1.e-10);objValue.push_back(-4.1573224074e+02);bestStrategy.push_back(3); 391 mpsName.push_back("shell");min.push_back(true);nRows.push_back(537);nCols.push_back(1775);objValueTol.push_back(1.e-10);objValue.push_back(1.2088253460e+09);bestStrategy.push_back(3); 392 mpsName.push_back("ship04l");min.push_back(true);nRows.push_back(403);nCols.push_back(2118);objValueTol.push_back(1.e-10);objValue.push_back(1.7933245380e+06);bestStrategy.push_back(3); 393 mpsName.push_back("ship04s");min.push_back(true);nRows.push_back(403);nCols.push_back(1458);objValueTol.push_back(1.e-10);objValue.push_back(1.7987147004e+06);bestStrategy.push_back(3); 394 mpsName.push_back("ship08l");min.push_back(true);nRows.push_back(779);nCols.push_back(4283);objValueTol.push_back(1.e-10);objValue.push_back(1.9090552114e+06);bestStrategy.push_back(3); 395 mpsName.push_back("ship08s");min.push_back(true);nRows.push_back(779);nCols.push_back(2387);objValueTol.push_back(1.e-10);objValue.push_back(1.9200982105e+06);bestStrategy.push_back(2); 396 mpsName.push_back("ship12l");min.push_back(true);nRows.push_back(1152);nCols.push_back(5427);objValueTol.push_back(1.e-10);objValue.push_back(1.4701879193e+06);bestStrategy.push_back(3); 397 mpsName.push_back("ship12s");min.push_back(true);nRows.push_back(1152);nCols.push_back(2763);objValueTol.push_back(1.e-10);objValue.push_back(1.4892361344e+06);bestStrategy.push_back(2); 398 mpsName.push_back("sierra");min.push_back(true);nRows.push_back(1228);nCols.push_back(2036);objValueTol.push_back(1.e-10);objValue.push_back(1.5394362184e+07);bestStrategy.push_back(3); 399 mpsName.push_back("stair");min.push_back(true);nRows.push_back(357);nCols.push_back(467);objValueTol.push_back(1.e-10);objValue.push_back(-2.5126695119e+02);bestStrategy.push_back(3); 400 mpsName.push_back("standata");min.push_back(true);nRows.push_back(360);nCols.push_back(1075);objValueTol.push_back(1.e-10);objValue.push_back(1.2576995000e+03);bestStrategy.push_back(3); 401 //mpsName.push_back("standgub");min.push_back(true);nRows.push_back(362);nCols.push_back(1184);objValueTol.push_back(1.e-10);objValue.push_back(1257.6995); bestStrategy.push_back(3); 402 mpsName.push_back("standmps");min.push_back(true);nRows.push_back(468);nCols.push_back(1075);objValueTol.push_back(1.e-10);objValue.push_back(1.4060175000E+03); bestStrategy.push_back(3); 403 mpsName.push_back("stocfor1");min.push_back(true);nRows.push_back(118);nCols.push_back(111);objValueTol.push_back(1.e-10);objValue.push_back(-4.1131976219E+04);bestStrategy.push_back(3); 404 mpsName.push_back("stocfor2");min.push_back(true);nRows.push_back(2158);nCols.push_back(2031);objValueTol.push_back(1.e-10);objValue.push_back(-3.9024408538e+04);bestStrategy.push_back(3); 405 //mpsName.push_back("stocfor3");min.push_back(true);nRows.push_back(16676);nCols.push_back(15695);objValueTol.push_back(1.e-10);objValue.push_back(-3.9976661576e+04);bestStrategy.push_back(3); 406 //mpsName.push_back("truss");min.push_back(true);nRows.push_back(1001);nCols.push_back(8806);objValueTol.push_back(1.e-10);objValue.push_back(4.5881584719e+05);bestStrategy.push_back(3); 407 mpsName.push_back("tuff");min.push_back(true);nRows.push_back(334);nCols.push_back(587);objValueTol.push_back(1.e-10);objValue.push_back(2.9214776509e-01);bestStrategy.push_back(3); 408 mpsName.push_back("vtpbase");min.push_back(true);nRows.push_back(199);nCols.push_back(203);objValueTol.push_back(1.e-10);objValue.push_back(1.2983146246e+05);bestStrategy.push_back(3); 409 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); 410 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); 411 } else { 412 // Just testing one 413 mpsName.push_back(empty.problemName());min.push_back(true);nRows.push_back(-1); 414 nCols.push_back(-1);objValueTol.push_back(1.e-10); 415 objValue.push_back(0.0);bestStrategy.push_back(0); 416 int iTest; 417 std::string alg; 418 for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 419 ClpSolve solveOptions=setupForSolve(iTest,alg,0); 420 printf("%d %s ",iTest,alg.c_str()); 421 if (switchOff[iTest]) 422 printf("skipped by user\n"); 423 else if(solveOptions.getSolveType()==ClpSolve::notImplemented) 424 printf("skipped as not available\n"); 425 else 426 printf("will be tested\n"); 427 } 428 } 429 430 double timeTaken =0.0; 431 if( !barrierAvailable) 432 switchOff[0]=1; 433 // Loop once for each Mps File 434 for (m=0; m<mpsName.size(); m++ ) { 435 std::cerr <<" processing mps file: " <<mpsName[m] 436 <<" (" <<m+1 <<" out of " <<mpsName.size() <<")" <<std::endl; 437 438 ClpSimplex solutionBase=empty; 439 std::string fn = netlibDir+mpsName[m]; 440 if (!empty.numberRows()||algorithm<6) { 441 // Read data mps file, 442 CoinMpsIO mps; 443 mps.readMps(fn.c_str(),"mps"); 444 solutionBase.loadProblem(*mps.getMatrixByCol(),mps.getColLower(), 445 mps.getColUpper(), 446 mps.getObjCoefficients(), 447 mps.getRowLower(),mps.getRowUpper()); 448 449 solutionBase.setDblParam(ClpObjOffset,mps.objectiveOffset()); 450 } 451 452 // Runs through strategies 453 if (algorithm==6||algorithm==7) { 454 // algorithms tested are at top of file 455 double testTime[NUMBER_ALGORITHMS]; 456 std::string alg[NUMBER_ALGORITHMS]; 457 int iTest; 458 for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 459 ClpSolve solveOptions=setupForSolve(iTest,alg[iTest],1); 460 if (solveOptions.getSolveType()!=ClpSolve::notImplemented) { 461 double time1 = CoinCpuTime(); 462 ClpSimplex solution=solutionBase; 463 if (solution.maximumSeconds()<0.0) 464 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 } 472 solution.initialSolve(solveOptions); 473 double time2 = CoinCpuTime()-time1; 474 testTime[iTest]=time2; 475 printf("Took %g seconds - status %d\n",time2,solution.problemStatus()); 476 if (solution.problemStatus()) 477 testTime[iTest]=1.0e20; 478 } else { 479 testTime[iTest]=1.0e30; 480 } 481 } 482 int iBest=-1; 483 double dBest=1.0e10; 484 printf("%s",fn.c_str()); 485 for (iTest=0;iTest<NUMBER_ALGORITHMS;iTest++) { 486 if (testTime[iTest]<1.0e30) { 487 printf(" %s %g", 488 alg[iTest].c_str(),testTime[iTest]); 489 if (testTime[iTest]<dBest) { 490 dBest=testTime[iTest]; 491 iBest=iTest; 492 } 493 } 494 } 495 printf("\n"); 496 if (iBest>=0) 497 printf("Best strategy for %s is %s (%d) which takes %g seconds\n", 498 fn.c_str(),alg[iBest].c_str(),iBest,testTime[iBest]); 499 else 500 printf("No strategy finished in time limit\n"); 501 continue; 502 } 503 double time1 = CoinCpuTime(); 504 ClpSimplex solution=solutionBase; 505 #if 0 506 solution.setOptimizationDirection(-1); 507 { 508 int j; 509 double * obj = solution.objective(); 510 int n=solution.numberColumns(); 511 for (j=0;j<n;j++) 512 obj[j] *= -1.0; 513 } 514 #endif 515 ClpSolve::SolveType method; 516 ClpSolve::PresolveType presolveType; 517 ClpSolve solveOptions; 518 if (doPresolve) 519 presolveType=ClpSolve::presolveOn; 520 else 521 presolveType=ClpSolve::presolveOff; 522 solveOptions.setPresolveType(presolveType,5); 523 std::string nameAlgorithm; 524 if (algorithm!=5) { 525 if (algorithm==0) { 526 method=ClpSolve::useDual; 527 nameAlgorithm="dual"; 528 } else if (algorithm==1) { 529 method=ClpSolve::usePrimalorSprint; 530 nameAlgorithm="primal"; 531 } else if (algorithm==3) { 532 method=ClpSolve::automatic; 533 nameAlgorithm="either"; 534 } else { 535 nameAlgorithm="barrier-slow"; 536 #ifdef UFL_BARRIER 537 solveOptions.setSpecialOption(4,4); 538 nameAlgorithm="barrier-UFL"; 539 #endif 540 #ifdef WSSMP_BARRIER 541 solveOptions.setSpecialOption(4,2); 542 nameAlgorithm="barrier-WSSMP"; 543 #endif 544 method = ClpSolve::useBarrier; 545 } 546 solveOptions.setSolveType(method); 547 } else { 548 int iAlg = bestStrategy[m]; 549 int presolveOff=iAlg/100; 550 iAlg=iAlg % 100; 551 if( !barrierAvailable&&iAlg==0) { 552 if (nRows[m]!=2172) 553 iAlg = 5; // try primal 554 else 555 iAlg=3; // d2q06c 556 } 557 solveOptions=setupForSolve(iAlg,nameAlgorithm,0); 558 if (presolveOff) 559 solveOptions.setPresolveType(ClpSolve::presolveOff); 560 } 561 if (doVector) { 562 ClpMatrixBase * matrix = solution.clpMatrix(); 563 if (dynamic_cast< ClpPackedMatrix*>(matrix)) { 564 ClpPackedMatrix * clpMatrix = dynamic_cast< ClpPackedMatrix*>(matrix); 565 clpMatrix->makeSpecialColumnCopy(); 566 } 567 } 568 solution.initialSolve(solveOptions); 569 double time2 = CoinCpuTime()-time1; 570 timeTaken += time2; 571 printf("%s took %g seconds using algorithm %s\n",fn.c_str(),time2,nameAlgorithm.c_str()); 572 // Test objective solution value 573 { 574 double soln = solution.objectiveValue(); 575 CoinRelFltEq eq(objValueTol[m]); 576 std::cerr <<soln <<", " <<objValue[m] <<" diff "<< 577 soln-objValue[m]<<std::endl; 578 if(!eq(soln,objValue[m])) 579 printf("** difference fails\n"); 580 } 581 } 582 printf("Total time %g seconds\n",timeTaken); 583 } 584 else { 585 testingMessage( "***Skipped Testing on netlib ***\n" ); 586 testingMessage( "***use -netlib to test class***\n" ); 587 } 588 589 testingMessage( "All tests completed successfully\n" ); 590 return 0; 591 } 592 593 19 //############################################################################# 20 594 21 // Display message on stdout and stderr 595 22 void testingMessage( const char * const msg ) 596 23 { 597 std::c err<<msg;24 std::cout <<msg; 598 25 //cout <<endl <<"*****************************************" 599 26 // <<endl <<msg <<endl; 600 27 } 601 28 602 //-------------------------------------------------------------------------- 603 // test factorization methods and simplex method and simple barrier 604 void 605 ClpSimplexUnitTest(const std::string & mpsDir, 606 const std::string & netlibDir) 607 { 608 609 CoinRelFltEq eq(0.000001); 610 611 { 612 ClpSimplex solution; 613 614 // matrix data 615 //deliberate hiccup of 2 between 0 and 1 616 CoinBigIndex start[5]={0,4,7,8,9}; 617 int length[5]={2,3,1,1,1}; 618 int rows[11]={0,2,-1,-1,0,1,2,0,1,2}; 619 double elements[11]={7.0,2.0,1.0e10,1.0e10,-2.0,1.0,-2.0,1,1,1}; 620 CoinPackedMatrix matrix(true,3,5,8,elements,rows,start,length); 621 622 // rim data 623 double objective[7]={-4.0,1.0,0.0,0.0,0.0,0.0,0.0}; 624 double rowLower[5]={14.0,3.0,3.0,1.0e10,1.0e10}; 625 double rowUpper[5]={14.0,3.0,3.0,-1.0e10,-1.0e10}; 626 double colLower[7]={0.0,0.0,0.0,0.0,0.0,0.0,0.0}; 627 double colUpper[7]={100.0,100.0,100.0,100.0,100.0,100.0,100.0}; 628 629 // basis 1 630 int rowBasis1[3]={-1,-1,-1}; 631 int colBasis1[5]={1,1,-1,-1,1}; 632 solution.loadProblem(matrix,colLower,colUpper,objective, 633 rowLower,rowUpper); 634 int i; 635 solution.createStatus(); 636 for (i=0;i<3;i++) { 637 if (rowBasis1[i]<0) { 638 solution.setRowStatus(i,ClpSimplex::atLowerBound); 639 } else { 640 solution.setRowStatus(i,ClpSimplex::basic); 641 } 642 } 643 for (i=0;i<5;i++) { 644 if (colBasis1[i]<0) { 645 solution.setColumnStatus(i,ClpSimplex::atLowerBound); 646 } else { 647 solution.setColumnStatus(i,ClpSimplex::basic); 648 } 649 } 650 solution.setLogLevel(3+4+8+16+32); 651 solution.primal(); 652 for (i=0;i<3;i++) { 653 if (rowBasis1[i]<0) { 654 solution.setRowStatus(i,ClpSimplex::atLowerBound); 655 } else { 656 solution.setRowStatus(i,ClpSimplex::basic); 657 } 658 } 659 for (i=0;i<5;i++) { 660 if (colBasis1[i]<0) { 661 solution.setColumnStatus(i,ClpSimplex::atLowerBound); 662 } else { 663 solution.setColumnStatus(i,ClpSimplex::basic); 664 } 665 } 666 // intricate stuff does not work with scaling 667 solution.scaling(0); 668 int returnCode = solution.factorize ( ); 669 assert(!returnCode); 670 const double * colsol = solution.primalColumnSolution(); 671 const double * rowsol = solution.primalRowSolution(); 672 solution.getSolution(rowsol,colsol); 673 double colsol1[5]={20.0/7.0,3.0,0.0,0.0,23.0/7.0}; 674 for (i=0;i<5;i++) { 675 assert(eq(colsol[i],colsol1[i])); 676 } 677 // now feed in again without actually doing factorization 678 ClpFactorization factorization2 = *solution.factorization(); 679 ClpSimplex solution2 = solution; 680 solution2.setFactorization(factorization2); 681 solution2.createStatus(); 682 for (i=0;i<3;i++) { 683 if (rowBasis1[i]<0) { 684 solution2.setRowStatus(i,ClpSimplex::atLowerBound); 685 } else { 686 solution2.setRowStatus(i,ClpSimplex::basic); 687 } 688 } 689 for (i=0;i<5;i++) { 690 if (colBasis1[i]<0) { 691 solution2.setColumnStatus(i,ClpSimplex::atLowerBound); 692 } else { 693 solution2.setColumnStatus(i,ClpSimplex::basic); 694 } 695 } 696 // intricate stuff does not work with scaling 697 solution2.scaling(0); 698 solution2.getSolution(rowsol,colsol); 699 colsol = solution2.primalColumnSolution(); 700 rowsol = solution2.primalRowSolution(); 701 for (i=0;i<5;i++) { 702 assert(eq(colsol[i],colsol1[i])); 703 } 704 solution2.setDualBound(0.1); 705 solution2.dual(); 706 objective[2]=-1.0; 707 objective[3]=-0.5; 708 objective[4]=10.0; 709 solution.dual(); 710 for (i=0;i<3;i++) { 711 rowLower[i]=-1.0e20; 712 colUpper[i+2]=0.0; 713 } 714 solution.setLogLevel(3); 715 solution.dual(); 716 double rowObjective[]={1.0,0.5,-10.0}; 717 solution.loadProblem(matrix,colLower,colUpper,objective, 718 rowLower,rowUpper,rowObjective); 719 solution.dual(); 720 solution.loadProblem(matrix,colLower,colUpper,objective, 721 rowLower,rowUpper,rowObjective); 722 solution.primal(); 723 } 724 #ifndef COIN_NO_CLP_MESSAGE 725 { 726 CoinMpsIO m; 727 std::string fn = mpsDir+"exmip1"; 728 m.readMps(fn.c_str(),"mps"); 729 ClpSimplex solution; 730 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 731 m.getObjCoefficients(), 732 m.getRowLower(),m.getRowUpper()); 733 solution.dual(); 734 // Test event handling 735 MyEventHandler handler; 736 solution.passInEventHandler(&handler); 737 int numberRows=solution.numberRows(); 738 // make sure values pass has something to do 739 for (int i=0;i<numberRows;i++) 740 solution.setRowStatus(i,ClpSimplex::basic); 741 solution.primal(1); 742 assert (solution.secondaryStatus()==102); // Came out at end of pass 743 } 744 // Test Message handler 745 { 746 CoinMpsIO m; 747 std::string fn = mpsDir+"exmip1"; 748 //fn = "Test/subGams4"; 749 m.readMps(fn.c_str(),"mps"); 750 ClpSimplex model; 751 model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 752 m.getObjCoefficients(), 753 m.getRowLower(),m.getRowUpper()); 754 // Message handler 755 MyMessageHandler messageHandler(&model); 756 std::cout<<"Testing derived message handler"<<std::endl; 757 model.passInMessageHandler(&messageHandler); 758 model.messagesPointer()->setDetailMessage(1,102); 759 model.setFactorizationFrequency(10); 760 model.primal(); 761 762 // Write saved solutions 763 int nc = model.getNumCols(); 764 int s; 765 std::deque<StdVectorDouble> fep = messageHandler.getFeasibleExtremePoints(); 766 int numSavedSolutions = fep.size(); 767 for ( s=0; s<numSavedSolutions; ++s ) { 768 const StdVectorDouble & solnVec = fep[s]; 769 for ( int c=0; c<nc; ++c ) { 770 if (fabs(solnVec[c])>1.0e-8) 771 std::cout <<"Saved Solution: " <<s <<" ColNum: " <<c <<" Value: " <<solnVec[c] <<std::endl; 772 } 773 } 774 // Solve again without scaling 775 // and maximize then minimize 776 messageHandler.clearFeasibleExtremePoints(); 777 model.scaling(0); 778 model.setOptimizationDirection(-1); 779 model.primal(); 780 model.setOptimizationDirection(1); 781 model.primal(); 782 fep = messageHandler.getFeasibleExtremePoints(); 783 numSavedSolutions = fep.size(); 784 for ( s=0; s<numSavedSolutions; ++s ) { 785 const StdVectorDouble & solnVec = fep[s]; 786 for ( int c=0; c<nc; ++c ) { 787 if (fabs(solnVec[c])>1.0e-8) 788 std::cout <<"Saved Solution: " <<s <<" ColNum: " <<c <<" Value: " <<solnVec[c] <<std::endl; 789 } 790 } 791 } 792 #endif 793 // Test dual ranging 794 { 795 CoinMpsIO m; 796 std::string fn = mpsDir+"exmip1"; 797 m.readMps(fn.c_str(),"mps"); 798 ClpSimplex model; 799 model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 800 m.getObjCoefficients(), 801 m.getRowLower(),m.getRowUpper()); 802 model.primal(); 803 int which[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; 804 double costIncrease[13]; 805 int sequenceIncrease[13]; 806 double costDecrease[13]; 807 int sequenceDecrease[13]; 808 // ranging 809 model.dualRanging(13,which,costIncrease,sequenceIncrease, 810 costDecrease,sequenceDecrease); 811 int i; 812 for ( i=0;i<13;i++) 813 printf("%d increase %g %d, decrease %g %d\n", 814 i,costIncrease[i],sequenceIncrease[i], 815 costDecrease[i],sequenceDecrease[i]); 816 assert (fabs(costDecrease[3])<1.0e-4); 817 assert (fabs(costIncrease[7]-1.0)<1.0e-4); 818 model.setOptimizationDirection(-1); 819 { 820 int j; 821 double * obj = model.objective(); 822 int n=model.numberColumns(); 823 for (j=0;j<n;j++) 824 obj[j] *= -1.0; 825 } 826 double costIncrease2[13]; 827 int sequenceIncrease2[13]; 828 double costDecrease2[13]; 829 int sequenceDecrease2[13]; 830 // ranging 831 model.dualRanging(13,which,costIncrease2,sequenceIncrease2, 832 costDecrease2,sequenceDecrease2); 833 for (i=0;i<13;i++) { 834 assert (fabs(costIncrease[i]-costDecrease2[i])<1.0e-6); 835 assert (fabs(costDecrease[i]-costIncrease2[i])<1.0e-6); 836 assert (sequenceIncrease[i]==sequenceDecrease2[i]); 837 assert (sequenceDecrease[i]==sequenceIncrease2[i]); 838 } 839 // Now delete all rows and see what happens 840 model.deleteRows(model.numberRows(),which); 841 model.primal(); 842 // ranging 843 if (!model.dualRanging(8,which,costIncrease,sequenceIncrease, 844 costDecrease,sequenceDecrease)) { 845 for (i=0;i<8;i++) { 846 printf("%d increase %g %d, decrease %g %d\n", 847 i,costIncrease[i],sequenceIncrease[i], 848 costDecrease[i],sequenceDecrease[i]); 849 } 850 } 851 } 852 // Test primal ranging 853 { 854 CoinMpsIO m; 855 std::string fn = mpsDir+"exmip1"; 856 m.readMps(fn.c_str(),"mps"); 857 ClpSimplex model; 858 model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 859 m.getObjCoefficients(), 860 m.getRowLower(),m.getRowUpper()); 861 model.primal(); 862 int which[13] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; 863 double valueIncrease[13]; 864 int sequenceIncrease[13]; 865 double valueDecrease[13]; 866 int sequenceDecrease[13]; 867 // ranging 868 model.primalRanging(13,which,valueIncrease,sequenceIncrease, 869 valueDecrease,sequenceDecrease); 870 int i; 871 for ( i=0;i<13;i++) 872 printf("%d increase %g %d, decrease %g %d\n", 873 i,valueIncrease[i],sequenceIncrease[i], 874 valueDecrease[i],sequenceDecrease[i]); 875 assert (fabs(valueDecrease[3]-0.642857)<1.0e-4); 876 assert (fabs(valueDecrease[8]-2.95113)<1.0e-4); 877 #if 0 878 // out until I find optimization bug 879 // Test parametrics 880 ClpSimplexOther * model2 = (ClpSimplexOther *) (&model); 881 double rhs[]={ 1.0,2.0,3.0,4.0,5.0}; 882 double endingTheta=1.0; 883 model2->scaling(0); 884 model2->setLogLevel(63); 885 model2->parametrics(0.0,endingTheta,0.1, 886 NULL,NULL,rhs,rhs,NULL); 887 #endif 888 } 889 // Test binv etc 890 { 891 /* 892 Wolsey : Page 130 893 max 4x1 - x2 894 7x1 - 2x2 <= 14 895 x2 <= 3 896 2x1 - 2x2 <= 3 897 x1 in Z+, x2 >= 0 898 899 note slacks are -1 in Clp so signs may be different 900 */ 901 902 int n_cols = 2; 903 int n_rows = 3; 904 905 double obj[2] = {-4.0, 1.0}; 906 double collb[2] = {0.0, 0.0}; 907 double colub[2] = {COIN_DBL_MAX, COIN_DBL_MAX}; 908 double rowlb[3] = {-COIN_DBL_MAX, -COIN_DBL_MAX, -COIN_DBL_MAX}; 909 double rowub[3] = {14.0, 3.0, 3.0}; 910 911 int rowIndices[5] = {0, 2, 0, 1, 2}; 912 int colIndices[5] = {0, 0, 1, 1, 1}; 913 double elements[5] = {7.0, 2.0, -2.0, 1.0, -2.0}; 914 CoinPackedMatrix M(true, rowIndices, colIndices, elements, 5); 915 916 ClpSimplex model; 917 model.loadProblem(M, collb, colub, obj, rowlb, rowub); 918 model.dual(0,1); // keep factorization 919 920 //check that the tableau matches wolsey (B-1 A) 921 // slacks in second part of binvA 922 double * binvA = (double*) malloc((n_cols+n_rows) * sizeof(double)); 923 924 printf("B-1 A by row\n"); 925 int i; 926 for( i = 0; i < n_rows; i++){ 927 model.getBInvARow(i, binvA,binvA+n_cols); 928 printf("row: %d -> ",i); 929 for(int j=0; j < n_cols+n_rows; j++){ 930 printf("%g, ", binvA[j]); 931 } 932 printf("\n"); 933 } 934 // See if can re-use factorization AND arrays 935 model.primal(0,3+4); // keep factorization 936 // And do by column 937 printf("B-1 A by column\n"); 938 for( i = 0; i < n_rows+n_cols; i++){ 939 model.getBInvACol(i, binvA); 940 printf("column: %d -> ",i); 941 for(int j=0; j < n_rows; j++){ 942 printf("%g, ", binvA[j]); 943 } 944 printf("\n"); 945 } 946 free(binvA); 947 model.setColUpper(1,2.0); 948 model.dual(0,2+4); // use factorization and arrays 949 model.dual(0,2); // hopefully will not use factorization 950 model.primal(0,3+4); // keep factorization 951 // but say basis has changed 952 model.setWhatsChanged(model.whatsChanged()&(~512)); 953 model.dual(0,2); // hopefully will not use factorization 954 } 955 // test steepest edge 956 { 957 CoinMpsIO m; 958 std::string fn = netlibDir+"finnis"; 959 int returnCode = m.readMps(fn.c_str(),"mps"); 960 if (returnCode) { 961 // probable cause is that gz not there 962 fprintf(stderr,"Unable to open finnis.mps in Data/Netlib!\n"); 963 fprintf(stderr,"Most probable cause is finnis.mps is gzipped i.e. finnis.mps.gz and libz has not been activated\n"); 964 fprintf(stderr,"Either gunzip files or edit Makefiles/Makefile.location to get libz\n"); 965 exit(999); 966 } 967 ClpModel model; 968 model.loadProblem(*m.getMatrixByCol(),m.getColLower(), 969 m.getColUpper(), 970 m.getObjCoefficients(), 971 m.getRowLower(),m.getRowUpper()); 972 ClpSimplex solution(model); 973 974 solution.scaling(1); 975 solution.setDualBound(1.0e8); 976 //solution.factorization()->maximumPivots(1); 977 //solution.setLogLevel(3); 978 solution.setDualTolerance(1.0e-7); 979 // set objective sense, 980 ClpDualRowSteepest steep; 981 solution.setDualRowPivotAlgorithm(steep); 982 solution.setDblParam(ClpObjOffset,m.objectiveOffset()); 983 solution.dual(); 984 } 985 // test normal solution 986 { 987 CoinMpsIO m; 988 std::string fn = netlibDir+"afiro"; 989 m.readMps(fn.c_str(),"mps"); 990 ClpSimplex solution; 991 ClpModel model; 992 // do twice - without and with scaling 993 int iPass; 994 for (iPass=0;iPass<2;iPass++) { 995 // explicit row objective for testing 996 int nr = m.getNumRows(); 997 double * rowObj = new double[nr]; 998 CoinFillN(rowObj,nr,0.0); 999 model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1000 m.getObjCoefficients(), 1001 m.getRowLower(),m.getRowUpper(),rowObj); 1002 delete [] rowObj; 1003 solution = ClpSimplex(model); 1004 if (iPass) { 1005 solution.scaling(); 1006 } 1007 solution.dual(); 1008 solution.dual(); 1009 // test optimal 1010 assert (solution.status()==0); 1011 int numberColumns = solution.numberColumns(); 1012 int numberRows = solution.numberRows(); 1013 CoinPackedVector colsol(numberColumns,solution.primalColumnSolution()); 1014 double * objective = solution.objective(); 1015 double objValue = colsol.dotProduct(objective); 1016 CoinRelFltEq eq(1.0e-8); 1017 assert(eq(objValue,-4.6475314286e+02)); 1018 // Test auxiliary model 1019 //solution.scaling(0); 1020 solution.auxiliaryModel(63-2); // bounds may change 1021 solution.dual(); 1022 solution.primal(); 1023 solution.allSlackBasis(); 1024 solution.dual(); 1025 assert(eq(solution.objectiveValue(),-4.6475314286e+02)); 1026 solution.auxiliaryModel(-1); 1027 solution.dual(); 1028 assert(eq(solution.objectiveValue(),-4.6475314286e+02)); 1029 double * lower = solution.columnLower(); 1030 double * upper = solution.columnUpper(); 1031 double * sol = solution.primalColumnSolution(); 1032 double * result = new double[numberColumns]; 1033 CoinFillN ( result, numberColumns,0.0); 1034 solution.matrix()->transposeTimes(solution.dualRowSolution(), result); 1035 int iRow , iColumn; 1036 // see if feasible and dual feasible 1037 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1038 double value = sol[iColumn]; 1039 assert(value<upper[iColumn]+1.0e-8); 1040 assert(value>lower[iColumn]-1.0e-8); 1041 value = objective[iColumn]-result[iColumn]; 1042 assert (value>-1.0e-5); 1043 if (sol[iColumn]>1.0e-5) 1044 assert (value<1.0e-5); 1045 } 1046 delete [] result; 1047 result = new double[numberRows]; 1048 CoinFillN ( result, numberRows,0.0); 1049 solution.matrix()->times(colsol, result); 1050 lower = solution.rowLower(); 1051 upper = solution.rowUpper(); 1052 sol = solution.primalRowSolution(); 1053 for (iRow=0;iRow<numberRows;iRow++) { 1054 double value = result[iRow]; 1055 assert(eq(value,sol[iRow])); 1056 assert(value<upper[iRow]+1.0e-8); 1057 assert(value>lower[iRow]-1.0e-8); 1058 } 1059 delete [] result; 1060 // test row objective 1061 double * rowObjective = solution.rowObjective(); 1062 CoinDisjointCopyN(solution.dualRowSolution(),numberRows,rowObjective); 1063 CoinDisjointCopyN(solution.dualColumnSolution(),numberColumns,objective); 1064 // this sets up all slack basis 1065 solution.createStatus(); 1066 solution.dual(); 1067 CoinFillN(rowObjective,numberRows,0.0); 1068 CoinDisjointCopyN(m.getObjCoefficients(),numberColumns,objective); 1069 solution.dual(); 1070 } 1071 } 1072 // test unbounded 1073 { 1074 CoinMpsIO m; 1075 std::string fn = netlibDir+"brandy"; 1076 m.readMps(fn.c_str(),"mps"); 1077 ClpSimplex solution; 1078 // do twice - without and with scaling 1079 int iPass; 1080 for (iPass=0;iPass<2;iPass++) { 1081 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1082 m.getObjCoefficients(), 1083 m.getRowLower(),m.getRowUpper()); 1084 if (iPass) 1085 solution.scaling(); 1086 solution.setOptimizationDirection(-1); 1087 // test unbounded and ray 1088 #ifdef DUAL 1089 solution.setDualBound(100.0); 1090 solution.dual(); 1091 #else 1092 solution.primal(); 1093 #endif 1094 assert (solution.status()==2); 1095 int numberColumns = solution.numberColumns(); 1096 int numberRows = solution.numberRows(); 1097 double * lower = solution.columnLower(); 1098 double * upper = solution.columnUpper(); 1099 double * sol = solution.primalColumnSolution(); 1100 double * ray = solution.unboundedRay(); 1101 double * objective = solution.objective(); 1102 double objChange=0.0; 1103 int iRow , iColumn; 1104 // make sure feasible and columns form ray 1105 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1106 double value = sol[iColumn]; 1107 assert(value<upper[iColumn]+1.0e-8); 1108 assert(value>lower[iColumn]-1.0e-8); 1109 value = ray[iColumn]; 1110 if (value>0.0) 1111 assert(upper[iColumn]>1.0e30); 1112 else if (value<0.0) 1113 assert(lower[iColumn]<-1.0e30); 1114 objChange += value*objective[iColumn]; 1115 } 1116 // make sure increasing objective 1117 assert(objChange>0.0); 1118 double * result = new double[numberRows]; 1119 CoinFillN ( result, numberRows,0.0); 1120 solution.matrix()->times(sol, result); 1121 lower = solution.rowLower(); 1122 upper = solution.rowUpper(); 1123 sol = solution.primalRowSolution(); 1124 for (iRow=0;iRow<numberRows;iRow++) { 1125 double value = result[iRow]; 1126 assert(eq(value,sol[iRow])); 1127 assert(value<upper[iRow]+2.0e-8); 1128 assert(value>lower[iRow]-2.0e-8); 1129 } 1130 CoinFillN ( result, numberRows,0.0); 1131 solution.matrix()->times(ray, result); 1132 // there may be small differences (especially if scaled) 1133 for (iRow=0;iRow<numberRows;iRow++) { 1134 double value = result[iRow]; 1135 if (value>1.0e-8) 1136 assert(upper[iRow]>1.0e30); 1137 else if (value<-1.0e-8) 1138 assert(lower[iRow]<-1.0e30); 1139 } 1140 delete [] result; 1141 delete [] ray; 1142 } 1143 } 1144 // test infeasible 1145 { 1146 CoinMpsIO m; 1147 std::string fn = netlibDir+"brandy"; 1148 m.readMps(fn.c_str(),"mps"); 1149 ClpSimplex solution; 1150 // do twice - without and with scaling 1151 int iPass; 1152 for (iPass=0;iPass<2;iPass++) { 1153 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1154 m.getObjCoefficients(), 1155 m.getRowLower(),m.getRowUpper()); 1156 if (iPass) 1157 solution.scaling(); 1158 // test infeasible and ray 1159 solution.columnUpper()[0]=0.0; 1160 #ifdef DUAL 1161 solution.setDualBound(100.0); 1162 solution.dual(); 1163 #else 1164 solution.primal(); 1165 #endif 1166 assert (solution.status()==1); 1167 int numberColumns = solution.numberColumns(); 1168 int numberRows = solution.numberRows(); 1169 double * lower = solution.rowLower(); 1170 double * upper = solution.rowUpper(); 1171 double * ray = solution.infeasibilityRay(); 1172 assert(ray); 1173 // construct proof of infeasibility 1174 int iRow , iColumn; 1175 double lo=0.0,up=0.0; 1176 int nl=0,nu=0; 1177 for (iRow=0;iRow<numberRows;iRow++) { 1178 if (lower[iRow]>-1.0e20) { 1179 lo += ray[iRow]*lower[iRow]; 1180 } else { 1181 if (ray[iRow]>1.0e-8) 1182 nl++; 1183 } 1184 if (upper[iRow]<1.0e20) { 1185 up += ray[iRow]*upper[iRow]; 1186 } else { 1187 if (ray[iRow]>1.0e-8) 1188 nu++; 1189 } 1190 } 1191 if (nl) 1192 lo=-1.0e100; 1193 if (nu) 1194 up=1.0e100; 1195 double * result = new double[numberColumns]; 1196 double lo2=0.0,up2=0.0; 1197 CoinFillN ( result, numberColumns,0.0); 1198 solution.matrix()->transposeTimes(ray, result); 1199 lower = solution.columnLower(); 1200 upper = solution.columnUpper(); 1201 nl=nu=0; 1202 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1203 if (result[iColumn]>1.0e-8) { 1204 if (lower[iColumn]>-1.0e20) 1205 lo2 += result[iColumn]*lower[iColumn]; 1206 else 1207 nl++; 1208 if (upper[iColumn]<1.0e20) 1209 up2 += result[iColumn]*upper[iColumn]; 1210 else 1211 nu++; 1212 } else if (result[iColumn]<-1.0e-8) { 1213 if (lower[iColumn]>-1.0e20) 1214 up2 += result[iColumn]*lower[iColumn]; 1215 else 1216 nu++; 1217 if (upper[iColumn]<1.0e20) 1218 lo2 += result[iColumn]*upper[iColumn]; 1219 else 1220 nl++; 1221 } 1222 } 1223 if (nl) 1224 lo2=-1.0e100; 1225 if (nu) 1226 up2=1.0e100; 1227 // make sure inconsistency 1228 assert(lo2>up||up2<lo); 1229 delete [] result; 1230 delete [] ray; 1231 } 1232 } 1233 // test delete and add 1234 { 1235 CoinMpsIO m; 1236 std::string fn = netlibDir+"brandy"; 1237 m.readMps(fn.c_str(),"mps"); 1238 ClpSimplex solution; 1239 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1240 m.getObjCoefficients(), 1241 m.getRowLower(),m.getRowUpper()); 1242 solution.dual(); 1243 CoinRelFltEq eq(1.0e-8); 1244 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1245 1246 int numberColumns = solution.numberColumns(); 1247 int numberRows = solution.numberRows(); 1248 double * saveObj = new double [numberColumns]; 1249 double * saveLower = new double[numberRows+numberColumns]; 1250 double * saveUpper = new double[numberRows+numberColumns]; 1251 int * which = new int [numberRows+numberColumns]; 1252 1253 int numberElements = m.getMatrixByCol()->getNumElements(); 1254 int * starts = new int[numberRows+numberColumns]; 1255 int * index = new int[numberElements]; 1256 double * element = new double[numberElements]; 1257 1258 const CoinBigIndex * startM; 1259 const int * lengthM; 1260 const int * indexM; 1261 const double * elementM; 1262 1263 int n,nel; 1264 1265 // delete non basic columns 1266 n=0; 1267 nel=0; 1268 int iRow , iColumn; 1269 const double * lower = m.getColLower(); 1270 const double * upper = m.getColUpper(); 1271 const double * objective = m.getObjCoefficients(); 1272 startM = m.getMatrixByCol()->getVectorStarts(); 1273 lengthM = m.getMatrixByCol()->getVectorLengths(); 1274 indexM = m.getMatrixByCol()->getIndices(); 1275 elementM = m.getMatrixByCol()->getElements(); 1276 starts[0]=0; 1277 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1278 if (solution.getColumnStatus(iColumn)!=ClpSimplex::basic) { 1279 saveObj[n]=objective[iColumn]; 1280 saveLower[n]=lower[iColumn]; 1281 saveUpper[n]=upper[iColumn]; 1282 int j; 1283 for (j=startM[iColumn];j<startM[iColumn]+lengthM[iColumn];j++) { 1284 index[nel]=indexM[j]; 1285 element[nel++]=elementM[j]; 1286 } 1287 which[n++]=iColumn; 1288 starts[n]=nel; 1289 } 1290 } 1291 solution.deleteColumns(n,which); 1292 solution.dual(); 1293 // Put back 1294 solution.addColumns(n,saveLower,saveUpper,saveObj, 1295 starts,index,element); 1296 solution.dual(); 1297 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1298 // Delete all columns and add back 1299 n=0; 1300 nel=0; 1301 starts[0]=0; 1302 lower = m.getColLower(); 1303 upper = m.getColUpper(); 1304 objective = m.getObjCoefficients(); 1305 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1306 saveObj[n]=objective[iColumn]; 1307 saveLower[n]=lower[iColumn]; 1308 saveUpper[n]=upper[iColumn]; 1309 int j; 1310 for (j=startM[iColumn];j<startM[iColumn]+lengthM[iColumn];j++) { 1311 index[nel]=indexM[j]; 1312 element[nel++]=elementM[j]; 1313 } 1314 which[n++]=iColumn; 1315 starts[n]=nel; 1316 } 1317 solution.deleteColumns(n,which); 1318 solution.dual(); 1319 // Put back 1320 solution.addColumns(n,saveLower,saveUpper,saveObj, 1321 starts,index,element); 1322 solution.dual(); 1323 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1324 1325 // reload with original 1326 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1327 m.getObjCoefficients(), 1328 m.getRowLower(),m.getRowUpper()); 1329 // delete half rows 1330 n=0; 1331 nel=0; 1332 lower = m.getRowLower(); 1333 upper = m.getRowUpper(); 1334 startM = m.getMatrixByRow()->getVectorStarts(); 1335 lengthM = m.getMatrixByRow()->getVectorLengths(); 1336 indexM = m.getMatrixByRow()->getIndices(); 1337 elementM = m.getMatrixByRow()->getElements(); 1338 starts[0]=0; 1339 for (iRow=0;iRow<numberRows;iRow++) { 1340 if ((iRow&1)==0) { 1341 saveLower[n]=lower[iRow]; 1342 saveUpper[n]=upper[iRow]; 1343 int j; 1344 for (j=startM[iRow];j<startM[iRow]+lengthM[iRow];j++) { 1345 index[nel]=indexM[j]; 1346 element[nel++]=elementM[j]; 1347 } 1348 which[n++]=iRow; 1349 starts[n]=nel; 1350 } 1351 } 1352 solution.deleteRows(n,which); 1353 solution.dual(); 1354 // Put back 1355 solution.addRows(n,saveLower,saveUpper, 1356 starts,index,element); 1357 solution.dual(); 1358 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1359 solution.writeMps("yy.mps"); 1360 // Delete all rows 1361 n=0; 1362 nel=0; 1363 lower = m.getRowLower(); 1364 upper = m.getRowUpper(); 1365 starts[0]=0; 1366 for (iRow=0;iRow<numberRows;iRow++) { 1367 saveLower[n]=lower[iRow]; 1368 saveUpper[n]=upper[iRow]; 1369 int j; 1370 for (j=startM[iRow];j<startM[iRow]+lengthM[iRow];j++) { 1371 index[nel]=indexM[j]; 1372 element[nel++]=elementM[j]; 1373 } 1374 which[n++]=iRow; 1375 starts[n]=nel; 1376 } 1377 solution.deleteRows(n,which); 1378 solution.dual(); 1379 // Put back 1380 solution.addRows(n,saveLower,saveUpper, 1381 starts,index,element); 1382 solution.dual(); 1383 solution.writeMps("xx.mps"); 1384 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1385 // Zero out status array to give some interest 1386 memset(solution.statusArray()+numberColumns,0,numberRows); 1387 solution.primal(1); 1388 assert(eq(solution.objectiveValue(),1.5185098965e+03)); 1389 // Delete all columns and rows 1390 n=0; 1391 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1392 which[n++]=iColumn; 1393 starts[n]=nel; 1394 } 1395 solution.deleteColumns(n,which); 1396 n=0; 1397 for (iRow=0;iRow<numberRows;iRow++) { 1398 which[n++]=iRow; 1399 starts[n]=nel; 1400 } 1401 solution.deleteRows(n,which); 1402 1403 delete [] saveObj; 1404 delete [] saveLower; 1405 delete [] saveUpper; 1406 delete [] which; 1407 delete [] starts; 1408 delete [] index; 1409 delete [] element; 1410 } 1411 #if 1 1412 // Test barrier 1413 { 1414 CoinMpsIO m; 1415 std::string fn = mpsDir+"exmip1"; 1416 m.readMps(fn.c_str(),"mps"); 1417 ClpInterior solution; 1418 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1419 m.getObjCoefficients(), 1420 m.getRowLower(),m.getRowUpper()); 1421 solution.primalDual(); 1422 } 1423 #endif 1424 // test network 1425 #define QUADRATIC 1426 if (1) { 1427 std::string fn = mpsDir+"input.130"; 1428 int numberColumns; 1429 int numberRows; 1430 1431 FILE * fp = fopen(fn.c_str(),"r"); 1432 if (!fp) { 1433 // Try in Data 1434 fn = "Data/Sample/input.130"; 1435 fp = fopen(fn.c_str(),"r"); 1436 } 1437 if (!fp) { 1438 fprintf(stderr,"Unable to open file input.130 in mpsDir or Data/Sample directory\n"); 1439 } else { 1440 int problem; 1441 char temp[100]; 1442 // read and skip 1443 fscanf(fp,"%s",temp); 1444 assert (!strcmp(temp,"BEGIN")); 1445 fscanf(fp,"%*s %*s %d %d %*s %*s %d %*s",&problem, &numberRows, 1446 &numberColumns); 1447 // scan down to SUPPLY 1448 while (fgets(temp,100,fp)) { 1449 if (!strncmp(temp,"SUPPLY",6)) 1450 break; 1451 } 1452 if (strncmp(temp,"SUPPLY",6)) { 1453 fprintf(stderr,"Unable to find SUPPLY\n"); 1454 exit(2); 1455 } 1456 // get space for rhs 1457 double * lower = new double[numberRows]; 1458 double * upper = new double[numberRows]; 1459 int i; 1460 for (i=0;i<numberRows;i++) { 1461 lower[i]=0.0; 1462 upper[i]=0.0; 1463 } 1464 // ***** Remember to convert to C notation 1465 while (fgets(temp,100,fp)) { 1466 int row; 1467 int value; 1468 if (!strncmp(temp,"ARCS",4)) 1469 break; 1470 sscanf(temp,"%d %d",&row,&value); 1471 upper[row-1]=-value; 1472 lower[row-1]=-value; 1473 } 1474 if (strncmp(temp,"ARCS",4)) { 1475 fprintf(stderr,"Unable to find ARCS\n"); 1476 exit(2); 1477 } 1478 // number of columns may be underestimate 1479 int * head = new int[2*numberColumns]; 1480 int * tail = new int[2*numberColumns]; 1481 int * ub = new int[2*numberColumns]; 1482 int * cost = new int[2*numberColumns]; 1483 // ***** Remember to convert to C notation 1484 numberColumns=0; 1485 while (fgets(temp,100,fp)) { 1486 int iHead; 1487 int iTail; 1488 int iUb; 1489 int iCost; 1490 if (!strncmp(temp,"DEMAND",6)) 1491 break; 1492 sscanf(temp,"%d %d %d %d",&iHead,&iTail,&iCost,&iUb); 1493 iHead--; 1494 iTail--; 1495 head[numberColumns]=iHead; 1496 tail[numberColumns]=iTail; 1497 ub[numberColumns]=iUb; 1498 cost[numberColumns]=iCost; 1499 numberColumns++; 1500 } 1501 if (strncmp(temp,"DEMAND",6)) { 1502 fprintf(stderr,"Unable to find DEMAND\n"); 1503 exit(2); 1504 } 1505 // ***** Remember to convert to C notation 1506 while (fgets(temp,100,fp)) { 1507 int row; 1508 int value; 1509 if (!strncmp(temp,"END",3)) 1510 break; 1511 sscanf(temp,"%d %d",&row,&value); 1512 upper[row-1]=value; 1513 lower[row-1]=value; 1514 } 1515 if (strncmp(temp,"END",3)) { 1516 fprintf(stderr,"Unable to find END\n"); 1517 exit(2); 1518 } 1519 printf("Problem %d has %d rows and %d columns\n",problem, 1520 numberRows,numberColumns); 1521 fclose(fp); 1522 ClpSimplex model; 1523 // now build model 1524 1525 double * objective =new double[numberColumns]; 1526 double * lowerColumn = new double[numberColumns]; 1527 double * upperColumn = new double[numberColumns]; 1528 1529 double * element = new double [2*numberColumns]; 1530 CoinBigIndex * start = new CoinBigIndex [numberColumns+1]; 1531 int * row = new int[2*numberColumns]; 1532 start[numberColumns]=2*numberColumns; 1533 for (i=0;i<numberColumns;i++) { 1534 start[i]=2*i; 1535 element[2*i]=-1.0; 1536 element[2*i+1]=1.0; 1537 row[2*i]=head[i]; 1538 row[2*i+1]=tail[i]; 1539 lowerColumn[i]=0.0; 1540 upperColumn[i]=ub[i]; 1541 objective[i]=cost[i]; 1542 } 1543 // Create Packed Matrix 1544 CoinPackedMatrix matrix; 1545 int * lengths = NULL; 1546 matrix.assignMatrix(true,numberRows,numberColumns, 1547 2*numberColumns,element,row,start,lengths); 1548 // load model 1549 model.loadProblem(matrix, 1550 lowerColumn,upperColumn,objective, 1551 lower,upper); 1552 model.factorization()->maximumPivots(200+model.numberRows()/100); 1553 model.createStatus(); 1554 double time1 = CoinCpuTime(); 1555 model.dual(); 1556 std::cout<<"Network problem, ClpPackedMatrix took "<<CoinCpuTime()-time1<<" seconds"<<std::endl; 1557 ClpPlusMinusOneMatrix * plusMinus = new ClpPlusMinusOneMatrix(matrix); 1558 assert (plusMinus->getIndices()); // would be zero if not +- one 1559 //ClpPlusMinusOneMatrix *plusminus_matrix; 1560 1561 //plusminus_matrix = new ClpPlusMinusOneMatrix; 1562 1563 //plusminus_matrix->passInCopy(numberRows, numberColumns, true, plusMinus->getMutableIndices(), 1564 // plusMinus->startPositive(),plusMinus->startNegative()); 1565 model.loadProblem(*plusMinus, 1566 lowerColumn,upperColumn,objective, 1567 lower,upper); 1568 //model.replaceMatrix( plusminus_matrix , true); 1569 delete plusMinus; 1570 //model.createStatus(); 1571 //model.initialSolve(); 1572 //model.writeMps("xx.mps"); 1573 1574 model.factorization()->maximumPivots(200+model.numberRows()/100); 1575 model.createStatus(); 1576 time1 = CoinCpuTime(); 1577 model.dual(); 1578 std::cout<<"Network problem, ClpPlusMinusOneMatrix took "<<CoinCpuTime()-time1<<" seconds"<<std::endl; 1579 ClpNetworkMatrix network(numberColumns,head,tail); 1580 model.loadProblem(network, 1581 lowerColumn,upperColumn,objective, 1582 lower,upper); 1583 1584 model.factorization()->maximumPivots(200+model.numberRows()/100); 1585 model.createStatus(); 1586 time1 = CoinCpuTime(); 1587 model.dual(); 1588 std::cout<<"Network problem, ClpNetworkMatrix took "<<CoinCpuTime()-time1<<" seconds"<<std::endl; 1589 delete [] lower; 1590 delete [] upper; 1591 delete [] head; 1592 delete [] tail; 1593 delete [] ub; 1594 delete [] cost; 1595 delete [] objective; 1596 delete [] lowerColumn; 1597 delete [] upperColumn; 1598 } 1599 } 1600 #ifdef QUADRATIC 1601 // Test quadratic to solve linear 1602 if (1) { 1603 CoinMpsIO m; 1604 std::string fn = mpsDir+"exmip1"; 1605 m.readMps(fn.c_str(),"mps"); 1606 ClpSimplex solution; 1607 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1608 m.getObjCoefficients(), 1609 m.getRowLower(),m.getRowUpper()); 1610 //solution.dual(); 1611 // get quadratic part 1612 int numberColumns=solution.numberColumns(); 1613 int * start=new int [numberColumns+1]; 1614 int * column = new int[numberColumns]; 1615 double * element = new double[numberColumns]; 1616 int i; 1617 start[0]=0; 1618 int n=0; 1619 int kk=numberColumns-1; 1620 int kk2=numberColumns-1; 1621 for (i=0;i<numberColumns;i++) { 1622 if (i>=kk) { 1623 column[n]=i; 1624 if (i>=kk2) 1625 element[n]=1.0e-1; 1626 else 1627 element[n]=0.0; 1628 n++; 1629 } 1630 start[i+1]=n; 1631 } 1632 // Load up objective 1633 solution.loadQuadraticObjective(numberColumns,start,column,element); 1634 delete [] start; 1635 delete [] column; 1636 delete [] element; 1637 //solution.quadraticSLP(50,1.0e-4); 1638 double objValue = solution.getObjValue(); 1639 CoinRelFltEq eq(1.0e-4); 1640 //assert(eq(objValue,820.0)); 1641 //solution.setLogLevel(63); 1642 solution.primal(); 1643 int numberRows = solution.numberRows(); 1644 1645 double * rowPrimal = solution.primalRowSolution(); 1646 double * rowDual = solution.dualRowSolution(); 1647 double * rowLower = solution.rowLower(); 1648 double * rowUpper = solution.rowUpper(); 1649 1650 int iRow; 1651 printf("Rows\n"); 1652 for (iRow=0;iRow<numberRows;iRow++) { 1653 printf("%d primal %g dual %g low %g up %g\n", 1654 iRow,rowPrimal[iRow],rowDual[iRow], 1655 rowLower[iRow],rowUpper[iRow]); 1656 } 1657 double * columnPrimal = solution.primalColumnSolution(); 1658 double * columnDual = solution.dualColumnSolution(); 1659 double * columnLower = solution.columnLower(); 1660 double * columnUpper = solution.columnUpper(); 1661 objValue = solution.getObjValue(); 1662 int iColumn; 1663 printf("Columns\n"); 1664 for (iColumn=0;iColumn<numberColumns;iColumn++) { 1665 printf("%d primal %g dual %g low %g up %g\n", 1666 iColumn,columnPrimal[iColumn],columnDual[iColumn], 1667 columnLower[iColumn],columnUpper[iColumn]); 1668 } 1669 //assert(eq(objValue,3.2368421)); 1670 //exit(77); 1671 } 1672 // Test quadratic 1673 if (1) { 1674 CoinMpsIO m; 1675 std::string fn = mpsDir+"share2qp"; 1676 //fn = "share2qpb"; 1677 m.readMps(fn.c_str(),"mps"); 1678 ClpSimplex model; 1679 model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1680 m.getObjCoefficients(), 1681 m.getRowLower(),m.getRowUpper()); 1682 model.dual(); 1683 // get quadratic part 1684 int * start=NULL; 1685 int * column = NULL; 1686 double * element = NULL; 1687 m.readQuadraticMps(NULL,start,column,element,2); 1688 int column2[200]; 1689 double element2[200]; 1690 int start2[80]; 1691 int j; 1692 start2[0]=0; 1693 int nel=0; 1694 bool good=false; 1695 for (j=0;j<79;j++) { 1696 if (start[j]==start[j+1]) { 1697 column2[nel]=j; 1698 element2[nel]=0.0; 1699 nel++; 1700 } else { 1701 int i; 1702 for (i=start[j];i<start[j+1];i++) { 1703 column2[nel]=column[i]; 1704 element2[nel++]=element[i]; 1705 } 1706 } 1707 start2[j+1]=nel; 1708 } 1709 // Load up objective 1710 if (good) 1711 model.loadQuadraticObjective(model.numberColumns(),start2,column2,element2); 1712 else 1713 model.loadQuadraticObjective(model.numberColumns(),start,column,element); 1714 delete [] start; 1715 delete [] column; 1716 delete [] element; 1717 int numberColumns=model.numberColumns(); 1718 #if 0 1719 model.nonlinearSLP(50,1.0e-4); 1720 #else 1721 // Get feasible 1722 ClpObjective * saveObjective = model.objectiveAsObject()->clone(); 1723 ClpLinearObjective zeroObjective(NULL,numberColumns); 1724 model.setObjective(&zeroObjective); 1725 model.dual(); 1726 model.setObjective(saveObjective); 1727 delete saveObjective; 1728 #endif 1729 //model.setLogLevel(63); 1730 //exit(77); 1731 model.setFactorizationFrequency(10); 1732 model.primal(); 1733 double objValue = model.getObjValue(); 1734 CoinRelFltEq eq(1.0e-4); 1735 assert(eq(objValue,-400.92)); 1736 } 1737 if (0) { 1738 CoinMpsIO m; 1739 std::string fn = "./beale"; 1740 //fn = "./jensen"; 1741 m.readMps(fn.c_str(),"mps"); 1742 ClpSimplex solution; 1743 solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(), 1744 m.getObjCoefficients(), 1745 m.getRowLower(),m.getRowUpper()); 1746 solution.setDblParam(ClpObjOffset,m.objectiveOffset()); 1747 solution.dual(); 1748 // get quadratic part 1749 int * start=NULL; 1750 int * column = NULL; 1751 double * element = NULL; 1752 m.readQuadraticMps(NULL,start,column,element,2); 1753 // Load up objective 1754 solution.loadQuadraticObjective(solution.numberColumns(),start,column,element); 1755 delete [] start; 1756 delete [] column; 1757 delete [] element; 1758 solution.primal(1); 1759 solution.nonlinearSLP(50,1.0e-4); 1760 double objValue = solution.getObjValue(); 1761 CoinRelFltEq eq(1.0e-4); 1762 assert(eq(objValue,0.5)); 1763 solution.primal(); 1764 objValue = solution.getObjValue(); 1765 assert(eq(objValue,0.5)); 1766 } 1767 #endif 1768 } 1769 void CbcClpUnitTest (const CbcModel & saveModel) 29 //############################################################################# 30 31 void CbcClpUnitTest (const CbcModel & saveModel, std::string& miplibDir, 32 bool unitTestOnly) 1770 33 { 1771 34 unsigned int m ; … … 1773 36 FILE * fp; 1774 37 bool doTest=false; 1775 const char dirsep = CoinFindDirSeparator(); 1776 38 1777 39 // Set directory containing miplib data files. 1778 std::string miplibDir;1779 miplibDir = dirsep == '/' ? "../../Data/miplib3/" : "..\\..\\Data\\miplib3\\";1780 40 std::string test1 = miplibDir +"p0033"; 1781 41 fp=fopen(test1.c_str(),"r"); … … 1819 79 strategy.push_back(zz_strategy_zz) ; \ 1820 80 objValue.push_back(zz_objValue_zz) ; 1821 1822 /* 1823 Load up the problem vector. Note that the row counts here include the 1824 objective function. 1825 1826 */ 1827 // 0 for no test, 1 for some, 2 for many, 3 for all 81 82 if (unitTestOnly) { 83 PUSH_MPS("p0033",16,33,3089,2520.57,7); 84 PUSH_MPS("p0201",133,201,7615,6875.0,7); 85 PUSH_MPS("p0548",176,548,8691,315.29,7); 86 } else { 87 /* 88 Load up the problem vector. Note that the row counts here include the 89 objective function. 90 */ 91 // 0 for no test, 1 for some, 2 for many, 3 for all 1828 92 #define HOWMANY 2 1829 93 #if HOWMANY 1830 94 #if HOWMANY>1 1831 PUSH_MPS("10teams",230,2025,924,917,7);1832 #endif 1833 PUSH_MPS("air03",124,10757,340160,338864.25,7);1834 #if HOWMANY==3 1835 PUSH_MPS("air04",823,8904,56137,55535.436,8);1836 PUSH_MPS("air05",426,7195,26374,25877.609,8);95 PUSH_MPS("10teams",230,2025,924,917,7); 96 #endif 97 PUSH_MPS("air03",124,10757,340160,338864.25,7); 98 #if HOWMANY==3 99 PUSH_MPS("air04",823,8904,56137,55535.436,8); 100 PUSH_MPS("air05",426,7195,26374,25877.609,8); 1837 101 #endif 1838 102 // PUSH_MPS("arki001",1048,1388,7580813.0459,7579599.80787,7); 1839 PUSH_MPS("bell3a",123,133,878430.32,862578.64,7); 1840 #if HOWMANY>1 1841 PUSH_MPS("bell5",91,104,8966406.49,8608417.95,7); 1842 #endif 1843 PUSH_MPS("blend2",274,353,7.598985,6.9156751140,7); 1844 #if HOWMANY>1 1845 PUSH_MPS("cap6000",2176,6000,-2451377,-2451537.325,7); 1846 #endif 1847 // PUSH_MPS("dano3mip",3202,13873,728.1111,576.23162474,7); 1848 //PUSH_MPS("danoint",664,521,65.67,62.637280418,7); 1849 PUSH_MPS("dcmulti",290,548,188182,183975.5397,7); 1850 PUSH_MPS("dsbmip",1182,1886,-305.19817501,-305.19817501,7); 1851 PUSH_MPS("egout",98,141,568.101,149.589,7); 1852 PUSH_MPS("enigma",21,100,0.0,0.0,7); 1853 #if HOWMANY==3 1854 PUSH_MPS("fast0507",507,63009,174,172.14556668,7); 1855 #endif 1856 PUSH_MPS("fiber",363,1298,405935.18000,156082.51759,7); 1857 #if HOWMANY>1 1858 PUSH_MPS("fixnet6",478,878,3983,1200.88,7); 1859 #endif 1860 PUSH_MPS("flugpl",18,18,1201500,1167185.7,7); 1861 PUSH_MPS("gen",780,870,112313,112130.0,7); 1862 #if HOWMANY>1 1863 PUSH_MPS("gesa2",1392,1224,25779856.372,25476489.678,7); 1864 PUSH_MPS("gesa2_o",1248,1224,25779856.372,25476489.678,7); 1865 #endif 1866 PUSH_MPS("gesa3",1368,1152,27991042.648,27833632.451,7); 1867 PUSH_MPS("gesa3_o",1224,1152,27991042.648,27833632.451,7); 1868 PUSH_MPS("gt2",29,188,21166.000,13460.233074,7); 1869 #if HOWMANY==3 1870 PUSH_MPS("harp2",112,2993,-73899798.00,-74353341.502,7); 1871 #endif 1872 PUSH_MPS("khb05250",101,1350,106940226,95919464.0,7); 1873 #if HOWMANY>1 1874 PUSH_MPS("l152lav",97,1989,4722,4656.36,7); 1875 #endif 1876 PUSH_MPS("lseu",28,89,1120,834.68,7); 1877 PUSH_MPS("misc03",96,160,3360,1910.,7); 1878 PUSH_MPS("misc06",820,1808,12850.8607,12841.6,7); 1879 #if HOWMANY>1 1880 PUSH_MPS("misc07",212,260,2810,1415.0,7); 1881 PUSH_MPS("mitre",2054,10724,115155,114740.5184,7); 1882 #endif 1883 PUSH_MPS("mod008",6,319,307,290.9,7); 1884 PUSH_MPS("mod010",146,2655,6548,6532.08,7); 1885 #if HOWMANY==3 1886 PUSH_MPS("mod011",4480,10958,-54558535,-62121982.55,7); 1887 PUSH_MPS("modglob",291,422,20740508,20430947.,7); 1888 PUSH_MPS("noswot",182,128,-43,-43.0,7); 1889 #endif 1890 #if HOWMANY>1 1891 PUSH_MPS("nw04",36,87482,16862,16310.66667,7); 1892 #endif 1893 PUSH_MPS("p0033",16,33,3089,2520.57,7); 1894 PUSH_MPS("p0201",133,201,7615,6875.0,7); 1895 PUSH_MPS("p0282",241,282,258411,176867.50,7); 1896 PUSH_MPS("p0548",176,548,8691,315.29,7); 1897 PUSH_MPS("p2756",755,2756,3124,2688.75,7); 1898 #if HOWMANY==3 1899 PUSH_MPS("pk1",45,86,11.0,0.0,7); 1900 #endif 1901 #if HOWMANY>1 1902 PUSH_MPS("pp08a",136,240,7350.0,2748.3452381,7); 1903 PUSH_MPS("pp08aCUTS",246,240,7350.0,5480.6061563,7); 1904 #endif 1905 #if HOWMANY==3 1906 PUSH_MPS("qiu",1192,840,-132.873137,-931.638857,7); 1907 #endif 1908 PUSH_MPS("qnet1",503,1541,16029.692681,14274.102667,7); 1909 PUSH_MPS("qnet1_o",456,1541,16029.692681,12095.571667,7); 1910 PUSH_MPS("rentacar",6803,9557,30356761,28806137.644,7); 1911 PUSH_MPS("rgn",24,180,82.1999,48.7999,7); 1912 #if HOWMANY==3 1913 PUSH_MPS("rout",291,556,1077.56,981.86428571,7); 1914 PUSH_MPS("set1ch",492,712,54537.75,32007.73,7); 1915 #endif 1916 // PUSH_MPS("seymour",4944,1372,423,403.84647413,7); 1917 PUSH_MPS("stein27",118,27,18,13.0,7); 1918 #if HOWMANY>1 1919 PUSH_MPS("stein45",331,45,30,22.0,7); 1920 #endif 1921 PUSH_MPS("vpm1",234,378,20,15.4167,7); 1922 PUSH_MPS("vpm2",234,378,13.75,9.8892645972,7); 1923 #endif 103 PUSH_MPS("bell3a",123,133,878430.32,862578.64,7); 104 #if HOWMANY>1 105 PUSH_MPS("bell5",91,104,8966406.49,8608417.95,7); 106 #endif 107 PUSH_MPS("blend2",274,353,7.598985,6.9156751140,7); 108 #if HOWMANY>1 109 PUSH_MPS("cap6000",2176,6000,-2451377,-2451537.325,7); 110 #endif 111 // PUSH_MPS("dano3mip",3202,13873,728.1111,576.23162474,7); 112 //PUSH_MPS("danoint",664,521,65.67,62.637280418,7); 113 PUSH_MPS("dcmulti",290,548,188182,183975.5397,7); 114 PUSH_MPS("dsbmip",1182,1886,-305.19817501,-305.19817501,7); 115 PUSH_MPS("egout",98,141,568.101,149.589,7); 116 PUSH_MPS("enigma",21,100,0.0,0.0,7); 117 #if HOWMANY==3 118 PUSH_MPS("fast0507",507,63009,174,172.14556668,7); 119 #endif 120 PUSH_MPS("fiber",363,1298,405935.18000,156082.51759,7); 121 #if HOWMANY>1 122 PUSH_MPS("fixnet6",478,878,3983,1200.88,7); 123 #endif 124 PUSH_MPS("flugpl",18,18,1201500,1167185.7,7); 125 PUSH_MPS("gen",780,870,112313,112130.0,7); 126 #if HOWMANY>1 127 PUSH_MPS("gesa2",1392,1224,25779856.372,25476489.678,7); 128 PUSH_MPS("gesa2_o",1248,1224,25779856.372,25476489.678,7); 129 #endif 130 PUSH_MPS("gesa3",1368,1152,27991042.648,27833632.451,7); 131 PUSH_MPS("gesa3_o",1224,1152,27991042.648,27833632.451,7); 132 PUSH_MPS("gt2",29,188,21166.000,13460.233074,7); 133 #if HOWMANY==3 134 PUSH_MPS("harp2",112,2993,-73899798.00,-74353341.502,7); 135 #endif 136 PUSH_MPS("khb05250",101,1350,106940226,95919464.0,7); 137 #if HOWMANY>1 138 PUSH_MPS("l152lav",97,1989,4722,4656.36,7); 139 #endif 140 PUSH_MPS("lseu",28,89,1120,834.68,7); 141 PUSH_MPS("misc03",96,160,3360,1910.,7); 142 PUSH_MPS("misc06",820,1808,12850.8607,12841.6,7); 143 #if HOWMANY>1 144 PUSH_MPS("misc07",212,260,2810,1415.0,7); 145 PUSH_MPS("mitre",2054,10724,115155,114740.5184,7); 146 #endif 147 PUSH_MPS("mod008",6,319,307,290.9,7); 148 PUSH_MPS("mod010",146,2655,6548,6532.08,7); 149 #if HOWMANY==3 150 PUSH_MPS("mod011",4480,10958,-54558535,-62121982.55,7); 151 PUSH_MPS("modglob",291,422,20740508,20430947.,7); 152 PUSH_MPS("noswot",182,128,-43,-43.0,7); 153 #endif 154 #if HOWMANY>1 155 PUSH_MPS("nw04",36,87482,16862,16310.66667,7); 156 #endif 157 PUSH_MPS("p0033",16,33,3089,2520.57,7); 158 PUSH_MPS("p0201",133,201,7615,6875.0,7); 159 PUSH_MPS("p0282",241,282,258411,176867.50,7); 160 PUSH_MPS("p0548",176,548,8691,315.29,7); 161 PUSH_MPS("p2756",755,2756,3124,2688.75,7); 162 #if HOWMANY==3 163 PUSH_MPS("pk1",45,86,11.0,0.0,7); 164 #endif 165 #if HOWMANY>1 166 PUSH_MPS("pp08a",136,240,7350.0,2748.3452381,7); 167 PUSH_MPS("pp08aCUTS",246,240,7350.0,5480.6061563,7); 168 #endif 169 #if HOWMANY==3 170 PUSH_MPS("qiu",1192,840,-132.873137,-931.638857,7); 171 #endif 172 PUSH_MPS("qnet1",503,1541,16029.692681,14274.102667,7); 173 PUSH_MPS("qnet1_o",456,1541,16029.692681,12095.571667,7); 174 PUSH_MPS("rentacar",6803,9557,30356761,28806137.644,7); 175 PUSH_MPS("rgn",24,180,82.1999,48.7999,7); 176 #if HOWMANY==3 177 PUSH_MPS("rout",291,556,1077.56,981.86428571,7); 178 PUSH_MPS("set1ch",492,712,54537.75,32007.73,7); 179 #endif 180 // PUSH_MPS("seymour",4944,1372,423,403.84647413,7); 181 PUSH_MPS("stein27",118,27,18,13.0,7); 182 #if HOWMANY>1 183 PUSH_MPS("stein45",331,45,30,22.0,7); 184 #endif 185 PUSH_MPS("vpm1",234,378,20,15.4167,7); 186 PUSH_MPS("vpm2",234,378,13.75,9.8892645972,7); 187 #endif 188 } 1924 189 #undef PUSH_MPS 1925 190 … … 1931 196 */ 1932 197 for (m = 0 ; m < mpsName.size() ; m++) { 1933 std::c err<< " processing mps file: " << mpsName[m]1934 << " (" << m+1 << " out of " << mpsName.size() << ") " << std::endl;198 std::cout << " processing mps file: " << mpsName[m] 199 << " (" << m+1 << " out of " << mpsName.size() << ")\n"; 1935 200 /* 1936 201 Stage 1: Read the MPS … … 1941 206 std::string fn = miplibDir+mpsName[m] ; 1942 207 model->solver()->readMps(fn.c_str(),"") ; 1943 int nr = model->getNumRows() ; 1944 int nc = model->getNumCols() ; 1945 assert(nr == nRows[m]) ; 1946 assert(nc == nCols[m]) ; 208 assert(model->getNumRows() == nRows[m]) ; 209 assert(model->getNumCols() == nCols[m]) ; 210 1947 211 /* 1948 212 Stage 2: Call solver to solve the problem. 1949 1950 213 then check the return code and objective. 1951 1952 214 */ 1953 215 1954 216 double startTime = CoinCpuTime()+CoinCpuTimeJustChildren(); 1955 if (model->getMaximumNodes()>200000) 217 if (model->getMaximumNodes()>200000) { 1956 218 model->setMaximumNodes(200000); 219 } 1957 220 OsiClpSolverInterface * si = 1958 221 dynamic_cast<OsiClpSolverInterface *>(model->solver()) ; … … 1981 244 below *= multiplier; 1982 245 } 1983 if (above<1.0e12) 246 if (above<1.0e12) { 1984 247 largest = CoinMax(largest,above); 1985 if (below<1.0e12) 248 } 249 if (below<1.0e12) { 1986 250 largest = CoinMax(largest,below); 251 } 1987 252 } 1988 253 … … 2002 267 below *= multiplier; 2003 268 } 2004 if (above<1.0e12) 269 if (above<1.0e12) { 2005 270 largest = CoinMax(largest,above); 2006 if (below<1.0e12) 271 } 272 if (below<1.0e12) { 2007 273 largest = CoinMax(largest,below); 274 } 2008 275 } 2009 276 //std::cout<<"Largest (scaled) away from bound "<<largest<<std::endl; 2010 modelC->setDualBound(CoinMax(1.0001e8,CoinMin(1000.0*largest,1.00001e10))); 277 modelC->setDualBound(CoinMax(1.0001e8, 278 CoinMin(1000.0*largest,1.00001e10))); 2011 279 } 2012 280 model->setMinimumDrop(min(5.0e-2, 2013 2014 if (model->getNumCols()<500) 281 fabs(model->getMinimizationObjValue())*1.0e-3+1.0e-4)); 282 if (model->getNumCols()<500) { 2015 283 model->setMaximumCutPassesAtRoot(-100); // always do 100 if possible 2016 else if (model->getNumCols()<5000)284 } else if (model->getNumCols()<5000) { 2017 285 model->setMaximumCutPassesAtRoot(100); // use minimum drop 2018 else286 } else { 2019 287 model->setMaximumCutPassesAtRoot(20); 288 } 2020 289 // If defaults then increase trust for small models 2021 290 if (model->numberStrong()==5&&model->numberBeforeTrust()==10) { 2022 291 int numberColumns = model->getNumCols(); 2023 if (numberColumns<=50) 292 if (numberColumns<=50) { 2024 293 model->setNumberBeforeTrust(1000); 2025 else if (numberColumns<=100)294 } else if (numberColumns<=100) { 2026 295 model->setNumberBeforeTrust(100); 2027 else if (numberColumns<=300)296 } else if (numberColumns<=300) { 2028 297 model->setNumberBeforeTrust(50); 298 } 2029 299 } 2030 300 model->branchAndBound(); … … 2050 320 CoinRelFltEq eq(1.0e-3) ; 2051 321 if (eq(soln,objValue[m])) { 2052 std::c err322 std::cout 2053 323 <<"cbc_clp"<<" " 2054 324 << soln << " = " << objValue[m] << " ; okay"; 2055 325 numProbSolved++; 2056 326 } else { 2057 std::c err <<"cbc_clp" <<" " <<soln << " != " <<objValue[m] << "; error=" ;2058 std::cerr <<fabs(objValue[m] - soln);327 std::cout <<"cbc_clp" <<" " <<soln << " != " <<objValue[m] 328 << "; error=" << fabs(objValue[m] - soln); 2059 329 } 2060 330 } else { 2061 std::c err<< "error; too many nodes" ;2062 } 2063 std::c err<<" - took " <<timeOfSolution<<" seconds."<<std::endl;331 std::cout << "error; too many nodes" ; 332 } 333 std::cout<<" - took " <<timeOfSolution<<" seconds.\n"; 2064 334 timeTaken += timeOfSolution; 2065 335 delete model; 2066 336 } 2067 std::c err337 std::cout 2068 338 <<"cbc_clp" 2069 339 <<" solved " -
trunk/Cbc/test/Makefile.am
r640 r765 27 27 28 28 test_cbc: ../src/cbc$(EXEEXT) 29 cd ../../Data/Netlib; make uncompress 30 cd ../../Data/miplib3; make uncompress 31 ../src/cbc$(EXEEXT) -unitTest -netlib -miplib 29 if test x"$(DIRMIPLIB)" != x; then \ 30 MIPLIBARG="-dirMiplib $(DIRMIPLIB) -miplib"; \ 31 fi; \ 32 if test x"$(DIRSAMPLE)" != x; then \ 33 SAMPLEARG="-dirSample $(DIRSAMPLE)"; \ 34 fi; \ 35 ../src/cbc$(EXEEXT) $$SAMPLEARG -unitTest $$MIPLIBARG 32 36 33 37 test_cbc_generic: ../src/cbc-generic$(EXEEXT) 34 38 echo "A minimal test is all that cbc-generic can manage just yet." 35 39 ../src/cbc-generic$(EXEEXT) \ 36 -directory ../../Data/ miplib3-import p0033 -branch40 -directory ../../Data/Sample -import p0033 -branch 37 41 38 42 .PHONY: test -
trunk/Cbc/test/Makefile.in
r710 r765 437 437 438 438 test_cbc: ../src/cbc$(EXEEXT) 439 cd ../../Data/Netlib; make uncompress 440 cd ../../Data/miplib3; make uncompress 441 ../src/cbc$(EXEEXT) -unitTest -netlib -miplib 439 if test x"$(DIRMIPLIB)" != x; then \ 440 MIPLIBARG="-dirMiplib $(DIRMIPLIB) -miplib"; \ 441 fi; \ 442 if test x"$(DIRSAMPLE)" != x; then \ 443 SAMPLEARG="-dirSample $(DIRSAMPLE)"; \ 444 fi; \ 445 ../src/cbc$(EXEEXT) $$SAMPLEARG -unitTest $$MIPLIBARG 442 446 443 447 test_cbc_generic: ../src/cbc-generic$(EXEEXT) 444 448 echo "A minimal test is all that cbc-generic can manage just yet." 445 449 ../src/cbc-generic$(EXEEXT) \ 446 -directory ../../Data/ miplib3-import p0033 -branch450 -directory ../../Data/Sample -import p0033 -branch 447 451 448 452 .PHONY: test
Note: See TracChangeset
for help on using the changeset viewer.