qilisdk 0.1.8__cp311-cp311-win32.whl
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.
- include/eigen3/Eigen/Cholesky +45 -0
- include/eigen3/Eigen/CholmodSupport +48 -0
- include/eigen3/Eigen/Core +384 -0
- include/eigen3/Eigen/Dense +7 -0
- include/eigen3/Eigen/Eigen +2 -0
- include/eigen3/Eigen/Eigenvalues +60 -0
- include/eigen3/Eigen/Geometry +59 -0
- include/eigen3/Eigen/Householder +29 -0
- include/eigen3/Eigen/IterativeLinearSolvers +48 -0
- include/eigen3/Eigen/Jacobi +32 -0
- include/eigen3/Eigen/KLUSupport +41 -0
- include/eigen3/Eigen/LU +47 -0
- include/eigen3/Eigen/MetisSupport +35 -0
- include/eigen3/Eigen/OrderingMethods +70 -0
- include/eigen3/Eigen/PaStiXSupport +49 -0
- include/eigen3/Eigen/PardisoSupport +35 -0
- include/eigen3/Eigen/QR +50 -0
- include/eigen3/Eigen/QtAlignedMalloc +39 -0
- include/eigen3/Eigen/SPQRSupport +34 -0
- include/eigen3/Eigen/SVD +50 -0
- include/eigen3/Eigen/Sparse +34 -0
- include/eigen3/Eigen/SparseCholesky +37 -0
- include/eigen3/Eigen/SparseCore +69 -0
- include/eigen3/Eigen/SparseLU +50 -0
- include/eigen3/Eigen/SparseQR +36 -0
- include/eigen3/Eigen/StdDeque +27 -0
- include/eigen3/Eigen/StdList +26 -0
- include/eigen3/Eigen/StdVector +27 -0
- include/eigen3/Eigen/SuperLUSupport +64 -0
- include/eigen3/Eigen/UmfPackSupport +40 -0
- include/eigen3/Eigen/src/Cholesky/LDLT.h +688 -0
- include/eigen3/Eigen/src/Cholesky/LLT.h +558 -0
- include/eigen3/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
- include/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +682 -0
- include/eigen3/Eigen/src/Core/ArithmeticSequence.h +413 -0
- include/eigen3/Eigen/src/Core/Array.h +417 -0
- include/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
- include/eigen3/Eigen/src/Core/ArrayWrapper.h +209 -0
- include/eigen3/Eigen/src/Core/Assign.h +90 -0
- include/eigen3/Eigen/src/Core/AssignEvaluator.h +1010 -0
- include/eigen3/Eigen/src/Core/Assign_MKL.h +178 -0
- include/eigen3/Eigen/src/Core/BandMatrix.h +353 -0
- include/eigen3/Eigen/src/Core/Block.h +448 -0
- include/eigen3/Eigen/src/Core/BooleanRedux.h +162 -0
- include/eigen3/Eigen/src/Core/CommaInitializer.h +164 -0
- include/eigen3/Eigen/src/Core/ConditionEstimator.h +175 -0
- include/eigen3/Eigen/src/Core/CoreEvaluators.h +1741 -0
- include/eigen3/Eigen/src/Core/CoreIterators.h +132 -0
- include/eigen3/Eigen/src/Core/CwiseBinaryOp.h +183 -0
- include/eigen3/Eigen/src/Core/CwiseNullaryOp.h +1001 -0
- include/eigen3/Eigen/src/Core/CwiseTernaryOp.h +197 -0
- include/eigen3/Eigen/src/Core/CwiseUnaryOp.h +103 -0
- include/eigen3/Eigen/src/Core/CwiseUnaryView.h +132 -0
- include/eigen3/Eigen/src/Core/DenseBase.h +701 -0
- include/eigen3/Eigen/src/Core/DenseCoeffsBase.h +685 -0
- include/eigen3/Eigen/src/Core/DenseStorage.h +652 -0
- include/eigen3/Eigen/src/Core/Diagonal.h +258 -0
- include/eigen3/Eigen/src/Core/DiagonalMatrix.h +391 -0
- include/eigen3/Eigen/src/Core/DiagonalProduct.h +28 -0
- include/eigen3/Eigen/src/Core/Dot.h +318 -0
- include/eigen3/Eigen/src/Core/EigenBase.h +160 -0
- include/eigen3/Eigen/src/Core/ForceAlignedAccess.h +150 -0
- include/eigen3/Eigen/src/Core/Fuzzy.h +155 -0
- include/eigen3/Eigen/src/Core/GeneralProduct.h +465 -0
- include/eigen3/Eigen/src/Core/GenericPacketMath.h +1040 -0
- include/eigen3/Eigen/src/Core/GlobalFunctions.h +194 -0
- include/eigen3/Eigen/src/Core/IO.h +258 -0
- include/eigen3/Eigen/src/Core/IndexedView.h +237 -0
- include/eigen3/Eigen/src/Core/Inverse.h +117 -0
- include/eigen3/Eigen/src/Core/Map.h +171 -0
- include/eigen3/Eigen/src/Core/MapBase.h +310 -0
- include/eigen3/Eigen/src/Core/MathFunctions.h +2057 -0
- include/eigen3/Eigen/src/Core/MathFunctionsImpl.h +200 -0
- include/eigen3/Eigen/src/Core/Matrix.h +565 -0
- include/eigen3/Eigen/src/Core/MatrixBase.h +547 -0
- include/eigen3/Eigen/src/Core/NestByValue.h +85 -0
- include/eigen3/Eigen/src/Core/NoAlias.h +109 -0
- include/eigen3/Eigen/src/Core/NumTraits.h +335 -0
- include/eigen3/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
- include/eigen3/Eigen/src/Core/PermutationMatrix.h +605 -0
- include/eigen3/Eigen/src/Core/PlainObjectBase.h +1128 -0
- include/eigen3/Eigen/src/Core/Product.h +191 -0
- include/eigen3/Eigen/src/Core/ProductEvaluators.h +1179 -0
- include/eigen3/Eigen/src/Core/Random.h +218 -0
- include/eigen3/Eigen/src/Core/Redux.h +515 -0
- include/eigen3/Eigen/src/Core/Ref.h +381 -0
- include/eigen3/Eigen/src/Core/Replicate.h +142 -0
- include/eigen3/Eigen/src/Core/Reshaped.h +454 -0
- include/eigen3/Eigen/src/Core/ReturnByValue.h +119 -0
- include/eigen3/Eigen/src/Core/Reverse.h +217 -0
- include/eigen3/Eigen/src/Core/Select.h +164 -0
- include/eigen3/Eigen/src/Core/SelfAdjointView.h +365 -0
- include/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
- include/eigen3/Eigen/src/Core/Solve.h +188 -0
- include/eigen3/Eigen/src/Core/SolveTriangular.h +235 -0
- include/eigen3/Eigen/src/Core/SolverBase.h +168 -0
- include/eigen3/Eigen/src/Core/StableNorm.h +251 -0
- include/eigen3/Eigen/src/Core/StlIterators.h +463 -0
- include/eigen3/Eigen/src/Core/Stride.h +116 -0
- include/eigen3/Eigen/src/Core/Swap.h +68 -0
- include/eigen3/Eigen/src/Core/Transpose.h +464 -0
- include/eigen3/Eigen/src/Core/Transpositions.h +386 -0
- include/eigen3/Eigen/src/Core/TriangularMatrix.h +1001 -0
- include/eigen3/Eigen/src/Core/VectorBlock.h +96 -0
- include/eigen3/Eigen/src/Core/VectorwiseOp.h +784 -0
- include/eigen3/Eigen/src/Core/Visitor.h +381 -0
- include/eigen3/Eigen/src/Core/arch/AVX/Complex.h +372 -0
- include/eigen3/Eigen/src/Core/arch/AVX/MathFunctions.h +228 -0
- include/eigen3/Eigen/src/Core/arch/AVX/PacketMath.h +1574 -0
- include/eigen3/Eigen/src/Core/arch/AVX/TypeCasting.h +115 -0
- include/eigen3/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
- include/eigen3/Eigen/src/Core/arch/AVX512/MathFunctions.h +362 -0
- include/eigen3/Eigen/src/Core/arch/AVX512/PacketMath.h +2303 -0
- include/eigen3/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +417 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/MathFunctions.h +90 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
- include/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +2711 -0
- include/eigen3/Eigen/src/Core/arch/CUDA/Complex.h +258 -0
- include/eigen3/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
- include/eigen3/Eigen/src/Core/arch/Default/ConjHelper.h +117 -0
- include/eigen3/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
- include/eigen3/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
- include/eigen3/Eigen/src/Core/arch/Default/Half.h +942 -0
- include/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
- include/eigen3/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
- include/eigen3/Eigen/src/Core/arch/GPU/MathFunctions.h +103 -0
- include/eigen3/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
- include/eigen3/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
- include/eigen3/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
- include/eigen3/Eigen/src/Core/arch/MSA/Complex.h +648 -0
- include/eigen3/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
- include/eigen3/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
- include/eigen3/Eigen/src/Core/arch/NEON/Complex.h +584 -0
- include/eigen3/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
- include/eigen3/Eigen/src/Core/arch/NEON/MathFunctions.h +75 -0
- include/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +4587 -0
- include/eigen3/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
- include/eigen3/Eigen/src/Core/arch/SSE/Complex.h +351 -0
- include/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +199 -0
- include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +1505 -0
- include/eigen3/Eigen/src/Core/arch/SSE/TypeCasting.h +142 -0
- include/eigen3/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
- include/eigen3/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
- include/eigen3/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
- include/eigen3/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
- include/eigen3/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
- include/eigen3/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
- include/eigen3/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
- include/eigen3/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
- include/eigen3/Eigen/src/Core/arch/ZVector/Complex.h +426 -0
- include/eigen3/Eigen/src/Core/arch/ZVector/MathFunctions.h +233 -0
- include/eigen3/Eigen/src/Core/arch/ZVector/PacketMath.h +1060 -0
- include/eigen3/Eigen/src/Core/functors/AssignmentFunctors.h +177 -0
- include/eigen3/Eigen/src/Core/functors/BinaryFunctors.h +541 -0
- include/eigen3/Eigen/src/Core/functors/NullaryFunctors.h +189 -0
- include/eigen3/Eigen/src/Core/functors/StlFunctors.h +166 -0
- include/eigen3/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
- include/eigen3/Eigen/src/Core/functors/UnaryFunctors.h +1131 -0
- include/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2645 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +517 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +317 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +124 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +518 -0
- include/eigen3/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
- include/eigen3/Eigen/src/Core/products/Parallelizer.h +180 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +544 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +295 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +262 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
- include/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +94 -0
- include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +472 -0
- include/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +317 -0
- include/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
- include/eigen3/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
- include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +337 -0
- include/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +167 -0
- include/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +148 -0
- include/eigen3/Eigen/src/Core/util/BlasUtil.h +583 -0
- include/eigen3/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
- include/eigen3/Eigen/src/Core/util/Constants.h +563 -0
- include/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +106 -0
- include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +322 -0
- include/eigen3/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
- include/eigen3/Eigen/src/Core/util/IntegralConstant.h +272 -0
- include/eigen3/Eigen/src/Core/util/MKL_support.h +137 -0
- include/eigen3/Eigen/src/Core/util/Macros.h +1464 -0
- include/eigen3/Eigen/src/Core/util/Memory.h +1163 -0
- include/eigen3/Eigen/src/Core/util/Meta.h +812 -0
- include/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
- include/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +31 -0
- include/eigen3/Eigen/src/Core/util/ReshapedHelper.h +51 -0
- include/eigen3/Eigen/src/Core/util/StaticAssert.h +221 -0
- include/eigen3/Eigen/src/Core/util/SymbolicIndex.h +293 -0
- include/eigen3/Eigen/src/Core/util/XprHelper.h +856 -0
- include/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
- include/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +462 -0
- include/eigen3/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
- include/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
- include/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
- include/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
- include/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
- include/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
- include/eigen3/Eigen/src/Eigenvalues/RealQZ.h +657 -0
- include/eigen3/Eigen/src/Eigenvalues/RealSchur.h +558 -0
- include/eigen3/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
- include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +904 -0
- include/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
- include/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +561 -0
- include/eigen3/Eigen/src/Geometry/AlignedBox.h +486 -0
- include/eigen3/Eigen/src/Geometry/AngleAxis.h +247 -0
- include/eigen3/Eigen/src/Geometry/EulerAngles.h +114 -0
- include/eigen3/Eigen/src/Geometry/Homogeneous.h +501 -0
- include/eigen3/Eigen/src/Geometry/Hyperplane.h +282 -0
- include/eigen3/Eigen/src/Geometry/OrthoMethods.h +235 -0
- include/eigen3/Eigen/src/Geometry/ParametrizedLine.h +232 -0
- include/eigen3/Eigen/src/Geometry/Quaternion.h +870 -0
- include/eigen3/Eigen/src/Geometry/Rotation2D.h +199 -0
- include/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
- include/eigen3/Eigen/src/Geometry/Scaling.h +188 -0
- include/eigen3/Eigen/src/Geometry/Transform.h +1563 -0
- include/eigen3/Eigen/src/Geometry/Translation.h +202 -0
- include/eigen3/Eigen/src/Geometry/Umeyama.h +166 -0
- include/eigen3/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
- include/eigen3/Eigen/src/Householder/BlockHouseholder.h +110 -0
- include/eigen3/Eigen/src/Householder/Householder.h +176 -0
- include/eigen3/Eigen/src/Householder/HouseholderSequence.h +545 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +212 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +229 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +394 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +453 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +444 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +198 -0
- include/eigen3/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +117 -0
- include/eigen3/Eigen/src/Jacobi/Jacobi.h +483 -0
- include/eigen3/Eigen/src/KLUSupport/KLUSupport.h +358 -0
- include/eigen3/Eigen/src/LU/Determinant.h +117 -0
- include/eigen3/Eigen/src/LU/FullPivLU.h +877 -0
- include/eigen3/Eigen/src/LU/InverseImpl.h +432 -0
- include/eigen3/Eigen/src/LU/PartialPivLU.h +624 -0
- include/eigen3/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
- include/eigen3/Eigen/src/LU/arch/InverseSize4.h +351 -0
- include/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- include/eigen3/Eigen/src/OrderingMethods/Amd.h +435 -0
- include/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1863 -0
- include/eigen3/Eigen/src/OrderingMethods/Ordering.h +153 -0
- include/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
- include/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +545 -0
- include/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +674 -0
- include/eigen3/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
- include/eigen3/Eigen/src/QR/CompleteOrthogonalDecomposition.h +635 -0
- include/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +713 -0
- include/eigen3/Eigen/src/QR/HouseholderQR.h +434 -0
- include/eigen3/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
- include/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +335 -0
- include/eigen3/Eigen/src/SVD/BDCSVD.h +1366 -0
- include/eigen3/Eigen/src/SVD/JacobiSVD.h +812 -0
- include/eigen3/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
- include/eigen3/Eigen/src/SVD/SVDBase.h +376 -0
- include/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
- include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +697 -0
- include/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +174 -0
- include/eigen3/Eigen/src/SparseCore/AmbiVector.h +378 -0
- include/eigen3/Eigen/src/SparseCore/CompressedStorage.h +274 -0
- include/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
- include/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
- include/eigen3/Eigen/src/SparseCore/SparseAssign.h +270 -0
- include/eigen3/Eigen/src/SparseCore/SparseBlock.h +571 -0
- include/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- include/eigen3/Eigen/src/SparseCore/SparseCompressedBase.h +370 -0
- include/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +722 -0
- include/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +150 -0
- include/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +342 -0
- include/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
- include/eigen3/Eigen/src/SparseCore/SparseDot.h +98 -0
- include/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
- include/eigen3/Eigen/src/SparseCore/SparseMap.h +305 -0
- include/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1518 -0
- include/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +398 -0
- include/eigen3/Eigen/src/SparseCore/SparsePermutation.h +178 -0
- include/eigen3/Eigen/src/SparseCore/SparseProduct.h +181 -0
- include/eigen3/Eigen/src/SparseCore/SparseRedux.h +49 -0
- include/eigen3/Eigen/src/SparseCore/SparseRef.h +397 -0
- include/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +659 -0
- include/eigen3/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
- include/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
- include/eigen3/Eigen/src/SparseCore/SparseTranspose.h +92 -0
- include/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
- include/eigen3/Eigen/src/SparseCore/SparseUtil.h +186 -0
- include/eigen3/Eigen/src/SparseCore/SparseVector.h +478 -0
- include/eigen3/Eigen/src/SparseCore/SparseView.h +254 -0
- include/eigen3/Eigen/src/SparseCore/TriangularSolver.h +315 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU.h +923 -0
- include/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +375 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
- include/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- include/eigen3/Eigen/src/SparseQR/SparseQR.h +758 -0
- include/eigen3/Eigen/src/StlSupport/StdDeque.h +116 -0
- include/eigen3/Eigen/src/StlSupport/StdList.h +106 -0
- include/eigen3/Eigen/src/StlSupport/StdVector.h +131 -0
- include/eigen3/Eigen/src/StlSupport/details.h +84 -0
- include/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1025 -0
- include/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +642 -0
- include/eigen3/Eigen/src/misc/Image.h +82 -0
- include/eigen3/Eigen/src/misc/Kernel.h +79 -0
- include/eigen3/Eigen/src/misc/RealSvd2x2.h +55 -0
- include/eigen3/Eigen/src/misc/blas.h +440 -0
- include/eigen3/Eigen/src/misc/lapack.h +152 -0
- include/eigen3/Eigen/src/misc/lapacke.h +16292 -0
- include/eigen3/Eigen/src/misc/lapacke_mangling.h +17 -0
- include/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +358 -0
- include/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +696 -0
- include/eigen3/Eigen/src/plugins/BlockMethods.h +1442 -0
- include/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
- include/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +177 -0
- include/eigen3/Eigen/src/plugins/IndexedViewMethods.h +262 -0
- include/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
- include/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +95 -0
- include/eigen3/Eigen/src/plugins/ReshapedMethods.h +149 -0
- include/eigen3/signature_of_eigen3_matrix_library +1 -0
- include/eigen3/unsupported/Eigen/AdolcForward +159 -0
- include/eigen3/unsupported/Eigen/AlignedVector3 +234 -0
- include/eigen3/unsupported/Eigen/ArpackSupport +30 -0
- include/eigen3/unsupported/Eigen/AutoDiff +46 -0
- include/eigen3/unsupported/Eigen/BVH +95 -0
- include/eigen3/unsupported/Eigen/CXX11/Tensor +137 -0
- include/eigen3/unsupported/Eigen/CXX11/TensorSymmetry +42 -0
- include/eigen3/unsupported/Eigen/CXX11/ThreadPool +74 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +554 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorArgMax.h +329 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h +247 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h +1176 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h +1559 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h +1093 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h +518 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h +377 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContraction.h +1023 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionBlocking.h +73 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionCuda.h +6 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionGpu.h +1413 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionMapper.h +575 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionSycl.h +1650 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorContractionThreadPool.h +1679 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h +456 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h +1132 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorConvolutionSycl.h +544 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorCostModel.h +214 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorCustomOp.h +347 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDevice.h +137 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceCuda.h +6 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceDefault.h +104 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h +389 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +1048 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h +409 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h +236 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +490 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h +236 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h +983 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +703 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorExpr.h +388 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h +669 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFixedSize.h +379 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h +237 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h +191 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h +488 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h +302 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGlobalFunctions.h +33 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGpuHipCudaDefines.h +99 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorGpuHipCudaUndefines.h +44 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIO.h +79 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h +603 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h +738 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorInflation.h +247 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorInitializer.h +82 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +263 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h +216 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h +98 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMap.h +327 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h +311 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h +1102 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h +708 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h +291 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorRandom.h +322 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +998 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionCuda.h +6 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionGpu.h +966 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReductionSycl.h +582 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorRef.h +454 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h +465 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorScan.h +528 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorScanSycl.h +513 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h +471 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h +161 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h +346 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorTrace.h +303 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h +264 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorUInt128.h +249 -0
- include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h +629 -0
- include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/DynamicSymmetry.h +293 -0
- include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/StaticSymmetry.h +236 -0
- include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/Symmetry.h +338 -0
- include/eigen3/unsupported/Eigen/CXX11/src/TensorSymmetry/util/TemplateGroupTheory.h +669 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/Barrier.h +67 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/EventCount.h +249 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h +486 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/RunQueue.h +236 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadCancel.h +23 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadEnvironment.h +40 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h +301 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h +48 -0
- include/eigen3/unsupported/Eigen/CXX11/src/ThreadPool/ThreadYield.h +20 -0
- include/eigen3/unsupported/Eigen/CXX11/src/util/CXX11Meta.h +537 -0
- include/eigen3/unsupported/Eigen/CXX11/src/util/CXX11Workarounds.h +88 -0
- include/eigen3/unsupported/Eigen/CXX11/src/util/EmulateArray.h +261 -0
- include/eigen3/unsupported/Eigen/CXX11/src/util/MaxSizeVector.h +158 -0
- include/eigen3/unsupported/Eigen/EulerAngles +43 -0
- include/eigen3/unsupported/Eigen/FFT +419 -0
- include/eigen3/unsupported/Eigen/IterativeSolvers +51 -0
- include/eigen3/unsupported/Eigen/KroneckerProduct +36 -0
- include/eigen3/unsupported/Eigen/LevenbergMarquardt +49 -0
- include/eigen3/unsupported/Eigen/MPRealSupport +213 -0
- include/eigen3/unsupported/Eigen/MatrixFunctions +504 -0
- include/eigen3/unsupported/Eigen/MoreVectorization +24 -0
- include/eigen3/unsupported/Eigen/NonLinearOptimization +140 -0
- include/eigen3/unsupported/Eigen/NumericalDiff +56 -0
- include/eigen3/unsupported/Eigen/OpenGLSupport +322 -0
- include/eigen3/unsupported/Eigen/Polynomials +137 -0
- include/eigen3/unsupported/Eigen/Skyline +39 -0
- include/eigen3/unsupported/Eigen/SparseExtra +54 -0
- include/eigen3/unsupported/Eigen/SpecialFunctions +103 -0
- include/eigen3/unsupported/Eigen/Splines +35 -0
- include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h +108 -0
- include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +730 -0
- include/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h +220 -0
- include/eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h +293 -0
- include/eigen3/unsupported/Eigen/src/BVH/KdBVH.h +223 -0
- include/eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h +790 -0
- include/eigen3/unsupported/Eigen/src/EulerAngles/EulerAngles.h +355 -0
- include/eigen3/unsupported/Eigen/src/EulerAngles/EulerSystem.h +305 -0
- include/eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h +261 -0
- include/eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h +449 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h +187 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h +511 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h +335 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/IDRS.h +436 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h +90 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h +154 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h +267 -0
- include/eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h +193 -0
- include/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h +305 -0
- include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h +84 -0
- include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h +202 -0
- include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h +160 -0
- include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h +188 -0
- include/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h +396 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h +441 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h +569 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h +373 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +705 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h +368 -0
- include/eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h +117 -0
- include/eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h +95 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h +601 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h +657 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h +66 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h +70 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +107 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h +79 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h +298 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h +91 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h +30 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1updt.h +99 -0
- include/eigen3/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h +49 -0
- include/eigen3/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h +130 -0
- include/eigen3/unsupported/Eigen/src/Polynomials/Companion.h +280 -0
- include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialSolver.h +428 -0
- include/eigen3/unsupported/Eigen/src/Polynomials/PolynomialUtils.h +143 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h +352 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrix.h +862 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h +212 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineProduct.h +295 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h +259 -0
- include/eigen3/unsupported/Eigen/src/Skyline/SkylineUtil.h +89 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h +122 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/BlockSparseMatrix.h +1079 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h +404 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h +282 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h +247 -0
- include/eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h +349 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsArrayAPI.h +286 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsBFloat16.h +68 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsFunctors.h +357 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsHalf.h +66 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsImpl.h +1959 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/BesselFunctionsPacketMath.h +118 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/HipVectorCompatibility.h +67 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsArrayAPI.h +167 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsBFloat16.h +58 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsFunctors.h +330 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsHalf.h +58 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsImpl.h +2045 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/SpecialFunctionsPacketMath.h +79 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX/BesselFunctions.h +46 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX/SpecialFunctions.h +16 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX512/BesselFunctions.h +46 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/AVX512/SpecialFunctions.h +16 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/GPU/SpecialFunctions.h +369 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/NEON/BesselFunctions.h +54 -0
- include/eigen3/unsupported/Eigen/src/SpecialFunctions/arch/NEON/SpecialFunctions.h +34 -0
- include/eigen3/unsupported/Eigen/src/Splines/Spline.h +507 -0
- include/eigen3/unsupported/Eigen/src/Splines/SplineFitting.h +431 -0
- include/eigen3/unsupported/Eigen/src/Splines/SplineFwd.h +93 -0
- qilisdk/__init__.py +26 -0
- qilisdk/__init__.pyi +16 -0
- qilisdk/_logging.py +135 -0
- qilisdk/_optionals.py +137 -0
- qilisdk/analog/__init__.py +18 -0
- qilisdk/analog/exceptions.py +17 -0
- qilisdk/analog/hamiltonian.py +1068 -0
- qilisdk/analog/schedule.py +483 -0
- qilisdk/backends/__init__.py +46 -0
- qilisdk/backends/__init__.pyi +18 -0
- qilisdk/backends/backend.py +132 -0
- qilisdk/backends/cuda_backend.py +752 -0
- qilisdk/backends/qilisim.py +148 -0
- qilisdk/backends/qutip_backend.py +504 -0
- qilisdk/core/__init__.py +70 -0
- qilisdk/core/exceptions.py +29 -0
- qilisdk/core/interpolator.py +640 -0
- qilisdk/core/model.py +1012 -0
- qilisdk/core/parameterizable.py +133 -0
- qilisdk/core/qtensor.py +684 -0
- qilisdk/core/result.py +18 -0
- qilisdk/core/types.py +49 -0
- qilisdk/core/variables.py +2035 -0
- qilisdk/cost_functions/__init__.py +18 -0
- qilisdk/cost_functions/cost_function.py +77 -0
- qilisdk/cost_functions/model_cost_function.py +152 -0
- qilisdk/cost_functions/observable_cost_function.py +112 -0
- qilisdk/digital/__init__.py +67 -0
- qilisdk/digital/ansatz.py +382 -0
- qilisdk/digital/circuit.py +371 -0
- qilisdk/digital/circuit_transpiler.py +46 -0
- qilisdk/digital/circuit_transpiler_passes/__init__.py +18 -0
- qilisdk/digital/circuit_transpiler_passes/circuit_transpiler_pass.py +36 -0
- qilisdk/digital/circuit_transpiler_passes/decompose_multi_controlled_gates_pass.py +220 -0
- qilisdk/digital/circuit_transpiler_passes/numeric_helpers.py +82 -0
- qilisdk/digital/exceptions.py +37 -0
- qilisdk/digital/gates.py +1308 -0
- qilisdk/experiments/__init__.py +36 -0
- qilisdk/experiments/experiment_functional.py +212 -0
- qilisdk/experiments/experiment_result.py +247 -0
- qilisdk/functionals/__init__.py +29 -0
- qilisdk/functionals/functional.py +39 -0
- qilisdk/functionals/functional_result.py +18 -0
- qilisdk/functionals/sampling.py +89 -0
- qilisdk/functionals/sampling_result.py +92 -0
- qilisdk/functionals/time_evolution.py +111 -0
- qilisdk/functionals/time_evolution_result.py +91 -0
- qilisdk/functionals/variational_program.py +138 -0
- qilisdk/functionals/variational_program_result.py +69 -0
- qilisdk/logging_config.yaml +16 -0
- qilisdk/noise/__init__.py +56 -0
- qilisdk/noise/amplitude_damping.py +71 -0
- qilisdk/noise/bit_flip.py +45 -0
- qilisdk/noise/dephasing.py +69 -0
- qilisdk/noise/depolarizing.py +44 -0
- qilisdk/noise/gaussian_perturbation.py +69 -0
- qilisdk/noise/noise.py +20 -0
- qilisdk/noise/noise_abc.py +31 -0
- qilisdk/noise/noise_config.py +77 -0
- qilisdk/noise/noise_model.py +259 -0
- qilisdk/noise/offset_perturbation.py +39 -0
- qilisdk/noise/parameter_perturbation.py +45 -0
- qilisdk/noise/pauli_channel.py +115 -0
- qilisdk/noise/phase_flip.py +45 -0
- qilisdk/noise/protocols.py +107 -0
- qilisdk/noise/readout_assignment.py +60 -0
- qilisdk/noise/representations.py +149 -0
- qilisdk/noise/utils.py +90 -0
- qilisdk/optimizers/__init__.py +17 -0
- qilisdk/optimizers/optimizer.py +39 -0
- qilisdk/optimizers/optimizer_result.py +101 -0
- qilisdk/optimizers/scipy_optimizer.py +118 -0
- qilisdk/py.typed +0 -0
- qilisdk/settings.py +103 -0
- qilisdk/speqtrum/__init__.py +41 -0
- qilisdk/speqtrum/__init__.pyi +18 -0
- qilisdk/speqtrum/keyring.py +58 -0
- qilisdk/speqtrum/speqtrum.py +817 -0
- qilisdk/speqtrum/speqtrum_models.py +560 -0
- qilisdk/utils/__init__.py +13 -0
- qilisdk/utils/openfermion/__init__.py +38 -0
- qilisdk/utils/openfermion/__init__.pyi +17 -0
- qilisdk/utils/openfermion/openfermion.py +45 -0
- qilisdk/utils/openqasm2.py +215 -0
- qilisdk/utils/serialization.py +128 -0
- qilisdk/utils/trotterization/__init__.py +18 -0
- qilisdk/utils/trotterization/trotterization.py +127 -0
- qilisdk/utils/visualization/PlusJakartaSans-SemiBold.ttf +0 -0
- qilisdk/utils/visualization/__init__.py +24 -0
- qilisdk/utils/visualization/circuit_renderers.py +781 -0
- qilisdk/utils/visualization/schedule_renderers.py +175 -0
- qilisdk/utils/visualization/style.py +154 -0
- qilisdk/utils/visualization/themes.py +76 -0
- qilisdk/yaml.py +260 -0
- qilisdk-0.1.8.dist-info/METADATA +657 -0
- qilisdk-0.1.8.dist-info/RECORD +633 -0
- qilisdk-0.1.8.dist-info/WHEEL +5 -0
- qilisdk-0.1.8.dist-info/licenses/LICENCE +201 -0
- qilisim_module.cp311-win32.pyd +0 -0
- share/eigen3/cmake/Eigen3Config.cmake +37 -0
- share/eigen3/cmake/Eigen3ConfigVersion.cmake +65 -0
- share/eigen3/cmake/Eigen3Targets.cmake +106 -0
- share/eigen3/cmake/UseEigen3.cmake +6 -0
qilisdk/core/model.py
ADDED
|
@@ -0,0 +1,1012 @@
|
|
|
1
|
+
# Copyright 2025 Qilimanjaro Quantum Tech
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# import numpy as np
|
|
17
|
+
import copy
|
|
18
|
+
from typing import TYPE_CHECKING, Literal, Mapping, Type
|
|
19
|
+
|
|
20
|
+
# import cupy as np
|
|
21
|
+
import numpy as np
|
|
22
|
+
from loguru import logger
|
|
23
|
+
|
|
24
|
+
from qilisdk.settings import get_settings
|
|
25
|
+
from qilisdk.yaml import yaml
|
|
26
|
+
|
|
27
|
+
from .types import QiliEnum
|
|
28
|
+
from .variables import (
|
|
29
|
+
GEQ,
|
|
30
|
+
LEQ,
|
|
31
|
+
BaseVariable,
|
|
32
|
+
Bitwise,
|
|
33
|
+
ComparisonOperation,
|
|
34
|
+
ComparisonTerm,
|
|
35
|
+
Domain,
|
|
36
|
+
Number,
|
|
37
|
+
Operation,
|
|
38
|
+
RealNumber,
|
|
39
|
+
Term,
|
|
40
|
+
Variable,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from qilisdk.analog.hamiltonian import Hamiltonian
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class SlackCounter:
|
|
48
|
+
"""A singleton class to generate a slack counter id that increments continuously within the user's active session."""
|
|
49
|
+
|
|
50
|
+
_instance: SlackCounter | None = None
|
|
51
|
+
_count: int = 0
|
|
52
|
+
|
|
53
|
+
def __new__(cls: Type[SlackCounter]) -> SlackCounter: # noqa: PYI034
|
|
54
|
+
if cls._instance is None:
|
|
55
|
+
cls._instance = super().__new__(cls)
|
|
56
|
+
return cls._instance
|
|
57
|
+
|
|
58
|
+
def next(self) -> int:
|
|
59
|
+
"""Return the next counter value and increment the counter."""
|
|
60
|
+
value = self._count
|
|
61
|
+
self._count += 1
|
|
62
|
+
return value
|
|
63
|
+
|
|
64
|
+
def reset_counter(self) -> None:
|
|
65
|
+
self._count = 0
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@yaml.register_class
|
|
69
|
+
class ObjectiveSense(QiliEnum):
|
|
70
|
+
"""An Enumeration of the Objective sense options."""
|
|
71
|
+
|
|
72
|
+
MINIMIZE = "minimize"
|
|
73
|
+
MAXIMIZE = "maximize"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@yaml.register_class
|
|
77
|
+
class Constraint:
|
|
78
|
+
"""
|
|
79
|
+
Represent a symbolic constraint inside a ``Model``.
|
|
80
|
+
|
|
81
|
+
Example:
|
|
82
|
+
.. code-block:: python
|
|
83
|
+
|
|
84
|
+
from qilisdk.core.model import Constraint
|
|
85
|
+
from qilisdk.core.variables import BinaryVariable, LEQ
|
|
86
|
+
|
|
87
|
+
x = BinaryVariable("x")
|
|
88
|
+
constraint = Constraint("limit", LEQ(x, 1))
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
def __init__(self, label: str, term: ComparisonTerm) -> None:
|
|
92
|
+
"""
|
|
93
|
+
Build a constraint defined by a comparison term such as ``x + y <= 2``.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
label (str): The constraint's label.
|
|
97
|
+
term (ComparisonTerm): The comparison term that defines the constraint.
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
ValueError: if the term provided is not a ConstraintTerm.
|
|
101
|
+
"""
|
|
102
|
+
self._label = label
|
|
103
|
+
if not isinstance(term, ComparisonTerm):
|
|
104
|
+
raise ValueError(f"the parameter term is expecting a {ComparisonTerm} but received {term.__class__}")
|
|
105
|
+
|
|
106
|
+
self._term = term
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def label(self) -> str:
|
|
110
|
+
"""
|
|
111
|
+
Returns:
|
|
112
|
+
str: The label of the constraint object.
|
|
113
|
+
"""
|
|
114
|
+
return self._label
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def term(self) -> ComparisonTerm:
|
|
118
|
+
"""
|
|
119
|
+
Returns:
|
|
120
|
+
ComparisonTerm: The comparison term of the constraint object.
|
|
121
|
+
"""
|
|
122
|
+
return self._term
|
|
123
|
+
|
|
124
|
+
def variables(self) -> list[BaseVariable]:
|
|
125
|
+
"""
|
|
126
|
+
Returns the list of variables in the constraint term.
|
|
127
|
+
|
|
128
|
+
:rtype: list[BaseVariable]
|
|
129
|
+
Returns:
|
|
130
|
+
list[BaseVariable]: the list of variables in the constraint term.
|
|
131
|
+
"""
|
|
132
|
+
return self._term.variables()
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def lhs(self) -> Term:
|
|
136
|
+
"""
|
|
137
|
+
Returns:
|
|
138
|
+
Term: The left hand side of the constraint term.
|
|
139
|
+
"""
|
|
140
|
+
return self.term.lhs
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def rhs(self) -> Term:
|
|
144
|
+
"""
|
|
145
|
+
Returns:
|
|
146
|
+
Term: The right hand side of the constraint term.
|
|
147
|
+
"""
|
|
148
|
+
return self.term.rhs
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def degree(self) -> int:
|
|
152
|
+
"""
|
|
153
|
+
Returns:
|
|
154
|
+
int: The degree of the constraint term.
|
|
155
|
+
"""
|
|
156
|
+
return max(self.lhs.degree, self.rhs.degree)
|
|
157
|
+
|
|
158
|
+
def __copy__(self) -> Constraint:
|
|
159
|
+
return Constraint(label=self.label, term=copy.copy(self.term))
|
|
160
|
+
|
|
161
|
+
def __repr__(self) -> str:
|
|
162
|
+
return f"{self.label}: {self.term}"
|
|
163
|
+
|
|
164
|
+
def __str__(self) -> str:
|
|
165
|
+
return f"{self.label}: {self.term}"
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@yaml.register_class
|
|
169
|
+
class Objective:
|
|
170
|
+
"""
|
|
171
|
+
Represent the scalar objective function optimized by a ``Model``.
|
|
172
|
+
|
|
173
|
+
Example:
|
|
174
|
+
.. code-block:: python
|
|
175
|
+
|
|
176
|
+
from qilisdk.core.model import Objective, ObjectiveSense
|
|
177
|
+
from qilisdk.core.variables import BinaryVariable
|
|
178
|
+
|
|
179
|
+
x = BinaryVariable("x")
|
|
180
|
+
obj = Objective("profit", 3 * x, sense=ObjectiveSense.MAXIMIZE)
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
def __init__(self, label: str, term: BaseVariable | Term, sense: ObjectiveSense = ObjectiveSense.MINIMIZE) -> None:
|
|
184
|
+
"""
|
|
185
|
+
Build a new objective function.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
label (str): Objective label.
|
|
189
|
+
term (BaseVariable | Term): Expression to minimize or maximize.
|
|
190
|
+
sense (ObjectiveSense, optional): Optimization sense. Defaults to ``ObjectiveSense.MINIMIZE``.
|
|
191
|
+
|
|
192
|
+
Raises:
|
|
193
|
+
ValueError: if the term provided is not a Term Object.
|
|
194
|
+
ValueError: if the optimization sense provided is not one that is defined by the ObjectiveSense Enum.
|
|
195
|
+
"""
|
|
196
|
+
if isinstance(term, Variable):
|
|
197
|
+
term = Term(elements=[term], operation=Operation.ADD)
|
|
198
|
+
if not isinstance(term, Term):
|
|
199
|
+
raise ValueError(f"the parameter term is expecting a {Term} but received {term.__class__}")
|
|
200
|
+
if not isinstance(sense, ObjectiveSense):
|
|
201
|
+
raise ValueError(f"the objective sense is expecting a {ObjectiveSense} but received {sense.__class__}")
|
|
202
|
+
self._term = term
|
|
203
|
+
self._label = label
|
|
204
|
+
self._sense = sense
|
|
205
|
+
|
|
206
|
+
@property
|
|
207
|
+
def label(self) -> str:
|
|
208
|
+
"""
|
|
209
|
+
Returns:
|
|
210
|
+
str: the label of the objective.
|
|
211
|
+
"""
|
|
212
|
+
return self._label
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def term(self) -> Term:
|
|
216
|
+
"""
|
|
217
|
+
Returns:
|
|
218
|
+
Term: the objective term.
|
|
219
|
+
"""
|
|
220
|
+
return self._term
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def sense(self) -> ObjectiveSense:
|
|
224
|
+
"""
|
|
225
|
+
Returns:
|
|
226
|
+
ObjectiveSense: the objective optimization sense.
|
|
227
|
+
"""
|
|
228
|
+
return self._sense
|
|
229
|
+
|
|
230
|
+
def variables(self) -> list[BaseVariable]:
|
|
231
|
+
"""Gathers a list of all the variables in the objective term.
|
|
232
|
+
|
|
233
|
+
Returns:
|
|
234
|
+
list[BaseVariable]: the list of variables in the objective term.
|
|
235
|
+
"""
|
|
236
|
+
return self._term.variables()
|
|
237
|
+
|
|
238
|
+
def __repr__(self) -> str:
|
|
239
|
+
return f"{self.label}: {self.term}"
|
|
240
|
+
|
|
241
|
+
def __str__(self) -> str:
|
|
242
|
+
return f"{self.label}: {self.term}"
|
|
243
|
+
|
|
244
|
+
def __copy__(self) -> Objective:
|
|
245
|
+
return Objective(label=self.label, term=copy.copy(self.term), sense=self.sense)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@yaml.register_class
|
|
249
|
+
class Model:
|
|
250
|
+
"""
|
|
251
|
+
Aggregate an objective and constraints into an optimization problem.
|
|
252
|
+
|
|
253
|
+
Example:
|
|
254
|
+
.. code-block:: python
|
|
255
|
+
|
|
256
|
+
from qilisdk.core import BinaryVariable, LEQ, Model
|
|
257
|
+
|
|
258
|
+
num_items = 4
|
|
259
|
+
values = [1, 3, 5, 2]
|
|
260
|
+
weights = [3, 2, 4, 5]
|
|
261
|
+
max_weight = 6
|
|
262
|
+
bin_vars = [BinaryVariable(f"b{i}") for i in range(num_items)]
|
|
263
|
+
model = Model("Knapsack")
|
|
264
|
+
objective = sum(values[i] * bin_vars[i] for i in range(num_items))
|
|
265
|
+
model.set_objective(objective)
|
|
266
|
+
constraint = LEQ(sum(weights[i] * bin_vars[i] for i in range(num_items)), max_weight)
|
|
267
|
+
model.add_constraint("maximum weight", constraint)
|
|
268
|
+
|
|
269
|
+
print(model)
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
def __init__(self, label: str) -> None:
|
|
273
|
+
"""
|
|
274
|
+
Args:
|
|
275
|
+
label (str): Model label.
|
|
276
|
+
"""
|
|
277
|
+
self._constraints: dict[str, Constraint] = {}
|
|
278
|
+
self._encoding_constraints: dict[str, Constraint] = {}
|
|
279
|
+
self._lagrange_multipliers: dict[str, float] = {}
|
|
280
|
+
self._objective = Objective("objective", Term([0], Operation.ADD))
|
|
281
|
+
self._label = label
|
|
282
|
+
|
|
283
|
+
@property
|
|
284
|
+
def lagrange_multipliers(self) -> dict[str, float]:
|
|
285
|
+
return self._lagrange_multipliers
|
|
286
|
+
|
|
287
|
+
def set_lagrange_multiplier(self, constraint_label: str, lagrange_multiplier: float) -> None:
|
|
288
|
+
"""Sets the lagrange multiplier value for a given constraint.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
constraint_label (str): the constraint to which the lagrange multiplier value corresponds.
|
|
292
|
+
lagrange_multiplier (float): the lagrange multiplier value.
|
|
293
|
+
|
|
294
|
+
Raises:
|
|
295
|
+
ValueError: if the constraint provided is not in the model.
|
|
296
|
+
"""
|
|
297
|
+
if constraint_label not in self._lagrange_multipliers:
|
|
298
|
+
raise ValueError(f'constraint "{constraint_label}" not in model.')
|
|
299
|
+
self.lagrange_multipliers[constraint_label] = lagrange_multiplier
|
|
300
|
+
|
|
301
|
+
@property
|
|
302
|
+
def label(self) -> str:
|
|
303
|
+
"""
|
|
304
|
+
Returns:
|
|
305
|
+
str: The model label.
|
|
306
|
+
"""
|
|
307
|
+
return self._label
|
|
308
|
+
|
|
309
|
+
@property
|
|
310
|
+
def constraints(self) -> list[Constraint]:
|
|
311
|
+
"""
|
|
312
|
+
Returns:
|
|
313
|
+
list[Constraint]: a list of all the constraints in the model.
|
|
314
|
+
"""
|
|
315
|
+
return list(self._constraints.values())
|
|
316
|
+
|
|
317
|
+
@property
|
|
318
|
+
def encoding_constraints(self) -> list[Constraint]:
|
|
319
|
+
"""
|
|
320
|
+
Returns:
|
|
321
|
+
list[Constraint]: a list of all variable encoding constraints in the model.
|
|
322
|
+
"""
|
|
323
|
+
return list(self._encoding_constraints.values())
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def objective(self) -> Objective:
|
|
327
|
+
"""
|
|
328
|
+
Returns:
|
|
329
|
+
Objective: The objective of the model.
|
|
330
|
+
"""
|
|
331
|
+
return self._objective
|
|
332
|
+
|
|
333
|
+
def variables(self) -> list[BaseVariable]:
|
|
334
|
+
"""
|
|
335
|
+
Returns:
|
|
336
|
+
list[BaseVariable]: a list of variables that are used in the model whether that is in the constraints
|
|
337
|
+
or the objective.
|
|
338
|
+
"""
|
|
339
|
+
var = set()
|
|
340
|
+
|
|
341
|
+
for c in self.constraints:
|
|
342
|
+
var.update(c.variables())
|
|
343
|
+
|
|
344
|
+
var.update(self.objective.variables())
|
|
345
|
+
|
|
346
|
+
return sorted(var, key=lambda x: x.label)
|
|
347
|
+
|
|
348
|
+
def _generate_encoding_constraints(
|
|
349
|
+
self,
|
|
350
|
+
lagrange_multiplier: float = 100,
|
|
351
|
+
) -> None:
|
|
352
|
+
for var in self.variables():
|
|
353
|
+
if not isinstance(var, Variable) or var.domain in {Domain.BINARY, Domain.SPIN}:
|
|
354
|
+
continue
|
|
355
|
+
ub_encoding_name = f"{var}_upper_bound_constraint"
|
|
356
|
+
lb_encoding_name = f"{var}_lower_bound_constraint"
|
|
357
|
+
if ub_encoding_name not in self._encoding_constraints:
|
|
358
|
+
self._encoding_constraints[ub_encoding_name] = Constraint(
|
|
359
|
+
label=ub_encoding_name, term=LEQ(var, var.upper_bound)
|
|
360
|
+
)
|
|
361
|
+
self._lagrange_multipliers[ub_encoding_name] = lagrange_multiplier
|
|
362
|
+
if lb_encoding_name not in self._encoding_constraints:
|
|
363
|
+
self._encoding_constraints[lb_encoding_name] = Constraint(
|
|
364
|
+
label=lb_encoding_name, term=GEQ(var, var.lower_bound)
|
|
365
|
+
)
|
|
366
|
+
self._lagrange_multipliers[lb_encoding_name] = lagrange_multiplier
|
|
367
|
+
|
|
368
|
+
def __str__(self) -> str:
|
|
369
|
+
output = f"Model name: {self.label} \n"
|
|
370
|
+
if self.objective is not None:
|
|
371
|
+
output += (
|
|
372
|
+
f"objective ({self.objective.label}):"
|
|
373
|
+
+ f" \n\t {self.objective.sense.value} : \n\t {self.objective.term} \n\n"
|
|
374
|
+
)
|
|
375
|
+
if len(self.constraints) > 0:
|
|
376
|
+
output += "subject to the constraint/s: \n"
|
|
377
|
+
for c in self.constraints:
|
|
378
|
+
output += f"\t {c} \n"
|
|
379
|
+
output += "\n"
|
|
380
|
+
|
|
381
|
+
if len(self.encoding_constraints) > 0:
|
|
382
|
+
output += "subject to the encoding constraint/s: \n"
|
|
383
|
+
for c in self.encoding_constraints:
|
|
384
|
+
output += f"\t {c} \n"
|
|
385
|
+
output += "\n"
|
|
386
|
+
|
|
387
|
+
if len(self.lagrange_multipliers) > 0:
|
|
388
|
+
output += "With Lagrange Multiplier/s: \n"
|
|
389
|
+
for key, value in self.lagrange_multipliers.items():
|
|
390
|
+
output += f"\t {key} : {value} \n"
|
|
391
|
+
return output
|
|
392
|
+
|
|
393
|
+
def __repr__(self) -> str:
|
|
394
|
+
return self.label
|
|
395
|
+
|
|
396
|
+
def __copy__(self) -> Model:
|
|
397
|
+
out = Model(label=self.label)
|
|
398
|
+
obj = copy.copy(self.objective)
|
|
399
|
+
out.set_objective(term=obj.term, label=obj.label, sense=obj.sense)
|
|
400
|
+
for c in self.constraints:
|
|
401
|
+
out.add_constraint(label=c.label, term=copy.copy(c.term))
|
|
402
|
+
return out
|
|
403
|
+
|
|
404
|
+
def add_constraint(
|
|
405
|
+
self,
|
|
406
|
+
label: str,
|
|
407
|
+
term: ComparisonTerm,
|
|
408
|
+
lagrange_multiplier: float = 100,
|
|
409
|
+
) -> None:
|
|
410
|
+
"""Add a constraint to the model.
|
|
411
|
+
|
|
412
|
+
Args:
|
|
413
|
+
label (str): constraint label.
|
|
414
|
+
term (ComparisonTerm): The constraint's comparison term.
|
|
415
|
+
|
|
416
|
+
Raises:
|
|
417
|
+
ValueError: if the constraint label is already used in the model.
|
|
418
|
+
"""
|
|
419
|
+
if label in self._constraints:
|
|
420
|
+
raise ValueError((f'Constraint "{label}" already exists:\n \t\t{self._constraints[label]}'))
|
|
421
|
+
c = Constraint(label=label, term=copy.copy(term))
|
|
422
|
+
self._constraints[label] = c
|
|
423
|
+
self._lagrange_multipliers[label] = lagrange_multiplier
|
|
424
|
+
self._generate_encoding_constraints(lagrange_multiplier=lagrange_multiplier)
|
|
425
|
+
|
|
426
|
+
def set_objective(self, term: Term, label: str = "obj", sense: ObjectiveSense = ObjectiveSense.MINIMIZE) -> None:
|
|
427
|
+
"""Sets the model's objective.
|
|
428
|
+
|
|
429
|
+
Args:
|
|
430
|
+
term (Term): the objective term.
|
|
431
|
+
label (str, optional): the objective's label. Defaults to "obj".
|
|
432
|
+
sense (ObjectiveSense, optional): The optimization sense of the model's objective.
|
|
433
|
+
Defaults to ObjectiveSense.MINIMIZE.
|
|
434
|
+
"""
|
|
435
|
+
self._objective = Objective(label=label, term=copy.copy(term), sense=sense)
|
|
436
|
+
self._generate_encoding_constraints()
|
|
437
|
+
|
|
438
|
+
def evaluate(self, sample: Mapping[BaseVariable, RealNumber | list[int]]) -> dict[str, Number]:
|
|
439
|
+
"""Evaluates the objective and the constraints of the model given a set of values for the variables.
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
sample (Mapping[BaseVariable, Number | list[int]]): The dictionary maps the variable to the value to be
|
|
443
|
+
used during the evaluation. In case the variable is
|
|
444
|
+
continuous (Not Binary or Spin) then the value could
|
|
445
|
+
either be a number or a list of binary bits that
|
|
446
|
+
correspond to the encoding of the variable.
|
|
447
|
+
Note: All the model's variables must be provided for
|
|
448
|
+
the model to be evaluated.
|
|
449
|
+
|
|
450
|
+
Returns:
|
|
451
|
+
dict[str, float]: a dictionary that maps the name of the objective/constraint to it's evaluated value.
|
|
452
|
+
Note: For constraints, the value is equal to lagrange multiplier of that constraint if
|
|
453
|
+
the constraint is not satisfied or 0 otherwise.
|
|
454
|
+
"""
|
|
455
|
+
results = {}
|
|
456
|
+
|
|
457
|
+
results[self.objective.label] = self.objective.term.evaluate(sample)
|
|
458
|
+
results[self.objective.label] *= -1 if self.objective.sense is ObjectiveSense.MAXIMIZE else 1
|
|
459
|
+
|
|
460
|
+
for c in self.constraints:
|
|
461
|
+
results[c.label] = float(not c.term.evaluate(sample)) * self.lagrange_multipliers[c.label]
|
|
462
|
+
return results
|
|
463
|
+
|
|
464
|
+
def to_qubo(
|
|
465
|
+
self,
|
|
466
|
+
lagrange_multiplier_dict: dict[str, float] | None = None,
|
|
467
|
+
penalization: Literal["unbalanced", "slack"] = "slack",
|
|
468
|
+
parameters: list[float] | None = None,
|
|
469
|
+
) -> QUBO:
|
|
470
|
+
"""Export the model to a qubo model.
|
|
471
|
+
Args:
|
|
472
|
+
lagrange_multiplier_dict (dict[str, float] | None, optional): A dictionary with lagrange multiplier values to scale the model's constraints. Defaults to None.
|
|
473
|
+
penalization (Literal["unbalanced", "slack"], optional): the penalization used to handel inequality constraints. Defaults to "slack".
|
|
474
|
+
parameters (list[float] | None, optional): the parameters used for the unbalanced penalization method. Defaults to None.
|
|
475
|
+
|
|
476
|
+
Note:
|
|
477
|
+
this exportation only works if the model doesn't violate the QUBO format.
|
|
478
|
+
Automatic constraint and objective linearization will be added in the future.
|
|
479
|
+
Returns:
|
|
480
|
+
QUBO: A QUBO model that is generate from the model object.
|
|
481
|
+
"""
|
|
482
|
+
if lagrange_multiplier_dict is None:
|
|
483
|
+
lagrange_multiplier_dict = {}
|
|
484
|
+
for lm in self.lagrange_multipliers:
|
|
485
|
+
if lm not in lagrange_multiplier_dict:
|
|
486
|
+
lagrange_multiplier_dict[lm] = self.lagrange_multipliers[lm]
|
|
487
|
+
return QUBO.from_model(self, lagrange_multiplier_dict, penalization, parameters)
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@yaml.register_class
|
|
491
|
+
class QUBO(Model):
|
|
492
|
+
"""
|
|
493
|
+
Specialized ``Model`` constrained to Quadratic Unconstrained Binary Optimization form.
|
|
494
|
+
|
|
495
|
+
Example:
|
|
496
|
+
.. code-block:: python
|
|
497
|
+
|
|
498
|
+
from qilisdk.core.model import QUBO
|
|
499
|
+
from qilisdk.core.variables import BinaryVariable
|
|
500
|
+
|
|
501
|
+
x0, x1 = BinaryVariable("x0"), BinaryVariable("x1")
|
|
502
|
+
qubo = QUBO("Example")
|
|
503
|
+
qubo.set_objective((x0 + x1) ** 2)
|
|
504
|
+
"""
|
|
505
|
+
|
|
506
|
+
def __init__(self, label: str) -> None:
|
|
507
|
+
"""
|
|
508
|
+
Args:
|
|
509
|
+
label (str): QUBO model label.
|
|
510
|
+
"""
|
|
511
|
+
super().__init__(label)
|
|
512
|
+
self.continuous_vars: dict[str, Variable] = {}
|
|
513
|
+
self.__qubo_objective: Objective | None = None
|
|
514
|
+
|
|
515
|
+
@property
|
|
516
|
+
def qubo_objective(self) -> Objective | None:
|
|
517
|
+
"""
|
|
518
|
+
Returns:
|
|
519
|
+
Objective | None: The QUBO objective (factoring in the constraints and objective of the model). If the objective and constraints are not defined in the model, this property returns None.
|
|
520
|
+
"""
|
|
521
|
+
self.__qubo_objective = None
|
|
522
|
+
if self.objective is not None:
|
|
523
|
+
self._build_qubo_objective(self.objective.term, self.objective.label, self.objective.sense)
|
|
524
|
+
for constraint in self.constraints:
|
|
525
|
+
if constraint.label in self.lagrange_multipliers:
|
|
526
|
+
self._build_qubo_objective(
|
|
527
|
+
constraint.term.lhs * self.lagrange_multipliers[constraint.label]
|
|
528
|
+
- constraint.term.rhs * self.lagrange_multipliers[constraint.label]
|
|
529
|
+
)
|
|
530
|
+
else:
|
|
531
|
+
self._build_qubo_objective(
|
|
532
|
+
constraint.term.lhs - constraint.term.rhs
|
|
533
|
+
) # I don't think this line can be reached.
|
|
534
|
+
return self.__qubo_objective
|
|
535
|
+
|
|
536
|
+
def __repr__(self) -> str:
|
|
537
|
+
return self.label
|
|
538
|
+
|
|
539
|
+
def _parse_term(self, term: Term) -> tuple[Number, list[tuple[Number, BaseVariable]]]:
|
|
540
|
+
"""parses a Term object into a list of variables and coefficients.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
term (Term): The term to be parsed.
|
|
544
|
+
|
|
545
|
+
Raises:
|
|
546
|
+
ValueError: if the degree of the term is higher than 1.
|
|
547
|
+
|
|
548
|
+
Returns:
|
|
549
|
+
tuple[Number, list[tuple[Number, BaseVariable]]]:
|
|
550
|
+
The first return value is the constant value in the term.
|
|
551
|
+
The second return value is a list of variables and their respective coefficients.
|
|
552
|
+
"""
|
|
553
|
+
const = term.get_constant()
|
|
554
|
+
terms: list[tuple[Number, BaseVariable]] = []
|
|
555
|
+
|
|
556
|
+
if term.degree > 1:
|
|
557
|
+
raise ValueError(f'QUBO constraints only allow linear terms but received "{term}" of degree {term.degree}')
|
|
558
|
+
|
|
559
|
+
if term.operation is Operation.ADD:
|
|
560
|
+
for element in term:
|
|
561
|
+
if isinstance(element, Term): # I don't think this will ever be true for a QUBO model.
|
|
562
|
+
_, aux_terms = self._parse_term(element)
|
|
563
|
+
terms.extend(aux_terms)
|
|
564
|
+
elif element != Term.CONST:
|
|
565
|
+
terms.append((term[element], element))
|
|
566
|
+
if term.operation is Operation.MUL:
|
|
567
|
+
for element in term:
|
|
568
|
+
if not isinstance(element, Term) and element != Term.CONST:
|
|
569
|
+
terms.append((1, element))
|
|
570
|
+
return const, terms
|
|
571
|
+
|
|
572
|
+
def _check_valid_constraint(self, label: str, term: Term, operation: ComparisonOperation) -> int | None:
|
|
573
|
+
"""Checks if a given constraint is valid. Assumes that the right hand side of the constraint is set to zero.
|
|
574
|
+
|
|
575
|
+
Args:
|
|
576
|
+
label (str): the label of the constraint.
|
|
577
|
+
term (Term): the left hand side of the constraint term.
|
|
578
|
+
operation (ComparisonOperation): the comparison operation between the left and right hand sides.
|
|
579
|
+
|
|
580
|
+
Raises:
|
|
581
|
+
ValueError: if the constraint is never feasible given the variable ranges.
|
|
582
|
+
|
|
583
|
+
Returns:
|
|
584
|
+
int | None: the upper bound of the continuous slack variable needed for this given constraint.
|
|
585
|
+
None in case the constraint is always feasible.
|
|
586
|
+
"""
|
|
587
|
+
ub = np.iinfo(np.int64).max if operation in {ComparisonOperation.GEQ, ComparisonOperation.GT} else 0
|
|
588
|
+
lb = np.iinfo(np.int64).min if operation in {ComparisonOperation.LEQ, ComparisonOperation.LT} else 0
|
|
589
|
+
_const, terms = self._parse_term(term)
|
|
590
|
+
|
|
591
|
+
def to_real(num: Number) -> RealNumber:
|
|
592
|
+
if isinstance(num, RealNumber):
|
|
593
|
+
return num
|
|
594
|
+
if isinstance(num, complex) and abs(num.imag) < get_settings().atol:
|
|
595
|
+
return num.real
|
|
596
|
+
raise ValueError("Complex values encountered in the constraint.")
|
|
597
|
+
|
|
598
|
+
const = to_real(_const)
|
|
599
|
+
term_upper_limit: RealNumber = sum(to_real(coeff) for coeff, _ in terms if to_real(coeff) > 0)
|
|
600
|
+
term_lower_limit: RealNumber = sum(to_real(coeff) for coeff, _ in terms if to_real(coeff) < 0)
|
|
601
|
+
|
|
602
|
+
if operation == ComparisonOperation.GT and term_upper_limit + const <= 0:
|
|
603
|
+
raise ValueError(f"Constraint {label} is unsatisfiable.")
|
|
604
|
+
if operation == ComparisonOperation.LT and term_lower_limit + const >= 0:
|
|
605
|
+
raise ValueError(f"Constraint {label} is unsatisfiable.")
|
|
606
|
+
|
|
607
|
+
upper_cut = min(term_upper_limit, ub - const)
|
|
608
|
+
lower_cut = max(term_lower_limit, lb - const)
|
|
609
|
+
|
|
610
|
+
if term_upper_limit <= upper_cut and term_lower_limit >= lower_cut:
|
|
611
|
+
logger.warning(
|
|
612
|
+
f'constraint "{label}" was not added to model "{self.label}" because it is always feasible.',
|
|
613
|
+
)
|
|
614
|
+
return None
|
|
615
|
+
|
|
616
|
+
ub_slack = int(upper_cut - lower_cut)
|
|
617
|
+
|
|
618
|
+
if upper_cut < lower_cut:
|
|
619
|
+
raise ValueError(f"Constraint {label} is unsatisfiable.")
|
|
620
|
+
|
|
621
|
+
return ub_slack
|
|
622
|
+
|
|
623
|
+
def _transform_constraint(
|
|
624
|
+
self,
|
|
625
|
+
label: str,
|
|
626
|
+
term: ComparisonTerm,
|
|
627
|
+
penalization: Literal["unbalanced", "slack"] = "slack",
|
|
628
|
+
parameters: list[float] | None = None,
|
|
629
|
+
) -> Term | None:
|
|
630
|
+
"""Transforms a constraint into QUBO format.
|
|
631
|
+
|
|
632
|
+
Args:
|
|
633
|
+
label (str): the constraint's label.
|
|
634
|
+
term (ComparisonTerm): the constraint term.
|
|
635
|
+
penalization (Literal["unbalanced", "slack"], optional): The penalization used to
|
|
636
|
+
handel inequality constraints. Defaults to "slack".
|
|
637
|
+
parameters (list[float] | None, optional): the parameters used for the unbalanced penalization method.
|
|
638
|
+
Defaults to None.
|
|
639
|
+
|
|
640
|
+
Raises:
|
|
641
|
+
ValueError: if a penalization method is provided that is not ("unbalanced", "slack")
|
|
642
|
+
ValueError: if unbalanced penalization method is used and not enough parameters are provided.
|
|
643
|
+
|
|
644
|
+
Returns:
|
|
645
|
+
Term | None: A transformed term that is in QUBO format.
|
|
646
|
+
None if the constraint is always feasible.
|
|
647
|
+
"""
|
|
648
|
+
|
|
649
|
+
lower_penalization = penalization.lower()
|
|
650
|
+
|
|
651
|
+
if lower_penalization not in {"unbalanced", "slack"}:
|
|
652
|
+
raise ValueError('Only penalization of type "unbalanced" or "slack" is supported.')
|
|
653
|
+
|
|
654
|
+
if parameters is None:
|
|
655
|
+
parameters = []
|
|
656
|
+
|
|
657
|
+
if term.operation is ComparisonOperation.EQ:
|
|
658
|
+
h = term.lhs - term.rhs
|
|
659
|
+
ub_slack = self._check_valid_constraint(label, h, term.operation)
|
|
660
|
+
if ub_slack is None:
|
|
661
|
+
return None
|
|
662
|
+
return h**2
|
|
663
|
+
|
|
664
|
+
if term.operation in {
|
|
665
|
+
ComparisonOperation.GEQ,
|
|
666
|
+
ComparisonOperation.GT,
|
|
667
|
+
}:
|
|
668
|
+
# assuming the operation is h >= 0 or h > 0
|
|
669
|
+
h = term.lhs - term.rhs
|
|
670
|
+
if lower_penalization == "unbalanced":
|
|
671
|
+
if len(parameters) < 2: # noqa: PLR2004
|
|
672
|
+
raise ValueError("using unbalanced penalization requires at least 2 parameters.")
|
|
673
|
+
return -parameters[0] * h + parameters[1] * (h**2)
|
|
674
|
+
|
|
675
|
+
if lower_penalization == "slack":
|
|
676
|
+
ub_slack = self._check_valid_constraint(label, h, term.operation)
|
|
677
|
+
|
|
678
|
+
if ub_slack is None:
|
|
679
|
+
return None
|
|
680
|
+
if ub_slack == 0:
|
|
681
|
+
return h**2
|
|
682
|
+
|
|
683
|
+
slack = Variable(
|
|
684
|
+
f"{label}_slack", domain=Domain.POSITIVE_INTEGER, bounds=(0, ub_slack), encoding=Bitwise
|
|
685
|
+
)
|
|
686
|
+
slack_terms = slack.to_binary()
|
|
687
|
+
out = h + slack_terms
|
|
688
|
+
return (out) ** 2
|
|
689
|
+
|
|
690
|
+
if term.operation in {
|
|
691
|
+
ComparisonOperation.LEQ,
|
|
692
|
+
ComparisonOperation.LT,
|
|
693
|
+
}:
|
|
694
|
+
if lower_penalization == "unbalanced":
|
|
695
|
+
# assuming the operation is -> 0 < h or 0 <= h
|
|
696
|
+
h = term.rhs - term.lhs
|
|
697
|
+
if len(parameters) < 2: # noqa: PLR2004
|
|
698
|
+
raise ValueError("using unbalanced penalization requires at least 2 parameters.")
|
|
699
|
+
return -parameters[0] * h + parameters[1] * (h**2)
|
|
700
|
+
if lower_penalization == "slack":
|
|
701
|
+
# assuming the operation is h <= 0 or h < 0
|
|
702
|
+
h = term.lhs - term.rhs
|
|
703
|
+
ub_slack = self._check_valid_constraint(label, h, term.operation)
|
|
704
|
+
|
|
705
|
+
if ub_slack is None:
|
|
706
|
+
return None
|
|
707
|
+
if ub_slack == 0:
|
|
708
|
+
return h**2
|
|
709
|
+
|
|
710
|
+
slack = Variable(
|
|
711
|
+
f"{label}_slack", domain=Domain.POSITIVE_INTEGER, bounds=(0, ub_slack), encoding=Bitwise
|
|
712
|
+
)
|
|
713
|
+
|
|
714
|
+
slack_terms = slack.to_binary()
|
|
715
|
+
out = h + slack_terms
|
|
716
|
+
return (out) ** 2
|
|
717
|
+
return None
|
|
718
|
+
|
|
719
|
+
def add_constraint(
|
|
720
|
+
self,
|
|
721
|
+
label: str,
|
|
722
|
+
term: ComparisonTerm,
|
|
723
|
+
lagrange_multiplier: float = 100,
|
|
724
|
+
penalization: Literal["unbalanced", "slack"] = "slack",
|
|
725
|
+
parameters: list[float] | None = None,
|
|
726
|
+
transform_to_qubo: bool = True,
|
|
727
|
+
) -> None:
|
|
728
|
+
"""Adds a constraint to the QUBO model.
|
|
729
|
+
|
|
730
|
+
Args:
|
|
731
|
+
label (str): the constraint label.
|
|
732
|
+
term (ComparisonTerm): the constraint's comparison term.
|
|
733
|
+
lagrange_multiplier (float, optional): the lagrange multiplier used to scale this constraint.
|
|
734
|
+
Defaults to 100.
|
|
735
|
+
penalization (Literal["unbalanced", "slack"], optional): the penalization used to
|
|
736
|
+
handel inequality constraints. Defaults to "slack".
|
|
737
|
+
parameters (list[float] | None, optional): the parameters used for the unbalanced penalization method.
|
|
738
|
+
Defaults to None.
|
|
739
|
+
transform_to_qubo (bool, optional): Automatically transform a given constraint to QUBO format.
|
|
740
|
+
Defaults to True.
|
|
741
|
+
|
|
742
|
+
Raises:
|
|
743
|
+
ValueError: if constraint label already exists in the model.
|
|
744
|
+
ValueError: if a penalization method is provided that is not ("unbalanced", "slack")
|
|
745
|
+
ValueError: if unbalanced penalization method is used and not enough parameters are provided.
|
|
746
|
+
ValueError: if the degree of the provided term is larger than 2.
|
|
747
|
+
ValueError: if the constraint term contains variables that are not from Positive Integers or Binary domains.
|
|
748
|
+
ValueError: if the constraint term contains variable that do not have 0 as their lower bound.
|
|
749
|
+
"""
|
|
750
|
+
if label in self._constraints:
|
|
751
|
+
raise ValueError((f'Constraint "{label}" already exists:\n \t\t{self._constraints[label]}'))
|
|
752
|
+
|
|
753
|
+
lower_penalization = penalization.lower()
|
|
754
|
+
|
|
755
|
+
if lower_penalization not in {"unbalanced", "slack"}:
|
|
756
|
+
raise ValueError(
|
|
757
|
+
'Only penalization of type "unbalanced" or "slack" is supported for inequality constraints.'
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
if parameters is None:
|
|
761
|
+
parameters = [1, 1] if lower_penalization == "unbalanced" else []
|
|
762
|
+
|
|
763
|
+
if term.operation in {ComparisonOperation.GEQ, ComparisonOperation.GT}:
|
|
764
|
+
c = ComparisonTerm(lhs=(term.lhs - term.rhs), rhs=0, operation=term.operation)
|
|
765
|
+
elif term.operation in {ComparisonOperation.LEQ, ComparisonOperation.LT}:
|
|
766
|
+
c = ComparisonTerm(lhs=0, rhs=(term.rhs - term.lhs), operation=term.operation)
|
|
767
|
+
else:
|
|
768
|
+
c = copy.copy(term)
|
|
769
|
+
|
|
770
|
+
if c.degree > 2: # noqa: PLR2004
|
|
771
|
+
raise ValueError(
|
|
772
|
+
f"QUBO models can not contain terms of order 2 or higher but received terms with degree {c.degree}."
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
self._check_variables(c, lagrange_multiplier=lagrange_multiplier)
|
|
776
|
+
|
|
777
|
+
if transform_to_qubo:
|
|
778
|
+
c = c.to_binary()
|
|
779
|
+
transformed_c = self._transform_constraint(label, c, penalization=penalization, parameters=parameters)
|
|
780
|
+
if transformed_c is None:
|
|
781
|
+
return
|
|
782
|
+
if lower_penalization == "unbalanced" and lagrange_multiplier != 1:
|
|
783
|
+
self.lagrange_multipliers[label] = 1
|
|
784
|
+
logger.warning(
|
|
785
|
+
"add_constraint() in QUBO model:"
|
|
786
|
+
+ f' The Lagrange Multiplier for the constraint "{label}" in the QUBO model ({self.label})'
|
|
787
|
+
+ " has been set to 1 because the constraint uses unbalanced"
|
|
788
|
+
+ " penalization method."
|
|
789
|
+
+ ' To customize the penalization coefficient, please use the "parameters" field.',
|
|
790
|
+
)
|
|
791
|
+
else:
|
|
792
|
+
self.lagrange_multipliers[label] = lagrange_multiplier
|
|
793
|
+
self._constraints[label] = Constraint(label, term=ComparisonTerm(transformed_c, 0, ComparisonOperation.EQ))
|
|
794
|
+
|
|
795
|
+
else:
|
|
796
|
+
self.lagrange_multipliers[label] = lagrange_multiplier
|
|
797
|
+
self._constraints[label] = Constraint(label, term=c)
|
|
798
|
+
|
|
799
|
+
def set_objective(self, term: Term, label: str = "obj", sense: ObjectiveSense = ObjectiveSense.MINIMIZE) -> None:
|
|
800
|
+
"""Set the QUBO objective.
|
|
801
|
+
|
|
802
|
+
Args:
|
|
803
|
+
term (Term): The objective's term.
|
|
804
|
+
label (str, optional): the objective's label. Defaults to "obj".
|
|
805
|
+
sense (ObjectiveSense, optional): The optimization sense of the model's objective.
|
|
806
|
+
Defaults to ObjectiveSense.MINIMIZE.
|
|
807
|
+
|
|
808
|
+
"""
|
|
809
|
+
|
|
810
|
+
self._check_variables(term)
|
|
811
|
+
|
|
812
|
+
term = term.to_binary()
|
|
813
|
+
self._objective = Objective(label=label, term=term, sense=sense)
|
|
814
|
+
|
|
815
|
+
def _check_variables(self, term: Term | ComparisonTerm, lagrange_multiplier: RealNumber = 100) -> None:
|
|
816
|
+
"""checks if the variables in the provided term are valid to be used in a QUBO model. Moreover, we add all the
|
|
817
|
+
encoding constraint for supported continuous variables.
|
|
818
|
+
|
|
819
|
+
Args:
|
|
820
|
+
term (Term): the term to be checked.
|
|
821
|
+
|
|
822
|
+
Raises:
|
|
823
|
+
ValueError: if the constraint term contains variables that are not from Positive Integers or Binary domains.
|
|
824
|
+
ValueError: if the constraint term contains variable that do not have 0 as their lower bound.
|
|
825
|
+
"""
|
|
826
|
+
for v in term.variables():
|
|
827
|
+
if v.domain not in {Domain.POSITIVE_INTEGER, Domain.BINARY}:
|
|
828
|
+
raise ValueError(
|
|
829
|
+
"QUBO models are not supported for variables that are not in the positive integers or binary domains."
|
|
830
|
+
)
|
|
831
|
+
if v.lower_bound != 0:
|
|
832
|
+
raise ValueError(
|
|
833
|
+
f"All variables must have a lower bound of 0. But variable {v} has a lower bound of {v.lower_bound}"
|
|
834
|
+
)
|
|
835
|
+
if isinstance(v, Variable) and v.domain is Domain.POSITIVE_INTEGER and v.label not in self.continuous_vars:
|
|
836
|
+
self.continuous_vars[v.label] = v
|
|
837
|
+
encoding_constraint = v.encoding_constraint()
|
|
838
|
+
if encoding_constraint is not None:
|
|
839
|
+
enc_label = f"{v.label}_encoding_constraint"
|
|
840
|
+
self.add_constraint(
|
|
841
|
+
label=enc_label, term=encoding_constraint, lagrange_multiplier=lagrange_multiplier
|
|
842
|
+
)
|
|
843
|
+
|
|
844
|
+
def _build_qubo_objective(
|
|
845
|
+
self, term: Term, label: str | None = None, sense: ObjectiveSense = ObjectiveSense.MINIMIZE
|
|
846
|
+
) -> None:
|
|
847
|
+
"""updates the internal qubo objective term.
|
|
848
|
+
|
|
849
|
+
Args:
|
|
850
|
+
term (Term): A term to be added to the qubo objective.
|
|
851
|
+
label (str | None, optional): the label of the objective (if None then the current label is maintained).
|
|
852
|
+
Defaults to None.
|
|
853
|
+
sense (ObjectiveSense, optional): The optimization sense of the model's objective.
|
|
854
|
+
Defaults to ObjectiveSense.MINIMIZE.
|
|
855
|
+
"""
|
|
856
|
+
term = copy.copy(term.to_binary())
|
|
857
|
+
if self.__qubo_objective is None:
|
|
858
|
+
self.__qubo_objective = Objective(
|
|
859
|
+
label=label if label is not None else "obj",
|
|
860
|
+
term=-term if sense == ObjectiveSense.MAXIMIZE else term,
|
|
861
|
+
sense=ObjectiveSense.MINIMIZE,
|
|
862
|
+
)
|
|
863
|
+
else:
|
|
864
|
+
self.__qubo_objective = Objective(
|
|
865
|
+
label=label if label is not None else self.__qubo_objective.label,
|
|
866
|
+
term=(
|
|
867
|
+
copy.copy(self.__qubo_objective.term) - term
|
|
868
|
+
if sense == ObjectiveSense.MAXIMIZE
|
|
869
|
+
else copy.copy(self.__qubo_objective.term) + term
|
|
870
|
+
),
|
|
871
|
+
sense=ObjectiveSense.MINIMIZE,
|
|
872
|
+
)
|
|
873
|
+
|
|
874
|
+
def evaluate(self, sample: Mapping[BaseVariable, RealNumber | list[int]]) -> dict[str, Number]:
|
|
875
|
+
"""Evaluates the objective and the constraints of the model given a set of values for the variables.
|
|
876
|
+
|
|
877
|
+
Args:
|
|
878
|
+
sample (Mapping[BaseVariable, RealNumber | list[int]]): The dictionary maps the variable to the value to be
|
|
879
|
+
used during the evaluation. In case the variable is
|
|
880
|
+
continuous (Not Binary or Spin) then the value could
|
|
881
|
+
either be a number or a list of binary bits that
|
|
882
|
+
correspond to the encoding of the variable.
|
|
883
|
+
Note: All the model's variables must be provided for
|
|
884
|
+
the model to be evaluated.
|
|
885
|
+
|
|
886
|
+
Returns:
|
|
887
|
+
dict[str, float]: a dictionary that maps the name of the objective/constraint to it's evaluated value.
|
|
888
|
+
Note: For constraints, the value is equal to the value of the evaluated constraint term
|
|
889
|
+
multiplied by the lagrange multiplier of that constraint.
|
|
890
|
+
"""
|
|
891
|
+
results = {}
|
|
892
|
+
|
|
893
|
+
results[self.objective.label] = self.objective.term.evaluate(sample)
|
|
894
|
+
results[self.objective.label] *= -1 if self.objective.sense is ObjectiveSense.MAXIMIZE else 1
|
|
895
|
+
|
|
896
|
+
for c in self.constraints:
|
|
897
|
+
results[c.label] = c.term.lhs.evaluate(sample) - c.term.rhs.evaluate(sample)
|
|
898
|
+
results[c.label] *= self.lagrange_multipliers[c.label]
|
|
899
|
+
return results
|
|
900
|
+
|
|
901
|
+
@classmethod
|
|
902
|
+
def from_model(
|
|
903
|
+
cls,
|
|
904
|
+
model: Model,
|
|
905
|
+
lagrange_multiplier_dict: dict[str, float] | None = None,
|
|
906
|
+
penalization: Literal["unbalanced", "slack"] = "slack",
|
|
907
|
+
parameters: list[float] | None = None,
|
|
908
|
+
) -> QUBO:
|
|
909
|
+
"""A class method that constructs a QUBO model from a regular model if possible.
|
|
910
|
+
|
|
911
|
+
Args:
|
|
912
|
+
model (Model): the model to be used to construct the QUBO model.
|
|
913
|
+
lagrange_multiplier_dict (dict[str, float] | None, optional): A dictionary with lagrange multiplier values
|
|
914
|
+
to scale the model's constraints. Defaults to None.
|
|
915
|
+
penalization (Literal["unbalanced", "slack"], optional): the penalization used to
|
|
916
|
+
handel inequality constraints. Defaults to "slack".
|
|
917
|
+
parameters (list[float] | None, optional): the parameters used for the unbalanced penalization method.
|
|
918
|
+
Defaults to None.
|
|
919
|
+
Returns:
|
|
920
|
+
QUBO: _description_
|
|
921
|
+
"""
|
|
922
|
+
instance = QUBO(label="QUBO_" + model.label)
|
|
923
|
+
instance.set_objective(term=model.objective.term, label=model.objective.label, sense=model.objective.sense)
|
|
924
|
+
for constraint in model.constraints:
|
|
925
|
+
if lagrange_multiplier_dict is not None and constraint.label in lagrange_multiplier_dict:
|
|
926
|
+
lagrange_multiplier = lagrange_multiplier_dict[constraint.label]
|
|
927
|
+
|
|
928
|
+
else:
|
|
929
|
+
lagrange_multiplier = 100
|
|
930
|
+
|
|
931
|
+
instance.add_constraint(
|
|
932
|
+
label=constraint.label,
|
|
933
|
+
term=constraint.term,
|
|
934
|
+
lagrange_multiplier=lagrange_multiplier,
|
|
935
|
+
penalization=penalization,
|
|
936
|
+
parameters=parameters,
|
|
937
|
+
)
|
|
938
|
+
return instance
|
|
939
|
+
|
|
940
|
+
def to_hamiltonian(self) -> Hamiltonian:
|
|
941
|
+
"""Construct an ising hamiltonian from the current QUBO model.
|
|
942
|
+
|
|
943
|
+
Raises:
|
|
944
|
+
ValueError: if the QUBO model is empty (doesn't have an objective nor constraints.)
|
|
945
|
+
ValueError: if the QUBO model uses operations that are not addition or multiplications.
|
|
946
|
+
|
|
947
|
+
Returns:
|
|
948
|
+
Hamiltonian: An ising hamiltonian that represents the QUBO model.
|
|
949
|
+
"""
|
|
950
|
+
from qilisdk.analog.hamiltonian import Hamiltonian, Z # noqa: PLC0415
|
|
951
|
+
|
|
952
|
+
spins: dict[BaseVariable, Hamiltonian] = {}
|
|
953
|
+
obj = self.qubo_objective
|
|
954
|
+
|
|
955
|
+
if obj is None:
|
|
956
|
+
raise ValueError("Can't transform empty QUBO model to a Hamiltonian.")
|
|
957
|
+
|
|
958
|
+
for i, v in enumerate(obj.variables()):
|
|
959
|
+
spins[v] = (1 - Z(i)) / 2
|
|
960
|
+
|
|
961
|
+
def _parse_term(term: Term) -> Hamiltonian:
|
|
962
|
+
ham = Hamiltonian()
|
|
963
|
+
terms = term.to_list()
|
|
964
|
+
operation = term.operation
|
|
965
|
+
default = 0.0 if operation is Operation.ADD else 1.0
|
|
966
|
+
aux_term: Number | Hamiltonian = copy.copy(default)
|
|
967
|
+
for t in terms:
|
|
968
|
+
aux: Number | Hamiltonian = copy.copy(default)
|
|
969
|
+
if isinstance(t, Term):
|
|
970
|
+
aux = _parse_term(t)
|
|
971
|
+
elif isinstance(t, Number):
|
|
972
|
+
aux = t
|
|
973
|
+
elif isinstance(t, BaseVariable):
|
|
974
|
+
aux = spins[t]
|
|
975
|
+
|
|
976
|
+
if operation is Operation.ADD:
|
|
977
|
+
aux_term += aux
|
|
978
|
+
elif operation is Operation.MUL:
|
|
979
|
+
aux_term *= aux
|
|
980
|
+
else: # I don't think this can be reached.
|
|
981
|
+
raise ValueError(f"operation {operation} is not supported")
|
|
982
|
+
ham += aux_term
|
|
983
|
+
return ham
|
|
984
|
+
|
|
985
|
+
ham = _parse_term(obj.term)
|
|
986
|
+
|
|
987
|
+
return ham
|
|
988
|
+
|
|
989
|
+
def to_qubo(
|
|
990
|
+
self,
|
|
991
|
+
lagrange_multiplier_dict: dict[str, float] | None = None,
|
|
992
|
+
penalization: Literal["unbalanced", "slack"] = "slack",
|
|
993
|
+
parameters: list[float] | None = None,
|
|
994
|
+
) -> QUBO:
|
|
995
|
+
logger.warning(
|
|
996
|
+
f"Running `to_qubo()` on the model {self.label} that is already in QUBO format.",
|
|
997
|
+
)
|
|
998
|
+
return copy.copy(self)
|
|
999
|
+
|
|
1000
|
+
def __copy__(self) -> QUBO:
|
|
1001
|
+
out = QUBO(label=self.label)
|
|
1002
|
+
obj = copy.copy(self.objective)
|
|
1003
|
+
out.set_objective(term=obj.term, label=obj.label, sense=obj.sense)
|
|
1004
|
+
for c in self.constraints:
|
|
1005
|
+
# THIS DOESN'T COPY ANY PARAMETERS ATTACHED TO A CONSTRAINT
|
|
1006
|
+
out.add_constraint(
|
|
1007
|
+
label=c.label,
|
|
1008
|
+
term=copy.copy(c.term),
|
|
1009
|
+
lagrange_multiplier=self.lagrange_multipliers[c.label],
|
|
1010
|
+
transform_to_qubo=False,
|
|
1011
|
+
)
|
|
1012
|
+
return out
|