ruby-cbc 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +203 -0
- data/Rakefile +40 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ext/ruby-cbc/cbc.i +15 -0
- data/ext/ruby-cbc/cbc_wrap.c +4618 -0
- data/ext/ruby-cbc/extconf.rb +60 -0
- data/ext/ruby-cbc/install/bin/cbc +0 -0
- data/ext/ruby-cbc/install/bin/clp +0 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchActual.hpp +24 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchAllDifferent.hpp +62 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchBase.hpp +78 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchCut.hpp +183 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchDecision.hpp +129 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchDefaultDecision.hpp +100 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchDynamic.hpp +206 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchLotsize.hpp +242 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchToFixLots.hpp +94 -0
- data/ext/ruby-cbc/install/include/coin/CbcBranchingObject.hpp +236 -0
- data/ext/ruby-cbc/install/include/coin/CbcClique.hpp +303 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompare.hpp +39 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareActual.hpp +14 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareBase.hpp +142 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareDefault.hpp +120 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareDepth.hpp +47 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareEstimate.hpp +48 -0
- data/ext/ruby-cbc/install/include/coin/CbcCompareObjective.hpp +49 -0
- data/ext/ruby-cbc/install/include/coin/CbcConfig.h +14 -0
- data/ext/ruby-cbc/install/include/coin/CbcConsequence.hpp +49 -0
- data/ext/ruby-cbc/install/include/coin/CbcCountRowCut.hpp +168 -0
- data/ext/ruby-cbc/install/include/coin/CbcCutGenerator.hpp +482 -0
- data/ext/ruby-cbc/install/include/coin/CbcCutModifier.hpp +57 -0
- data/ext/ruby-cbc/install/include/coin/CbcCutSubsetModifier.hpp +66 -0
- data/ext/ruby-cbc/install/include/coin/CbcDummyBranchingObject.hpp +83 -0
- data/ext/ruby-cbc/install/include/coin/CbcEventHandler.hpp +245 -0
- data/ext/ruby-cbc/install/include/coin/CbcFathom.hpp +137 -0
- data/ext/ruby-cbc/install/include/coin/CbcFathomDynamicProgramming.hpp +169 -0
- data/ext/ruby-cbc/install/include/coin/CbcFeasibilityBase.hpp +56 -0
- data/ext/ruby-cbc/install/include/coin/CbcFixVariable.hpp +67 -0
- data/ext/ruby-cbc/install/include/coin/CbcFollowOn.hpp +207 -0
- data/ext/ruby-cbc/install/include/coin/CbcFullNodeInfo.hpp +161 -0
- data/ext/ruby-cbc/install/include/coin/CbcGeneral.hpp +60 -0
- data/ext/ruby-cbc/install/include/coin/CbcGeneralDepth.hpp +279 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristic.hpp +682 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDINS.hpp +96 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDW.hpp +309 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDive.hpp +192 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveCoefficient.hpp +52 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveFractional.hpp +52 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveGuided.hpp +55 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveLineSearch.hpp +52 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDivePseudoCost.hpp +60 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicDiveVectorLength.hpp +52 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicFPump.hpp +340 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicGreedy.hpp +280 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicLocal.hpp +271 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicPivotAndFix.hpp +58 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicRENS.hpp +77 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicRINS.hpp +102 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicRandRound.hpp +58 -0
- data/ext/ruby-cbc/install/include/coin/CbcHeuristicVND.hpp +94 -0
- data/ext/ruby-cbc/install/include/coin/CbcLinked.hpp +1406 -0
- data/ext/ruby-cbc/install/include/coin/CbcMessage.hpp +94 -0
- data/ext/ruby-cbc/install/include/coin/CbcMipStartIO.hpp +26 -0
- data/ext/ruby-cbc/install/include/coin/CbcModel.hpp +2952 -0
- data/ext/ruby-cbc/install/include/coin/CbcNWay.hpp +166 -0
- data/ext/ruby-cbc/install/include/coin/CbcNode.hpp +351 -0
- data/ext/ruby-cbc/install/include/coin/CbcNodeInfo.hpp +349 -0
- data/ext/ruby-cbc/install/include/coin/CbcObject.hpp +272 -0
- data/ext/ruby-cbc/install/include/coin/CbcObjectUpdateData.hpp +64 -0
- data/ext/ruby-cbc/install/include/coin/CbcOrClpParam.cpp +4134 -0
- data/ext/ruby-cbc/install/include/coin/CbcOrClpParam.hpp +532 -0
- data/ext/ruby-cbc/install/include/coin/CbcParam.hpp +324 -0
- data/ext/ruby-cbc/install/include/coin/CbcPartialNodeInfo.hpp +110 -0
- data/ext/ruby-cbc/install/include/coin/CbcSOS.hpp +279 -0
- data/ext/ruby-cbc/install/include/coin/CbcSimpleInteger.hpp +286 -0
- data/ext/ruby-cbc/install/include/coin/CbcSimpleIntegerDynamicPseudoCost.hpp +564 -0
- data/ext/ruby-cbc/install/include/coin/CbcSimpleIntegerPseudoCost.hpp +114 -0
- data/ext/ruby-cbc/install/include/coin/CbcSolver.hpp +447 -0
- data/ext/ruby-cbc/install/include/coin/CbcStrategy.hpp +258 -0
- data/ext/ruby-cbc/install/include/coin/CbcSubProblem.hpp +83 -0
- data/ext/ruby-cbc/install/include/coin/CbcTree.hpp +490 -0
- data/ext/ruby-cbc/install/include/coin/CbcTreeLocal.hpp +372 -0
- data/ext/ruby-cbc/install/include/coin/Cbc_C_Interface.h +381 -0
- data/ext/ruby-cbc/install/include/coin/Cgl012cut.hpp +464 -0
- data/ext/ruby-cbc/install/include/coin/CglAllDifferent.hpp +115 -0
- data/ext/ruby-cbc/install/include/coin/CglClique.hpp +308 -0
- data/ext/ruby-cbc/install/include/coin/CglConfig.h +19 -0
- data/ext/ruby-cbc/install/include/coin/CglCutGenerator.hpp +121 -0
- data/ext/ruby-cbc/install/include/coin/CglDuplicateRow.hpp +189 -0
- data/ext/ruby-cbc/install/include/coin/CglFlowCover.hpp +371 -0
- data/ext/ruby-cbc/install/include/coin/CglGMI.hpp +364 -0
- data/ext/ruby-cbc/install/include/coin/CglGMIParam.hpp +313 -0
- data/ext/ruby-cbc/install/include/coin/CglGomory.hpp +204 -0
- data/ext/ruby-cbc/install/include/coin/CglKnapsackCover.hpp +310 -0
- data/ext/ruby-cbc/install/include/coin/CglLandP.hpp +306 -0
- data/ext/ruby-cbc/install/include/coin/CglLandPValidator.hpp +130 -0
- data/ext/ruby-cbc/install/include/coin/CglLiftAndProject.hpp +104 -0
- data/ext/ruby-cbc/install/include/coin/CglMessage.hpp +50 -0
- data/ext/ruby-cbc/install/include/coin/CglMixedIntegerRounding.hpp +429 -0
- data/ext/ruby-cbc/install/include/coin/CglMixedIntegerRounding2.hpp +427 -0
- data/ext/ruby-cbc/install/include/coin/CglOddHole.hpp +160 -0
- data/ext/ruby-cbc/install/include/coin/CglParam.hpp +93 -0
- data/ext/ruby-cbc/install/include/coin/CglPreProcess.hpp +492 -0
- data/ext/ruby-cbc/install/include/coin/CglProbing.hpp +543 -0
- data/ext/ruby-cbc/install/include/coin/CglRedSplit.hpp +448 -0
- data/ext/ruby-cbc/install/include/coin/CglRedSplit2.hpp +494 -0
- data/ext/ruby-cbc/install/include/coin/CglRedSplit2Param.hpp +495 -0
- data/ext/ruby-cbc/install/include/coin/CglRedSplitParam.hpp +272 -0
- data/ext/ruby-cbc/install/include/coin/CglResidualCapacity.hpp +240 -0
- data/ext/ruby-cbc/install/include/coin/CglSimpleRounding.hpp +174 -0
- data/ext/ruby-cbc/install/include/coin/CglStored.hpp +125 -0
- data/ext/ruby-cbc/install/include/coin/CglTreeInfo.hpp +180 -0
- data/ext/ruby-cbc/install/include/coin/CglTwomir.hpp +565 -0
- data/ext/ruby-cbc/install/include/coin/CglZeroHalf.hpp +133 -0
- data/ext/ruby-cbc/install/include/coin/ClpAmplObjective.hpp +113 -0
- data/ext/ruby-cbc/install/include/coin/ClpCholeskyBase.hpp +294 -0
- data/ext/ruby-cbc/install/include/coin/ClpCholeskyDense.hpp +162 -0
- data/ext/ruby-cbc/install/include/coin/ClpConfig.h +17 -0
- data/ext/ruby-cbc/install/include/coin/ClpConstraint.hpp +125 -0
- data/ext/ruby-cbc/install/include/coin/ClpConstraintAmpl.hpp +108 -0
- data/ext/ruby-cbc/install/include/coin/ClpConstraintLinear.hpp +110 -0
- data/ext/ruby-cbc/install/include/coin/ClpConstraintQuadratic.hpp +119 -0
- data/ext/ruby-cbc/install/include/coin/ClpDualRowDantzig.hpp +71 -0
- data/ext/ruby-cbc/install/include/coin/ClpDualRowPivot.hpp +129 -0
- data/ext/ruby-cbc/install/include/coin/ClpDualRowSteepest.hpp +153 -0
- data/ext/ruby-cbc/install/include/coin/ClpDummyMatrix.hpp +183 -0
- data/ext/ruby-cbc/install/include/coin/ClpDynamicExampleMatrix.hpp +186 -0
- data/ext/ruby-cbc/install/include/coin/ClpDynamicMatrix.hpp +381 -0
- data/ext/ruby-cbc/install/include/coin/ClpEventHandler.hpp +187 -0
- data/ext/ruby-cbc/install/include/coin/ClpFactorization.hpp +432 -0
- data/ext/ruby-cbc/install/include/coin/ClpGubDynamicMatrix.hpp +247 -0
- data/ext/ruby-cbc/install/include/coin/ClpGubMatrix.hpp +358 -0
- data/ext/ruby-cbc/install/include/coin/ClpInterior.hpp +570 -0
- data/ext/ruby-cbc/install/include/coin/ClpLinearObjective.hpp +103 -0
- data/ext/ruby-cbc/install/include/coin/ClpMatrixBase.hpp +524 -0
- data/ext/ruby-cbc/install/include/coin/ClpMessage.hpp +131 -0
- data/ext/ruby-cbc/install/include/coin/ClpModel.hpp +1307 -0
- data/ext/ruby-cbc/install/include/coin/ClpNetworkMatrix.hpp +229 -0
- data/ext/ruby-cbc/install/include/coin/ClpNode.hpp +349 -0
- data/ext/ruby-cbc/install/include/coin/ClpNonLinearCost.hpp +401 -0
- data/ext/ruby-cbc/install/include/coin/ClpObjective.hpp +134 -0
- data/ext/ruby-cbc/install/include/coin/ClpPackedMatrix.hpp +638 -0
- data/ext/ruby-cbc/install/include/coin/ClpParameters.hpp +126 -0
- data/ext/ruby-cbc/install/include/coin/ClpPdcoBase.hpp +103 -0
- data/ext/ruby-cbc/install/include/coin/ClpPlusMinusOneMatrix.hpp +290 -0
- data/ext/ruby-cbc/install/include/coin/ClpPresolve.hpp +299 -0
- data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnDantzig.hpp +72 -0
- data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnPivot.hpp +155 -0
- data/ext/ruby-cbc/install/include/coin/ClpPrimalColumnSteepest.hpp +247 -0
- data/ext/ruby-cbc/install/include/coin/ClpQuadraticObjective.hpp +155 -0
- data/ext/ruby-cbc/install/include/coin/ClpSimplex.hpp +1797 -0
- data/ext/ruby-cbc/install/include/coin/ClpSimplexDual.hpp +300 -0
- data/ext/ruby-cbc/install/include/coin/ClpSimplexNonlinear.hpp +117 -0
- data/ext/ruby-cbc/install/include/coin/ClpSimplexOther.hpp +277 -0
- data/ext/ruby-cbc/install/include/coin/ClpSimplexPrimal.hpp +244 -0
- data/ext/ruby-cbc/install/include/coin/ClpSolve.hpp +446 -0
- data/ext/ruby-cbc/install/include/coin/Clp_C_Interface.h +525 -0
- data/ext/ruby-cbc/install/include/coin/CoinAlloc.hpp +176 -0
- data/ext/ruby-cbc/install/include/coin/CoinBuild.hpp +149 -0
- data/ext/ruby-cbc/install/include/coin/CoinDenseFactorization.hpp +419 -0
- data/ext/ruby-cbc/install/include/coin/CoinDenseVector.hpp +383 -0
- data/ext/ruby-cbc/install/include/coin/CoinDistance.hpp +48 -0
- data/ext/ruby-cbc/install/include/coin/CoinError.hpp +257 -0
- data/ext/ruby-cbc/install/include/coin/CoinFactorization.hpp +2044 -0
- data/ext/ruby-cbc/install/include/coin/CoinFileIO.hpp +166 -0
- data/ext/ruby-cbc/install/include/coin/CoinFinite.hpp +34 -0
- data/ext/ruby-cbc/install/include/coin/CoinFloatEqual.hpp +177 -0
- data/ext/ruby-cbc/install/include/coin/CoinHelperFunctions.hpp +1111 -0
- data/ext/ruby-cbc/install/include/coin/CoinIndexedVector.hpp +1164 -0
- data/ext/ruby-cbc/install/include/coin/CoinLpIO.hpp +805 -0
- data/ext/ruby-cbc/install/include/coin/CoinMessage.hpp +96 -0
- data/ext/ruby-cbc/install/include/coin/CoinMessageHandler.hpp +666 -0
- data/ext/ruby-cbc/install/include/coin/CoinModel.hpp +1054 -0
- data/ext/ruby-cbc/install/include/coin/CoinModelUseful.hpp +441 -0
- data/ext/ruby-cbc/install/include/coin/CoinMpsIO.hpp +1056 -0
- data/ext/ruby-cbc/install/include/coin/CoinOslFactorization.hpp +280 -0
- data/ext/ruby-cbc/install/include/coin/CoinPackedMatrix.hpp +947 -0
- data/ext/ruby-cbc/install/include/coin/CoinPackedVector.hpp +657 -0
- data/ext/ruby-cbc/install/include/coin/CoinPackedVectorBase.hpp +269 -0
- data/ext/ruby-cbc/install/include/coin/CoinParam.hpp +644 -0
- data/ext/ruby-cbc/install/include/coin/CoinPragma.hpp +26 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveDoubleton.hpp +73 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveDual.hpp +85 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveDupcol.hpp +226 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveEmpty.hpp +116 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveFixed.hpp +181 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveForcing.hpp +61 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveImpliedFree.hpp +60 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveIsolated.hpp +51 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveMatrix.hpp +1842 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveMonitor.hpp +105 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolvePsdebug.hpp +166 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveSingleton.hpp +112 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveSubst.hpp +101 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveTighten.hpp +55 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveTripleton.hpp +66 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveUseless.hpp +63 -0
- data/ext/ruby-cbc/install/include/coin/CoinPresolveZeros.hpp +60 -0
- data/ext/ruby-cbc/install/include/coin/CoinRational.hpp +44 -0
- data/ext/ruby-cbc/install/include/coin/CoinSearchTree.hpp +465 -0
- data/ext/ruby-cbc/install/include/coin/CoinShallowPackedVector.hpp +148 -0
- data/ext/ruby-cbc/install/include/coin/CoinSignal.hpp +117 -0
- data/ext/ruby-cbc/install/include/coin/CoinSimpFactorization.hpp +431 -0
- data/ext/ruby-cbc/install/include/coin/CoinSmartPtr.hpp +528 -0
- data/ext/ruby-cbc/install/include/coin/CoinSnapshot.hpp +476 -0
- data/ext/ruby-cbc/install/include/coin/CoinSort.hpp +678 -0
- data/ext/ruby-cbc/install/include/coin/CoinStructuredModel.hpp +247 -0
- data/ext/ruby-cbc/install/include/coin/CoinTime.hpp +310 -0
- data/ext/ruby-cbc/install/include/coin/CoinTypes.hpp +64 -0
- data/ext/ruby-cbc/install/include/coin/CoinUtility.hpp +19 -0
- data/ext/ruby-cbc/install/include/coin/CoinUtilsConfig.h +34 -0
- data/ext/ruby-cbc/install/include/coin/CoinWarmStart.hpp +58 -0
- data/ext/ruby-cbc/install/include/coin/CoinWarmStartBasis.hpp +456 -0
- data/ext/ruby-cbc/install/include/coin/CoinWarmStartDual.hpp +166 -0
- data/ext/ruby-cbc/install/include/coin/CoinWarmStartPrimalDual.hpp +211 -0
- data/ext/ruby-cbc/install/include/coin/CoinWarmStartVector.hpp +488 -0
- data/ext/ruby-cbc/install/include/coin/Coin_C_defines.h +115 -0
- data/ext/ruby-cbc/install/include/coin/Idiot.hpp +298 -0
- data/ext/ruby-cbc/install/include/coin/OsiAuxInfo.hpp +206 -0
- data/ext/ruby-cbc/install/include/coin/OsiBranchingObject.hpp +1005 -0
- data/ext/ruby-cbc/install/include/coin/OsiCbcSolverInterface.hpp +764 -0
- data/ext/ruby-cbc/install/include/coin/OsiChooseVariable.hpp +534 -0
- data/ext/ruby-cbc/install/include/coin/OsiClpSolverInterface.hpp +1509 -0
- data/ext/ruby-cbc/install/include/coin/OsiColCut.hpp +324 -0
- data/ext/ruby-cbc/install/include/coin/OsiCollections.hpp +35 -0
- data/ext/ruby-cbc/install/include/coin/OsiConfig.h +19 -0
- data/ext/ruby-cbc/install/include/coin/OsiCut.hpp +245 -0
- data/ext/ruby-cbc/install/include/coin/OsiCuts.hpp +474 -0
- data/ext/ruby-cbc/install/include/coin/OsiPresolve.hpp +252 -0
- data/ext/ruby-cbc/install/include/coin/OsiRowCut.hpp +331 -0
- data/ext/ruby-cbc/install/include/coin/OsiRowCutDebugger.hpp +187 -0
- data/ext/ruby-cbc/install/include/coin/OsiSolverBranch.hpp +152 -0
- data/ext/ruby-cbc/install/include/coin/OsiSolverInterface.hpp +2143 -0
- data/ext/ruby-cbc/install/include/coin/OsiSolverParameters.hpp +142 -0
- data/ext/ruby-cbc/install/include/coin/OsiUnitTests.hpp +374 -0
- data/ext/ruby-cbc/install/lib/libCbc.la +35 -0
- data/ext/ruby-cbc/install/lib/libCbc.so +0 -0
- data/ext/ruby-cbc/install/lib/libCbc.so.3 +0 -0
- data/ext/ruby-cbc/install/lib/libCbc.so.3.9.7 +0 -0
- data/ext/ruby-cbc/install/lib/libCbcSolver.la +35 -0
- data/ext/ruby-cbc/install/lib/libCbcSolver.so +0 -0
- data/ext/ruby-cbc/install/lib/libCbcSolver.so.3 +0 -0
- data/ext/ruby-cbc/install/lib/libCbcSolver.so.3.9.7 +0 -0
- data/ext/ruby-cbc/install/lib/libCgl.la +35 -0
- data/ext/ruby-cbc/install/lib/libCgl.so +0 -0
- data/ext/ruby-cbc/install/lib/libCgl.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libCgl.so.1.9.7 +0 -0
- data/ext/ruby-cbc/install/lib/libClp.la +35 -0
- data/ext/ruby-cbc/install/lib/libClp.so +0 -0
- data/ext/ruby-cbc/install/lib/libClp.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libClp.so.1.13.9 +0 -0
- data/ext/ruby-cbc/install/lib/libClpSolver.la +35 -0
- data/ext/ruby-cbc/install/lib/libClpSolver.so +0 -0
- data/ext/ruby-cbc/install/lib/libClpSolver.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libClpSolver.so.1.13.9 +0 -0
- data/ext/ruby-cbc/install/lib/libCoinUtils.la +35 -0
- data/ext/ruby-cbc/install/lib/libCoinUtils.so +0 -0
- data/ext/ruby-cbc/install/lib/libCoinUtils.so.3 +0 -0
- data/ext/ruby-cbc/install/lib/libCoinUtils.so.3.10.11 +0 -0
- data/ext/ruby-cbc/install/lib/libOsi.la +35 -0
- data/ext/ruby-cbc/install/lib/libOsi.so +0 -0
- data/ext/ruby-cbc/install/lib/libOsi.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libOsi.so.1.12.6 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCbc.la +35 -0
- data/ext/ruby-cbc/install/lib/libOsiCbc.so +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCbc.so.3 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCbc.so.3.9.7 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiClp.la +35 -0
- data/ext/ruby-cbc/install/lib/libOsiClp.so +0 -0
- data/ext/ruby-cbc/install/lib/libOsiClp.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiClp.so.1.13.9 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCommonTests.la +35 -0
- data/ext/ruby-cbc/install/lib/libOsiCommonTests.so +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCommonTests.so.1 +0 -0
- data/ext/ruby-cbc/install/lib/libOsiCommonTests.so.1.12.6 +0 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/cbc.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/cgl.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/clp.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/coindatamiplib3.pc +9 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/coindatasample.pc +9 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/coinutils.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/osi-cbc.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/osi-clp.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/osi-unittests.pc +12 -0
- data/ext/ruby-cbc/install/lib/pkgconfig/osi.pc +12 -0
- data/lib/ruby-cbc/ilp/constant.rb +44 -0
- data/lib/ruby-cbc/ilp/constraint.rb +32 -0
- data/lib/ruby-cbc/ilp/objective.rb +26 -0
- data/lib/ruby-cbc/ilp/term.rb +47 -0
- data/lib/ruby-cbc/ilp/term_array.rb +80 -0
- data/lib/ruby-cbc/ilp/var.rb +62 -0
- data/lib/ruby-cbc/model.rb +125 -0
- data/lib/ruby-cbc/problem.rb +170 -0
- data/lib/ruby-cbc/version.rb +3 -0
- data/lib/ruby-cbc.rb +21 -0
- data/ruby-cbc.gemspec +36 -0
- metadata +431 -0
@@ -0,0 +1,657 @@
|
|
1
|
+
/* $Id: CoinPackedVector.hpp 1509 2011-12-05 13:50:48Z 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 CoinPackedVector_H
|
7
|
+
#define CoinPackedVector_H
|
8
|
+
|
9
|
+
#include <map>
|
10
|
+
|
11
|
+
#include "CoinPragma.hpp"
|
12
|
+
#include "CoinPackedVectorBase.hpp"
|
13
|
+
#include "CoinSort.hpp"
|
14
|
+
|
15
|
+
#ifdef COIN_FAST_CODE
|
16
|
+
#ifndef COIN_NOTEST_DUPLICATE
|
17
|
+
#define COIN_NOTEST_DUPLICATE
|
18
|
+
#endif
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#ifndef COIN_NOTEST_DUPLICATE
|
22
|
+
#define COIN_DEFAULT_VALUE_FOR_DUPLICATE true
|
23
|
+
#else
|
24
|
+
#define COIN_DEFAULT_VALUE_FOR_DUPLICATE false
|
25
|
+
#endif
|
26
|
+
/** Sparse Vector
|
27
|
+
|
28
|
+
Stores vector of indices and associated element values.
|
29
|
+
Supports sorting of vector while maintaining the original indices.
|
30
|
+
|
31
|
+
Here is a sample usage:
|
32
|
+
@verbatim
|
33
|
+
const int ne = 4;
|
34
|
+
int inx[ne] = { 1, 4, 0, 2 }
|
35
|
+
double el[ne] = { 10., 40., 1., 50. }
|
36
|
+
|
37
|
+
// Create vector and set its value
|
38
|
+
CoinPackedVector r(ne,inx,el);
|
39
|
+
|
40
|
+
// access each index and element
|
41
|
+
assert( r.indices ()[0]== 1 );
|
42
|
+
assert( r.elements()[0]==10. );
|
43
|
+
assert( r.indices ()[1]== 4 );
|
44
|
+
assert( r.elements()[1]==40. );
|
45
|
+
assert( r.indices ()[2]== 0 );
|
46
|
+
assert( r.elements()[2]== 1. );
|
47
|
+
assert( r.indices ()[3]== 2 );
|
48
|
+
assert( r.elements()[3]==50. );
|
49
|
+
|
50
|
+
// access original position of index
|
51
|
+
assert( r.originalPosition()[0]==0 );
|
52
|
+
assert( r.originalPosition()[1]==1 );
|
53
|
+
assert( r.originalPosition()[2]==2 );
|
54
|
+
assert( r.originalPosition()[3]==3 );
|
55
|
+
|
56
|
+
// access as a full storage vector
|
57
|
+
assert( r[ 0]==1. );
|
58
|
+
assert( r[ 1]==10.);
|
59
|
+
assert( r[ 2]==50.);
|
60
|
+
assert( r[ 3]==0. );
|
61
|
+
assert( r[ 4]==40.);
|
62
|
+
|
63
|
+
// sort Elements in increasing order
|
64
|
+
r.sortIncrElement();
|
65
|
+
|
66
|
+
// access each index and element
|
67
|
+
assert( r.indices ()[0]== 0 );
|
68
|
+
assert( r.elements()[0]== 1. );
|
69
|
+
assert( r.indices ()[1]== 1 );
|
70
|
+
assert( r.elements()[1]==10. );
|
71
|
+
assert( r.indices ()[2]== 4 );
|
72
|
+
assert( r.elements()[2]==40. );
|
73
|
+
assert( r.indices ()[3]== 2 );
|
74
|
+
assert( r.elements()[3]==50. );
|
75
|
+
|
76
|
+
// access original position of index
|
77
|
+
assert( r.originalPosition()[0]==2 );
|
78
|
+
assert( r.originalPosition()[1]==0 );
|
79
|
+
assert( r.originalPosition()[2]==1 );
|
80
|
+
assert( r.originalPosition()[3]==3 );
|
81
|
+
|
82
|
+
// access as a full storage vector
|
83
|
+
assert( r[ 0]==1. );
|
84
|
+
assert( r[ 1]==10.);
|
85
|
+
assert( r[ 2]==50.);
|
86
|
+
assert( r[ 3]==0. );
|
87
|
+
assert( r[ 4]==40.);
|
88
|
+
|
89
|
+
// Restore orignal sort order
|
90
|
+
r.sortOriginalOrder();
|
91
|
+
|
92
|
+
assert( r.indices ()[0]== 1 );
|
93
|
+
assert( r.elements()[0]==10. );
|
94
|
+
assert( r.indices ()[1]== 4 );
|
95
|
+
assert( r.elements()[1]==40. );
|
96
|
+
assert( r.indices ()[2]== 0 );
|
97
|
+
assert( r.elements()[2]== 1. );
|
98
|
+
assert( r.indices ()[3]== 2 );
|
99
|
+
assert( r.elements()[3]==50. );
|
100
|
+
|
101
|
+
// Tests for equality and equivalence
|
102
|
+
CoinPackedVector r1;
|
103
|
+
r1=r;
|
104
|
+
assert( r==r1 );
|
105
|
+
assert( r.equivalent(r1) );
|
106
|
+
r.sortIncrElement();
|
107
|
+
assert( r!=r1 );
|
108
|
+
assert( r.equivalent(r1) );
|
109
|
+
|
110
|
+
// Add packed vectors.
|
111
|
+
// Similarly for subtraction, multiplication,
|
112
|
+
// and division.
|
113
|
+
CoinPackedVector add = r + r1;
|
114
|
+
assert( add[0] == 1.+ 1. );
|
115
|
+
assert( add[1] == 10.+10. );
|
116
|
+
assert( add[2] == 50.+50. );
|
117
|
+
assert( add[3] == 0.+ 0. );
|
118
|
+
assert( add[4] == 40.+40. );
|
119
|
+
|
120
|
+
assert( r.sum() == 10.+40.+1.+50. );
|
121
|
+
@endverbatim
|
122
|
+
*/
|
123
|
+
class CoinPackedVector : public CoinPackedVectorBase {
|
124
|
+
friend void CoinPackedVectorUnitTest();
|
125
|
+
|
126
|
+
public:
|
127
|
+
/**@name Get methods. */
|
128
|
+
//@{
|
129
|
+
/// Get the size
|
130
|
+
virtual int getNumElements() const { return nElements_; }
|
131
|
+
/// Get indices of elements
|
132
|
+
virtual const int * getIndices() const { return indices_; }
|
133
|
+
/// Get element values
|
134
|
+
virtual const double * getElements() const { return elements_; }
|
135
|
+
/// Get indices of elements
|
136
|
+
int * getIndices() { return indices_; }
|
137
|
+
/// Get the size
|
138
|
+
inline int getVectorNumElements() const { return nElements_; }
|
139
|
+
/// Get indices of elements
|
140
|
+
inline const int * getVectorIndices() const { return indices_; }
|
141
|
+
/// Get element values
|
142
|
+
inline const double * getVectorElements() const { return elements_; }
|
143
|
+
/// Get element values
|
144
|
+
double * getElements() { return elements_; }
|
145
|
+
/** Get pointer to int * vector of original postions.
|
146
|
+
If the packed vector has not been sorted then this
|
147
|
+
function returns the vector: 0, 1, 2, ..., size()-1. */
|
148
|
+
const int * getOriginalPosition() const { return origIndices_; }
|
149
|
+
//@}
|
150
|
+
|
151
|
+
//-------------------------------------------------------------------
|
152
|
+
// Set indices and elements
|
153
|
+
//-------------------------------------------------------------------
|
154
|
+
/**@name Set methods */
|
155
|
+
//@{
|
156
|
+
/// Reset the vector (as if were just created an empty vector)
|
157
|
+
void clear();
|
158
|
+
/** Assignment operator. <br>
|
159
|
+
<strong>NOTE</strong>: This operator keeps the current
|
160
|
+
<code>testForDuplicateIndex</code> setting, and affter copying the data
|
161
|
+
it acts accordingly. */
|
162
|
+
CoinPackedVector & operator=(const CoinPackedVector &);
|
163
|
+
/** Assignment operator from a CoinPackedVectorBase. <br>
|
164
|
+
<strong>NOTE</strong>: This operator keeps the current
|
165
|
+
<code>testForDuplicateIndex</code> setting, and affter copying the data
|
166
|
+
it acts accordingly. */
|
167
|
+
CoinPackedVector & operator=(const CoinPackedVectorBase & rhs);
|
168
|
+
|
169
|
+
/** Assign the ownership of the arguments to this vector.
|
170
|
+
Size is the length of both the indices and elements vectors.
|
171
|
+
The indices and elements vectors are copied into this class instance's
|
172
|
+
member data. The last argument indicates whether this vector will have
|
173
|
+
to be tested for duplicate indices.
|
174
|
+
*/
|
175
|
+
void assignVector(int size, int*& inds, double*& elems,
|
176
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
177
|
+
|
178
|
+
/** Set vector size, indices, and elements.
|
179
|
+
Size is the length of both the indices and elements vectors.
|
180
|
+
The indices and elements vectors are copied into this class instance's
|
181
|
+
member data. The last argument specifies whether this vector will have
|
182
|
+
to be checked for duplicate indices whenever that can happen. */
|
183
|
+
void setVector(int size, const int * inds, const double * elems,
|
184
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
185
|
+
|
186
|
+
/** Elements set to have the same scalar value */
|
187
|
+
void setConstant(int size, const int * inds, double elems,
|
188
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
189
|
+
|
190
|
+
/** Indices are not specified and are taken to be 0,1,...,size-1 */
|
191
|
+
void setFull(int size, const double * elems,
|
192
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
193
|
+
|
194
|
+
/** Indices are not specified and are taken to be 0,1,...,size-1,
|
195
|
+
but only where non zero*/
|
196
|
+
void setFullNonZero(int size, const double * elems,
|
197
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
198
|
+
|
199
|
+
/** Set an existing element in the packed vector
|
200
|
+
The first argument is the "index" into the elements() array
|
201
|
+
*/
|
202
|
+
void setElement(int index, double element);
|
203
|
+
|
204
|
+
/// Insert an element into the vector
|
205
|
+
void insert(int index, double element);
|
206
|
+
/// Append a CoinPackedVector to the end
|
207
|
+
void append(const CoinPackedVectorBase & caboose);
|
208
|
+
|
209
|
+
/// Swap values in positions i and j of indices and elements
|
210
|
+
void swap(int i, int j);
|
211
|
+
|
212
|
+
/** Resize the packed vector to be the first newSize elements.
|
213
|
+
Problem with truncate: what happens with origIndices_ ??? */
|
214
|
+
void truncate(int newSize);
|
215
|
+
//@}
|
216
|
+
|
217
|
+
/**@name Arithmetic operators. */
|
218
|
+
//@{
|
219
|
+
/// add <code>value</code> to every entry
|
220
|
+
void operator+=(double value);
|
221
|
+
/// subtract <code>value</code> from every entry
|
222
|
+
void operator-=(double value);
|
223
|
+
/// multiply every entry by <code>value</code>
|
224
|
+
void operator*=(double value);
|
225
|
+
/// divide every entry by <code>value</code>
|
226
|
+
void operator/=(double value);
|
227
|
+
//@}
|
228
|
+
|
229
|
+
/**@name Sorting */
|
230
|
+
//@{
|
231
|
+
/** Sort the packed storage vector.
|
232
|
+
Typcical usages:
|
233
|
+
<pre>
|
234
|
+
packedVector.sort(CoinIncrIndexOrdered()); //increasing indices
|
235
|
+
packedVector.sort(CoinIncrElementOrdered()); // increasing elements
|
236
|
+
</pre>
|
237
|
+
*/
|
238
|
+
template <class CoinCompare3>
|
239
|
+
void sort(const CoinCompare3 & tc)
|
240
|
+
{ CoinSort_3(indices_, indices_ + nElements_, origIndices_, elements_,
|
241
|
+
tc); }
|
242
|
+
|
243
|
+
void sortIncrIndex()
|
244
|
+
{ CoinSort_3(indices_, indices_ + nElements_, origIndices_, elements_,
|
245
|
+
CoinFirstLess_3<int, int, double>()); }
|
246
|
+
|
247
|
+
void sortDecrIndex()
|
248
|
+
{ CoinSort_3(indices_, indices_ + nElements_, origIndices_, elements_,
|
249
|
+
CoinFirstGreater_3<int, int, double>()); }
|
250
|
+
|
251
|
+
void sortIncrElement()
|
252
|
+
{ CoinSort_3(elements_, elements_ + nElements_, origIndices_, indices_,
|
253
|
+
CoinFirstLess_3<double, int, int>()); }
|
254
|
+
|
255
|
+
void sortDecrElement()
|
256
|
+
{ CoinSort_3(elements_, elements_ + nElements_, origIndices_, indices_,
|
257
|
+
CoinFirstGreater_3<double, int, int>()); }
|
258
|
+
|
259
|
+
|
260
|
+
/** Sort in original order.
|
261
|
+
If the vector has been sorted, then this method restores
|
262
|
+
to its orignal sort order.
|
263
|
+
*/
|
264
|
+
void sortOriginalOrder();
|
265
|
+
//@}
|
266
|
+
|
267
|
+
/**@name Memory usage */
|
268
|
+
//@{
|
269
|
+
/** Reserve space.
|
270
|
+
If one knows the eventual size of the packed vector,
|
271
|
+
then it may be more efficient to reserve the space.
|
272
|
+
*/
|
273
|
+
void reserve(int n);
|
274
|
+
/** capacity returns the size which could be accomodated without
|
275
|
+
having to reallocate storage.
|
276
|
+
*/
|
277
|
+
int capacity() const { return capacity_; }
|
278
|
+
//@}
|
279
|
+
/**@name Constructors and destructors */
|
280
|
+
//@{
|
281
|
+
/** Default constructor */
|
282
|
+
CoinPackedVector(bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
283
|
+
/** \brief Alternate Constructors - set elements to vector of doubles
|
284
|
+
|
285
|
+
This constructor copies the vectors provided as parameters.
|
286
|
+
*/
|
287
|
+
CoinPackedVector(int size, const int * inds, const double * elems,
|
288
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
289
|
+
/** \brief Alternate Constructors - set elements to vector of doubles
|
290
|
+
|
291
|
+
This constructor takes ownership of the vectors passed as parameters.
|
292
|
+
\p inds and \p elems will be NULL on return.
|
293
|
+
*/
|
294
|
+
CoinPackedVector(int capacity, int size, int *&inds, double *&elems,
|
295
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
296
|
+
/** Alternate Constructors - set elements to same scalar value */
|
297
|
+
CoinPackedVector(int size, const int * inds, double element,
|
298
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
299
|
+
/** Alternate Constructors - construct full storage with indices 0 through
|
300
|
+
size-1. */
|
301
|
+
CoinPackedVector(int size, const double * elements,
|
302
|
+
bool testForDuplicateIndex = COIN_DEFAULT_VALUE_FOR_DUPLICATE);
|
303
|
+
/** Copy constructor. */
|
304
|
+
CoinPackedVector(const CoinPackedVector &);
|
305
|
+
/** Copy constructor <em>from a PackedVectorBase</em>. */
|
306
|
+
CoinPackedVector(const CoinPackedVectorBase & rhs);
|
307
|
+
/** Destructor */
|
308
|
+
virtual ~CoinPackedVector ();
|
309
|
+
//@}
|
310
|
+
|
311
|
+
private:
|
312
|
+
/**@name Private methods */
|
313
|
+
//@{
|
314
|
+
/// Copy internal date
|
315
|
+
void gutsOfSetVector(int size,
|
316
|
+
const int * inds, const double * elems,
|
317
|
+
bool testForDuplicateIndex,
|
318
|
+
const char * method);
|
319
|
+
///
|
320
|
+
void gutsOfSetConstant(int size,
|
321
|
+
const int * inds, double value,
|
322
|
+
bool testForDuplicateIndex,
|
323
|
+
const char * method);
|
324
|
+
//@}
|
325
|
+
|
326
|
+
private:
|
327
|
+
/**@name Private member data */
|
328
|
+
//@{
|
329
|
+
/// Vector indices
|
330
|
+
int * indices_;
|
331
|
+
///Vector elements
|
332
|
+
double * elements_;
|
333
|
+
/// Size of indices and elements vectors
|
334
|
+
int nElements_;
|
335
|
+
/// original unsorted indices
|
336
|
+
int * origIndices_;
|
337
|
+
/// Amount of memory allocated for indices_, origIndices_, and elements_.
|
338
|
+
int capacity_;
|
339
|
+
//@}
|
340
|
+
};
|
341
|
+
|
342
|
+
//#############################################################################
|
343
|
+
|
344
|
+
/**@name Arithmetic operators on packed vectors.
|
345
|
+
|
346
|
+
<strong>NOTE</strong>: These methods operate on those positions where at
|
347
|
+
least one of the arguments has a value listed. At those positions the
|
348
|
+
appropriate operation is executed, Otherwise the result of the operation is
|
349
|
+
considered 0.<br>
|
350
|
+
<strong>NOTE 2</strong>: There are two kind of operators here. One is used
|
351
|
+
like "c = binaryOp(a, b)", the other is used like "binaryOp(c, a, b)", but
|
352
|
+
they are really the same. The first is much more natural to use, but it
|
353
|
+
involves the creation of a temporary object (the function *must* return an
|
354
|
+
object), while the second form puts the result directly into the argument
|
355
|
+
"c". Therefore, depending on the circumstances, the second form can be
|
356
|
+
significantly faster.
|
357
|
+
*/
|
358
|
+
//@{
|
359
|
+
template <class BinaryFunction> void
|
360
|
+
binaryOp(CoinPackedVector& retVal,
|
361
|
+
const CoinPackedVectorBase& op1, double value,
|
362
|
+
BinaryFunction bf)
|
363
|
+
{
|
364
|
+
retVal.clear();
|
365
|
+
const int s = op1.getNumElements();
|
366
|
+
if (s > 0) {
|
367
|
+
retVal.reserve(s);
|
368
|
+
const int * inds = op1.getIndices();
|
369
|
+
const double * elems = op1.getElements();
|
370
|
+
for (int i=0; i<s; ++i ) {
|
371
|
+
retVal.insert(inds[i], bf(value, elems[i]));
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
template <class BinaryFunction> inline void
|
377
|
+
binaryOp(CoinPackedVector& retVal,
|
378
|
+
double value, const CoinPackedVectorBase& op2,
|
379
|
+
BinaryFunction bf)
|
380
|
+
{
|
381
|
+
binaryOp(retVal, op2, value, bf);
|
382
|
+
}
|
383
|
+
|
384
|
+
template <class BinaryFunction> void
|
385
|
+
binaryOp(CoinPackedVector& retVal,
|
386
|
+
const CoinPackedVectorBase& op1, const CoinPackedVectorBase& op2,
|
387
|
+
BinaryFunction bf)
|
388
|
+
{
|
389
|
+
retVal.clear();
|
390
|
+
const int s1 = op1.getNumElements();
|
391
|
+
const int s2 = op2.getNumElements();
|
392
|
+
/*
|
393
|
+
Replaced || with &&, in response to complaint from Sven deVries, who
|
394
|
+
rightly points out || is not appropriate for additive operations. &&
|
395
|
+
should be ok as long as binaryOp is understood not to create something
|
396
|
+
from nothing. -- lh, 04.06.11
|
397
|
+
*/
|
398
|
+
if (s1 == 0 && s2 == 0)
|
399
|
+
return;
|
400
|
+
|
401
|
+
retVal.reserve(s1+s2);
|
402
|
+
|
403
|
+
const int * inds1 = op1.getIndices();
|
404
|
+
const double * elems1 = op1.getElements();
|
405
|
+
const int * inds2 = op2.getIndices();
|
406
|
+
const double * elems2 = op2.getElements();
|
407
|
+
|
408
|
+
int i;
|
409
|
+
// loop once for each element in op1
|
410
|
+
for ( i=0; i<s1; ++i ) {
|
411
|
+
const int index = inds1[i];
|
412
|
+
const int pos2 = op2.findIndex(index);
|
413
|
+
const double val = bf(elems1[i], pos2 == -1 ? 0.0 : elems2[pos2]);
|
414
|
+
// if (val != 0.0) // *THINK* : should we put in only nonzeros?
|
415
|
+
retVal.insert(index, val);
|
416
|
+
}
|
417
|
+
// loop once for each element in operand2
|
418
|
+
for ( i=0; i<s2; ++i ) {
|
419
|
+
const int index = inds2[i];
|
420
|
+
// if index exists in op1, then element was processed in prior loop
|
421
|
+
if ( op1.isExistingIndex(index) )
|
422
|
+
continue;
|
423
|
+
// Index does not exist in op1, so the element value must be zero
|
424
|
+
const double val = bf(0.0, elems2[i]);
|
425
|
+
// if (val != 0.0) // *THINK* : should we put in only nonzeros?
|
426
|
+
retVal.insert(index, val);
|
427
|
+
}
|
428
|
+
}
|
429
|
+
|
430
|
+
//-----------------------------------------------------------------------------
|
431
|
+
|
432
|
+
template <class BinaryFunction> CoinPackedVector
|
433
|
+
binaryOp(const CoinPackedVectorBase& op1, double value,
|
434
|
+
BinaryFunction bf)
|
435
|
+
{
|
436
|
+
CoinPackedVector retVal;
|
437
|
+
retVal.setTestForDuplicateIndex(true);
|
438
|
+
binaryOp(retVal, op1, value, bf);
|
439
|
+
return retVal;
|
440
|
+
}
|
441
|
+
|
442
|
+
template <class BinaryFunction> CoinPackedVector
|
443
|
+
binaryOp(double value, const CoinPackedVectorBase& op2,
|
444
|
+
BinaryFunction bf)
|
445
|
+
{
|
446
|
+
CoinPackedVector retVal;
|
447
|
+
retVal.setTestForDuplicateIndex(true);
|
448
|
+
binaryOp(retVal, op2, value, bf);
|
449
|
+
return retVal;
|
450
|
+
}
|
451
|
+
|
452
|
+
template <class BinaryFunction> CoinPackedVector
|
453
|
+
binaryOp(const CoinPackedVectorBase& op1, const CoinPackedVectorBase& op2,
|
454
|
+
BinaryFunction bf)
|
455
|
+
{
|
456
|
+
CoinPackedVector retVal;
|
457
|
+
retVal.setTestForDuplicateIndex(true);
|
458
|
+
binaryOp(retVal, op1, op2, bf);
|
459
|
+
return retVal;
|
460
|
+
}
|
461
|
+
|
462
|
+
//-----------------------------------------------------------------------------
|
463
|
+
/// Return the sum of two packed vectors
|
464
|
+
inline CoinPackedVector operator+(const CoinPackedVectorBase& op1,
|
465
|
+
const CoinPackedVectorBase& op2)
|
466
|
+
{
|
467
|
+
CoinPackedVector retVal;
|
468
|
+
retVal.setTestForDuplicateIndex(true);
|
469
|
+
binaryOp(retVal, op1, op2, std::plus<double>());
|
470
|
+
return retVal;
|
471
|
+
}
|
472
|
+
|
473
|
+
/// Return the difference of two packed vectors
|
474
|
+
inline CoinPackedVector operator-(const CoinPackedVectorBase& op1,
|
475
|
+
const CoinPackedVectorBase& op2)
|
476
|
+
{
|
477
|
+
CoinPackedVector retVal;
|
478
|
+
retVal.setTestForDuplicateIndex(true);
|
479
|
+
binaryOp(retVal, op1, op2, std::minus<double>());
|
480
|
+
return retVal;
|
481
|
+
}
|
482
|
+
|
483
|
+
/// Return the element-wise product of two packed vectors
|
484
|
+
inline CoinPackedVector operator*(const CoinPackedVectorBase& op1,
|
485
|
+
const CoinPackedVectorBase& op2)
|
486
|
+
{
|
487
|
+
CoinPackedVector retVal;
|
488
|
+
retVal.setTestForDuplicateIndex(true);
|
489
|
+
binaryOp(retVal, op1, op2, std::multiplies<double>());
|
490
|
+
return retVal;
|
491
|
+
}
|
492
|
+
|
493
|
+
/// Return the element-wise ratio of two packed vectors
|
494
|
+
inline CoinPackedVector operator/(const CoinPackedVectorBase& op1,
|
495
|
+
const CoinPackedVectorBase& op2)
|
496
|
+
{
|
497
|
+
CoinPackedVector retVal;
|
498
|
+
retVal.setTestForDuplicateIndex(true);
|
499
|
+
binaryOp(retVal, op1, op2, std::divides<double>());
|
500
|
+
return retVal;
|
501
|
+
}
|
502
|
+
//@}
|
503
|
+
|
504
|
+
/// Returns the dot product of two CoinPackedVector objects whose elements are
|
505
|
+
/// doubles. Use this version if the vectors are *not* guaranteed to be sorted.
|
506
|
+
inline double sparseDotProduct(const CoinPackedVectorBase& op1,
|
507
|
+
const CoinPackedVectorBase& op2){
|
508
|
+
int len, i;
|
509
|
+
double acc = 0.0;
|
510
|
+
CoinPackedVector retVal;
|
511
|
+
|
512
|
+
CoinPackedVector retval = op1*op2;
|
513
|
+
len = retval.getNumElements();
|
514
|
+
double * CParray = retval.getElements();
|
515
|
+
|
516
|
+
for(i = 0; i < len; i++){
|
517
|
+
acc += CParray[i];
|
518
|
+
}
|
519
|
+
return acc;
|
520
|
+
}
|
521
|
+
|
522
|
+
|
523
|
+
/// Returns the dot product of two sorted CoinPackedVector objects.
|
524
|
+
/// The vectors should be sorted in ascending order of indices.
|
525
|
+
inline double sortedSparseDotProduct(const CoinPackedVectorBase& op1,
|
526
|
+
const CoinPackedVectorBase& op2){
|
527
|
+
int i, j, len1, len2;
|
528
|
+
double acc = 0.0;
|
529
|
+
|
530
|
+
const double* v1val = op1.getElements();
|
531
|
+
const double* v2val = op2.getElements();
|
532
|
+
const int* v1ind = op1.getIndices();
|
533
|
+
const int* v2ind = op2.getIndices();
|
534
|
+
|
535
|
+
len1 = op1.getNumElements();
|
536
|
+
len2 = op2.getNumElements();
|
537
|
+
|
538
|
+
i = 0;
|
539
|
+
j = 0;
|
540
|
+
|
541
|
+
while(i < len1 && j < len2){
|
542
|
+
if(v1ind[i] == v2ind[j]){
|
543
|
+
acc += v1val[i] * v2val[j];
|
544
|
+
i++;
|
545
|
+
j++;
|
546
|
+
}
|
547
|
+
else if(v2ind[j] < v1ind[i]){
|
548
|
+
j++;
|
549
|
+
}
|
550
|
+
else{
|
551
|
+
i++;
|
552
|
+
} // end if-else-elseif
|
553
|
+
} // end while
|
554
|
+
return acc;
|
555
|
+
}
|
556
|
+
|
557
|
+
|
558
|
+
//-----------------------------------------------------------------------------
|
559
|
+
|
560
|
+
/**@name Arithmetic operators on packed vector and a constant. <br>
|
561
|
+
These functions create a packed vector as a result. That packed vector will
|
562
|
+
have the same indices as <code>op1</code> and the specified operation is
|
563
|
+
done entry-wise with the given value. */
|
564
|
+
//@{
|
565
|
+
/// Return the sum of a packed vector and a constant
|
566
|
+
inline CoinPackedVector
|
567
|
+
operator+(const CoinPackedVectorBase& op1, double value)
|
568
|
+
{
|
569
|
+
CoinPackedVector retVal(op1);
|
570
|
+
retVal += value;
|
571
|
+
return retVal;
|
572
|
+
}
|
573
|
+
|
574
|
+
/// Return the difference of a packed vector and a constant
|
575
|
+
inline CoinPackedVector
|
576
|
+
operator-(const CoinPackedVectorBase& op1, double value)
|
577
|
+
{
|
578
|
+
CoinPackedVector retVal(op1);
|
579
|
+
retVal -= value;
|
580
|
+
return retVal;
|
581
|
+
}
|
582
|
+
|
583
|
+
/// Return the element-wise product of a packed vector and a constant
|
584
|
+
inline CoinPackedVector
|
585
|
+
operator*(const CoinPackedVectorBase& op1, double value)
|
586
|
+
{
|
587
|
+
CoinPackedVector retVal(op1);
|
588
|
+
retVal *= value;
|
589
|
+
return retVal;
|
590
|
+
}
|
591
|
+
|
592
|
+
/// Return the element-wise ratio of a packed vector and a constant
|
593
|
+
inline CoinPackedVector
|
594
|
+
operator/(const CoinPackedVectorBase& op1, double value)
|
595
|
+
{
|
596
|
+
CoinPackedVector retVal(op1);
|
597
|
+
retVal /= value;
|
598
|
+
return retVal;
|
599
|
+
}
|
600
|
+
|
601
|
+
//-----------------------------------------------------------------------------
|
602
|
+
|
603
|
+
/// Return the sum of a constant and a packed vector
|
604
|
+
inline CoinPackedVector
|
605
|
+
operator+(double value, const CoinPackedVectorBase& op1)
|
606
|
+
{
|
607
|
+
CoinPackedVector retVal(op1);
|
608
|
+
retVal += value;
|
609
|
+
return retVal;
|
610
|
+
}
|
611
|
+
|
612
|
+
/// Return the difference of a constant and a packed vector
|
613
|
+
inline CoinPackedVector
|
614
|
+
operator-(double value, const CoinPackedVectorBase& op1)
|
615
|
+
{
|
616
|
+
CoinPackedVector retVal(op1);
|
617
|
+
const int size = retVal.getNumElements();
|
618
|
+
double* elems = retVal.getElements();
|
619
|
+
for (int i = 0; i < size; ++i) {
|
620
|
+
elems[i] = value - elems[i];
|
621
|
+
}
|
622
|
+
return retVal;
|
623
|
+
}
|
624
|
+
|
625
|
+
/// Return the element-wise product of a constant and a packed vector
|
626
|
+
inline CoinPackedVector
|
627
|
+
operator*(double value, const CoinPackedVectorBase& op1)
|
628
|
+
{
|
629
|
+
CoinPackedVector retVal(op1);
|
630
|
+
retVal *= value;
|
631
|
+
return retVal;
|
632
|
+
}
|
633
|
+
|
634
|
+
/// Return the element-wise ratio of a a constant and packed vector
|
635
|
+
inline CoinPackedVector
|
636
|
+
operator/(double value, const CoinPackedVectorBase& op1)
|
637
|
+
{
|
638
|
+
CoinPackedVector retVal(op1);
|
639
|
+
const int size = retVal.getNumElements();
|
640
|
+
double* elems = retVal.getElements();
|
641
|
+
for (int i = 0; i < size; ++i) {
|
642
|
+
elems[i] = value / elems[i];
|
643
|
+
}
|
644
|
+
return retVal;
|
645
|
+
}
|
646
|
+
//@}
|
647
|
+
|
648
|
+
//#############################################################################
|
649
|
+
/** A function that tests the methods in the CoinPackedVector class. The
|
650
|
+
only reason for it not to be a member method is that this way it doesn't
|
651
|
+
have to be compiled into the library. And that's a gain, because the
|
652
|
+
library should be compiled with optimization on, but this method should be
|
653
|
+
compiled with debugging. */
|
654
|
+
void
|
655
|
+
CoinPackedVectorUnitTest();
|
656
|
+
|
657
|
+
#endif
|