ruby-cbc 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/README.md +203 -0
  7. data/Rakefile +40 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/ext/ruby-cbc/cbc.i +15 -0
  11. data/ext/ruby-cbc/cbc_wrap.c +4618 -0
  12. data/ext/ruby-cbc/extconf.rb +60 -0
  13. data/ext/ruby-cbc/install/bin/cbc +0 -0
  14. data/ext/ruby-cbc/install/bin/clp +0 -0
  15. data/ext/ruby-cbc/install/include/coin/CbcBranchActual.hpp +24 -0
  16. data/ext/ruby-cbc/install/include/coin/CbcBranchAllDifferent.hpp +62 -0
  17. data/ext/ruby-cbc/install/include/coin/CbcBranchBase.hpp +78 -0
  18. data/ext/ruby-cbc/install/include/coin/CbcBranchCut.hpp +183 -0
  19. data/ext/ruby-cbc/install/include/coin/CbcBranchDecision.hpp +129 -0
  20. data/ext/ruby-cbc/install/include/coin/CbcBranchDefaultDecision.hpp +100 -0
  21. data/ext/ruby-cbc/install/include/coin/CbcBranchDynamic.hpp +206 -0
  22. data/ext/ruby-cbc/install/include/coin/CbcBranchLotsize.hpp +242 -0
  23. data/ext/ruby-cbc/install/include/coin/CbcBranchToFixLots.hpp +94 -0
  24. data/ext/ruby-cbc/install/include/coin/CbcBranchingObject.hpp +236 -0
  25. data/ext/ruby-cbc/install/include/coin/CbcClique.hpp +303 -0
  26. data/ext/ruby-cbc/install/include/coin/CbcCompare.hpp +39 -0
  27. data/ext/ruby-cbc/install/include/coin/CbcCompareActual.hpp +14 -0
  28. data/ext/ruby-cbc/install/include/coin/CbcCompareBase.hpp +142 -0
  29. data/ext/ruby-cbc/install/include/coin/CbcCompareDefault.hpp +120 -0
  30. data/ext/ruby-cbc/install/include/coin/CbcCompareDepth.hpp +47 -0
  31. data/ext/ruby-cbc/install/include/coin/CbcCompareEstimate.hpp +48 -0
  32. data/ext/ruby-cbc/install/include/coin/CbcCompareObjective.hpp +49 -0
  33. data/ext/ruby-cbc/install/include/coin/CbcConfig.h +14 -0
  34. data/ext/ruby-cbc/install/include/coin/CbcConsequence.hpp +49 -0
  35. data/ext/ruby-cbc/install/include/coin/CbcCountRowCut.hpp +168 -0
  36. data/ext/ruby-cbc/install/include/coin/CbcCutGenerator.hpp +482 -0
  37. data/ext/ruby-cbc/install/include/coin/CbcCutModifier.hpp +57 -0
  38. data/ext/ruby-cbc/install/include/coin/CbcCutSubsetModifier.hpp +66 -0
  39. data/ext/ruby-cbc/install/include/coin/CbcDummyBranchingObject.hpp +83 -0
  40. data/ext/ruby-cbc/install/include/coin/CbcEventHandler.hpp +245 -0
  41. data/ext/ruby-cbc/install/include/coin/CbcFathom.hpp +137 -0
  42. data/ext/ruby-cbc/install/include/coin/CbcFathomDynamicProgramming.hpp +169 -0
  43. data/ext/ruby-cbc/install/include/coin/CbcFeasibilityBase.hpp +56 -0
  44. data/ext/ruby-cbc/install/include/coin/CbcFixVariable.hpp +67 -0
  45. data/ext/ruby-cbc/install/include/coin/CbcFollowOn.hpp +207 -0
  46. data/ext/ruby-cbc/install/include/coin/CbcFullNodeInfo.hpp +161 -0
  47. data/ext/ruby-cbc/install/include/coin/CbcGeneral.hpp +60 -0
  48. data/ext/ruby-cbc/install/include/coin/CbcGeneralDepth.hpp +279 -0
  49. data/ext/ruby-cbc/install/include/coin/CbcHeuristic.hpp +682 -0
  50. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDINS.hpp +96 -0
  51. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDW.hpp +309 -0
  52. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDive.hpp +192 -0
  53. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveCoefficient.hpp +52 -0
  54. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveFractional.hpp +52 -0
  55. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveGuided.hpp +55 -0
  56. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveLineSearch.hpp +52 -0
  57. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDivePseudoCost.hpp +60 -0
  58. data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveVectorLength.hpp +52 -0
  59. data/ext/ruby-cbc/install/include/coin/CbcHeuristicFPump.hpp +340 -0
  60. data/ext/ruby-cbc/install/include/coin/CbcHeuristicGreedy.hpp +280 -0
  61. data/ext/ruby-cbc/install/include/coin/CbcHeuristicLocal.hpp +271 -0
  62. data/ext/ruby-cbc/install/include/coin/CbcHeuristicPivotAndFix.hpp +58 -0
  63. data/ext/ruby-cbc/install/include/coin/CbcHeuristicRENS.hpp +77 -0
  64. data/ext/ruby-cbc/install/include/coin/CbcHeuristicRINS.hpp +102 -0
  65. data/ext/ruby-cbc/install/include/coin/CbcHeuristicRandRound.hpp +58 -0
  66. data/ext/ruby-cbc/install/include/coin/CbcHeuristicVND.hpp +94 -0
  67. data/ext/ruby-cbc/install/include/coin/CbcLinked.hpp +1406 -0
  68. data/ext/ruby-cbc/install/include/coin/CbcMessage.hpp +94 -0
  69. data/ext/ruby-cbc/install/include/coin/CbcMipStartIO.hpp +26 -0
  70. data/ext/ruby-cbc/install/include/coin/CbcModel.hpp +2952 -0
  71. data/ext/ruby-cbc/install/include/coin/CbcNWay.hpp +166 -0
  72. data/ext/ruby-cbc/install/include/coin/CbcNode.hpp +351 -0
  73. data/ext/ruby-cbc/install/include/coin/CbcNodeInfo.hpp +349 -0
  74. data/ext/ruby-cbc/install/include/coin/CbcObject.hpp +272 -0
  75. data/ext/ruby-cbc/install/include/coin/CbcObjectUpdateData.hpp +64 -0
  76. data/ext/ruby-cbc/install/include/coin/CbcOrClpParam.cpp +4134 -0
  77. data/ext/ruby-cbc/install/include/coin/CbcOrClpParam.hpp +532 -0
  78. data/ext/ruby-cbc/install/include/coin/CbcParam.hpp +324 -0
  79. data/ext/ruby-cbc/install/include/coin/CbcPartialNodeInfo.hpp +110 -0
  80. data/ext/ruby-cbc/install/include/coin/CbcSOS.hpp +279 -0
  81. data/ext/ruby-cbc/install/include/coin/CbcSimpleInteger.hpp +286 -0
  82. data/ext/ruby-cbc/install/include/coin/CbcSimpleIntegerDynamicPseudoCost.hpp +564 -0
  83. data/ext/ruby-cbc/install/include/coin/CbcSimpleIntegerPseudoCost.hpp +114 -0
  84. data/ext/ruby-cbc/install/include/coin/CbcSolver.hpp +447 -0
  85. data/ext/ruby-cbc/install/include/coin/CbcStrategy.hpp +258 -0
  86. data/ext/ruby-cbc/install/include/coin/CbcSubProblem.hpp +83 -0
  87. data/ext/ruby-cbc/install/include/coin/CbcTree.hpp +490 -0
  88. data/ext/ruby-cbc/install/include/coin/CbcTreeLocal.hpp +372 -0
  89. data/ext/ruby-cbc/install/include/coin/Cbc_C_Interface.h +381 -0
  90. data/ext/ruby-cbc/install/include/coin/Cgl012cut.hpp +464 -0
  91. data/ext/ruby-cbc/install/include/coin/CglAllDifferent.hpp +115 -0
  92. data/ext/ruby-cbc/install/include/coin/CglClique.hpp +308 -0
  93. data/ext/ruby-cbc/install/include/coin/CglConfig.h +19 -0
  94. data/ext/ruby-cbc/install/include/coin/CglCutGenerator.hpp +121 -0
  95. data/ext/ruby-cbc/install/include/coin/CglDuplicateRow.hpp +189 -0
  96. data/ext/ruby-cbc/install/include/coin/CglFlowCover.hpp +371 -0
  97. data/ext/ruby-cbc/install/include/coin/CglGMI.hpp +364 -0
  98. data/ext/ruby-cbc/install/include/coin/CglGMIParam.hpp +313 -0
  99. data/ext/ruby-cbc/install/include/coin/CglGomory.hpp +204 -0
  100. data/ext/ruby-cbc/install/include/coin/CglKnapsackCover.hpp +310 -0
  101. data/ext/ruby-cbc/install/include/coin/CglLandP.hpp +306 -0
  102. data/ext/ruby-cbc/install/include/coin/CglLandPValidator.hpp +130 -0
  103. data/ext/ruby-cbc/install/include/coin/CglLiftAndProject.hpp +104 -0
  104. data/ext/ruby-cbc/install/include/coin/CglMessage.hpp +50 -0
  105. data/ext/ruby-cbc/install/include/coin/CglMixedIntegerRounding.hpp +429 -0
  106. data/ext/ruby-cbc/install/include/coin/CglMixedIntegerRounding2.hpp +427 -0
  107. data/ext/ruby-cbc/install/include/coin/CglOddHole.hpp +160 -0
  108. data/ext/ruby-cbc/install/include/coin/CglParam.hpp +93 -0
  109. data/ext/ruby-cbc/install/include/coin/CglPreProcess.hpp +492 -0
  110. data/ext/ruby-cbc/install/include/coin/CglProbing.hpp +543 -0
  111. data/ext/ruby-cbc/install/include/coin/CglRedSplit.hpp +448 -0
  112. data/ext/ruby-cbc/install/include/coin/CglRedSplit2.hpp +494 -0
  113. data/ext/ruby-cbc/install/include/coin/CglRedSplit2Param.hpp +495 -0
  114. data/ext/ruby-cbc/install/include/coin/CglRedSplitParam.hpp +272 -0
  115. data/ext/ruby-cbc/install/include/coin/CglResidualCapacity.hpp +240 -0
  116. data/ext/ruby-cbc/install/include/coin/CglSimpleRounding.hpp +174 -0
  117. data/ext/ruby-cbc/install/include/coin/CglStored.hpp +125 -0
  118. data/ext/ruby-cbc/install/include/coin/CglTreeInfo.hpp +180 -0
  119. data/ext/ruby-cbc/install/include/coin/CglTwomir.hpp +565 -0
  120. data/ext/ruby-cbc/install/include/coin/CglZeroHalf.hpp +133 -0
  121. data/ext/ruby-cbc/install/include/coin/ClpAmplObjective.hpp +113 -0
  122. data/ext/ruby-cbc/install/include/coin/ClpCholeskyBase.hpp +294 -0
  123. data/ext/ruby-cbc/install/include/coin/ClpCholeskyDense.hpp +162 -0
  124. data/ext/ruby-cbc/install/include/coin/ClpConfig.h +17 -0
  125. data/ext/ruby-cbc/install/include/coin/ClpConstraint.hpp +125 -0
  126. data/ext/ruby-cbc/install/include/coin/ClpConstraintAmpl.hpp +108 -0
  127. data/ext/ruby-cbc/install/include/coin/ClpConstraintLinear.hpp +110 -0
  128. data/ext/ruby-cbc/install/include/coin/ClpConstraintQuadratic.hpp +119 -0
  129. data/ext/ruby-cbc/install/include/coin/ClpDualRowDantzig.hpp +71 -0
  130. data/ext/ruby-cbc/install/include/coin/ClpDualRowPivot.hpp +129 -0
  131. data/ext/ruby-cbc/install/include/coin/ClpDualRowSteepest.hpp +153 -0
  132. data/ext/ruby-cbc/install/include/coin/ClpDummyMatrix.hpp +183 -0
  133. data/ext/ruby-cbc/install/include/coin/ClpDynamicExampleMatrix.hpp +186 -0
  134. data/ext/ruby-cbc/install/include/coin/ClpDynamicMatrix.hpp +381 -0
  135. data/ext/ruby-cbc/install/include/coin/ClpEventHandler.hpp +187 -0
  136. data/ext/ruby-cbc/install/include/coin/ClpFactorization.hpp +432 -0
  137. data/ext/ruby-cbc/install/include/coin/ClpGubDynamicMatrix.hpp +247 -0
  138. data/ext/ruby-cbc/install/include/coin/ClpGubMatrix.hpp +358 -0
  139. data/ext/ruby-cbc/install/include/coin/ClpInterior.hpp +570 -0
  140. data/ext/ruby-cbc/install/include/coin/ClpLinearObjective.hpp +103 -0
  141. data/ext/ruby-cbc/install/include/coin/ClpMatrixBase.hpp +524 -0
  142. data/ext/ruby-cbc/install/include/coin/ClpMessage.hpp +131 -0
  143. data/ext/ruby-cbc/install/include/coin/ClpModel.hpp +1307 -0
  144. data/ext/ruby-cbc/install/include/coin/ClpNetworkMatrix.hpp +229 -0
  145. data/ext/ruby-cbc/install/include/coin/ClpNode.hpp +349 -0
  146. data/ext/ruby-cbc/install/include/coin/ClpNonLinearCost.hpp +401 -0
  147. data/ext/ruby-cbc/install/include/coin/ClpObjective.hpp +134 -0
  148. data/ext/ruby-cbc/install/include/coin/ClpPackedMatrix.hpp +638 -0
  149. data/ext/ruby-cbc/install/include/coin/ClpParameters.hpp +126 -0
  150. data/ext/ruby-cbc/install/include/coin/ClpPdcoBase.hpp +103 -0
  151. data/ext/ruby-cbc/install/include/coin/ClpPlusMinusOneMatrix.hpp +290 -0
  152. data/ext/ruby-cbc/install/include/coin/ClpPresolve.hpp +299 -0
  153. data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnDantzig.hpp +72 -0
  154. data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnPivot.hpp +155 -0
  155. data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnSteepest.hpp +247 -0
  156. data/ext/ruby-cbc/install/include/coin/ClpQuadraticObjective.hpp +155 -0
  157. data/ext/ruby-cbc/install/include/coin/ClpSimplex.hpp +1797 -0
  158. data/ext/ruby-cbc/install/include/coin/ClpSimplexDual.hpp +300 -0
  159. data/ext/ruby-cbc/install/include/coin/ClpSimplexNonlinear.hpp +117 -0
  160. data/ext/ruby-cbc/install/include/coin/ClpSimplexOther.hpp +277 -0
  161. data/ext/ruby-cbc/install/include/coin/ClpSimplexPrimal.hpp +244 -0
  162. data/ext/ruby-cbc/install/include/coin/ClpSolve.hpp +446 -0
  163. data/ext/ruby-cbc/install/include/coin/Clp_C_Interface.h +525 -0
  164. data/ext/ruby-cbc/install/include/coin/CoinAlloc.hpp +176 -0
  165. data/ext/ruby-cbc/install/include/coin/CoinBuild.hpp +149 -0
  166. data/ext/ruby-cbc/install/include/coin/CoinDenseFactorization.hpp +419 -0
  167. data/ext/ruby-cbc/install/include/coin/CoinDenseVector.hpp +383 -0
  168. data/ext/ruby-cbc/install/include/coin/CoinDistance.hpp +48 -0
  169. data/ext/ruby-cbc/install/include/coin/CoinError.hpp +257 -0
  170. data/ext/ruby-cbc/install/include/coin/CoinFactorization.hpp +2044 -0
  171. data/ext/ruby-cbc/install/include/coin/CoinFileIO.hpp +166 -0
  172. data/ext/ruby-cbc/install/include/coin/CoinFinite.hpp +34 -0
  173. data/ext/ruby-cbc/install/include/coin/CoinFloatEqual.hpp +177 -0
  174. data/ext/ruby-cbc/install/include/coin/CoinHelperFunctions.hpp +1111 -0
  175. data/ext/ruby-cbc/install/include/coin/CoinIndexedVector.hpp +1164 -0
  176. data/ext/ruby-cbc/install/include/coin/CoinLpIO.hpp +805 -0
  177. data/ext/ruby-cbc/install/include/coin/CoinMessage.hpp +96 -0
  178. data/ext/ruby-cbc/install/include/coin/CoinMessageHandler.hpp +666 -0
  179. data/ext/ruby-cbc/install/include/coin/CoinModel.hpp +1054 -0
  180. data/ext/ruby-cbc/install/include/coin/CoinModelUseful.hpp +441 -0
  181. data/ext/ruby-cbc/install/include/coin/CoinMpsIO.hpp +1056 -0
  182. data/ext/ruby-cbc/install/include/coin/CoinOslFactorization.hpp +280 -0
  183. data/ext/ruby-cbc/install/include/coin/CoinPackedMatrix.hpp +947 -0
  184. data/ext/ruby-cbc/install/include/coin/CoinPackedVector.hpp +657 -0
  185. data/ext/ruby-cbc/install/include/coin/CoinPackedVectorBase.hpp +269 -0
  186. data/ext/ruby-cbc/install/include/coin/CoinParam.hpp +644 -0
  187. data/ext/ruby-cbc/install/include/coin/CoinPragma.hpp +26 -0
  188. data/ext/ruby-cbc/install/include/coin/CoinPresolveDoubleton.hpp +73 -0
  189. data/ext/ruby-cbc/install/include/coin/CoinPresolveDual.hpp +85 -0
  190. data/ext/ruby-cbc/install/include/coin/CoinPresolveDupcol.hpp +226 -0
  191. data/ext/ruby-cbc/install/include/coin/CoinPresolveEmpty.hpp +116 -0
  192. data/ext/ruby-cbc/install/include/coin/CoinPresolveFixed.hpp +181 -0
  193. data/ext/ruby-cbc/install/include/coin/CoinPresolveForcing.hpp +61 -0
  194. data/ext/ruby-cbc/install/include/coin/CoinPresolveImpliedFree.hpp +60 -0
  195. data/ext/ruby-cbc/install/include/coin/CoinPresolveIsolated.hpp +51 -0
  196. data/ext/ruby-cbc/install/include/coin/CoinPresolveMatrix.hpp +1842 -0
  197. data/ext/ruby-cbc/install/include/coin/CoinPresolveMonitor.hpp +105 -0
  198. data/ext/ruby-cbc/install/include/coin/CoinPresolvePsdebug.hpp +166 -0
  199. data/ext/ruby-cbc/install/include/coin/CoinPresolveSingleton.hpp +112 -0
  200. data/ext/ruby-cbc/install/include/coin/CoinPresolveSubst.hpp +101 -0
  201. data/ext/ruby-cbc/install/include/coin/CoinPresolveTighten.hpp +55 -0
  202. data/ext/ruby-cbc/install/include/coin/CoinPresolveTripleton.hpp +66 -0
  203. data/ext/ruby-cbc/install/include/coin/CoinPresolveUseless.hpp +63 -0
  204. data/ext/ruby-cbc/install/include/coin/CoinPresolveZeros.hpp +60 -0
  205. data/ext/ruby-cbc/install/include/coin/CoinRational.hpp +44 -0
  206. data/ext/ruby-cbc/install/include/coin/CoinSearchTree.hpp +465 -0
  207. data/ext/ruby-cbc/install/include/coin/CoinShallowPackedVector.hpp +148 -0
  208. data/ext/ruby-cbc/install/include/coin/CoinSignal.hpp +117 -0
  209. data/ext/ruby-cbc/install/include/coin/CoinSimpFactorization.hpp +431 -0
  210. data/ext/ruby-cbc/install/include/coin/CoinSmartPtr.hpp +528 -0
  211. data/ext/ruby-cbc/install/include/coin/CoinSnapshot.hpp +476 -0
  212. data/ext/ruby-cbc/install/include/coin/CoinSort.hpp +678 -0
  213. data/ext/ruby-cbc/install/include/coin/CoinStructuredModel.hpp +247 -0
  214. data/ext/ruby-cbc/install/include/coin/CoinTime.hpp +310 -0
  215. data/ext/ruby-cbc/install/include/coin/CoinTypes.hpp +64 -0
  216. data/ext/ruby-cbc/install/include/coin/CoinUtility.hpp +19 -0
  217. data/ext/ruby-cbc/install/include/coin/CoinUtilsConfig.h +34 -0
  218. data/ext/ruby-cbc/install/include/coin/CoinWarmStart.hpp +58 -0
  219. data/ext/ruby-cbc/install/include/coin/CoinWarmStartBasis.hpp +456 -0
  220. data/ext/ruby-cbc/install/include/coin/CoinWarmStartDual.hpp +166 -0
  221. data/ext/ruby-cbc/install/include/coin/CoinWarmStartPrimalDual.hpp +211 -0
  222. data/ext/ruby-cbc/install/include/coin/CoinWarmStartVector.hpp +488 -0
  223. data/ext/ruby-cbc/install/include/coin/Coin_C_defines.h +115 -0
  224. data/ext/ruby-cbc/install/include/coin/Idiot.hpp +298 -0
  225. data/ext/ruby-cbc/install/include/coin/OsiAuxInfo.hpp +206 -0
  226. data/ext/ruby-cbc/install/include/coin/OsiBranchingObject.hpp +1005 -0
  227. data/ext/ruby-cbc/install/include/coin/OsiCbcSolverInterface.hpp +764 -0
  228. data/ext/ruby-cbc/install/include/coin/OsiChooseVariable.hpp +534 -0
  229. data/ext/ruby-cbc/install/include/coin/OsiClpSolverInterface.hpp +1509 -0
  230. data/ext/ruby-cbc/install/include/coin/OsiColCut.hpp +324 -0
  231. data/ext/ruby-cbc/install/include/coin/OsiCollections.hpp +35 -0
  232. data/ext/ruby-cbc/install/include/coin/OsiConfig.h +19 -0
  233. data/ext/ruby-cbc/install/include/coin/OsiCut.hpp +245 -0
  234. data/ext/ruby-cbc/install/include/coin/OsiCuts.hpp +474 -0
  235. data/ext/ruby-cbc/install/include/coin/OsiPresolve.hpp +252 -0
  236. data/ext/ruby-cbc/install/include/coin/OsiRowCut.hpp +331 -0
  237. data/ext/ruby-cbc/install/include/coin/OsiRowCutDebugger.hpp +187 -0
  238. data/ext/ruby-cbc/install/include/coin/OsiSolverBranch.hpp +152 -0
  239. data/ext/ruby-cbc/install/include/coin/OsiSolverInterface.hpp +2143 -0
  240. data/ext/ruby-cbc/install/include/coin/OsiSolverParameters.hpp +142 -0
  241. data/ext/ruby-cbc/install/include/coin/OsiUnitTests.hpp +374 -0
  242. data/ext/ruby-cbc/install/lib/libCbc.la +35 -0
  243. data/ext/ruby-cbc/install/lib/libCbc.so +0 -0
  244. data/ext/ruby-cbc/install/lib/libCbc.so.3 +0 -0
  245. data/ext/ruby-cbc/install/lib/libCbc.so.3.9.7 +0 -0
  246. data/ext/ruby-cbc/install/lib/libCbcSolver.la +35 -0
  247. data/ext/ruby-cbc/install/lib/libCbcSolver.so +0 -0
  248. data/ext/ruby-cbc/install/lib/libCbcSolver.so.3 +0 -0
  249. data/ext/ruby-cbc/install/lib/libCbcSolver.so.3.9.7 +0 -0
  250. data/ext/ruby-cbc/install/lib/libCgl.la +35 -0
  251. data/ext/ruby-cbc/install/lib/libCgl.so +0 -0
  252. data/ext/ruby-cbc/install/lib/libCgl.so.1 +0 -0
  253. data/ext/ruby-cbc/install/lib/libCgl.so.1.9.7 +0 -0
  254. data/ext/ruby-cbc/install/lib/libClp.la +35 -0
  255. data/ext/ruby-cbc/install/lib/libClp.so +0 -0
  256. data/ext/ruby-cbc/install/lib/libClp.so.1 +0 -0
  257. data/ext/ruby-cbc/install/lib/libClp.so.1.13.9 +0 -0
  258. data/ext/ruby-cbc/install/lib/libClpSolver.la +35 -0
  259. data/ext/ruby-cbc/install/lib/libClpSolver.so +0 -0
  260. data/ext/ruby-cbc/install/lib/libClpSolver.so.1 +0 -0
  261. data/ext/ruby-cbc/install/lib/libClpSolver.so.1.13.9 +0 -0
  262. data/ext/ruby-cbc/install/lib/libCoinUtils.la +35 -0
  263. data/ext/ruby-cbc/install/lib/libCoinUtils.so +0 -0
  264. data/ext/ruby-cbc/install/lib/libCoinUtils.so.3 +0 -0
  265. data/ext/ruby-cbc/install/lib/libCoinUtils.so.3.10.11 +0 -0
  266. data/ext/ruby-cbc/install/lib/libOsi.la +35 -0
  267. data/ext/ruby-cbc/install/lib/libOsi.so +0 -0
  268. data/ext/ruby-cbc/install/lib/libOsi.so.1 +0 -0
  269. data/ext/ruby-cbc/install/lib/libOsi.so.1.12.6 +0 -0
  270. data/ext/ruby-cbc/install/lib/libOsiCbc.la +35 -0
  271. data/ext/ruby-cbc/install/lib/libOsiCbc.so +0 -0
  272. data/ext/ruby-cbc/install/lib/libOsiCbc.so.3 +0 -0
  273. data/ext/ruby-cbc/install/lib/libOsiCbc.so.3.9.7 +0 -0
  274. data/ext/ruby-cbc/install/lib/libOsiClp.la +35 -0
  275. data/ext/ruby-cbc/install/lib/libOsiClp.so +0 -0
  276. data/ext/ruby-cbc/install/lib/libOsiClp.so.1 +0 -0
  277. data/ext/ruby-cbc/install/lib/libOsiClp.so.1.13.9 +0 -0
  278. data/ext/ruby-cbc/install/lib/libOsiCommonTests.la +35 -0
  279. data/ext/ruby-cbc/install/lib/libOsiCommonTests.so +0 -0
  280. data/ext/ruby-cbc/install/lib/libOsiCommonTests.so.1 +0 -0
  281. data/ext/ruby-cbc/install/lib/libOsiCommonTests.so.1.12.6 +0 -0
  282. data/ext/ruby-cbc/install/lib/pkgconfig/cbc.pc +12 -0
  283. data/ext/ruby-cbc/install/lib/pkgconfig/cgl.pc +12 -0
  284. data/ext/ruby-cbc/install/lib/pkgconfig/clp.pc +12 -0
  285. data/ext/ruby-cbc/install/lib/pkgconfig/coindatamiplib3.pc +9 -0
  286. data/ext/ruby-cbc/install/lib/pkgconfig/coindatasample.pc +9 -0
  287. data/ext/ruby-cbc/install/lib/pkgconfig/coinutils.pc +12 -0
  288. data/ext/ruby-cbc/install/lib/pkgconfig/osi-cbc.pc +12 -0
  289. data/ext/ruby-cbc/install/lib/pkgconfig/osi-clp.pc +12 -0
  290. data/ext/ruby-cbc/install/lib/pkgconfig/osi-unittests.pc +12 -0
  291. data/ext/ruby-cbc/install/lib/pkgconfig/osi.pc +12 -0
  292. data/lib/ruby-cbc/ilp/constant.rb +44 -0
  293. data/lib/ruby-cbc/ilp/constraint.rb +32 -0
  294. data/lib/ruby-cbc/ilp/objective.rb +26 -0
  295. data/lib/ruby-cbc/ilp/term.rb +47 -0
  296. data/lib/ruby-cbc/ilp/term_array.rb +80 -0
  297. data/lib/ruby-cbc/ilp/var.rb +62 -0
  298. data/lib/ruby-cbc/model.rb +125 -0
  299. data/lib/ruby-cbc/problem.rb +170 -0
  300. data/lib/ruby-cbc/version.rb +3 -0
  301. data/lib/ruby-cbc.rb +21 -0
  302. data/ruby-cbc.gemspec +36 -0
  303. metadata +431 -0
@@ -0,0 +1,1111 @@
1
+ /* $Id: CoinHelperFunctions.hpp 1679 2013-12-05 11:27:45Z forrest $ */
2
+ // Copyright (C) 2000, International Business Machines
3
+ // Corporation and others. All Rights Reserved.
4
+ // This code is licensed under the terms of the Eclipse Public License (EPL).
5
+
6
+ #ifndef CoinHelperFunctions_H
7
+ #define CoinHelperFunctions_H
8
+
9
+ #include "CoinUtilsConfig.h"
10
+
11
+ #if defined(_MSC_VER)
12
+ # include <direct.h>
13
+ # include <cctype>
14
+ # define getcwd _getcwd
15
+ # include <cctype>
16
+ #else
17
+ # include <unistd.h>
18
+ #endif
19
+ //#define USE_MEMCPY
20
+
21
+ #include <cstdlib>
22
+ #include <cstdio>
23
+ #include <algorithm>
24
+ #include "CoinTypes.hpp"
25
+ #include "CoinError.hpp"
26
+
27
+ // Compilers can produce better code if they know about __restrict
28
+ #ifndef COIN_RESTRICT
29
+ #ifdef COIN_USE_RESTRICT
30
+ #define COIN_RESTRICT __restrict
31
+ #else
32
+ #define COIN_RESTRICT
33
+ #endif
34
+ #endif
35
+
36
+ //#############################################################################
37
+
38
+ /** This helper function copies an array to another location using Duff's
39
+ device (for a speedup of ~2). The arrays are given by pointers to their
40
+ first entries and by the size of the source array. Overlapping arrays are
41
+ handled correctly. */
42
+
43
+ template <class T> inline void
44
+ CoinCopyN(register const T* from, const int size, register T* to)
45
+ {
46
+ if (size == 0 || from == to)
47
+ return;
48
+
49
+ #ifndef NDEBUG
50
+ if (size < 0)
51
+ throw CoinError("trying to copy negative number of entries",
52
+ "CoinCopyN", "");
53
+ #endif
54
+
55
+ register int n = (size + 7) / 8;
56
+ if (to > from) {
57
+ register const T* downfrom = from + size;
58
+ register T* downto = to + size;
59
+ // Use Duff's device to copy
60
+ switch (size % 8) {
61
+ case 0: do{ *--downto = *--downfrom;
62
+ case 7: *--downto = *--downfrom;
63
+ case 6: *--downto = *--downfrom;
64
+ case 5: *--downto = *--downfrom;
65
+ case 4: *--downto = *--downfrom;
66
+ case 3: *--downto = *--downfrom;
67
+ case 2: *--downto = *--downfrom;
68
+ case 1: *--downto = *--downfrom;
69
+ }while(--n>0);
70
+ }
71
+ } else {
72
+ // Use Duff's device to copy
73
+ --from;
74
+ --to;
75
+ switch (size % 8) {
76
+ case 0: do{ *++to = *++from;
77
+ case 7: *++to = *++from;
78
+ case 6: *++to = *++from;
79
+ case 5: *++to = *++from;
80
+ case 4: *++to = *++from;
81
+ case 3: *++to = *++from;
82
+ case 2: *++to = *++from;
83
+ case 1: *++to = *++from;
84
+ }while(--n>0);
85
+ }
86
+ }
87
+ }
88
+
89
+ //-----------------------------------------------------------------------------
90
+
91
+ /** This helper function copies an array to another location using Duff's
92
+ device (for a speedup of ~2). The source array is given by its first and
93
+ "after last" entry; the target array is given by its first entry.
94
+ Overlapping arrays are handled correctly.
95
+
96
+ All of the various CoinCopyN variants use an int for size. On 64-bit
97
+ architectures, the address diff last-first will be a 64-bit quantity.
98
+ Given that everything else uses an int, I'm going to choose to kick
99
+ the difference down to int. -- lh, 100823 --
100
+ */
101
+ template <class T> inline void
102
+ CoinCopy(register const T* first, register const T* last, register T* to)
103
+ {
104
+ CoinCopyN(first, static_cast<int>(last-first), to);
105
+ }
106
+
107
+ //-----------------------------------------------------------------------------
108
+
109
+ /** This helper function copies an array to another location. The two arrays
110
+ must not overlap (otherwise an exception is thrown). For speed 8 entries
111
+ are copied at a time. The arrays are given by pointers to their first
112
+ entries and by the size of the source array.
113
+
114
+ Note JJF - the speed claim seems to be false on IA32 so I have added
115
+ CoinMemcpyN which can be used for atomic data */
116
+ template <class T> inline void
117
+ CoinDisjointCopyN(register const T* from, const int size, register T* to)
118
+ {
119
+ #ifndef _MSC_VER
120
+ if (size == 0 || from == to)
121
+ return;
122
+
123
+ #ifndef NDEBUG
124
+ if (size < 0)
125
+ throw CoinError("trying to copy negative number of entries",
126
+ "CoinDisjointCopyN", "");
127
+ #endif
128
+
129
+ #if 0
130
+ /* There is no point to do this test. If to and from are from different
131
+ blocks then dist is undefined, so this can crash correct code. It's
132
+ better to trust the user that the arrays are really disjoint. */
133
+ const long dist = to - from;
134
+ if (-size < dist && dist < size)
135
+ throw CoinError("overlapping arrays", "CoinDisjointCopyN", "");
136
+ #endif
137
+
138
+ for (register int n = size / 8; n > 0; --n, from += 8, to += 8) {
139
+ to[0] = from[0];
140
+ to[1] = from[1];
141
+ to[2] = from[2];
142
+ to[3] = from[3];
143
+ to[4] = from[4];
144
+ to[5] = from[5];
145
+ to[6] = from[6];
146
+ to[7] = from[7];
147
+ }
148
+ switch (size % 8) {
149
+ case 7: to[6] = from[6];
150
+ case 6: to[5] = from[5];
151
+ case 5: to[4] = from[4];
152
+ case 4: to[3] = from[3];
153
+ case 3: to[2] = from[2];
154
+ case 2: to[1] = from[1];
155
+ case 1: to[0] = from[0];
156
+ case 0: break;
157
+ }
158
+ #else
159
+ CoinCopyN(from, size, to);
160
+ #endif
161
+ }
162
+
163
+ //-----------------------------------------------------------------------------
164
+
165
+ /** This helper function copies an array to another location. The two arrays
166
+ must not overlap (otherwise an exception is thrown). For speed 8 entries
167
+ are copied at a time. The source array is given by its first and "after
168
+ last" entry; the target array is given by its first entry. */
169
+ template <class T> inline void
170
+ CoinDisjointCopy(register const T* first, register const T* last,
171
+ register T* to)
172
+ {
173
+ CoinDisjointCopyN(first, static_cast<int>(last - first), to);
174
+ }
175
+
176
+ //-----------------------------------------------------------------------------
177
+
178
+ /*! \brief Return an array of length \p size filled with input from \p array,
179
+ or null if \p array is null.
180
+ */
181
+
182
+ template <class T> inline T*
183
+ CoinCopyOfArray( const T * array, const int size)
184
+ {
185
+ if (array) {
186
+ T * arrayNew = new T[size];
187
+ std::memcpy(arrayNew,array,size*sizeof(T));
188
+ return arrayNew;
189
+ } else {
190
+ return NULL;
191
+ }
192
+ }
193
+
194
+
195
+ /*! \brief Return an array of length \p size filled with first copySize from \p array,
196
+ or null if \p array is null.
197
+ */
198
+
199
+ template <class T> inline T*
200
+ CoinCopyOfArrayPartial( const T * array, const int size,const int copySize)
201
+ {
202
+ if (array||size) {
203
+ T * arrayNew = new T[size];
204
+ assert (copySize<=size);
205
+ std::memcpy(arrayNew,array,copySize*sizeof(T));
206
+ return arrayNew;
207
+ } else {
208
+ return NULL;
209
+ }
210
+ }
211
+
212
+ /*! \brief Return an array of length \p size filled with input from \p array,
213
+ or filled with (scalar) \p value if \p array is null
214
+ */
215
+
216
+ template <class T> inline T*
217
+ CoinCopyOfArray( const T * array, const int size, T value)
218
+ {
219
+ T * arrayNew = new T[size];
220
+ if (array) {
221
+ std::memcpy(arrayNew,array,size*sizeof(T));
222
+ } else {
223
+ int i;
224
+ for (i=0;i<size;i++)
225
+ arrayNew[i] = value;
226
+ }
227
+ return arrayNew;
228
+ }
229
+
230
+
231
+ /*! \brief Return an array of length \p size filled with input from \p array,
232
+ or filled with zero if \p array is null
233
+ */
234
+
235
+ template <class T> inline T*
236
+ CoinCopyOfArrayOrZero( const T * array , const int size)
237
+ {
238
+ T * arrayNew = new T[size];
239
+ if (array) {
240
+ std::memcpy(arrayNew,array,size*sizeof(T));
241
+ } else {
242
+ std::memset(arrayNew,0,size*sizeof(T));
243
+ }
244
+ return arrayNew;
245
+ }
246
+
247
+
248
+ //-----------------------------------------------------------------------------
249
+
250
+ /** This helper function copies an array to another location. The two arrays
251
+ must not overlap (otherwise an exception is thrown). For speed 8 entries
252
+ are copied at a time. The arrays are given by pointers to their first
253
+ entries and by the size of the source array.
254
+
255
+ Note JJF - the speed claim seems to be false on IA32 so I have added
256
+ alternative coding if USE_MEMCPY defined*/
257
+ #ifndef COIN_USE_RESTRICT
258
+ template <class T> inline void
259
+ CoinMemcpyN(register const T* from, const int size, register T* to)
260
+ {
261
+ #ifndef _MSC_VER
262
+ #ifdef USE_MEMCPY
263
+ // Use memcpy - seems a lot faster on Intel with gcc
264
+ #ifndef NDEBUG
265
+ // Some debug so check
266
+ if (size < 0)
267
+ throw CoinError("trying to copy negative number of entries",
268
+ "CoinMemcpyN", "");
269
+
270
+ #if 0
271
+ /* There is no point to do this test. If to and from are from different
272
+ blocks then dist is undefined, so this can crash correct code. It's
273
+ better to trust the user that the arrays are really disjoint. */
274
+ const long dist = to - from;
275
+ if (-size < dist && dist < size)
276
+ throw CoinError("overlapping arrays", "CoinMemcpyN", "");
277
+ #endif
278
+ #endif
279
+ std::memcpy(to,from,size*sizeof(T));
280
+ #else
281
+ if (size == 0 || from == to)
282
+ return;
283
+
284
+ #ifndef NDEBUG
285
+ if (size < 0)
286
+ throw CoinError("trying to copy negative number of entries",
287
+ "CoinMemcpyN", "");
288
+ #endif
289
+
290
+ #if 0
291
+ /* There is no point to do this test. If to and from are from different
292
+ blocks then dist is undefined, so this can crash correct code. It's
293
+ better to trust the user that the arrays are really disjoint. */
294
+ const long dist = to - from;
295
+ if (-size < dist && dist < size)
296
+ throw CoinError("overlapping arrays", "CoinMemcpyN", "");
297
+ #endif
298
+
299
+ for (register int n = size / 8; n > 0; --n, from += 8, to += 8) {
300
+ to[0] = from[0];
301
+ to[1] = from[1];
302
+ to[2] = from[2];
303
+ to[3] = from[3];
304
+ to[4] = from[4];
305
+ to[5] = from[5];
306
+ to[6] = from[6];
307
+ to[7] = from[7];
308
+ }
309
+ switch (size % 8) {
310
+ case 7: to[6] = from[6];
311
+ case 6: to[5] = from[5];
312
+ case 5: to[4] = from[4];
313
+ case 4: to[3] = from[3];
314
+ case 3: to[2] = from[2];
315
+ case 2: to[1] = from[1];
316
+ case 1: to[0] = from[0];
317
+ case 0: break;
318
+ }
319
+ #endif
320
+ #else
321
+ CoinCopyN(from, size, to);
322
+ #endif
323
+ }
324
+ #else
325
+ template <class T> inline void
326
+ CoinMemcpyN(const T * COIN_RESTRICT from, int size, T* COIN_RESTRICT to)
327
+ {
328
+ #ifdef USE_MEMCPY
329
+ std::memcpy(to,from,size*sizeof(T));
330
+ #else
331
+ T * COIN_RESTRICT put = to;
332
+ const T * COIN_RESTRICT get = from;
333
+ for ( ; 0<size ; --size)
334
+ *put++ = *get++;
335
+ #endif
336
+ }
337
+ #endif
338
+
339
+ //-----------------------------------------------------------------------------
340
+
341
+ /** This helper function copies an array to another location. The two arrays
342
+ must not overlap (otherwise an exception is thrown). For speed 8 entries
343
+ are copied at a time. The source array is given by its first and "after
344
+ last" entry; the target array is given by its first entry. */
345
+ template <class T> inline void
346
+ CoinMemcpy(register const T* first, register const T* last,
347
+ register T* to)
348
+ {
349
+ CoinMemcpyN(first, static_cast<int>(last - first), to);
350
+ }
351
+
352
+ //#############################################################################
353
+
354
+ /** This helper function fills an array with a given value. For speed 8 entries
355
+ are filled at a time. The array is given by a pointer to its first entry
356
+ and its size.
357
+
358
+ Note JJF - the speed claim seems to be false on IA32 so I have added
359
+ CoinZero to allow for memset. */
360
+ template <class T> inline void
361
+ CoinFillN(register T* to, const int size, register const T value)
362
+ {
363
+ if (size == 0)
364
+ return;
365
+
366
+ #ifndef NDEBUG
367
+ if (size < 0)
368
+ throw CoinError("trying to fill negative number of entries",
369
+ "CoinFillN", "");
370
+ #endif
371
+ #if 1
372
+ for (register int n = size / 8; n > 0; --n, to += 8) {
373
+ to[0] = value;
374
+ to[1] = value;
375
+ to[2] = value;
376
+ to[3] = value;
377
+ to[4] = value;
378
+ to[5] = value;
379
+ to[6] = value;
380
+ to[7] = value;
381
+ }
382
+ switch (size % 8) {
383
+ case 7: to[6] = value;
384
+ case 6: to[5] = value;
385
+ case 5: to[4] = value;
386
+ case 4: to[3] = value;
387
+ case 3: to[2] = value;
388
+ case 2: to[1] = value;
389
+ case 1: to[0] = value;
390
+ case 0: break;
391
+ }
392
+ #else
393
+ // Use Duff's device to fill
394
+ register int n = (size + 7) / 8;
395
+ --to;
396
+ switch (size % 8) {
397
+ case 0: do{ *++to = value;
398
+ case 7: *++to = value;
399
+ case 6: *++to = value;
400
+ case 5: *++to = value;
401
+ case 4: *++to = value;
402
+ case 3: *++to = value;
403
+ case 2: *++to = value;
404
+ case 1: *++to = value;
405
+ }while(--n>0);
406
+ }
407
+ #endif
408
+ }
409
+
410
+ //-----------------------------------------------------------------------------
411
+
412
+ /** This helper function fills an array with a given value. For speed 8
413
+ entries are filled at a time. The array is given by its first and "after
414
+ last" entry. */
415
+ template <class T> inline void
416
+ CoinFill(register T* first, register T* last, const T value)
417
+ {
418
+ CoinFillN(first, last - first, value);
419
+ }
420
+
421
+ //#############################################################################
422
+
423
+ /** This helper function fills an array with zero. For speed 8 entries
424
+ are filled at a time. The array is given by a pointer to its first entry
425
+ and its size.
426
+
427
+ Note JJF - the speed claim seems to be false on IA32 so I have allowed
428
+ for memset as an alternative */
429
+ template <class T> inline void
430
+ CoinZeroN(register T* to, const int size)
431
+ {
432
+ #ifdef USE_MEMCPY
433
+ // Use memset - seems faster on Intel with gcc
434
+ #ifndef NDEBUG
435
+ // Some debug so check
436
+ if (size < 0)
437
+ throw CoinError("trying to fill negative number of entries",
438
+ "CoinZeroN", "");
439
+ #endif
440
+ memset(to,0,size*sizeof(T));
441
+ #else
442
+ if (size == 0)
443
+ return;
444
+
445
+ #ifndef NDEBUG
446
+ if (size < 0)
447
+ throw CoinError("trying to fill negative number of entries",
448
+ "CoinZeroN", "");
449
+ #endif
450
+ #if 1
451
+ for (register int n = size / 8; n > 0; --n, to += 8) {
452
+ to[0] = 0;
453
+ to[1] = 0;
454
+ to[2] = 0;
455
+ to[3] = 0;
456
+ to[4] = 0;
457
+ to[5] = 0;
458
+ to[6] = 0;
459
+ to[7] = 0;
460
+ }
461
+ switch (size % 8) {
462
+ case 7: to[6] = 0;
463
+ case 6: to[5] = 0;
464
+ case 5: to[4] = 0;
465
+ case 4: to[3] = 0;
466
+ case 3: to[2] = 0;
467
+ case 2: to[1] = 0;
468
+ case 1: to[0] = 0;
469
+ case 0: break;
470
+ }
471
+ #else
472
+ // Use Duff's device to fill
473
+ register int n = (size + 7) / 8;
474
+ --to;
475
+ switch (size % 8) {
476
+ case 0: do{ *++to = 0;
477
+ case 7: *++to = 0;
478
+ case 6: *++to = 0;
479
+ case 5: *++to = 0;
480
+ case 4: *++to = 0;
481
+ case 3: *++to = 0;
482
+ case 2: *++to = 0;
483
+ case 1: *++to = 0;
484
+ }while(--n>0);
485
+ }
486
+ #endif
487
+ #endif
488
+ }
489
+ /// This Debug helper function checks an array is all zero
490
+ inline void
491
+ CoinCheckDoubleZero(double * to, const int size)
492
+ {
493
+ int n=0;
494
+ for (int j=0;j<size;j++) {
495
+ if (to[j])
496
+ n++;
497
+ }
498
+ if (n) {
499
+ printf("array of length %d should be zero has %d nonzero\n",size,n);
500
+ }
501
+ }
502
+ /// This Debug helper function checks an array is all zero
503
+ inline void
504
+ CoinCheckIntZero(int * to, const int size)
505
+ {
506
+ int n=0;
507
+ for (int j=0;j<size;j++) {
508
+ if (to[j])
509
+ n++;
510
+ }
511
+ if (n) {
512
+ printf("array of length %d should be zero has %d nonzero\n",size,n);
513
+ }
514
+ }
515
+
516
+ //-----------------------------------------------------------------------------
517
+
518
+ /** This helper function fills an array with a given value. For speed 8
519
+ entries are filled at a time. The array is given by its first and "after
520
+ last" entry. */
521
+ template <class T> inline void
522
+ CoinZero(register T* first, register T* last)
523
+ {
524
+ CoinZeroN(first, last - first);
525
+ }
526
+
527
+ //#############################################################################
528
+
529
+ /** Returns strdup or NULL if original NULL */
530
+ inline char * CoinStrdup(const char * name)
531
+ {
532
+ char* dup = NULL;
533
+ if (name) {
534
+ const int len = static_cast<int>(strlen(name));
535
+ dup = static_cast<char*>(malloc(len+1));
536
+ CoinMemcpyN(name, len, dup);
537
+ dup[len] = 0;
538
+ }
539
+ return dup;
540
+ }
541
+
542
+ //#############################################################################
543
+
544
+ /** Return the larger (according to <code>operator<()</code> of the arguments.
545
+ This function was introduced because for some reason compiler tend to
546
+ handle the <code>max()</code> function differently. */
547
+ template <class T> inline T
548
+ CoinMax(register const T x1, register const T x2)
549
+ {
550
+ return (x1 > x2) ? x1 : x2;
551
+ }
552
+
553
+ //-----------------------------------------------------------------------------
554
+
555
+ /** Return the smaller (according to <code>operator<()</code> of the arguments.
556
+ This function was introduced because for some reason compiler tend to
557
+ handle the min() function differently. */
558
+ template <class T> inline T
559
+ CoinMin(register const T x1, register const T x2)
560
+ {
561
+ return (x1 < x2) ? x1 : x2;
562
+ }
563
+
564
+ //-----------------------------------------------------------------------------
565
+
566
+ /** Return the absolute value of the argument. This function was introduced
567
+ because for some reason compiler tend to handle the abs() function
568
+ differently. */
569
+ template <class T> inline T
570
+ CoinAbs(const T value)
571
+ {
572
+ return value<0 ? -value : value;
573
+ }
574
+
575
+ //#############################################################################
576
+
577
+ /** This helper function tests whether the entries of an array are sorted
578
+ according to operator<. The array is given by a pointer to its first entry
579
+ and by its size. */
580
+ template <class T> inline bool
581
+ CoinIsSorted(register const T* first, const int size)
582
+ {
583
+ if (size == 0)
584
+ return true;
585
+
586
+ #ifndef NDEBUG
587
+ if (size < 0)
588
+ throw CoinError("negative number of entries", "CoinIsSorted", "");
589
+ #endif
590
+ #if 1
591
+ // size1 is the number of comparisons to be made
592
+ const int size1 = size - 1;
593
+ for (register int n = size1 / 8; n > 0; --n, first += 8) {
594
+ if (first[8] < first[7]) return false;
595
+ if (first[7] < first[6]) return false;
596
+ if (first[6] < first[5]) return false;
597
+ if (first[5] < first[4]) return false;
598
+ if (first[4] < first[3]) return false;
599
+ if (first[3] < first[2]) return false;
600
+ if (first[2] < first[1]) return false;
601
+ if (first[1] < first[0]) return false;
602
+ }
603
+
604
+ switch (size1 % 8) {
605
+ case 7: if (first[7] < first[6]) return false;
606
+ case 6: if (first[6] < first[5]) return false;
607
+ case 5: if (first[5] < first[4]) return false;
608
+ case 4: if (first[4] < first[3]) return false;
609
+ case 3: if (first[3] < first[2]) return false;
610
+ case 2: if (first[2] < first[1]) return false;
611
+ case 1: if (first[1] < first[0]) return false;
612
+ case 0: break;
613
+ }
614
+ #else
615
+ register const T* next = first;
616
+ register const T* last = first + size;
617
+ for (++next; next != last; first = next, ++next)
618
+ if (*next < *first)
619
+ return false;
620
+ #endif
621
+ return true;
622
+ }
623
+
624
+ //-----------------------------------------------------------------------------
625
+
626
+ /** This helper function tests whether the entries of an array are sorted
627
+ according to operator<. The array is given by its first and "after
628
+ last" entry. */
629
+ template <class T> inline bool
630
+ CoinIsSorted(register const T* first, register const T* last)
631
+ {
632
+ return CoinIsSorted(first, static_cast<int>(last - first));
633
+ }
634
+
635
+ //#############################################################################
636
+
637
+ /** This helper function fills an array with the values init, init+1, init+2,
638
+ etc. For speed 8 entries are filled at a time. The array is given by a
639
+ pointer to its first entry and its size. */
640
+ template <class T> inline void
641
+ CoinIotaN(register T* first, const int size, register T init)
642
+ {
643
+ if (size == 0)
644
+ return;
645
+
646
+ #ifndef NDEBUG
647
+ if (size < 0)
648
+ throw CoinError("negative number of entries", "CoinIotaN", "");
649
+ #endif
650
+ #if 1
651
+ for (register int n = size / 8; n > 0; --n, first += 8, init += 8) {
652
+ first[0] = init;
653
+ first[1] = init + 1;
654
+ first[2] = init + 2;
655
+ first[3] = init + 3;
656
+ first[4] = init + 4;
657
+ first[5] = init + 5;
658
+ first[6] = init + 6;
659
+ first[7] = init + 7;
660
+ }
661
+ switch (size % 8) {
662
+ case 7: first[6] = init + 6;
663
+ case 6: first[5] = init + 5;
664
+ case 5: first[4] = init + 4;
665
+ case 4: first[3] = init + 3;
666
+ case 3: first[2] = init + 2;
667
+ case 2: first[1] = init + 1;
668
+ case 1: first[0] = init;
669
+ case 0: break;
670
+ }
671
+ #else
672
+ // Use Duff's device to fill
673
+ register int n = (size + 7) / 8;
674
+ --first;
675
+ --init;
676
+ switch (size % 8) {
677
+ case 0: do{ *++first = ++init;
678
+ case 7: *++first = ++init;
679
+ case 6: *++first = ++init;
680
+ case 5: *++first = ++init;
681
+ case 4: *++first = ++init;
682
+ case 3: *++first = ++init;
683
+ case 2: *++first = ++init;
684
+ case 1: *++first = ++init;
685
+ }while(--n>0);
686
+ }
687
+ #endif
688
+ }
689
+
690
+ //-----------------------------------------------------------------------------
691
+
692
+ /** This helper function fills an array with the values init, init+1, init+2,
693
+ etc. For speed 8 entries are filled at a time. The array is given by its
694
+ first and "after last" entry. */
695
+ template <class T> inline void
696
+ CoinIota(T* first, const T* last, T init)
697
+ {
698
+ CoinIotaN(first, last-first, init);
699
+ }
700
+
701
+ //#############################################################################
702
+
703
+ /** This helper function deletes certain entries from an array. The array is
704
+ given by pointers to its first and "after last" entry (first two
705
+ arguments). The positions of the entries to be deleted are given in the
706
+ integer array specified by the last two arguments (again, first and "after
707
+ last" entry). */
708
+ template <class T> inline T *
709
+ CoinDeleteEntriesFromArray(register T * arrayFirst, register T * arrayLast,
710
+ const int * firstDelPos, const int * lastDelPos)
711
+ {
712
+ int delNum = static_cast<int>(lastDelPos - firstDelPos);
713
+ if (delNum == 0)
714
+ return arrayLast;
715
+
716
+ if (delNum < 0)
717
+ throw CoinError("trying to delete negative number of entries",
718
+ "CoinDeleteEntriesFromArray", "");
719
+
720
+ int * delSortedPos = NULL;
721
+ if (! (CoinIsSorted(firstDelPos, lastDelPos) &&
722
+ std::adjacent_find(firstDelPos, lastDelPos) == lastDelPos)) {
723
+ // the positions of the to be deleted is either not sorted or not unique
724
+ delSortedPos = new int[delNum];
725
+ CoinDisjointCopy(firstDelPos, lastDelPos, delSortedPos);
726
+ std::sort(delSortedPos, delSortedPos + delNum);
727
+ delNum = static_cast<int>(std::unique(delSortedPos,
728
+ delSortedPos+delNum) - delSortedPos);
729
+ }
730
+ const int * delSorted = delSortedPos ? delSortedPos : firstDelPos;
731
+
732
+ const int last = delNum - 1;
733
+ int size = delSorted[0];
734
+ for (int i = 0; i < last; ++i) {
735
+ const int copyFirst = delSorted[i] + 1;
736
+ const int copyLast = delSorted[i+1];
737
+ CoinCopy(arrayFirst + copyFirst, arrayFirst + copyLast,
738
+ arrayFirst + size);
739
+ size += copyLast - copyFirst;
740
+ }
741
+ const int copyFirst = delSorted[last] + 1;
742
+ const int copyLast = static_cast<int>(arrayLast - arrayFirst);
743
+ CoinCopy(arrayFirst + copyFirst, arrayFirst + copyLast,
744
+ arrayFirst + size);
745
+ size += copyLast - copyFirst;
746
+
747
+ if (delSortedPos)
748
+ delete[] delSortedPos;
749
+
750
+ return arrayFirst + size;
751
+ }
752
+
753
+ //#############################################################################
754
+
755
+ #define COIN_OWN_RANDOM_32
756
+
757
+ #if defined COIN_OWN_RANDOM_32
758
+ /* Thanks to Stefano Gliozzi for providing an operating system
759
+ independent random number generator. */
760
+
761
+ /*! \brief Return a random number between 0 and 1
762
+
763
+ A platform-independent linear congruential generator. For a given seed, the
764
+ generated sequence is always the same regardless of the (32-bit)
765
+ architecture. This allows to build & test in different environments, getting
766
+ in most cases the same optimization path.
767
+
768
+ Set \p isSeed to true and supply an integer seed to set the seed
769
+ (vid. #CoinSeedRandom)
770
+
771
+ \todo Anyone want to volunteer an upgrade for 64-bit architectures?
772
+ */
773
+ inline double CoinDrand48 (bool isSeed = false, unsigned int seed = 1)
774
+ {
775
+ static unsigned int last = 123456;
776
+ if (isSeed) {
777
+ last = seed;
778
+ } else {
779
+ last = 1664525*last+1013904223;
780
+ return ((static_cast<double> (last))/4294967296.0);
781
+ }
782
+ return (0.0);
783
+ }
784
+
785
+ /// Set the seed for the random number generator
786
+ inline void CoinSeedRandom(int iseed)
787
+ {
788
+ CoinDrand48(true, iseed);
789
+ }
790
+
791
+ #else // COIN_OWN_RANDOM_32
792
+
793
+ #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN32__)
794
+
795
+ /// Return a random number between 0 and 1
796
+ inline double CoinDrand48() { return rand() / (double) RAND_MAX; }
797
+ /// Set the seed for the random number generator
798
+ inline void CoinSeedRandom(int iseed) { srand(iseed + 69822); }
799
+
800
+ #else
801
+
802
+ /// Return a random number between 0 and 1
803
+ inline double CoinDrand48() { return drand48(); }
804
+ /// Set the seed for the random number generator
805
+ inline void CoinSeedRandom(int iseed) { srand48(iseed + 69822); }
806
+
807
+ #endif
808
+
809
+ #endif // COIN_OWN_RANDOM_32
810
+
811
+ //#############################################################################
812
+
813
+ /** This function figures out whether file names should contain slashes or
814
+ backslashes as directory separator */
815
+ inline char CoinFindDirSeparator()
816
+ {
817
+ int size = 1000;
818
+ char* buf = 0;
819
+ while (true) {
820
+ buf = new char[size];
821
+ if (getcwd(buf, size))
822
+ break;
823
+ delete[] buf;
824
+ buf = 0;
825
+ size = 2*size;
826
+ }
827
+ // if first char is '/' then it's unix and the dirsep is '/'. otherwise we
828
+ // assume it's dos and the dirsep is '\'
829
+ char dirsep = buf[0] == '/' ? '/' : '\\';
830
+ delete[] buf;
831
+ return dirsep;
832
+ }
833
+ //#############################################################################
834
+
835
+ inline int CoinStrNCaseCmp(const char* s0, const char* s1,
836
+ const size_t len)
837
+ {
838
+ for (size_t i = 0; i < len; ++i) {
839
+ if (s0[i] == 0) {
840
+ return s1[i] == 0 ? 0 : -1;
841
+ }
842
+ if (s1[i] == 0) {
843
+ return 1;
844
+ }
845
+ const int c0 = std::tolower(s0[i]);
846
+ const int c1 = std::tolower(s1[i]);
847
+ if (c0 < c1)
848
+ return -1;
849
+ if (c0 > c1)
850
+ return 1;
851
+ }
852
+ return 0;
853
+ }
854
+
855
+ //#############################################################################
856
+
857
+ /// Swap the arguments.
858
+ template <class T> inline void CoinSwap (T &x, T &y)
859
+ {
860
+ T t = x;
861
+ x = y;
862
+ y = t;
863
+ }
864
+
865
+ //#############################################################################
866
+
867
+ /** This helper function copies an array to file
868
+ Returns 0 if OK, 1 if bad write.
869
+ */
870
+
871
+ template <class T> inline int
872
+ CoinToFile( const T* array, CoinBigIndex size, FILE * fp)
873
+ {
874
+ CoinBigIndex numberWritten;
875
+ if (array&&size) {
876
+ numberWritten =
877
+ static_cast<CoinBigIndex>(fwrite(&size,sizeof(int),1,fp));
878
+ if (numberWritten!=1)
879
+ return 1;
880
+ numberWritten =
881
+ static_cast<CoinBigIndex>(fwrite(array,sizeof(T),size_t(size),fp));
882
+ if (numberWritten!=size)
883
+ return 1;
884
+ } else {
885
+ size = 0;
886
+ numberWritten =
887
+ static_cast<CoinBigIndex>(fwrite(&size,sizeof(int),1,fp));
888
+ if (numberWritten!=1)
889
+ return 1;
890
+ }
891
+ return 0;
892
+ }
893
+
894
+ //#############################################################################
895
+
896
+ /** This helper function copies an array from file and creates with new.
897
+ Passed in array is ignored i.e. not deleted.
898
+ But if NULL and size does not match and newSize 0 then leaves as NULL and 0
899
+ Returns 0 if OK, 1 if bad read, 2 if size did not match.
900
+ */
901
+
902
+ template <class T> inline int
903
+ CoinFromFile( T* &array, CoinBigIndex size, FILE * fp, CoinBigIndex & newSize)
904
+ {
905
+ CoinBigIndex numberRead;
906
+ numberRead =
907
+ static_cast<CoinBigIndex>(fread(&newSize,sizeof(int),1,fp));
908
+ if (numberRead!=1)
909
+ return 1;
910
+ int returnCode=0;
911
+ if (size!=newSize&&(newSize||array))
912
+ returnCode=2;
913
+ if (newSize) {
914
+ array = new T [newSize];
915
+ numberRead =
916
+ static_cast<CoinBigIndex>(fread(array,sizeof(T),newSize,fp));
917
+ if (numberRead!=newSize)
918
+ returnCode=1;
919
+ } else {
920
+ array = NULL;
921
+ }
922
+ return returnCode;
923
+ }
924
+
925
+ //#############################################################################
926
+
927
+ /// Cube Root
928
+ #if 0
929
+ inline double CoinCbrt(double x)
930
+ {
931
+ #if defined(_MSC_VER)
932
+ return pow(x,(1./3.));
933
+ #else
934
+ return cbrt(x);
935
+ #endif
936
+ }
937
+ #endif
938
+
939
+ //-----------------------------------------------------------------------------
940
+
941
+ /// This helper returns "sizeof" as an int
942
+ #define CoinSizeofAsInt(type) (static_cast<int>(sizeof(type)))
943
+ /// This helper returns "strlen" as an int
944
+ inline int
945
+ CoinStrlenAsInt(const char * string)
946
+ {
947
+ return static_cast<int>(strlen(string));
948
+ }
949
+
950
+ /** Class for thread specific random numbers
951
+ */
952
+ #if defined COIN_OWN_RANDOM_32
953
+ class CoinThreadRandom {
954
+ public:
955
+ /**@name Constructors, destructor */
956
+
957
+ //@{
958
+ /** Default constructor. */
959
+ CoinThreadRandom()
960
+ { seed_=12345678;}
961
+ /** Constructor wih seed. */
962
+ CoinThreadRandom(int seed)
963
+ {
964
+ seed_ = seed;
965
+ }
966
+ /** Destructor */
967
+ ~CoinThreadRandom() {}
968
+ // Copy
969
+ CoinThreadRandom(const CoinThreadRandom & rhs)
970
+ { seed_ = rhs.seed_;}
971
+ // Assignment
972
+ CoinThreadRandom& operator=(const CoinThreadRandom & rhs)
973
+ {
974
+ if (this != &rhs) {
975
+ seed_ = rhs.seed_;
976
+ }
977
+ return *this;
978
+ }
979
+
980
+ //@}
981
+
982
+ /**@name Sets/gets */
983
+
984
+ //@{
985
+ /** Set seed. */
986
+ inline void setSeed(int seed)
987
+ {
988
+ seed_ = seed;
989
+ }
990
+ /** Get seed. */
991
+ inline unsigned int getSeed() const
992
+ {
993
+ return seed_;
994
+ }
995
+ /// return a random number
996
+ inline double randomDouble() const
997
+ {
998
+ double retVal;
999
+ seed_ = 1664525*(seed_)+1013904223;
1000
+ retVal = ((static_cast<double> (seed_))/4294967296.0);
1001
+ return retVal;
1002
+ }
1003
+ /// make more random (i.e. for startup)
1004
+ inline void randomize(int n=0)
1005
+ {
1006
+ if (!n)
1007
+ n=seed_ & 255;
1008
+ for (int i=0;i<n;i++)
1009
+ randomDouble();
1010
+ }
1011
+ //@}
1012
+
1013
+
1014
+ protected:
1015
+ /**@name Data members
1016
+ The data members are protected to allow access for derived classes. */
1017
+ //@{
1018
+ /// Current seed
1019
+ mutable unsigned int seed_;
1020
+ //@}
1021
+ };
1022
+ #else
1023
+ class CoinThreadRandom {
1024
+ public:
1025
+ /**@name Constructors, destructor */
1026
+
1027
+ //@{
1028
+ /** Default constructor. */
1029
+ CoinThreadRandom()
1030
+ { seed_[0]=50000;seed_[1]=40000;seed_[2]=30000;}
1031
+ /** Constructor wih seed. */
1032
+ CoinThreadRandom(const unsigned short seed[3])
1033
+ { memcpy(seed_,seed,3*sizeof(unsigned short));}
1034
+ /** Constructor wih seed. */
1035
+ CoinThreadRandom(int seed)
1036
+ {
1037
+ union { int i[2]; unsigned short int s[4];} put;
1038
+ put.i[0]=seed;
1039
+ put.i[1]=seed;
1040
+ memcpy(seed_,put.s,3*sizeof(unsigned short));
1041
+ }
1042
+ /** Destructor */
1043
+ ~CoinThreadRandom() {}
1044
+ // Copy
1045
+ CoinThreadRandom(const CoinThreadRandom & rhs)
1046
+ { memcpy(seed_,rhs.seed_,3*sizeof(unsigned short));}
1047
+ // Assignment
1048
+ CoinThreadRandom& operator=(const CoinThreadRandom & rhs)
1049
+ {
1050
+ if (this != &rhs) {
1051
+ memcpy(seed_,rhs.seed_,3*sizeof(unsigned short));
1052
+ }
1053
+ return *this;
1054
+ }
1055
+
1056
+ //@}
1057
+
1058
+ /**@name Sets/gets */
1059
+
1060
+ //@{
1061
+ /** Set seed. */
1062
+ inline void setSeed(const unsigned short seed[3])
1063
+ { memcpy(seed_,seed,3*sizeof(unsigned short));}
1064
+ /** Set seed. */
1065
+ inline void setSeed(int seed)
1066
+ {
1067
+ union { int i[2]; unsigned short int s[4];} put;
1068
+ put.i[0]=seed;
1069
+ put.i[1]=seed;
1070
+ memcpy(seed_,put.s,3*sizeof(unsigned short));
1071
+ }
1072
+ /// return a random number
1073
+ inline double randomDouble() const
1074
+ {
1075
+ double retVal;
1076
+ #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN32__)
1077
+ retVal=rand();
1078
+ retVal=retVal/(double) RAND_MAX;
1079
+ #else
1080
+ retVal = erand48(seed_);
1081
+ #endif
1082
+ return retVal;
1083
+ }
1084
+ /// make more random (i.e. for startup)
1085
+ inline void randomize(int n=0)
1086
+ {
1087
+ if (!n) {
1088
+ n=seed_[0]+seed_[1]+seed_[2];
1089
+ n &= 255;
1090
+ }
1091
+ for (int i=0;i<n;i++)
1092
+ randomDouble();
1093
+ }
1094
+ //@}
1095
+
1096
+
1097
+ protected:
1098
+ /**@name Data members
1099
+ The data members are protected to allow access for derived classes. */
1100
+ //@{
1101
+ /// Current seed
1102
+ mutable unsigned short seed_[3];
1103
+ //@}
1104
+ };
1105
+ #endif
1106
+ #ifndef COIN_DETAIL
1107
+ #define COIN_DETAIL_PRINT(s) {}
1108
+ #else
1109
+ #define COIN_DETAIL_PRINT(s) s
1110
+ #endif
1111
+ #endif