├── .github └── workflows │ ├── build_wheels.yml │ └── run_demo.yml ├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── CONTRIBUTE.md ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── benchmarks ├── deceptive_trap.py ├── deceptive_trap │ ├── CythonTrapFunction-cdef.pyx │ ├── CythonTrapFunction.pyx │ ├── Makefile │ ├── PythonTrapFunction.py │ ├── __init__.py │ ├── results │ │ └── .placeholder │ └── setup.py ├── experiments.py ├── maxcut.py ├── maxcut │ ├── CythonMaxCut.pyx │ ├── Makefile │ ├── PythonMaxCut.py │ ├── __init__.py │ └── setup.py ├── output.py ├── plotting.py ├── rosenbrock.py ├── rosenbrock │ └── PythonRosenbrock.py ├── soreb_chain.py └── soreb_chain │ ├── PythonSOREBChainStrong.py │ ├── __init__.py │ └── results │ └── .placeholder ├── demos ├── bbo_discrete │ └── main.py ├── bbo_realvalued │ └── main.py ├── demo.py ├── gbo_discrete │ └── main.py ├── gbo_realvalued │ └── main.py └── plotting │ └── main.py ├── docs ├── Makefile ├── make.bat └── source │ ├── conf.py │ ├── index.rst │ └── usage.rst ├── environment.yml ├── gomea-lib.code-workspace ├── gomea.code-workspace ├── gomea ├── EmbeddedFitness.pxi ├── __init__.pxd ├── __init__.py ├── discrete.pxd ├── discrete.pyx ├── fitness.pxd ├── fitness.pyx ├── lib │ ├── Eigen │ │ ├── Cholesky │ │ ├── CholmodSupport │ │ ├── Core │ │ ├── Dense │ │ ├── Eigen │ │ ├── Eigenvalues │ │ ├── Geometry │ │ ├── Householder │ │ ├── IterativeLinearSolvers │ │ ├── Jacobi │ │ ├── KLUSupport │ │ ├── LU │ │ ├── MetisSupport │ │ ├── OrderingMethods │ │ ├── PaStiXSupport │ │ ├── PardisoSupport │ │ ├── QR │ │ ├── QtAlignedMalloc │ │ ├── SPQRSupport │ │ ├── SVD │ │ ├── Sparse │ │ ├── SparseCholesky │ │ ├── SparseCore │ │ ├── SparseLU │ │ ├── SparseQR │ │ ├── StdDeque │ │ ├── StdList │ │ ├── StdVector │ │ ├── SuperLUSupport │ │ ├── UmfPackSupport │ │ └── src │ │ │ ├── Cholesky │ │ │ ├── LDLT.h │ │ │ ├── LLT.h │ │ │ └── LLT_LAPACKE.h │ │ │ ├── CholmodSupport │ │ │ └── CholmodSupport.h │ │ │ ├── Core │ │ │ ├── ArithmeticSequence.h │ │ │ ├── Array.h │ │ │ ├── ArrayBase.h │ │ │ ├── ArrayWrapper.h │ │ │ ├── Assign.h │ │ │ ├── AssignEvaluator.h │ │ │ ├── Assign_MKL.h │ │ │ ├── BandMatrix.h │ │ │ ├── Block.h │ │ │ ├── BooleanRedux.h │ │ │ ├── CommaInitializer.h │ │ │ ├── ConditionEstimator.h │ │ │ ├── CoreEvaluators.h │ │ │ ├── CoreIterators.h │ │ │ ├── CwiseBinaryOp.h │ │ │ ├── CwiseNullaryOp.h │ │ │ ├── CwiseTernaryOp.h │ │ │ ├── CwiseUnaryOp.h │ │ │ ├── CwiseUnaryView.h │ │ │ ├── DenseBase.h │ │ │ ├── DenseCoeffsBase.h │ │ │ ├── DenseStorage.h │ │ │ ├── Diagonal.h │ │ │ ├── DiagonalMatrix.h │ │ │ ├── DiagonalProduct.h │ │ │ ├── Dot.h │ │ │ ├── EigenBase.h │ │ │ ├── ForceAlignedAccess.h │ │ │ ├── Fuzzy.h │ │ │ ├── GeneralProduct.h │ │ │ ├── GenericPacketMath.h │ │ │ ├── GlobalFunctions.h │ │ │ ├── IO.h │ │ │ ├── IndexedView.h │ │ │ ├── Inverse.h │ │ │ ├── Map.h │ │ │ ├── MapBase.h │ │ │ ├── MathFunctions.h │ │ │ ├── MathFunctionsImpl.h │ │ │ ├── Matrix.h │ │ │ ├── MatrixBase.h │ │ │ ├── NestByValue.h │ │ │ ├── NoAlias.h │ │ │ ├── NumTraits.h │ │ │ ├── PartialReduxEvaluator.h │ │ │ ├── PermutationMatrix.h │ │ │ ├── PlainObjectBase.h │ │ │ ├── Product.h │ │ │ ├── ProductEvaluators.h │ │ │ ├── Random.h │ │ │ ├── Redux.h │ │ │ ├── Ref.h │ │ │ ├── Replicate.h │ │ │ ├── Reshaped.h │ │ │ ├── ReturnByValue.h │ │ │ ├── Reverse.h │ │ │ ├── Select.h │ │ │ ├── SelfAdjointView.h │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ ├── Solve.h │ │ │ ├── SolveTriangular.h │ │ │ ├── SolverBase.h │ │ │ ├── StableNorm.h │ │ │ ├── StlIterators.h │ │ │ ├── Stride.h │ │ │ ├── Swap.h │ │ │ ├── Transpose.h │ │ │ ├── Transpositions.h │ │ │ ├── TriangularMatrix.h │ │ │ ├── VectorBlock.h │ │ │ ├── VectorwiseOp.h │ │ │ ├── Visitor.h │ │ │ ├── arch │ │ │ │ ├── AVX │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── AVX512 │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── AltiVec │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── MatrixProduct.h │ │ │ │ │ ├── MatrixProductCommon.h │ │ │ │ │ ├── MatrixProductMMA.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── CUDA │ │ │ │ │ └── Complex.h │ │ │ │ ├── Default │ │ │ │ │ ├── BFloat16.h │ │ │ │ │ ├── ConjHelper.h │ │ │ │ │ ├── GenericPacketMathFunctions.h │ │ │ │ │ ├── GenericPacketMathFunctionsFwd.h │ │ │ │ │ ├── Half.h │ │ │ │ │ ├── Settings.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── GPU │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── HIP │ │ │ │ │ └── hcc │ │ │ │ │ │ └── math_constants.h │ │ │ │ ├── MSA │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── NEON │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── SSE │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── SVE │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── SYCL │ │ │ │ │ ├── InteropHeaders.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ ├── SyclMemoryModel.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ └── ZVector │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ ├── functors │ │ │ │ ├── AssignmentFunctors.h │ │ │ │ ├── BinaryFunctors.h │ │ │ │ ├── NullaryFunctors.h │ │ │ │ ├── StlFunctors.h │ │ │ │ ├── TernaryFunctors.h │ │ │ │ └── UnaryFunctors.h │ │ │ ├── products │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ │ ├── Parallelizer.h │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ │ └── TriangularSolverVector.h │ │ │ └── util │ │ │ │ ├── BlasUtil.h │ │ │ │ ├── ConfigureVectorization.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ ├── IndexedViewHelper.h │ │ │ │ ├── IntegralConstant.h │ │ │ │ ├── MKL_support.h │ │ │ │ ├── Macros.h │ │ │ │ ├── Memory.h │ │ │ │ ├── Meta.h │ │ │ │ ├── NonMPL2.h │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ ├── ReshapedHelper.h │ │ │ │ ├── StaticAssert.h │ │ │ │ ├── SymbolicIndex.h │ │ │ │ └── XprHelper.h │ │ │ ├── Eigenvalues │ │ │ ├── ComplexEigenSolver.h │ │ │ ├── ComplexSchur.h │ │ │ ├── ComplexSchur_LAPACKE.h │ │ │ ├── EigenSolver.h │ │ │ ├── GeneralizedEigenSolver.h │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ ├── HessenbergDecomposition.h │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ ├── RealQZ.h │ │ │ ├── RealSchur.h │ │ │ ├── RealSchur_LAPACKE.h │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ │ └── Tridiagonalization.h │ │ │ ├── Geometry │ │ │ ├── AlignedBox.h │ │ │ ├── AngleAxis.h │ │ │ ├── EulerAngles.h │ │ │ ├── Homogeneous.h │ │ │ ├── Hyperplane.h │ │ │ ├── OrthoMethods.h │ │ │ ├── ParametrizedLine.h │ │ │ ├── Quaternion.h │ │ │ ├── Rotation2D.h │ │ │ ├── RotationBase.h │ │ │ ├── Scaling.h │ │ │ ├── Transform.h │ │ │ ├── Translation.h │ │ │ ├── Umeyama.h │ │ │ └── arch │ │ │ │ └── Geometry_SIMD.h │ │ │ ├── Householder │ │ │ ├── BlockHouseholder.h │ │ │ ├── Householder.h │ │ │ └── HouseholderSequence.h │ │ │ ├── IterativeLinearSolvers │ │ │ ├── BasicPreconditioners.h │ │ │ ├── BiCGSTAB.h │ │ │ ├── ConjugateGradient.h │ │ │ ├── IncompleteCholesky.h │ │ │ ├── IncompleteLUT.h │ │ │ ├── IterativeSolverBase.h │ │ │ ├── LeastSquareConjugateGradient.h │ │ │ └── SolveWithGuess.h │ │ │ ├── Jacobi │ │ │ └── Jacobi.h │ │ │ ├── KLUSupport │ │ │ └── KLUSupport.h │ │ │ ├── LU │ │ │ ├── Determinant.h │ │ │ ├── FullPivLU.h │ │ │ ├── InverseImpl.h │ │ │ ├── PartialPivLU.h │ │ │ ├── PartialPivLU_LAPACKE.h │ │ │ └── arch │ │ │ │ └── InverseSize4.h │ │ │ ├── MetisSupport │ │ │ └── MetisSupport.h │ │ │ ├── OrderingMethods │ │ │ ├── Amd.h │ │ │ ├── Eigen_Colamd.h │ │ │ └── Ordering.h │ │ │ ├── PaStiXSupport │ │ │ └── PaStiXSupport.h │ │ │ ├── PardisoSupport │ │ │ └── PardisoSupport.h │ │ │ ├── QR │ │ │ ├── ColPivHouseholderQR.h │ │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ │ ├── CompleteOrthogonalDecomposition.h │ │ │ ├── FullPivHouseholderQR.h │ │ │ ├── HouseholderQR.h │ │ │ └── HouseholderQR_LAPACKE.h │ │ │ ├── SPQRSupport │ │ │ └── SuiteSparseQRSupport.h │ │ │ ├── SVD │ │ │ ├── BDCSVD.h │ │ │ ├── JacobiSVD.h │ │ │ ├── JacobiSVD_LAPACKE.h │ │ │ ├── SVDBase.h │ │ │ └── UpperBidiagonalization.h │ │ │ ├── SparseCholesky │ │ │ ├── SimplicialCholesky.h │ │ │ └── SimplicialCholesky_impl.h │ │ │ ├── SparseCore │ │ │ ├── AmbiVector.h │ │ │ ├── CompressedStorage.h │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ ├── MappedSparseMatrix.h │ │ │ ├── SparseAssign.h │ │ │ ├── SparseBlock.h │ │ │ ├── SparseColEtree.h │ │ │ ├── SparseCompressedBase.h │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ ├── SparseDenseProduct.h │ │ │ ├── SparseDiagonalProduct.h │ │ │ ├── SparseDot.h │ │ │ ├── SparseFuzzy.h │ │ │ ├── SparseMap.h │ │ │ ├── SparseMatrix.h │ │ │ ├── SparseMatrixBase.h │ │ │ ├── SparsePermutation.h │ │ │ ├── SparseProduct.h │ │ │ ├── SparseRedux.h │ │ │ ├── SparseRef.h │ │ │ ├── SparseSelfAdjointView.h │ │ │ ├── SparseSolverBase.h │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ ├── SparseTranspose.h │ │ │ ├── SparseTriangularView.h │ │ │ ├── SparseUtil.h │ │ │ ├── SparseVector.h │ │ │ ├── SparseView.h │ │ │ └── TriangularSolver.h │ │ │ ├── SparseLU │ │ │ ├── SparseLU.h │ │ │ ├── SparseLUImpl.h │ │ │ ├── SparseLU_Memory.h │ │ │ ├── SparseLU_Structs.h │ │ │ ├── SparseLU_SupernodalMatrix.h │ │ │ ├── SparseLU_Utils.h │ │ │ ├── SparseLU_column_bmod.h │ │ │ ├── SparseLU_column_dfs.h │ │ │ ├── SparseLU_copy_to_ucol.h │ │ │ ├── SparseLU_gemm_kernel.h │ │ │ ├── SparseLU_heap_relax_snode.h │ │ │ ├── SparseLU_kernel_bmod.h │ │ │ ├── SparseLU_panel_bmod.h │ │ │ ├── SparseLU_panel_dfs.h │ │ │ ├── SparseLU_pivotL.h │ │ │ ├── SparseLU_pruneL.h │ │ │ └── SparseLU_relax_snode.h │ │ │ ├── SparseQR │ │ │ └── SparseQR.h │ │ │ ├── StlSupport │ │ │ ├── StdDeque.h │ │ │ ├── StdList.h │ │ │ ├── StdVector.h │ │ │ └── details.h │ │ │ ├── SuperLUSupport │ │ │ └── SuperLUSupport.h │ │ │ ├── UmfPackSupport │ │ │ └── UmfPackSupport.h │ │ │ ├── misc │ │ │ ├── Image.h │ │ │ ├── Kernel.h │ │ │ ├── RealSvd2x2.h │ │ │ ├── blas.h │ │ │ ├── lapack.h │ │ │ ├── lapacke.h │ │ │ └── lapacke_mangling.h │ │ │ └── plugins │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ ├── BlockMethods.h │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ ├── IndexedViewMethods.h │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ ├── MatrixCwiseUnaryOps.h │ │ │ └── ReshapedMethods.h │ └── cxxopts-3.1.1 │ │ ├── LICENSE │ │ ├── README.md │ │ └── include │ │ └── cxxopts.hpp ├── linkage.pxd ├── linkage.pyx ├── meson.build ├── output.pxd ├── output.pyx ├── real_valued.pxd ├── real_valued.pyx └── src │ ├── common │ ├── gomea_defs.hpp │ ├── linkage_config.cpp │ ├── linkage_config.hpp │ ├── linkage_model.cpp │ ├── linkage_model.hpp │ ├── output_statistics.cpp │ ├── output_statistics.hpp │ ├── partial_solution.cpp │ ├── partial_solution.hpp │ ├── solution.cpp │ └── solution.hpp │ ├── discrete │ ├── Config.cpp │ ├── Config.hpp │ ├── Population.cpp │ ├── Population.hpp │ ├── gomea.cpp │ ├── gomea.hpp │ ├── gomeaIMS.cpp │ ├── gomeaIMS.hpp │ ├── main.cpp │ ├── shared.hpp │ ├── utils.cpp │ └── utils.hpp │ ├── fitness │ ├── bbo_fitness.cpp │ ├── bbo_fitness.hpp │ ├── benchmarks-discrete.hpp │ ├── benchmarks-discrete │ │ ├── NKlandscapesBBO_t.cpp │ │ ├── NKlandscapes_t.cpp │ │ ├── asymmetricDeceptiveTrapBBO_t.cpp │ │ ├── asymmetricDeceptiveTrap_t.cpp │ │ ├── asymmetricHierarchicalDeceptiveTrapBBO_t.cpp │ │ ├── bimodalDeceptiveTrapBBO_t.cpp │ │ ├── bimodalDeceptiveTrap_t.cpp │ │ ├── deceptiveTrapBBO_t.cpp │ │ ├── deceptiveTrap_t.cpp │ │ ├── hierarchicalDeceptiveTrapBBO_t.cpp │ │ ├── hierarchicalIfAndOnlyIfBBO_t.cpp │ │ ├── maxCutBBO_t.cpp │ │ ├── maxCut_t.cpp │ │ ├── oneMaxBBO_t.cpp │ │ └── oneMax_t.cpp │ ├── benchmarks-rv.hpp │ ├── benchmarks-rv │ │ ├── SOREBChainStrongBBO_t.cpp │ │ ├── SOREBChainStrong_t.cpp │ │ ├── circlesInASquareBBO_t.cpp │ │ ├── rosenbrockFunctionBBO_t.cpp │ │ ├── rosenbrockFunction_t.cpp │ │ ├── sphereFunctionBBO_t.cpp │ │ └── sphereFunction_t.cpp │ ├── fitness.cpp │ ├── fitness.hpp │ ├── gbo_fitness.cpp │ ├── gbo_fitness.hpp │ ├── py_bbo_fitness.cpp │ ├── py_bbo_fitness.hpp │ ├── py_gbo_fitness.cpp │ ├── py_gbo_fitness.hpp │ ├── your_fitness_discrete.cpp │ ├── your_fitness_discrete.hpp │ ├── your_fitness_realvalued.cpp │ └── your_fitness_realvalued.hpp │ ├── real_valued │ ├── Config.cpp │ ├── Config.hpp │ ├── distribution.cpp │ ├── distribution.hpp │ ├── linkage_model.cpp │ ├── linkage_model.hpp │ ├── main.cpp │ ├── partial_solutionRV.cpp │ ├── partial_solutionRV.hpp │ ├── population.cpp │ ├── population.hpp │ ├── rv-gomea.cpp │ ├── rv-gomea.hpp │ ├── solutionRV.cpp │ ├── solutionRV.hpp │ ├── tools.cpp │ └── tools.hpp │ └── utils │ ├── time.cpp │ ├── time.hpp │ ├── tools.cpp │ └── tools.hpp ├── meson.build ├── pyproject.toml └── setup.py /.github/workflows/build_wheels.yml: -------------------------------------------------------------------------------- 1 | name: Build and save wheels 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | 9 | name: Build wheels on ${{ matrix.os }} 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: [ubuntu-latest, windows-latest, macos-latest] 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - name: Build wheels 20 | uses: pypa/cibuildwheel@v2.21.3 21 | 22 | - uses: actions/upload-artifact@v4 23 | with: 24 | name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} 25 | path: ./wheelhouse/*.whl 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/run_demo.yml: -------------------------------------------------------------------------------- 1 | name: Build and run demo 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: [ "main", "dev" ] 7 | pull_request: 8 | branches: [ "main", "dev" ] 9 | 10 | jobs: 11 | build: 12 | name: ${{ matrix.config.name }} 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | config: 19 | - name: "Windows Latest" 20 | os: windows-latest 21 | - name: "Ubuntu Latest" 22 | os: ubuntu-latest 23 | - name: "MacOS Latest" 24 | os: macos-latest 25 | 26 | steps: 27 | - uses: actions/checkout@v3 28 | 29 | - name: Set up Python 30 | uses: actions/setup-python@v4 31 | with: 32 | python-version: '3.9' 33 | 34 | - name: Install dependencies 35 | run: make install 36 | shell: bash 37 | 38 | - name: Run check 39 | run: python3 demos/demo.py 40 | shell: bash 41 | 42 | - uses: actions/upload-artifact@v4 43 | with: 44 | name: wheel-${{ matrix.config.os }} 45 | path: dist/ 46 | 47 | src-dist: 48 | name: ${{ matrix.config.name }} 49 | runs-on: ${{ matrix.config.os }} 50 | 51 | strategy: 52 | fail-fast: false 53 | matrix: 54 | config: 55 | - name: "Windows Latest" 56 | os: windows-latest 57 | - name: "Ubuntu Latest" 58 | os: ubuntu-latest 59 | - name: "MacOS Latest" 60 | os: macos-latest 61 | 62 | steps: 63 | - uses: actions/checkout@v3 64 | 65 | - name: Set up Python 66 | uses: actions/setup-python@v4 67 | with: 68 | python-version: '3.9' 69 | 70 | - name: Install from source 71 | run: make src-install 72 | shell: bash 73 | 74 | - name: Run check 75 | run: python3 demos/demo.py 76 | shell: bash 77 | 78 | wheel: 79 | name: ${{ matrix.config.name }} 80 | runs-on: ${{ matrix.config.os }} 81 | 82 | strategy: 83 | fail-fast: false 84 | matrix: 85 | config: 86 | - name: "Windows Latest" 87 | os: windows-latest 88 | - name: "Ubuntu Latest" 89 | os: ubuntu-latest 90 | - name: "MacOS Latest" 91 | os: macos-latest 92 | 93 | steps: 94 | - uses: actions/checkout@v3 95 | - name: Set up Python 96 | uses: actions/setup-python@v4 97 | with: 98 | python-version: '3.9' 99 | 100 | - name: Build wheel 101 | run: make install 102 | shell: bash 103 | 104 | - name: Run check 105 | run: python3 demos/demo.py 106 | shell: bash 107 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **.o 2 | **.obj 3 | **.so 4 | **.swp 5 | **.log 6 | **.egg-info/ 7 | **.pdf 8 | **.json 9 | **/problem_data/ 10 | **/__pycache__/ 11 | gomea/*.cpp 12 | gomea/*.h 13 | gomea/*.hpp 14 | **/*.dat 15 | build/ 16 | dist/ 17 | tmp/ 18 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/usr/include/python3.10" 8 | ], 9 | "defines": [], 10 | "compilerPath": "/usr/bin/g++", 11 | "cStandard": "c17", 12 | "cppStandard": "c++17", 13 | "intelliSenseMode": "linux-clang-x64", 14 | "configurationProvider": "ms-vscode.makefile-tools" 15 | } 16 | ], 17 | "version": 4 18 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "benjamin-simmonds.pythoncpp-debug" 4 | ] 5 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Python C++ Debug", 6 | "type": "pythoncpp", 7 | "request": "launch", 8 | "pythonConfig": "custom", 9 | "pythonLaunchName": "Python: main", 10 | "cppConfig": "default (gdb) Attach" 11 | }, 12 | { 13 | "name": "C++ Discrete gdb", 14 | "type": "cppdbg", 15 | "request": "launch", 16 | "program": "${workspaceFolder}/build_cpp/DiscreteGOMEA", 17 | "args": ["-F10000", "0", "10", "0"], 18 | "cwd": "${workspaceFolder}/build_cpp/" 19 | }, 20 | { 21 | "name": "C++ Real-Valued gdb", 22 | "type": "cppdbg", 23 | "request": "launch", 24 | "program": "${workspaceFolder}/build_cpp/RealValuedGOMEA", 25 | "args": ["-s","-f","1","-r","0","10","-100","-115","0.35","10","1","0.9","1","100000","1e-10","100","0","10"], 26 | "cwd": "${workspaceFolder}/build_cpp/" 27 | }, 28 | { 29 | "name": "(gdb) Attach", 30 | "type": "cppdbg", 31 | "program": "gdb", 32 | "request": "attach", 33 | "logging": { 34 | "engineLogging": true 35 | }, 36 | "sourceFileMap": { 37 | "${workspaceFolder}": { 38 | "editorPath": "${workspaceFolder}", 39 | "useForBreakpoints": "true" 40 | } 41 | } 42 | }, 43 | { 44 | "name": "Python: main", 45 | "type": "debugpy", 46 | "request": "launch", 47 | "program": "${workspaceFolder}/debug/main.py", 48 | "console": "integratedTerminal", 49 | "cwd": "${workspaceFolder}/debug/" 50 | } 51 | ] 52 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.terminal.executeInFileDir": true 3 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "cppbuild", 6 | "label": "make", 7 | "command": "make", 8 | "args": [ 9 | "-j8" 10 | ], 11 | "options": { 12 | "cwd": "${workspaceFolder}" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTE 2 | 3 | This page is now incomplete, but will include information on how to contribute to the GOMEA library. 4 | 5 | ## Notes on including sub-module 6 | - Default constructor should be available. 7 | - Destructor should not free objects that are not initialized in the default constructor. 8 | - No exit statements should be used throughout the code. 9 | - No output to stdout and no files. 10 | - Options should be passed to the C++ class through a C++ config class. 11 | - Default parameters should be uniquely defined in the Cython .pyx file wrapping the sub-module. These default parameters are then used to initialize the C++ config class. 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Anton Bouter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include gomea/*pxd 2 | include gomea/*pyx 3 | include gomea/*pxi 4 | graft gomea/src 5 | graft gomea/lib 6 | -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/CythonTrapFunction-cdef.pyx: -------------------------------------------------------------------------------- 1 | # distutils: language=c++ 2 | # cython: language_level=3, boundscheck=False, wraparound=False 3 | 4 | import cython 5 | from libcpp.vector cimport vector 6 | import numpy as np 7 | cimport numpy as np 8 | from gomea.fitness cimport GBOFitnessFunction 9 | from gomea.fitness cimport pyGBOFitnessFunction_t 10 | from cpython cimport PyObject 11 | 12 | cdef class DeceptiveTrapFunction(GBOFitnessFunction): 13 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 14 | cdef int k 15 | def __cinit__(self, number_of_variables : cython.int, k : cython.int ): 16 | assert( number_of_variables % k == 0 ) 17 | self.k = k 18 | self.number_of_variables = number_of_variables 19 | self.value_to_reach = number_of_variables 20 | self.c_inst_discrete = new pyGBOFitnessFunction_t[char](number_of_variables,self.value_to_reach,self) 21 | 22 | cpdef int number_of_subfunctions( self ): 23 | return int(self.number_of_variables / self.k) 24 | 25 | cpdef vector[int] inputs_to_subfunction( self, int subfunction_index ): 26 | cdef vector[int] indices = vector[int](self.k) 27 | cdef int i 28 | for i in range(0,self.k,1): 29 | indices[i] = self.k*subfunction_index + i 30 | return indices 31 | 32 | cpdef double subfunction(self, int subfunction_index, np.ndarray variables ): 33 | cdef vector[int] trap_variables = self.inputs_to_subfunction(subfunction_index) 34 | cdef int unitation = 0 35 | for v in trap_variables: 36 | unitation = unitation + variables[v] 37 | if unitation == self.k: 38 | return unitation 39 | else: 40 | return self.k - unitation - 1 41 | 42 | -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/CythonTrapFunction.pyx: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | import cython 4 | from functools import cache 5 | 6 | # Custom fitness function resembling the concatenated deceptive trap function of size k 7 | class DeceptiveTrapFunction(gomea.fitness.GBOFitnessFunctionDiscrete): 8 | k : cython.int 9 | 10 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 11 | def __new__(self, number_of_variables, k ): 12 | assert( number_of_variables % k == 0 ) 13 | self.k = k 14 | value_to_reach = number_of_variables 15 | return super().__new__(self,number_of_variables,value_to_reach) 16 | 17 | @cache 18 | def number_of_subfunctions( self ) -> cython.int: 19 | return self.number_of_variables // self.k 20 | 21 | @cache 22 | def inputs_to_subfunction( self, subfunction_index : cython.int ) -> np.ndarray: 23 | return range(self.k*subfunction_index,self.k*subfunction_index+self.k) 24 | 25 | def subfunction(self, subfunction_index : cython.int, variables : np.ndarray ): 26 | trap_variables : np.ndarray = variables[self.inputs_to_subfunction(subfunction_index)] 27 | unitation : cython.int = np.sum(trap_variables) 28 | if unitation == self.k: 29 | return unitation 30 | else: 31 | return self.k - unitation - 1 -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | python setup.py build_ext --inplace 3 | 4 | clean: 5 | rm -r build/ 6 | rm *.so -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/PythonTrapFunction.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | from functools import cache 4 | 5 | # Custom fitness function resembling the concatenated deceptive trap function of size k 6 | class DeceptiveTrapFunctionGBO(gomea.fitness.GBOFitnessFunctionDiscrete): 7 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 8 | def __new__(self, number_of_variables, k ): 9 | assert( number_of_variables % k == 0 ) 10 | self.k = k 11 | value_to_reach = number_of_variables 12 | return super().__new__(self,number_of_variables,value_to_reach) 13 | 14 | @cache 15 | def number_of_subfunctions( self ): 16 | return self.number_of_variables // self.k 17 | 18 | @cache 19 | def inputs_to_subfunction( self, subfunction_index ): 20 | return range(self.k*subfunction_index,self.k*subfunction_index+self.k) 21 | 22 | def subfunction(self, subfunction_index, variables): 23 | trap_variables = variables[self.inputs_to_subfunction(subfunction_index)] 24 | unitation = np.sum(trap_variables) 25 | if unitation == self.k: 26 | return unitation 27 | else: 28 | return self.k - unitation - 1 29 | 30 | class DeceptiveTrapFunctionBBO(gomea.fitness.BBOFitnessFunctionDiscrete): 31 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 32 | def __new__(self, number_of_variables, k ): 33 | assert( number_of_variables % k == 0 ) 34 | self.k = k 35 | value_to_reach = number_of_variables 36 | return super().__new__(self,number_of_variables,value_to_reach) 37 | 38 | def objective_function(self, objective_index, variables): 39 | def trap_function(unitation): 40 | if unitation == self.k: 41 | return unitation 42 | else: 43 | return self.k - unitation - 1 44 | 45 | start_indices = np.arange(0,self.number_of_variables,self.k) 46 | unitations = [np.sum(variables[ind:ind+self.k]) for ind in start_indices] 47 | f = np.sum([trap_function(u) for u in unitations]) 48 | return f 49 | 50 | def constraint_function(self, variables): 51 | return 0.0 -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CWI-EvolutionaryIntelligence/GOMEA/769fa6e309c78565415eb65a8deb4c5da8f920af/benchmarks/deceptive_trap/__init__.py -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/results/.placeholder: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /benchmarks/deceptive_trap/setup.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from setuptools import setup, Extension 3 | from Cython.Build import cythonize 4 | from pathlib import Path 5 | import os 6 | import gomea 7 | 8 | extensions = [] 9 | 10 | libs_path = str(Path(gomea.__path__[0]).parent.absolute()) 11 | gomea_path = str(Path(gomea.__path__[0]).absolute()) 12 | libs_to_find = ['fitness', 'discrete', 'linkage', 'output'] 13 | libs_to_link = [] 14 | for root, dirs, files in os.walk(gomea_path): 15 | for lib_to_find in libs_to_find: 16 | for f in files: 17 | if f.startswith(lib_to_find) and f.endswith('.so'): 18 | libs_to_link.append("-l:"+str(f)) 19 | #print(libs_to_link) 20 | # find names of library files within gomea_path to link with and add to 'libs_to_link' 21 | extensions.append( Extension("CythonTrapFunction", 22 | ["CythonTrapFunction.pyx"], 23 | language="c++") 24 | ) 25 | extensions.append( Extension("CythonTrapFunctionCDEF", 26 | ["CythonTrapFunction-cdef.pyx"], 27 | include_dirs=[libs_path], 28 | extra_compile_args=libs_to_link, 29 | extra_link_args=libs_to_link, 30 | library_dirs=[gomea_path], 31 | language="c++") 32 | ) 33 | 34 | setup( 35 | ext_modules = cythonize(extensions, 36 | include_path = ["."] + [libs_path] + [np.get_include()], 37 | annotate = True, 38 | language_level = "3"), 39 | zip_safe = False 40 | ) 41 | -------------------------------------------------------------------------------- /benchmarks/maxcut/CythonMaxCut.pyx: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | import cython 4 | from functools import cache 5 | 6 | # Custom fitness function resembling the concatenated deceptive trap function of size k 7 | class MaxCut(gomea.fitness.GBOFitnessFunctionDiscrete): 8 | edges : np.ndarray 9 | def __new__(self, input_file, vtr_file ): 10 | number_of_variables : cython.int = 0 11 | value_to_reach : cython.double = 1e308 12 | self.edges : np.ndarray = [] 13 | with open(input_file,"r") as f: 14 | lines = [line.split() for line in f.readlines()] 15 | number_of_variables = int(lines[0][0]) 16 | number_of_edges = int(lines[0][1]) 17 | for i in range(number_of_edges): 18 | v1 = int(lines[i+1][0])-1 19 | v2 = int(lines[i+1][1])-1 20 | w = float(lines[i+1][2]) 21 | self.edges.append((v1,v2,w)) 22 | with open(vtr_file,"r") as f: 23 | lines = f.readlines() 24 | value_to_reach = float(lines[0].strip()) 25 | return super().__new__(self,number_of_variables,value_to_reach) 26 | 27 | @cache 28 | def number_of_subfunctions( self ) -> cython.int: 29 | return len(self.edges) 30 | 31 | @cache 32 | def inputs_to_subfunction( self, subfunction_index ) -> np.ndarray: 33 | return list(self.edges[subfunction_index]) 34 | 35 | def subfunction(self, subfunction_index, variables) -> cython.double: 36 | v1 : cython.int = self.edges[subfunction_index][0] 37 | v2 : cython.int = self.edges[subfunction_index][1] 38 | w : cython.double = self.edges[subfunction_index][2] 39 | if variables[v1] == variables[v2]: 40 | return 0.0 41 | else: 42 | return w -------------------------------------------------------------------------------- /benchmarks/maxcut/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | python setup.py build_ext --inplace 3 | 4 | clean: 5 | rm -r build/ 6 | rm *.so -------------------------------------------------------------------------------- /benchmarks/maxcut/PythonMaxCut.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | from functools import cache 4 | 5 | # Custom fitness function resembling the concatenated deceptive trap function of size k 6 | class MaxCutGBO(gomea.fitness.GBOFitnessFunctionDiscrete): 7 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 8 | def __new__(self, input_file, vtr_file ): 9 | number_of_variables = 0 10 | value_to_reach = 1e308 11 | self.edges = [] 12 | with open(input_file,"r") as f: 13 | lines = [line.split() for line in f.readlines()] 14 | number_of_variables = int(lines[0][0]) 15 | number_of_edges = int(lines[0][1]) 16 | for i in range(number_of_edges): 17 | v1 = int(lines[i+1][0])-1 18 | v2 = int(lines[i+1][1])-1 19 | w = float(lines[i+1][2]) 20 | self.edges.append((v1,v2,w)) 21 | assert(number_of_edges == len(self.edges)) 22 | with open(vtr_file,"r") as f: 23 | lines = f.readlines() 24 | value_to_reach = float(lines[0].strip()) 25 | return super().__new__(self,number_of_variables,value_to_reach) 26 | 27 | @cache 28 | def number_of_subfunctions( self ): 29 | return len(self.edges) 30 | 31 | @cache 32 | def inputs_to_subfunction( self, subfunction_index ): 33 | return list(self.edges[subfunction_index][0:2]) 34 | 35 | def subfunction(self, subfunction_index, variables): 36 | v1,v2,w = self.edges[subfunction_index] 37 | if variables[v1] == variables[v2]: 38 | return 0.0 39 | else: 40 | return w 41 | 42 | class MaxCutBBO(gomea.fitness.BBOFitnessFunctionDiscrete): 43 | def __new__(self, input_file, vtr_file ): 44 | number_of_variables = 0 45 | value_to_reach = 1e308 46 | self.edges = [] 47 | with open(input_file,"r") as f: 48 | lines = [line.split() for line in f.readlines()] 49 | number_of_variables = int(lines[0][0]) 50 | number_of_edges = int(lines[0][1]) 51 | for i in range(number_of_edges): 52 | v1 = int(lines[i+1][0])-1 53 | v2 = int(lines[i+1][1])-1 54 | w = float(lines[i+1][2]) 55 | self.edges.append((v1,v2,w)) 56 | assert(number_of_edges == len(self.edges)) 57 | with open(vtr_file,"r") as f: 58 | lines = f.readlines() 59 | value_to_reach = float(lines[0].strip()) 60 | return super().__new__(self,number_of_variables,value_to_reach) 61 | 62 | def objective_function(self, objective_index, variables): 63 | cut = 0.0 64 | for v1,v2,w in self.edges: 65 | if variables[v1] != variables[v2]: 66 | cut += w 67 | return cut -------------------------------------------------------------------------------- /benchmarks/maxcut/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CWI-EvolutionaryIntelligence/GOMEA/769fa6e309c78565415eb65a8deb4c5da8f920af/benchmarks/maxcut/__init__.py -------------------------------------------------------------------------------- /benchmarks/maxcut/setup.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from setuptools import setup, Extension 3 | from Cython.Build import cythonize 4 | 5 | extensions = [] 6 | extensions.append( Extension("CythonMaxCut", 7 | ["CythonMaxCut.pyx"], 8 | language="c++") 9 | ) 10 | 11 | setup( 12 | ext_modules = cythonize(extensions, 13 | include_path = ["."] + [np.get_include()], 14 | annotate = True, 15 | language_level = "3"), 16 | zip_safe = False 17 | ) 18 | -------------------------------------------------------------------------------- /benchmarks/output.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def getResDir(prob_tag): 4 | res_dir = "results/" 5 | if prob_tag == "trap5": 6 | res_dir = "deceptive_trap/" + res_dir 7 | elif prob_tag == "sorebchainstrong": 8 | res_dir = "soreb_chain/" + res_dir 9 | else: 10 | res_dir = prob_tag + "/" + res_dir 11 | return res_dir 12 | 13 | def writeResultsToJson(input,prob_tag,lang_tag,lm_tag): 14 | res_dir = getResDir(prob_tag) 15 | full_tag = prob_tag+"_"+lang_tag+"_"+lm_tag 16 | filename = res_dir+full_tag+".json" 17 | with open(filename,'w') as fp: 18 | json.dump(input,fp) 19 | 20 | def readResultsFromJson(prob_tag,lang_tag,lm_tag): 21 | res_dir = getResDir(prob_tag) 22 | full_tag = prob_tag+"_"+lang_tag+"_"+lm_tag 23 | filename = res_dir+full_tag+".json" 24 | try: 25 | with open(filename,'r') as fp: 26 | res = json.load(fp) 27 | for k,sub_dict in res.items(): 28 | try: 29 | res[k] = {int(dim):[float(r) for r in res] for dim,res in sub_dict.items()} 30 | except Exception as e: 31 | res[k] = {int(dim):res for dim,res in sub_dict.items()} 32 | return res 33 | except Exception as e: 34 | print(e) 35 | return {} 36 | 37 | def resultsExist(prob_tag,lang_tag,lm_tag): 38 | res_dir = getResDir(prob_tag) 39 | full_tag = prob_tag+"_"+lang_tag+"_"+lm_tag 40 | filename = res_dir+full_tag+".json" 41 | try: 42 | with open(filename,'r') as fp: 43 | return True 44 | except FileNotFoundError: 45 | return False -------------------------------------------------------------------------------- /benchmarks/rosenbrock/PythonRosenbrock.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | from functools import cache 4 | 5 | # Custom fitness function resembling the concatenated deceptive trap function of size k 6 | class RosenbrockFunctionGBO(gomea.fitness.GBOFitnessFunctionRealValued): 7 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 8 | @cache 9 | def number_of_subfunctions( self ): 10 | return self.number_of_variables - 1 11 | 12 | @cache 13 | def inputs_to_subfunction( self, subfunction_index ): 14 | return [subfunction_index, subfunction_index+1] 15 | 16 | def subfunction(self, subfunction_index, variables): 17 | x = variables[subfunction_index] 18 | y = variables[subfunction_index+1] 19 | return( 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) ) 20 | 21 | class RosenbrockFunctionBBO(gomea.fitness.BBOFitnessFunctionRealValued): 22 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 23 | def objective_function(self, objective_index, variables): 24 | result = 0.0 25 | for i in range(self.number_of_variables-1): 26 | x = variables[i] 27 | y = variables[i+1] 28 | result += 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) 29 | return result 30 | 31 | def constraint_function(self, variables): 32 | return 0.0 -------------------------------------------------------------------------------- /benchmarks/soreb_chain/PythonSOREBChainStrong.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | from functools import cache 4 | 5 | # Custom fitness function resembling the concatenated deceptive trap function of size k 6 | class SOREBChainStrongGBO(gomea.fitness.GBOFitnessFunctionRealValued): 7 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 8 | def __new__(self, number_of_variables, value_to_reach ): 9 | self.rotation_angle = 45 10 | self.rotation_block_size = 2 11 | return super().__new__(self,number_of_variables,value_to_reach) 12 | 13 | @cache 14 | def number_of_subfunctions( self ): 15 | return self.number_of_variables - 1 16 | 17 | @cache 18 | def inputs_to_subfunction( self, subfunction_index ): 19 | return [subfunction_index, subfunction_index+1] 20 | 21 | def subfunction(self, subfunction_index, variables): 22 | rotated_variables = self.rotate_variables(variables[self.inputs_to_subfunction(subfunction_index)],self.rotation_angle) 23 | result = 0.0 24 | for i in range(self.rotation_block_size): 25 | result += 10.0**(6.0*(i/(self.rotation_block_size-1) ))*rotated_variables[i]*rotated_variables[i] 26 | return result 27 | 28 | class SOREBChainStrongBBO(gomea.fitness.BBOFitnessFunctionRealValued): 29 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 30 | def __new__(self, number_of_variables, value_to_reach ): 31 | self.rotation_angle = 45 32 | self.rotation_block_size = 2 33 | return super().__new__(self,number_of_variables,value_to_reach) 34 | 35 | def objective_function(self, objective_index, variables): 36 | result = 0.0 37 | for i in range(self.number_of_variables-1): 38 | rotated_variables = self.rotate_variables(variables[i:i+2],self.rotation_angle) 39 | for i in range(self.rotation_block_size): 40 | result += 10.0**(6.0*(i/(self.rotation_block_size-1) ))*rotated_variables[i]*rotated_variables[i] 41 | return result 42 | 43 | def constraint_function(self, variables): 44 | return 0.0 -------------------------------------------------------------------------------- /benchmarks/soreb_chain/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CWI-EvolutionaryIntelligence/GOMEA/769fa6e309c78565415eb65a8deb4c5da8f920af/benchmarks/soreb_chain/__init__.py -------------------------------------------------------------------------------- /benchmarks/soreb_chain/results/.placeholder: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/bbo_discrete/main.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | 4 | # Custom fitness function resembling the concatenated deceptive trap function of size k 5 | class CustomTrapFunction(gomea.fitness.BBOFitnessFunctionDiscrete): 6 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 7 | def __new__(self, number_of_variables, k, **kwargs): 8 | assert( number_of_variables % k == 0 ) 9 | self.k = k 10 | return super().__new__(self,number_of_variables,**kwargs) 11 | 12 | def objective_function(self, objective_index, variables): 13 | f = 0 14 | for i in range(0,self.number_of_variables,self.k): 15 | trap_variables = variables[i:i+self.k] 16 | unitation = np.sum(trap_variables) 17 | if unitation == self.k: 18 | f += unitation 19 | else: 20 | f += self.k - unitation - 1 21 | return f 22 | 23 | dim = 20 24 | lm = gomea.linkage.BlockMarginalProduct(block_size=5) 25 | fd = CustomTrapFunction(dim,k=5,value_to_reach=dim) 26 | dgom = gomea.DiscreteGOMEA(fitness=fd,linkage_model=lm,max_number_of_evaluations=100000) 27 | result = dgom.run() 28 | result.printAllStatistics() 29 | -------------------------------------------------------------------------------- /demos/bbo_realvalued/main.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | 4 | # Custom BBO fitness function resembling the Rosenbrock function 5 | class CustomRosenbrockFunction(gomea.fitness.BBOFitnessFunctionRealValued): 6 | def objective_function( self, objective_index, variables ): 7 | f = 0 8 | for i in range(len(variables)-1): 9 | x = variables[i] 10 | y = variables[i+1] 11 | f += 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) 12 | return f 13 | 14 | dim = 10 15 | frv = CustomRosenbrockFunction(dim,value_to_reach=1e-6) 16 | lm = gomea.linkage.Univariate() 17 | rvgom = gomea.RealValuedGOMEA(fitness=frv, linkage_model=lm, lower_init_range=-115, upper_init_range=-100, max_number_of_populations=1, base_population_size=100, max_number_of_evaluations=1000000) 18 | result = rvgom.run() 19 | result.printAllStatistics() 20 | -------------------------------------------------------------------------------- /demos/gbo_discrete/main.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | 4 | # Custom fitness function resembling the concatenated deceptive trap function of size k 5 | class CustomTrapFunction(gomea.fitness.GBOFitnessFunctionDiscrete): 6 | # Any members must be assigned in __new__ to make them accessible during instantiation of superclass 7 | def __new__(self, number_of_variables, k, **kwargs): 8 | assert( number_of_variables % k == 0 ) 9 | self.k = k 10 | return super().__new__(self,number_of_variables,**kwargs) 11 | 12 | def number_of_subfunctions( self ): 13 | return self.number_of_variables // self.k 14 | 15 | def inputs_to_subfunction( self, subfunction_index ): 16 | return range(self.k*subfunction_index,self.k*subfunction_index+self.k) 17 | 18 | def subfunction(self, subfunction_index, variables): 19 | trap_variables = variables[self.inputs_to_subfunction(subfunction_index)] 20 | unitation = np.sum(trap_variables) 21 | if unitation == self.k: 22 | return unitation 23 | else: 24 | return self.k - unitation - 1 25 | 26 | dim = 20 27 | lm = gomea.linkage.StaticLinkageTree(maximum_set_size=5) 28 | fd = CustomTrapFunction(dim,k=5,value_to_reach=dim) 29 | dgom = gomea.DiscreteGOMEA(fitness=fd,linkage_model=lm,max_number_of_evaluations=100000) 30 | result = dgom.run() 31 | result.printAllStatistics() 32 | -------------------------------------------------------------------------------- /demos/gbo_realvalued/main.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import numpy as np 3 | 4 | # Custom GBO fitness function resembling the Rosenbrock function 5 | class CustomRosenbrockFunction(gomea.fitness.GBOFitnessFunctionRealValued): 6 | def number_of_subfunctions( self ): 7 | return self.number_of_variables-1 8 | 9 | def inputs_to_subfunction( self, subfunction_index ): 10 | return [subfunction_index, subfunction_index+1] 11 | 12 | def subfunction(self, subfunction_index, variables): 13 | x = variables[subfunction_index] 14 | y = variables[subfunction_index+1] 15 | return 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) 16 | 17 | dim = 10 18 | frv = CustomRosenbrockFunction(dim,value_to_reach=1e-6) 19 | lm = gomea.linkage.Univariate() 20 | rvgom = gomea.RealValuedGOMEA(fitness=frv, linkage_model=lm, lower_init_range=-115, upper_init_range=-100, max_number_of_populations=1, base_population_size=100, max_number_of_evaluations=1000000) 21 | result = rvgom.run() 22 | result.printAllStatistics() 23 | -------------------------------------------------------------------------------- /demos/plotting/main.py: -------------------------------------------------------------------------------- 1 | import gomea 2 | import matplotlib.pyplot as plt 3 | 4 | frv = gomea.fitness.RosenbrockFunction(10,value_to_reach=1e-10) 5 | lm = gomea.linkage.Univariate() 6 | rvgom = gomea.RealValuedGOMEA(fitness=frv, linkage_model=lm, lower_init_range=-115, upper_init_range=-100) 7 | result = rvgom.run() 8 | plt.grid() 9 | plt.yscale('log') 10 | plt.xscale('log') 11 | plt.xlabel('Number of evaluations') 12 | plt.ylabel('Best objective value') 13 | plt.plot(result['evaluations'],result['best_obj_val']) 14 | plt.savefig('convergence_plot.pdf') 15 | 16 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.https://www.sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | # import os 14 | # import sys 15 | # sys.path.insert(0, os.path.abspath('.')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = 'GOMEA' 21 | copyright = '2023, Anton Bouter' 22 | author = 'Anton Bouter' 23 | 24 | # The full version, including alpha/beta/rc tags 25 | release = '1.0' 26 | 27 | 28 | # -- General configuration --------------------------------------------------- 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [ 34 | 'sphinx.ext.duration', 35 | 'sphinx.ext.doctext', 36 | 'sphinx.ext.autodoc', 37 | 'sphinx.ext.autosummary', 38 | ] 39 | 40 | # Add any paths that contain templates here, relative to this directory. 41 | templates_path = ['_templates'] 42 | 43 | # List of patterns, relative to source directory, that match files and 44 | # directories to ignore when looking for source files. 45 | # This pattern also affects html_static_path and html_extra_path. 46 | exclude_patterns = [] 47 | 48 | 49 | # -- Options for HTML output ------------------------------------------------- 50 | 51 | # The theme to use for HTML and HTML Help pages. See the documentation for 52 | # a list of builtin themes. 53 | # 54 | html_theme = 'alabaster' 55 | 56 | # Add any paths that contain custom static files (such as style sheets) here, 57 | # relative to this directory. They are copied after the builtin static files, 58 | # so a file named "default.css" will overwrite the builtin "default.css". 59 | html_static_path = ['_static'] 60 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. GOMEA documentation master file, created by 2 | sphinx-quickstart on Wed Apr 12 17:14:33 2023. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to GOMEA's documentation! 7 | ================================= 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | 13 | 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | -------------------------------------------------------------------------------- /docs/source/usage.rst: -------------------------------------------------------------------------------- 1 | Usage 2 | ================================= 3 | 4 | Installation 5 | ------------ 6 | To install the gomea, run from the root directory: 7 | .. code-block:: console 8 | $ make install 9 | 10 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: gomea 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - make 6 | - c-compiler 7 | - cxx-compiler 8 | - python==3.12 9 | - python-devtools==0.9.0 10 | - numpy==2.0.1 11 | - ninja==1.12.1 12 | - pip 13 | - pip: 14 | - meson==1.5.1 15 | - meson-python==0.16.0 16 | - numpy==2.0.1 17 | - wheel==0.44.0 18 | - setuptools==72.1.0 19 | - Cython==3.0.10 20 | - tqdm==4.65.0 21 | -------------------------------------------------------------------------------- /gomea-lib.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "gomea-lib", 5 | "path": "." 6 | } 7 | ], 8 | "settings": { 9 | "files.associations": { 10 | "chrono": "cpp", 11 | "array": "cpp", 12 | "deque": "cpp", 13 | "unordered_map": "cpp", 14 | "vector": "cpp", 15 | "initializer_list": "cpp", 16 | "string_view": "cpp", 17 | "sstream": "cpp" 18 | }, 19 | "python.terminal.executeInFileDir": true 20 | } 21 | } -------------------------------------------------------------------------------- /gomea.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": { 8 | "files.associations": { 9 | "chrono": "cpp", 10 | "array": "cpp", 11 | "deque": "cpp", 12 | "unordered_map": "cpp", 13 | "vector": "cpp", 14 | "initializer_list": "cpp", 15 | "string_view": "cpp", 16 | "sstream": "cpp", 17 | "atomic": "cpp", 18 | "bit": "cpp", 19 | "*.tcc": "cpp", 20 | "cctype": "cpp", 21 | "clocale": "cpp", 22 | "cmath": "cpp", 23 | "compare": "cpp", 24 | "complex": "cpp", 25 | "concepts": "cpp", 26 | "cstddef": "cpp", 27 | "cstdint": "cpp", 28 | "cstdio": "cpp", 29 | "cstdlib": "cpp", 30 | "cstring": "cpp", 31 | "ctime": "cpp", 32 | "cwchar": "cpp", 33 | "cwctype": "cpp", 34 | "list": "cpp", 35 | "map": "cpp", 36 | "set": "cpp", 37 | "exception": "cpp", 38 | "fstream": "cpp", 39 | "functional": "cpp", 40 | "iosfwd": "cpp", 41 | "iostream": "cpp", 42 | "istream": "cpp", 43 | "limits": "cpp", 44 | "memory": "cpp", 45 | "new": "cpp", 46 | "numbers": "cpp", 47 | "numeric": "cpp", 48 | "ostream": "cpp", 49 | "ratio": "cpp", 50 | "semaphore": "cpp", 51 | "stdexcept": "cpp", 52 | "stop_token": "cpp", 53 | "streambuf": "cpp", 54 | "string": "cpp", 55 | "system_error": "cpp", 56 | "thread": "cpp", 57 | "type_traits": "cpp", 58 | "tuple": "cpp", 59 | "typeinfo": "cpp", 60 | "utility": "cpp", 61 | "variant": "cpp", 62 | "cstdarg": "cpp", 63 | "hash_map": "cpp", 64 | "condition_variable": "cpp", 65 | "unordered_set": "cpp", 66 | "algorithm": "cpp", 67 | "iterator": "cpp", 68 | "memory_resource": "cpp", 69 | "optional": "cpp", 70 | "random": "cpp", 71 | "mutex": "cpp", 72 | "cinttypes": "cpp", 73 | "charconv": "cpp", 74 | "format": "cpp", 75 | "iomanip": "cpp", 76 | "span": "cpp" 77 | }, 78 | "python.terminal.executeInFileDir": true 79 | } 80 | } -------------------------------------------------------------------------------- /gomea/__init__.pxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CWI-EvolutionaryIntelligence/GOMEA/769fa6e309c78565415eb65a8deb4c5da8f920af/gomea/__init__.pxd -------------------------------------------------------------------------------- /gomea/__init__.py: -------------------------------------------------------------------------------- 1 | import gomea.fitness 2 | import gomea.real_valued 3 | import gomea.discrete 4 | import gomea.linkage 5 | 6 | def RealValuedGOMEA(**kwargs): 7 | return gomea.real_valued.RealValuedGOMEA(**kwargs) 8 | 9 | def DiscreteGOMEA(**kwargs): 10 | return gomea.discrete.DiscreteGOMEA(**kwargs) -------------------------------------------------------------------------------- /gomea/discrete.pxd: -------------------------------------------------------------------------------- 1 | from libcpp.string cimport string 2 | from libcpp cimport bool 3 | from gomea.output cimport output_statistics_t 4 | from gomea.fitness cimport fitness_t 5 | from gomea.linkage cimport linkage_config_t 6 | 7 | cdef extern from "gomea/src/discrete/Config.hpp" namespace "gomea::discrete": 8 | cdef cppclass Config: 9 | Config() except + 10 | 11 | int maximumNumberOfGOMEAs, IMSsubgenerationFactor, basePopulationSize, maxArchiveSize, maximumNumberOfEvaluations, maximumNumberOfGenerations, AnalyzeFOS 12 | long long randomSeed 13 | bool gene_invariant, fix_seed, generational_statistics, generational_solution, verbose 14 | output_frequency_t output_frequency 15 | double maximumNumberOfSeconds 16 | string folder, problemInstancePath 17 | fitness_t[char] *fitness 18 | linkage_config_t *linkage_config 19 | 20 | cdef extern from "gomea/src/discrete/gomeaIMS.hpp" namespace "gomea::discrete": 21 | cdef cppclass gomeaIMS: 22 | gomeaIMS() except + 23 | gomeaIMS(Config*) except + 24 | 25 | void run() except + 26 | void runGeneration() except + 27 | bool checkTermination() except + 28 | double getProgressUntilTermination() except + 29 | output_statistics_t output 30 | 31 | cdef extern from "src/common/gomea_defs.hpp" namespace "gomea": 32 | ctypedef enum output_frequency_t: 33 | GEN, IMS_GEN, NEW_ELITE 34 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | #include "Jacobi" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** \defgroup Cholesky_Module Cholesky module 17 | * 18 | * 19 | * 20 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 21 | * Those decompositions are also accessible via the following methods: 22 | * - MatrixBase::llt() 23 | * - MatrixBase::ldlt() 24 | * - SelfAdjointView::llt() 25 | * - SelfAdjointView::ldlt() 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | */ 31 | 32 | #include "src/Cholesky/LLT.h" 33 | #include "src/Cholesky/LDLT.h" 34 | #ifdef EIGEN_USE_LAPACKE 35 | #ifdef EIGEN_USE_MKL 36 | #include "mkl_lapacke.h" 37 | #else 38 | #include "src/misc/lapacke.h" 39 | #endif 40 | #include "src/Cholesky/LLT_LAPACKE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_CHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | #include "LU" 17 | #include "Geometry" 18 | 19 | #include "src/Core/util/DisableStupidWarnings.h" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #ifdef EIGEN_USE_MKL 49 | #include "mkl_lapacke.h" 50 | #else 51 | #include "src/misc/lapacke.h" 52 | #endif 53 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 54 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 55 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_EIGENVALUES_MODULE_H 61 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "SVD" 14 | #include "LU" 15 | #include 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. 53 | #if (defined EIGEN_VECTORIZE_SSE) || (defined EIGEN_VECTORIZE_NEON) 54 | #include "src/Geometry/arch/Geometry_SIMD.h" 55 | #endif 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_GEOMETRY_MODULE_H 60 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | 33 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/KLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_KLUSUPPORT_MODULE_H 9 | #define EIGEN_KLUSUPPORT_MODULE_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup KLUSupport_Module KLUSupport module 22 | * 23 | * This module provides an interface to the KLU library which is part of the suitesparse package. 24 | * It provides the following factorization class: 25 | * - class KLU: a sparse LU factorization, well-suited for circuit simulation. 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | * 31 | * In order to use this module, the klu and btf headers must be accessible from the include paths, and your binary must be linked to the klu library and its dependencies. 32 | * The dependencies depend on how umfpack has been compiled. 33 | * For a cmake based project, you can use our FindKLU.cmake module to help you in this task. 34 | * 35 | */ 36 | 37 | #include "src/KLUSupport/KLUSupport.h" 38 | 39 | #include 40 | 41 | #endif // EIGEN_KLUSUPPORT_MODULE_H 42 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #ifdef EIGEN_USE_MKL 32 | #include "mkl_lapacke.h" 33 | #else 34 | #include "src/misc/lapacke.h" 35 | #endif 36 | #include "src/LU/PartialPivLU_LAPACKE.h" 37 | #endif 38 | #include "src/LU/Determinant.h" 39 | #include "src/LU/InverseImpl.h" 40 | 41 | #if defined EIGEN_VECTORIZE_SSE || defined EIGEN_VECTORIZE_NEON 42 | #include "src/LU/arch/InverseSize4.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_LU_MODULE_H 48 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 9 | #define EIGEN_ORDERINGMETHODS_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** 16 | * \defgroup OrderingMethods_Module OrderingMethods module 17 | * 18 | * This module is currently for internal use only 19 | * 20 | * It defines various built-in and external ordering methods for sparse matrices. 21 | * They are typically used to reduce the number of elements during 22 | * the sparse matrix decomposition (LLT, LU, QR). 23 | * Precisely, in a preprocessing step, a permutation matrix P is computed using 24 | * those ordering methods and applied to the columns of the matrix. 25 | * Using for instance the sparse Cholesky decomposition, it is expected that 26 | * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). 27 | * 28 | * 29 | * Usage : 30 | * \code 31 | * #include 32 | * \endcode 33 | * 34 | * A simple usage is as a template parameter in the sparse decomposition classes : 35 | * 36 | * \code 37 | * SparseLU > solver; 38 | * \endcode 39 | * 40 | * \code 41 | * SparseQR > solver; 42 | * \endcode 43 | * 44 | * It is possible as well to call directly a particular ordering method for your own purpose, 45 | * \code 46 | * AMDOrdering ordering; 47 | * PermutationMatrix perm; 48 | * SparseMatrix A; 49 | * //Fill the matrix ... 50 | * 51 | * ordering(A, perm); // Call AMD 52 | * \endcode 53 | * 54 | * \note Some of these methods (like AMD or METIS), need the sparsity pattern 55 | * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, 56 | * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. 57 | * If your matrix is already symmetric (at leat in structure), you can avoid that 58 | * by calling the method with a SelfAdjointView type. 59 | * 60 | * \code 61 | * // Call the ordering on the pattern of the lower triangular matrix A 62 | * ordering(A.selfadjointView(), perm); 63 | * \endcode 64 | */ 65 | 66 | #include "src/OrderingMethods/Amd.h" 67 | #include "src/OrderingMethods/Ordering.h" 68 | #include "src/Core/util/ReenableStupidWarnings.h" 69 | 70 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 71 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * This wrapper resuires PaStiX version 5.x compiled without MPI support. 40 | * The dependencies depend on how PaSTiX has been compiled. 41 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 42 | * 43 | */ 44 | 45 | #include "src/PaStiXSupport/PaStiXSupport.h" 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 50 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #ifdef EIGEN_USE_MKL 40 | #include "mkl_lapacke.h" 41 | #else 42 | #include "src/misc/lapacke.h" 43 | #endif 44 | #include "src/QR/HouseholderQR_LAPACKE.h" 45 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_QR_MODULE_H 51 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #ifdef EIGEN_USE_MKL 41 | #include "mkl_lapacke.h" 42 | #else 43 | #include "src/misc/lapacke.h" 44 | #endif 45 | #include "src/SVD/JacobiSVD_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SVD_MODULE_H 51 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #include "SparseCholesky" 29 | #include "SparseLU" 30 | #include "SparseQR" 31 | #include "IterativeLinearSolvers" 32 | 33 | #endif // EIGEN_SPARSE_MODULE_H 34 | 35 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/SparseCholesky/SimplicialCholesky.h" 34 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 38 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSECORE_MODULE_H 9 | #define EIGEN_SPARSECORE_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /** 22 | * \defgroup SparseCore_Module SparseCore module 23 | * 24 | * This module provides a sparse matrix representation, and basic associated matrix manipulations 25 | * and operations. 26 | * 27 | * See the \ref TutorialSparse "Sparse tutorial" 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | * 33 | * This module depends on: Core. 34 | */ 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/SparseAssign.h" 39 | #include "src/SparseCore/CompressedStorage.h" 40 | #include "src/SparseCore/AmbiVector.h" 41 | #include "src/SparseCore/SparseCompressedBase.h" 42 | #include "src/SparseCore/SparseMatrix.h" 43 | #include "src/SparseCore/SparseMap.h" 44 | #include "src/SparseCore/MappedSparseMatrix.h" 45 | #include "src/SparseCore/SparseVector.h" 46 | #include "src/SparseCore/SparseRef.h" 47 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 48 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 49 | #include "src/SparseCore/SparseTranspose.h" 50 | #include "src/SparseCore/SparseBlock.h" 51 | #include "src/SparseCore/SparseDot.h" 52 | #include "src/SparseCore/SparseRedux.h" 53 | #include "src/SparseCore/SparseView.h" 54 | #include "src/SparseCore/SparseDiagonalProduct.h" 55 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 56 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 57 | #include "src/SparseCore/SparseProduct.h" 58 | #include "src/SparseCore/SparseDenseProduct.h" 59 | #include "src/SparseCore/SparseSelfAdjointView.h" 60 | #include "src/SparseCore/SparseTriangularView.h" 61 | #include "src/SparseCore/TriangularSolver.h" 62 | #include "src/SparseCore/SparsePermutation.h" 63 | #include "src/SparseCore/SparseFuzzy.h" 64 | #include "src/SparseCore/SparseSolverBase.h" 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSECORE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/Core/util/DisableStupidWarnings.h" 27 | 28 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 29 | 30 | #include "src/SparseLU/SparseLU_Structs.h" 31 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 32 | #include "src/SparseLU/SparseLUImpl.h" 33 | #include "src/SparseCore/SparseColEtree.h" 34 | #include "src/SparseLU/SparseLU_Memory.h" 35 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 36 | #include "src/SparseLU/SparseLU_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_pivotL.h" 38 | #include "src/SparseLU/SparseLU_panel_dfs.h" 39 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 40 | #include "src/SparseLU/SparseLU_panel_bmod.h" 41 | #include "src/SparseLU/SparseLU_column_dfs.h" 42 | #include "src/SparseLU/SparseLU_column_bmod.h" 43 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 44 | #include "src/SparseLU/SparseLU_pruneL.h" 45 | #include "src/SparseLU/SparseLU_Utils.h" 46 | #include "src/SparseLU/SparseLU.h" 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SPARSELU_MODULE_H 51 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseQR/SparseQR.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 9 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #ifdef EMPTY 16 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 17 | #endif 18 | 19 | typedef int int_t; 20 | #include 21 | #include 22 | #include 23 | 24 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 25 | // so we remove it in favor of a SUPERLU_EMPTY token. 26 | // If EMPTY was already defined then we don't undef it. 27 | 28 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 29 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 30 | #elif defined(EMPTY) 31 | # undef EMPTY 32 | #endif 33 | 34 | #define SUPERLU_EMPTY (-1) 35 | 36 | namespace Eigen { struct SluMatrix; } 37 | 38 | /** \ingroup Support_modules 39 | * \defgroup SuperLUSupport_Module SuperLUSupport module 40 | * 41 | * This module provides an interface to the SuperLU library. 42 | * It provides the following factorization class: 43 | * - class SuperLU: a supernodal sequential LU factorization. 44 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 45 | * 46 | * \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported. 47 | * 48 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 49 | * 50 | * \code 51 | * #include 52 | * \endcode 53 | * 54 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 55 | * The dependencies depend on how superlu has been compiled. 56 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 57 | * 58 | */ 59 | 60 | #include "src/SuperLUSupport/SuperLUSupport.h" 61 | 62 | #include "src/Core/util/ReenableStupidWarnings.h" 63 | 64 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 65 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/Assign.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Michael Olbrich 5 | // Copyright (C) 2006-2010 Benoit Jacob 6 | // Copyright (C) 2008 Gael Guennebaud 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_ASSIGN_H 13 | #define EIGEN_ASSIGN_H 14 | 15 | namespace Eigen { 16 | 17 | template 18 | template 19 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase 20 | ::lazyAssign(const DenseBase& other) 21 | { 22 | enum{ 23 | SameType = internal::is_same::value 24 | }; 25 | 26 | EIGEN_STATIC_ASSERT_LVALUE(Derived) 27 | EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) 28 | EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 29 | 30 | eigen_assert(rows() == other.rows() && cols() == other.cols()); 31 | internal::call_assignment_no_alias(derived(),other.derived()); 32 | 33 | return derived(); 34 | } 35 | 36 | template 37 | template 38 | EIGEN_DEVICE_FUNC 39 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 40 | { 41 | internal::call_assignment(derived(), other.derived()); 42 | return derived(); 43 | } 44 | 45 | template 46 | EIGEN_DEVICE_FUNC 47 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 48 | { 49 | internal::call_assignment(derived(), other.derived()); 50 | return derived(); 51 | } 52 | 53 | template 54 | EIGEN_DEVICE_FUNC 55 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) 56 | { 57 | internal::call_assignment(derived(), other.derived()); 58 | return derived(); 59 | } 60 | 61 | template 62 | template 63 | EIGEN_DEVICE_FUNC 64 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const DenseBase& other) 65 | { 66 | internal::call_assignment(derived(), other.derived()); 67 | return derived(); 68 | } 69 | 70 | template 71 | template 72 | EIGEN_DEVICE_FUNC 73 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) 74 | { 75 | internal::call_assignment(derived(), other.derived()); 76 | return derived(); 77 | } 78 | 79 | template 80 | template 81 | EIGEN_DEVICE_FUNC 82 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) 83 | { 84 | other.derived().evalTo(derived()); 85 | return derived(); 86 | } 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_ASSIGN_H 91 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | EIGEN_DEVICE_FUNC inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/NestByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_NESTBYVALUE_H 12 | #define EIGEN_NESTBYVALUE_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | template 18 | struct traits > : public traits 19 | { 20 | enum { 21 | Flags = traits::Flags & ~NestByRefBit 22 | }; 23 | }; 24 | } 25 | 26 | /** \class NestByValue 27 | * \ingroup Core_Module 28 | * 29 | * \brief Expression which must be nested by value 30 | * 31 | * \tparam ExpressionType the type of the object of which we are requiring nesting-by-value 32 | * 33 | * This class is the return type of MatrixBase::nestByValue() 34 | * and most of the time this is the only way it is used. 35 | * 36 | * \sa MatrixBase::nestByValue() 37 | */ 38 | template class NestByValue 39 | : public internal::dense_xpr_base< NestByValue >::type 40 | { 41 | public: 42 | 43 | typedef typename internal::dense_xpr_base::type Base; 44 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 45 | 46 | EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 47 | 48 | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); } 49 | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); } 50 | 51 | EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; } 52 | 53 | EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; } 54 | 55 | protected: 56 | const ExpressionType m_expression; 57 | }; 58 | 59 | /** \returns an expression of the temporary version of *this. 60 | */ 61 | template 62 | EIGEN_DEVICE_FUNC inline const NestByValue 63 | DenseBase::nestByValue() const 64 | { 65 | return NestByValue(derived()); 66 | } 67 | 68 | namespace internal { 69 | 70 | // Evaluator of Solve -> eval into a temporary 71 | template 72 | struct evaluator > 73 | : public evaluator 74 | { 75 | typedef evaluator Base; 76 | 77 | EIGEN_DEVICE_FUNC explicit evaluator(const NestByValue& xpr) 78 | : Base(xpr.nestedExpression()) 79 | {} 80 | }; 81 | } 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_NESTBYVALUE_H 86 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 21 | return derived(); 22 | } 23 | 24 | template 25 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 26 | { 27 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 28 | return derived(); 29 | } 30 | 31 | template 32 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 33 | { 34 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 35 | return derived(); 36 | } 37 | 38 | template 39 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 40 | { 41 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 42 | return derived(); 43 | } 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_SELFCWISEBINARYOP_H 48 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/Swap.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SWAP_H 11 | #define EIGEN_SWAP_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // Overload default assignPacket behavior for swapping them 18 | template 19 | class generic_dense_assignment_kernel, Specialized> 20 | : public generic_dense_assignment_kernel, BuiltIn> 21 | { 22 | protected: 23 | typedef generic_dense_assignment_kernel, BuiltIn> Base; 24 | using Base::m_dst; 25 | using Base::m_src; 26 | using Base::m_functor; 27 | 28 | public: 29 | typedef typename Base::Scalar Scalar; 30 | typedef typename Base::DstXprType DstXprType; 31 | typedef swap_assign_op Functor; 32 | 33 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 34 | generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr) 35 | : Base(dst, src, func, dstExpr) 36 | {} 37 | 38 | template 39 | EIGEN_STRONG_INLINE void assignPacket(Index row, Index col) 40 | { 41 | PacketType tmp = m_src.template packet(row,col); 42 | const_cast(m_src).template writePacket(row,col, m_dst.template packet(row,col)); 43 | m_dst.template writePacket(row,col,tmp); 44 | } 45 | 46 | template 47 | EIGEN_STRONG_INLINE void assignPacket(Index index) 48 | { 49 | PacketType tmp = m_src.template packet(index); 50 | const_cast(m_src).template writePacket(index, m_dst.template packet(index)); 51 | m_dst.template writePacket(index,tmp); 52 | } 53 | 54 | // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael) 55 | template 56 | EIGEN_STRONG_INLINE void assignPacketByOuterInner(Index outer, Index inner) 57 | { 58 | Index row = Base::rowIndexByOuterInner(outer, inner); 59 | Index col = Base::colIndexByOuterInner(outer, inner); 60 | assignPacket(row, col); 61 | } 62 | }; 63 | 64 | } // namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_SWAP_H 69 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/AVX512/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2019 Rasmus Munk Larsen 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX512_H 11 | #define EIGEN_TYPE_CASTING_AVX512_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template<> EIGEN_STRONG_INLINE Packet16i pcast(const Packet16f& a) { 18 | return _mm512_cvttps_epi32(a); 19 | } 20 | 21 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16i& a) { 22 | return _mm512_cvtepi32_ps(a); 23 | } 24 | 25 | template<> EIGEN_STRONG_INLINE Packet16i preinterpret(const Packet16f& a) { 26 | return _mm512_castps_si512(a); 27 | } 28 | 29 | template<> EIGEN_STRONG_INLINE Packet16f preinterpret(const Packet16i& a) { 30 | return _mm512_castsi512_ps(a); 31 | } 32 | 33 | template <> 34 | struct type_casting_traits { 35 | enum { 36 | VectorizedCast = 1, 37 | SrcCoeffRatio = 1, 38 | TgtCoeffRatio = 1 39 | }; 40 | }; 41 | 42 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16h& a) { 43 | return half2float(a); 44 | } 45 | 46 | template <> 47 | struct type_casting_traits { 48 | enum { 49 | VectorizedCast = 1, 50 | SrcCoeffRatio = 1, 51 | TgtCoeffRatio = 1 52 | }; 53 | }; 54 | 55 | template<> EIGEN_STRONG_INLINE Packet16h pcast(const Packet16f& a) { 56 | return float2half(a); 57 | } 58 | 59 | template <> 60 | struct type_casting_traits { 61 | enum { 62 | VectorizedCast = 1, 63 | SrcCoeffRatio = 1, 64 | TgtCoeffRatio = 1 65 | }; 66 | }; 67 | 68 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16bf& a) { 69 | return Bf16ToF32(a); 70 | } 71 | 72 | template <> 73 | struct type_casting_traits { 74 | enum { 75 | VectorizedCast = 1, 76 | SrcCoeffRatio = 1, 77 | TgtCoeffRatio = 1 78 | }; 79 | }; 80 | 81 | template<> EIGEN_STRONG_INLINE Packet16bf pcast(const Packet16f& a) { 82 | return F32ToBf16(a); 83 | } 84 | 85 | } // end namespace internal 86 | 87 | } // end namespace Eigen 88 | 89 | #endif // EIGEN_TYPE_CASTING_AVX512_H 90 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/AltiVec/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Julien Pommier 5 | // Copyright (C) 2009 Gael Guennebaud 6 | // Copyright (C) 2016 Konstantinos Margaritis 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H 13 | #define EIGEN_MATH_FUNCTIONS_ALTIVEC_H 14 | 15 | namespace Eigen { 16 | 17 | namespace internal { 18 | 19 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 20 | Packet4f plog(const Packet4f& _x) 21 | { 22 | return plog_float(_x); 23 | } 24 | 25 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 26 | Packet4f pexp(const Packet4f& _x) 27 | { 28 | return pexp_float(_x); 29 | } 30 | 31 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 32 | Packet4f psin(const Packet4f& _x) 33 | { 34 | return psin_float(_x); 35 | } 36 | 37 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 38 | Packet4f pcos(const Packet4f& _x) 39 | { 40 | return pcos_float(_x); 41 | } 42 | 43 | #ifndef EIGEN_COMP_CLANG 44 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 45 | Packet4f prsqrt(const Packet4f& x) 46 | { 47 | return vec_rsqrt(x); 48 | } 49 | #endif 50 | 51 | #ifdef __VSX__ 52 | #ifndef EIGEN_COMP_CLANG 53 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 54 | Packet2d prsqrt(const Packet2d& x) 55 | { 56 | return vec_rsqrt(x); 57 | } 58 | #endif 59 | 60 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 61 | Packet4f psqrt(const Packet4f& x) 62 | { 63 | return vec_sqrt(x); 64 | } 65 | 66 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 67 | Packet2d psqrt(const Packet2d& x) 68 | { 69 | return vec_sqrt(x); 70 | } 71 | 72 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 73 | Packet2d pexp(const Packet2d& _x) 74 | { 75 | return pexp_double(_x); 76 | } 77 | #endif 78 | 79 | // Hyperbolic Tangent function. 80 | template <> 81 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f 82 | ptanh(const Packet4f& x) { 83 | return internal::generic_fast_tanh_float(x); 84 | } 85 | 86 | } // end namespace internal 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H 91 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 110 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/GPU/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_GPU_H 11 | #define EIGEN_TYPE_CASTING_GPU_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 18 | (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 19 | 20 | 21 | template <> 22 | struct type_casting_traits { 23 | enum { 24 | VectorizedCast = 1, 25 | SrcCoeffRatio = 1, 26 | TgtCoeffRatio = 2 27 | }; 28 | }; 29 | 30 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast(const half2& a, const half2& b) { 31 | float2 r1 = __half22float2(a); 32 | float2 r2 = __half22float2(b); 33 | return make_float4(r1.x, r1.y, r2.x, r2.y); 34 | } 35 | 36 | 37 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet4h2 pcast(const float4& a, const float4& b) { 38 | Packet4h2 r; 39 | half2* r_alias=reinterpret_cast(&r); 40 | r_alias[0]=__floats2half2_rn(a.x,a.y); 41 | r_alias[1]=__floats2half2_rn(a.z,a.w); 42 | r_alias[2]=__floats2half2_rn(b.x,b.y); 43 | r_alias[3]=__floats2half2_rn(b.z,b.w); 44 | return r; 45 | } 46 | 47 | template <> 48 | struct type_casting_traits { 49 | enum { 50 | VectorizedCast = 1, 51 | SrcCoeffRatio = 2, 52 | TgtCoeffRatio = 1 53 | }; 54 | }; 55 | 56 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast(const Packet4h2& a) { 57 | // Simply discard the second half of the input 58 | float4 r; 59 | const half2* a_alias=reinterpret_cast(&a); 60 | float2 r1 = __half22float2(a_alias[0]); 61 | float2 r2 = __half22float2(a_alias[1]); 62 | r.x=static_cast(r1.x); 63 | r.y=static_cast(r1.y); 64 | r.z=static_cast(r2.x); 65 | r.w=static_cast(r2.y); 66 | return r; 67 | } 68 | 69 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE half2 pcast(const float4& a) { 70 | // Simply discard the second half of the input 71 | return __floats2half2_rn(a.x, a.y); 72 | } 73 | 74 | #endif 75 | 76 | } // end namespace internal 77 | 78 | } // end namespace Eigen 79 | 80 | #endif // EIGEN_TYPE_CASTING_GPU_H 81 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/HIP/hcc/math_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * math_constants.h - 3 | * HIP equivalent of the CUDA header of the same name 4 | */ 5 | 6 | #ifndef __MATH_CONSTANTS_H__ 7 | #define __MATH_CONSTANTS_H__ 8 | 9 | /* single precision constants */ 10 | 11 | #define HIPRT_INF_F __int_as_float(0x7f800000) 12 | #define HIPRT_NAN_F __int_as_float(0x7fffffff) 13 | #define HIPRT_MIN_DENORM_F __int_as_float(0x00000001) 14 | #define HIPRT_MAX_NORMAL_F __int_as_float(0x7f7fffff) 15 | #define HIPRT_NEG_ZERO_F __int_as_float(0x80000000) 16 | #define HIPRT_ZERO_F 0.0f 17 | #define HIPRT_ONE_F 1.0f 18 | 19 | /* double precision constants */ 20 | #define HIPRT_INF __hiloint2double(0x7ff00000, 0x00000000) 21 | #define HIPRT_NAN __hiloint2double(0xfff80000, 0x00000000) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/SVE/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2020, Arm Limited and Contributors 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MATH_FUNCTIONS_SVE_H 11 | #define EIGEN_MATH_FUNCTIONS_SVE_H 12 | 13 | namespace Eigen { 14 | namespace internal { 15 | 16 | template <> 17 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf pexp(const PacketXf& x) { 18 | return pexp_float(x); 19 | } 20 | 21 | template <> 22 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf plog(const PacketXf& x) { 23 | return plog_float(x); 24 | } 25 | 26 | template <> 27 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf psin(const PacketXf& x) { 28 | return psin_float(x); 29 | } 30 | 31 | template <> 32 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf pcos(const PacketXf& x) { 33 | return pcos_float(x); 34 | } 35 | 36 | // Hyperbolic Tangent function. 37 | template <> 38 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf ptanh(const PacketXf& x) { 39 | return internal::generic_fast_tanh_float(x); 40 | } 41 | } // end namespace internal 42 | } // end namespace Eigen 43 | 44 | #endif // EIGEN_MATH_FUNCTIONS_SVE_H 45 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/SVE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2020, Arm Limited and Contributors 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_SVE_H 11 | #define EIGEN_TYPE_CASTING_SVE_H 12 | 13 | namespace Eigen { 14 | namespace internal { 15 | 16 | template <> 17 | struct type_casting_traits { 18 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 19 | }; 20 | 21 | template <> 22 | struct type_casting_traits { 23 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 24 | }; 25 | 26 | template <> 27 | EIGEN_STRONG_INLINE PacketXf pcast(const PacketXi& a) { 28 | return svcvt_f32_s32_z(svptrue_b32(), a); 29 | } 30 | 31 | template <> 32 | EIGEN_STRONG_INLINE PacketXi pcast(const PacketXf& a) { 33 | return svcvt_s32_f32_z(svptrue_b32(), a); 34 | } 35 | 36 | template <> 37 | EIGEN_STRONG_INLINE PacketXf preinterpret(const PacketXi& a) { 38 | return svreinterpret_f32_s32(a); 39 | } 40 | 41 | template <> 42 | EIGEN_STRONG_INLINE PacketXi preinterpret(const PacketXf& a) { 43 | return svreinterpret_s32_f32(a); 44 | } 45 | 46 | } // namespace internal 47 | } // namespace Eigen 48 | 49 | #endif // EIGEN_TYPE_CASTING_SVE_H 50 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/arch/SYCL/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Mehdi Goli Codeplay Software Ltd. 5 | // Ralph Potter Codeplay Software Ltd. 6 | // Luke Iwanski Codeplay Software Ltd. 7 | // Contact: 8 | // 9 | // This Source Code Form is subject to the terms of the Mozilla 10 | // Public License v. 2.0. If a copy of the MPL was not distributed 11 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 12 | 13 | /***************************************************************** 14 | * TypeCasting.h 15 | * 16 | * \brief: 17 | * TypeCasting 18 | * 19 | *****************************************************************/ 20 | 21 | #ifndef EIGEN_TYPE_CASTING_SYCL_H 22 | #define EIGEN_TYPE_CASTING_SYCL_H 23 | 24 | namespace Eigen { 25 | 26 | namespace internal { 27 | #ifdef SYCL_DEVICE_ONLY 28 | template <> 29 | struct type_casting_traits { 30 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 31 | }; 32 | 33 | template <> 34 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_int4 35 | pcast(const cl::sycl::cl_float4& a) { 36 | return a 37 | .template convert(); 38 | } 39 | 40 | template <> 41 | struct type_casting_traits { 42 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 43 | }; 44 | 45 | template <> 46 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 47 | pcast(const cl::sycl::cl_int4& a) { 48 | return a.template convert(); 50 | } 51 | 52 | template <> 53 | struct type_casting_traits { 54 | enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 }; 55 | }; 56 | 57 | template <> 58 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 59 | pcast( 60 | const cl::sycl::cl_double2& a, const cl::sycl::cl_double2& b) { 61 | auto a1 = a.template convert(); 63 | auto b1 = b.template convert(); 65 | return cl::sycl::float4(a1.x(), a1.y(), b1.x(), b1.y()); 66 | } 67 | 68 | template <> 69 | struct type_casting_traits { 70 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 2 }; 71 | }; 72 | 73 | template <> 74 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_double2 75 | pcast(const cl::sycl::cl_float4& a) { 76 | // Simply discard the second half of the input 77 | return cl::sycl::cl_double2(a.x(), a.y()); 78 | } 79 | 80 | #endif 81 | } // end namespace internal 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_TYPE_CASTING_SYCL_H 86 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED_2 2 | // "DisableStupidWarnings.h" was included twice recursively: Do not reenable warnings yet! 3 | # undef EIGEN_WARNINGS_DISABLED_2 4 | 5 | #elif defined(EIGEN_WARNINGS_DISABLED) 6 | #undef EIGEN_WARNINGS_DISABLED 7 | 8 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 9 | #ifdef _MSC_VER 10 | #pragma warning( pop ) 11 | #elif defined __INTEL_COMPILER 12 | #pragma warning pop 13 | #elif defined __clang__ 14 | #pragma clang diagnostic pop 15 | #elif defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 16 | #pragma GCC diagnostic pop 17 | #endif 18 | 19 | #if defined __NVCC__ 20 | // Don't reenable the diagnostic messages, as it turns out these messages need 21 | // to be disabled at the point of the template instantiation (i.e the user code) 22 | // otherwise they'll be triggered by nvcc. 23 | // #pragma diag_default code_is_unreachable 24 | // #pragma diag_default initialization_not_reachable 25 | // #pragma diag_default 2651 26 | // #pragma diag_default 2653 27 | #endif 28 | 29 | #endif 30 | 31 | #endif // EIGEN_WARNINGS_DISABLED 32 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/Core/util/ReshapedHelper.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2017 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_RESHAPED_HELPER_H 12 | #define EIGEN_RESHAPED_HELPER_H 13 | 14 | namespace Eigen { 15 | 16 | enum AutoSize_t { AutoSize }; 17 | const int AutoOrder = 2; 18 | 19 | namespace internal { 20 | 21 | template 22 | struct get_compiletime_reshape_size { 23 | enum { value = get_fixed_value::value }; 24 | }; 25 | 26 | template 27 | Index get_runtime_reshape_size(SizeType size, Index /*other*/, Index /*total*/) { 28 | return internal::get_runtime_value(size); 29 | } 30 | 31 | template 32 | struct get_compiletime_reshape_size { 33 | enum { 34 | other_size = get_fixed_value::value, 35 | value = (TotalSize==Dynamic || other_size==Dynamic) ? Dynamic : TotalSize / other_size }; 36 | }; 37 | 38 | inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { 39 | return total/other; 40 | } 41 | 42 | template 43 | struct get_compiletime_reshape_order { 44 | enum { value = Order == AutoOrder ? Flags & RowMajorBit : Order }; 45 | }; 46 | 47 | } 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_RESHAPED_HELPER_H 52 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/SparseCore/MappedSparseMatrix.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MAPPED_SPARSEMATRIX_H 11 | #define EIGEN_MAPPED_SPARSEMATRIX_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated Use Map > 16 | * \class MappedSparseMatrix 17 | * 18 | * \brief Sparse matrix 19 | * 20 | * \param _Scalar the scalar type, i.e. the type of the coefficients 21 | * 22 | * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. 23 | * 24 | */ 25 | namespace internal { 26 | template 27 | struct traits > : traits > 28 | {}; 29 | } // end namespace internal 30 | 31 | template 32 | class MappedSparseMatrix 33 | : public Map > 34 | { 35 | typedef Map > Base; 36 | 37 | public: 38 | 39 | typedef typename Base::StorageIndex StorageIndex; 40 | typedef typename Base::Scalar Scalar; 41 | 42 | inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0) 43 | : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr) 44 | {} 45 | 46 | /** Empty destructor */ 47 | inline ~MappedSparseMatrix() {} 48 | }; 49 | 50 | namespace internal { 51 | 52 | template 53 | struct evaluator > 54 | : evaluator > > 55 | { 56 | typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType; 57 | typedef evaluator > Base; 58 | 59 | evaluator() : Base() {} 60 | explicit evaluator(const XprType &mat) : Base(mat) {} 61 | }; 62 | 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN_MAPPED_SPARSEMATRIX_H 68 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | StorageIndex nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_KERNEL_H 11 | #define EIGEN_MISC_KERNEL_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class kernel_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 27 | // is the number of cols of the original matrix 28 | // so that the product "matrix * kernel = zero" makes sense 29 | Dynamic, // we don't know at compile-time the dimension of the kernel 30 | MatrixType::Options, 31 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 32 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 33 | // whose dimension is the number of columns of the original matrix 34 | > ReturnType; 35 | }; 36 | 37 | template struct kernel_retval_base 38 | : public ReturnByValue > 39 | { 40 | typedef _DecompositionType DecompositionType; 41 | typedef ReturnByValue Base; 42 | 43 | explicit kernel_retval_base(const DecompositionType& dec) 44 | : m_dec(dec), 45 | m_rank(dec.rank()), 46 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.cols(); } 50 | inline Index cols() const { return m_cols; } 51 | inline Index rank() const { return m_rank; } 52 | inline const DecompositionType& dec() const { return m_dec; } 53 | 54 | template inline void evalTo(Dest& dst) const 55 | { 56 | static_cast*>(this)->evalTo(dst); 57 | } 58 | 59 | protected: 60 | const DecompositionType& m_dec; 61 | Index m_rank, m_cols; 62 | }; 63 | 64 | } // end namespace internal 65 | 66 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 67 | typedef typename DecompositionType::MatrixType MatrixType; \ 68 | typedef typename MatrixType::Scalar Scalar; \ 69 | typedef typename MatrixType::RealScalar RealScalar; \ 70 | typedef Eigen::internal::kernel_retval_base Base; \ 71 | using Base::dec; \ 72 | using Base::rank; \ 73 | using Base::rows; \ 74 | using Base::cols; \ 75 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 76 | 77 | } // end namespace Eigen 78 | 79 | #endif // EIGEN_MISC_KERNEL_H 80 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /gomea/lib/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /gomea/lib/cxxopts-3.1.1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Jarryd Beck 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gomea/linkage.pxd: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | cimport numpy as np 3 | from libcpp.vector cimport vector 4 | from libcpp.string cimport string 5 | from libcpp cimport bool 6 | 7 | cdef extern from "gomea/src/common/linkage_config.hpp" namespace "gomea": 8 | cdef cppclass linkage_config_t: 9 | @staticmethod 10 | linkage_config_t *constructor_UNI() 11 | @staticmethod 12 | linkage_config_t *constructor_MPM(int) 13 | @staticmethod 14 | linkage_config_t *constructor_LT(string,bool,int,bool) 15 | @staticmethod 16 | linkage_config_t *constructor_COND(int,bool,bool) 17 | @staticmethod 18 | linkage_config_t *constructor_CUSTOM(vector[vector[int]]) 19 | @staticmethod 20 | linkage_config_t *constructor_FILE(string) 21 | 22 | cdef class LinkageModel: 23 | cdef linkage_config_t *c_inst 24 | 25 | cdef class Univariate(LinkageModel): 26 | pass 27 | 28 | cdef class BlockMarginalProduct(LinkageModel): 29 | pass 30 | 31 | cdef class Full(LinkageModel): 32 | pass 33 | 34 | cdef class LinkageTree(LinkageModel): 35 | pass 36 | 37 | cdef class StaticLinkageTree(LinkageModel): 38 | pass 39 | 40 | #cdef class Conditional(LinkageModel): 41 | # pass 42 | 43 | cdef class Custom(LinkageModel): 44 | pass -------------------------------------------------------------------------------- /gomea/meson.build: -------------------------------------------------------------------------------- 1 | # Manually cythonize so that we get the header file `fitness.h` 2 | gomea_fitness_cython = custom_target( 3 | 'fitness.pyx', 4 | output : ['fitness.h'], 5 | input : ['fitness.pyx'], 6 | command : [cython, '-3', '--cplus', '@INPUT@', '-o', '@OUTPUT@'], 7 | ) 8 | gomea_fitness_cython_dep = declare_dependency( 9 | sources: [gomea_fitness_cython], 10 | ) 11 | 12 | # Manually cythonize so that we get the header file `real_valued.h` 13 | gomea_real_valued_cython = custom_target( 14 | 'real_valued.pyx', 15 | output : ['real_valued.h'], 16 | input : 'real_valued.pyx', 17 | command : [cython, '-3', '--cplus', '@INPUT@', '-o', '@OUTPUT@'], 18 | ) 19 | gomea_real_valued_cython_dep = declare_dependency( 20 | sources: [gomea_real_valued_cython], 21 | ) 22 | 23 | copy_ef = fs.copyfile('EmbeddedFitness.pxi') -------------------------------------------------------------------------------- /gomea/output.pxd: -------------------------------------------------------------------------------- 1 | from libcpp.map cimport map 2 | from libcpp.string cimport string 3 | from libcpp.vector cimport vector 4 | 5 | cdef extern from "gomea/src/common/output_statistics.hpp" namespace "gomea": 6 | cdef cppclass output_statistics_t: 7 | output_statistics_t() except + 8 | vector[string] getGenerationalMetricNames() except + 9 | vector[T] getGenerationalMetricValues[T](string) except + 10 | vector[string] getFinalMetricNames() except + 11 | T getFinalMetricValue[T](string) except + 12 | 13 | cdef class OutputStatisticsWrapper: 14 | cdef output_statistics_t *c_ptr 15 | 16 | @staticmethod 17 | cdef OutputStatisticsWrapper from_ptr(output_statistics_t *_ptr) 18 | -------------------------------------------------------------------------------- /gomea/real_valued.pxd: -------------------------------------------------------------------------------- 1 | from libcpp.string cimport string 2 | from libcpp cimport bool 3 | from gomea.output cimport output_statistics_t 4 | from gomea.fitness cimport fitness_t 5 | from gomea.linkage cimport linkage_config_t 6 | 7 | cdef extern from "src/real_valued/Config.hpp" namespace "gomea::realvalued": 8 | cdef cppclass Config: 9 | Config() except + 10 | 11 | int problem_index, maximum_no_improvement_stretch, maximum_number_of_populations, number_of_subgenerations_per_population_factor, base_population_size, maximum_number_of_generations 12 | double lower_user_range, upper_user_range, tau, distribution_multiplier_decrease, st_dev_ratio_threshold, fitness_variance_tolerance, maximum_number_of_evaluations, maximum_number_of_seconds 13 | bool fix_seed, use_vtr, generational_statistics, generational_solution, black_box_evaluations, selection_during_gom, update_elitist_during_gom, verbose, verbose, print_verbose_overview 14 | output_frequency_t output_frequency 15 | long long random_seed 16 | linkage_config_t *linkage_config 17 | fitness_t[double] *fitness 18 | 19 | cdef extern from "src/real_valued/rv-gomea.hpp" namespace "gomea::realvalued": 20 | cdef cppclass rvg_t: 21 | rvg_t() except + 22 | rvg_t(Config*) except + 23 | 24 | void printUsage() except + 25 | void run() except + 26 | 27 | output_statistics_t output 28 | 29 | cdef extern from "src/common/gomea_defs.hpp" namespace "gomea": 30 | ctypedef enum output_frequency_t: 31 | GEN, IMS_GEN, NEW_ELITE 32 | -------------------------------------------------------------------------------- /gomea/src/common/gomea_defs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define MY_PI 3.141592653589793238462643383279 22 | namespace gomea{ 23 | 24 | template 25 | using vec_t = std::vector; 26 | typedef std::variant genotype_t; 27 | typedef std::map> graph_t; 28 | typedef enum output_frequency_t { GEN, IMS_GEN, NEW_ELITE } output_frequency_t; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /gomea/src/common/linkage_config.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/common/linkage_config.hpp" 2 | 3 | namespace gomea{ 4 | 5 | linkage_config_t::linkage_config_t() 6 | { 7 | type = linkage::UNIVARIATE; 8 | } 9 | 10 | linkage_config_t::linkage_config_t( int block_size_ ) : mpm_block_size(block_size_) 11 | { 12 | type = linkage::MPM; 13 | is_mpm = true; 14 | } 15 | 16 | linkage_config_t::linkage_config_t(std::string similarityMeasure_, bool filtered_, int maximumSetSize_, bool is_static ) 17 | : lt_filtered(filtered_), lt_maximum_set_size(maximumSetSize_), lt_is_static(is_static) 18 | { 19 | type = linkage::LINKAGE_TREE; 20 | lt_similarity_measure = parseSimilarityMeasure(similarityMeasure_); 21 | } 22 | 23 | linkage_config_t::linkage_config_t( const vec_t> &FOS_ ) : FOS(FOS_) 24 | { 25 | type = linkage::CUSTOM_LM; 26 | } 27 | 28 | linkage_config_t::linkage_config_t( std::string filename_ ) : filename(filename_) 29 | { 30 | type = linkage::FROM_FILE; 31 | } 32 | 33 | linkage_config_t::linkage_config_t( int max_clique_size_, bool include_cliques_as_fos_elements_, bool include_full_fos_element_) 34 | : cond_max_clique_size(max_clique_size_), cond_include_cliques_as_fos_elements(include_cliques_as_fos_elements_), cond_include_full_fos_element(include_full_fos_element_) 35 | { 36 | type = linkage::CONDITIONAL; 37 | } 38 | 39 | } // namespace gomea -------------------------------------------------------------------------------- /gomea/src/common/output_statistics.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/common/gomea_defs.hpp" 4 | #include "gomea/src/common/solution.hpp" 5 | 6 | namespace gomea{ 7 | 8 | typedef std::variant metric_t; 9 | 10 | class output_statistics_t 11 | { 12 | public: 13 | output_statistics_t(){}; 14 | 15 | void addGenerationalMetricValue( std::string metric_name, int key, int value ); 16 | void addGenerationalMetricValue( std::string metric_name, int key, double value ); 17 | void addGenerationalMetricValue( std::string metric_name, int key, std::string value ); 18 | template 19 | void addGenerationalMetricValueGeneric( std::string metric_name, int key, T value ); 20 | 21 | vec_t getGenerationalMetricNames(); 22 | template 23 | vec_t getGenerationalMetricValues( std::string metric_name ); 24 | template 25 | vec_t getGenerationalMetricValuesForKeys( std::string metric_name, vec_t input_keys ); 26 | template 27 | T getGenerationalMetricValue( std::string metric_name, int key ); 28 | 29 | void addFinalMetricValue( std::string metric_name, int value ); 30 | void addFinalMetricValue( std::string metric_name, double value ); 31 | void addFinalMetricValue( std::string metric_name, std::string value ); 32 | template 33 | void addFinalMetricValueGeneric( std::string metric_name, T value ); 34 | 35 | vec_t getFinalMetricNames(); 36 | template 37 | T getFinalMetricValue( std::string metric_name ); 38 | 39 | void writeToFile( std::string filename = "statistics.dat" ); 40 | 41 | std::unordered_map> generational_metrics_map; 42 | std::unordered_map final_metrics_map; 43 | std::set generational_keys; 44 | solution_t *elitist_solution; 45 | int number_of_writes = 0; 46 | }; 47 | 48 | } -------------------------------------------------------------------------------- /gomea/src/common/partial_solution.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/common/gomea_defs.hpp" 4 | 5 | namespace gomea{ 6 | 7 | template 8 | class solution_t; 9 | 10 | template 11 | class partial_solution_t 12 | { 13 | public: 14 | vec_t touched_indices; 15 | vec_t touched_variables; 16 | std::set touched_subfunctions; 17 | std::unordered_map partial_objective_values; 18 | vec_t fitness_buffers; 19 | 20 | partial_solution_t( int num_touched_variables ); 21 | partial_solution_t( const vec_t &touched_variables, const vec_t &touched_indices ); 22 | 23 | void initMemory( int number_of_fitness_buffers, int number_of_objectives ); 24 | void initObjectiveValues( int number_of_objectives ); 25 | void initFitnessBuffers( int number_of_fitness_buffers ); 26 | 27 | int getNumberOfTouchedVariables(); 28 | 29 | double getObjectiveValue( int objective_value_index = 0 ) const; 30 | const vec_t getObjectiveValues() const; 31 | double getConstraintValue() const; 32 | 33 | void setObjectiveValue( double v ); 34 | void setObjectiveValue( int objective_value_index, double v ); 35 | void setObjectiveValues( vec_t objective_values ); 36 | void setConstraintValue( double v ); 37 | 38 | double getFitnessBuffer(int buffer_index) const; 39 | const vec_t getFitnessBuffers() const; 40 | void setFitnessBuffers( vec_t buffers ); 41 | void resetFitnessBuffers(); 42 | void addToFitnessBuffer( int buffer_index, double partial_fitness ); 43 | void subtractFromFitnessBuffer( int buffer_index, double partial_fitness ); 44 | 45 | void insertSolution( solution_t *solution ); 46 | 47 | int getTouchedIndex( int ind ); 48 | 49 | void print(); 50 | 51 | private: 52 | vec_t objective_values; 53 | double constraint_value; 54 | 55 | std::unordered_map touched_index_map; 56 | }; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gomea/src/discrete/Config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "gomea/src/common/linkage_model.hpp" 12 | #include "gomea/src/common/linkage_config.hpp" 13 | #include "gomea/src/fitness/fitness.hpp" 14 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 15 | 16 | namespace gomea{ 17 | namespace discrete{ 18 | 19 | using gomea::fitness::fitness_t; 20 | 21 | class Config 22 | { 23 | void splitString(const std::string &str, vec_t &splitted, char delim); 24 | bool isNumber(const std::string &s); 25 | 26 | public: 27 | Config(); 28 | virtual ~Config(); 29 | 30 | bool parseCommandLine(int argc, char **argv); 31 | void checkOptions(); 32 | void printOverview(); 33 | 34 | fitness_t *fitness; 35 | bool gene_invariant = false, 36 | generational_statistics = true, 37 | generational_solution = false, 38 | write_generational_population = false, 39 | verbose = false; 40 | int usePartialEvaluations = 1, 41 | useParallelGOM = 1, 42 | useParallelFOSOrder = 0, 43 | popUpdatesDuringGOM = 0, 44 | fixFOSOrderForPopulation = 0, 45 | AnalyzeFOS = 0, 46 | writeElitists = 0, 47 | saveEvaluations = 0, 48 | useForcedImprovements = 1, 49 | printHelp = 0, 50 | maximumNumberOfEvaluations = -1, 51 | maximumNumberOfGenerations = -1; 52 | double maximumNumberOfSeconds = -1; 53 | double vtr = 1e+308; 54 | size_t k = 1, s = 1, 55 | FOSIndex = 0; 56 | int GPUIndex = -1; 57 | int maximumFOSSetSize = -1; 58 | output_frequency_t output_frequency = output_frequency_t::GEN; 59 | 60 | std::string folder = "discrete_gomea_output"; 61 | //std::string problemName, 62 | std::string FOSName; 63 | std::string problemInstancePath = ""; 64 | 65 | //long long timelimitMilliseconds = -1, 66 | bool fix_seed = false; 67 | long long randomSeed; 68 | 69 | size_t maxArchiveSize = 1000000; 70 | int maximumNumberOfGOMEAs = 100, 71 | IMSsubgenerationFactor = 4, 72 | basePopulationSize = 2; 73 | linkage_config_t *linkage_config; 74 | 75 | private: 76 | cxxopts::Options options = cxxopts::Options("DiscreteGOMEA", "GOMEA for discrete optimization"); 77 | int problemIndex = 0, numberOfVariables = 10; 78 | }; 79 | 80 | }} 81 | -------------------------------------------------------------------------------- /gomea/src/discrete/Population.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "gomea/src/discrete/Config.hpp" 8 | #include "gomea/src/discrete/shared.hpp" 9 | #include "gomea/src/fitness/fitness.hpp" 10 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 11 | #include "gomea/src/common/solution.hpp" 12 | #include "gomea/src/common/partial_solution.hpp" 13 | #include "gomea/src/common/linkage_model.hpp" 14 | #include "gomea/src/common/output_statistics.hpp" 15 | 16 | namespace gomea{ 17 | namespace discrete{ 18 | 19 | class Population 20 | { 21 | public: 22 | Config *config; 23 | fitness_t *problemInstance; 24 | sharedInformation *sharedInformationPointer; 25 | output_statistics_t *output; 26 | size_t GOMEAIndex; 27 | size_t populationSize; 28 | 29 | vec_t*> population; 30 | vec_t*> offspringPopulation; 31 | vec_t noImprovementStretches; 32 | 33 | bool terminated; 34 | double averageFitness; 35 | size_t numberOfGenerations; 36 | 37 | linkage_model_pt FOSInstance = NULL; 38 | 39 | Population(Config *config_, output_statistics_t *output_, fitness_t *problemInstance_, sharedInformation *sharedInformationPointer_, size_t GOMEAIndex_, size_t populationSize_, linkage_model_pt FOSInstance_ = NULL ); 40 | ~Population(); 41 | 42 | friend std::ostream & operator << (std::ostream &out, const Population &populationInstance); 43 | 44 | void initializeAndEvaluatePopulation(); 45 | void initializePopulationProbabilisticallyComplete(); 46 | void initializePopulationRandomUniform(); 47 | 48 | void calculateAverageFitness(); 49 | double getFitnessMean(); 50 | double getFitnessVariance(); 51 | double getConstraintValueMean(); 52 | double getConstraintValueVariance(); 53 | solution_t *getBestSolution(); 54 | solution_t *getWorstSolution(); 55 | bool allSolutionsAreEqual(); 56 | void makeOffspring(); 57 | void copyOffspringToPopulation(); 58 | void generateOffspring(); 59 | void evaluateSolution(solution_t *solution); 60 | void evaluateSolution(solution_t *solution, solution_t *solutionBefore, vec_t &touchedGenes, double fitnessBefore); 61 | bool GOM(size_t offspringIndex, int FOSIndex, bool isElitistSolution = false); 62 | void GeneInvariantGOM(size_t parent_index, int FOS_index); 63 | bool FI(size_t offspringIndex); 64 | void updateElitistAndCheckVTR(solution_t *solution); 65 | void checkTimeLimit(); 66 | void writeStatistics( bool is_final = false ); 67 | }; 68 | 69 | }} -------------------------------------------------------------------------------- /gomea/src/discrete/gomea.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/discrete/gomea.hpp" 2 | 3 | namespace gomea{ 4 | namespace discrete{ 5 | 6 | double GOMEA::readVTR(Config *config) 7 | { 8 | std::string filename = config->folder + "/vtr.txt"; 9 | std::ifstream inFile; 10 | inFile.open(filename); 11 | 12 | std::string vtr_str; 13 | inFile >> vtr_str; 14 | double vtr = std::stod(vtr_str); 15 | 16 | inFile.close(); 17 | 18 | return vtr; 19 | } 20 | 21 | }} -------------------------------------------------------------------------------- /gomea/src/discrete/gomea.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "gomea/src/common/output_statistics.hpp" 7 | #include "gomea/src/discrete/Config.hpp" 8 | 9 | namespace gomea{ 10 | namespace discrete{ 11 | 12 | class GOMEA 13 | { 14 | public: 15 | virtual void run() = 0; 16 | virtual ~GOMEA(){}; 17 | 18 | double readVTR(Config *config); 19 | 20 | output_statistics_t output; 21 | Config *config; 22 | }; 23 | 24 | }} -------------------------------------------------------------------------------- /gomea/src/discrete/gomeaIMS.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "gomea/src/discrete/Config.hpp" 6 | #include "gomea/src/discrete/Population.hpp" 7 | #include "gomea/src/discrete/shared.hpp" 8 | #include "gomea/src/discrete/gomea.hpp" 9 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 10 | #include "gomea/src/utils/time.hpp" 11 | #include "gomea/src/common/output_statistics.hpp" 12 | 13 | namespace gomea{ 14 | namespace discrete{ 15 | 16 | class gomeaIMS: public GOMEA 17 | { 18 | public: 19 | int maximumNumberOfGOMEAs; 20 | int IMSsubgenerationFactor, 21 | basePopulationSize, 22 | numberOfGOMEAs = 0, 23 | numberOfGenerationsIMS = 0, 24 | minimumGOMEAIndex = 0, 25 | currentGOMEAIndex = 0, 26 | numberOfStatisticsWrites = 0; 27 | bool isInitialized = false, 28 | hasTerminated = false; 29 | vec_t GOMEAs; 30 | fitness_t *problemInstance = NULL; 31 | sharedInformation *sharedInformationInstance = NULL; 32 | 33 | gomeaIMS(); 34 | //gomeaIMS(int _problemIndex, int _numberOfVariables, int _maximumNumberOfGOMEAs, int _IMSsubgenerationFactor, int _basePopulationSize, int _maxArchiveSize, string _folder ); 35 | gomeaIMS(Config *config_); 36 | ~gomeaIMS(); 37 | 38 | void initialize(); 39 | void initializeNewGOMEA(); 40 | void initializeGPU( void ); 41 | bool checkTermination(); 42 | bool checkEvaluationLimitTerminationCriterion(); 43 | bool checkTimeLimitTerminationCriterion(); 44 | double getProgressUntilTermination(); 45 | void generationalStepAllGOMEAs(); 46 | bool checkTerminationGOMEA(int GOMEAIndex); 47 | void GOMEAGenerationalStepAllGOMEAsRecursiveFold(int indexSmallest, int indexBiggest); 48 | void run(); 49 | void runGeneration(); 50 | void runGeneration( int GOMEAIndex ); 51 | void writeStatistics( int population_index, bool is_final = false ); 52 | void ezilaitini(); 53 | }; 54 | 55 | }} -------------------------------------------------------------------------------- /gomea/src/discrete/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/discrete/Config.hpp" 2 | #include "gomea/src/discrete/gomea.hpp" 3 | #include "gomea/src/discrete/gomeaIMS.hpp" 4 | 5 | using gomea::discrete::Config; 6 | using gomea::discrete::GOMEA; 7 | using gomea::discrete::gomeaIMS; 8 | int main(int argc, char **argv) 9 | { 10 | Config *config = new Config(); 11 | config->parseCommandLine(argc, argv); 12 | config->checkOptions(); 13 | config->printOverview(); 14 | 15 | GOMEA *gomeaInstance = new gomeaIMS(config); 16 | 17 | try 18 | { 19 | gomeaInstance->run(); 20 | } 21 | catch (gomea::utils::terminationException &ex) 22 | {} 23 | 24 | gomeaInstance->output.writeToFile("out.dat"); 25 | 26 | delete gomeaInstance; 27 | delete config->fitness; 28 | delete config; 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /gomea/src/discrete/shared.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "gomea/src/discrete/utils.hpp" 6 | #include "gomea/src/utils/time.hpp" 7 | 8 | namespace gomea{ 9 | namespace discrete{ 10 | 11 | class sharedInformation 12 | { 13 | public: 14 | double elitistSolutionHittingTimeMilliseconds, 15 | elitistSolutionHittingTimeEvaluations; 16 | 17 | solutionsArchive *evaluatedSolutions; 18 | bool firstEvaluationEver; 19 | double elitistFitness; 20 | double elitistConstraintValue; 21 | solution_t elitist = solution_t(1,2); 22 | 23 | sharedInformation(int maxArchiveSize) 24 | { 25 | firstEvaluationEver = true; 26 | evaluatedSolutions = new solutionsArchive(maxArchiveSize); 27 | gomea::utils::clearTimers(); 28 | } 29 | 30 | ~sharedInformation() 31 | { 32 | delete evaluatedSolutions; 33 | } 34 | }; 35 | 36 | }} -------------------------------------------------------------------------------- /gomea/src/discrete/utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "gomea/src/common/solution.hpp" 17 | #include "gomea/src/common/gomea_defs.hpp" 18 | 19 | namespace gomea{ 20 | namespace discrete{ 21 | 22 | typedef std::chrono::time_point chtime; 23 | 24 | struct archiveRecord 25 | { 26 | bool isFound = false; 27 | double value = 0.0; 28 | }; 29 | 30 | struct hashVector 31 | { 32 | size_t operator()(const vec_t &vec) const 33 | { 34 | std::hash hashChar; 35 | size_t hash_value = 0; 36 | for (size_t i = 0; i < vec.size(); ++i) 37 | hash_value = hash_value*31 + hashChar(vec[i]); 38 | return hash_value; 39 | } 40 | }; 41 | 42 | class solutionsArchive 43 | { 44 | size_t maxArchiveSize; 45 | public: 46 | solutionsArchive(size_t maxArchiveSize_): maxArchiveSize(maxArchiveSize_){}; 47 | std::unordered_map, double, hashVector > archive; 48 | void checkAlreadyEvaluated(vec_t &genotype, archiveRecord *result); 49 | void insertSolution(vec_t &genotype, double fitness); 50 | }; 51 | 52 | void prepareFolder(std::string &folder); 53 | void initElitistFile(std::string &folder); 54 | void writeStatisticsToFile(std::string &folder, long long numberOfEvaluations, long long time, solution_t *solution); 55 | void writeElitistSolutionToFile(std::string &folder, long long numberOfEvaluations, long long time, solution_t *solution); 56 | 57 | }} -------------------------------------------------------------------------------- /gomea/src/fitness/bbo_fitness.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/bbo_fitness.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | template 7 | BBOFitnessFunction_t::BBOFitnessFunction_t() : fitness_t() 8 | { 9 | this->name = "Custom fitness function (C++)"; 10 | } 11 | 12 | template 13 | BBOFitnessFunction_t::BBOFitnessFunction_t( int number_of_variables ) : fitness_t(number_of_variables) 14 | { 15 | this->name = "Custom fitness function (C++)"; 16 | } 17 | 18 | template 19 | BBOFitnessFunction_t::BBOFitnessFunction_t( int number_of_variables, double vtr ) : fitness_t(number_of_variables,vtr) 20 | { 21 | this->name = "Custom fitness function (C++)"; 22 | } 23 | 24 | template 25 | void BBOFitnessFunction_t::initialize() 26 | { 27 | return; 28 | } 29 | 30 | template 31 | void BBOFitnessFunction_t::evaluationFunction( solution_t *solution ) 32 | { 33 | for( int i = 0; i < this->number_of_objectives; i++ ) 34 | { 35 | double ffitness = objectiveFunction( i, solution ); 36 | solution->setObjectiveValue(ffitness); 37 | } 38 | double fcons = constraintFunction(solution); 39 | solution->setConstraintValue(fcons); 40 | 41 | this->full_number_of_evaluations++; 42 | this->number_of_evaluations++; 43 | } 44 | 45 | template 46 | void BBOFitnessFunction_t::partialEvaluationFunction( solution_t *parent, partial_solution_t *solution ) 47 | { 48 | // Create backup of parent variables before modification 49 | vec_t partial_backup = parent->getCopyOfVariables( solution->touched_indices ); 50 | 51 | // Insert variables of partial solution and then calculate fitness 52 | parent->insertVariables( solution->touched_variables, solution->touched_indices ); 53 | for( int i = 0; i < this->number_of_objectives; i++ ) 54 | { 55 | double ffitness = objectiveFunction( i, parent ); 56 | solution->setObjectiveValue(ffitness); 57 | } 58 | double fcons = constraintFunction(parent); 59 | solution->setConstraintValue(fcons); 60 | 61 | // Return parent variables to original state 62 | parent->insertVariables(partial_backup, solution->touched_indices); 63 | 64 | this->full_number_of_evaluations++; 65 | this->number_of_evaluations++; 66 | } 67 | 68 | template 69 | double BBOFitnessFunction_t::objectiveFunction( int objective_index, solution_t *solution ) 70 | { 71 | return objectiveFunction(objective_index,solution->variables); 72 | } 73 | 74 | template 75 | double BBOFitnessFunction_t::constraintFunction( solution_t *solution ) 76 | { 77 | return constraintFunction(solution->variables); 78 | } 79 | 80 | template 81 | double BBOFitnessFunction_t::constraintFunction( vec_t &variables ) 82 | { 83 | return 0; 84 | } 85 | 86 | template class BBOFitnessFunction_t; 87 | template class BBOFitnessFunction_t; 88 | 89 | }} 90 | -------------------------------------------------------------------------------- /gomea/src/fitness/bbo_fitness.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/fitness/fitness.hpp" 4 | #include "gomea/src/common/solution.hpp" 5 | #include "gomea/src/common/partial_solution.hpp" 6 | #include "gomea/src/common/gomea_defs.hpp" 7 | #include "gomea/src/utils/tools.hpp" 8 | 9 | namespace gomea{ 10 | namespace fitness{ 11 | 12 | template 13 | class BBOFitnessFunction_t : public fitness_t 14 | { 15 | public: 16 | BBOFitnessFunction_t(); 17 | BBOFitnessFunction_t( int number_of_parameters ); 18 | BBOFitnessFunction_t( int number_of_parameters, double vtr ); 19 | 20 | void initialize(); 21 | 22 | double objectiveFunction( int objective_index, solution_t *solution ); 23 | virtual double objectiveFunction( int objective_index, vec_t &variables ) = 0; 24 | 25 | double constraintFunction( solution_t *solution ); 26 | virtual double constraintFunction( vec_t &variables ); 27 | 28 | private: 29 | void evaluationFunction( solution_t *solution ); 30 | void partialEvaluationFunction( solution_t *parent, partial_solution_t *solution ); 31 | }; 32 | 33 | }} 34 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/NKlandscapesBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | #include 5 | 6 | namespace gomea{ 7 | namespace fitness{ 8 | 9 | NKlandscapesBBO_t::NKlandscapesBBO_t( int number_of_variables, int K, long long fitness_table_seed ) : BBOFitnessFunction_t(number_of_variables) 10 | { 11 | this->name = "NK Landscapes function"; 12 | this->vtr = -1; 13 | this->use_vtr = false; 14 | this->K = K; 15 | this->fitness_table_seed = fitness_table_seed; 16 | this->initializeFitnessTables(); 17 | this->initialize(); 18 | } 19 | 20 | void NKlandscapesBBO_t::initializeFitnessTables() 21 | { 22 | static std::uniform_real_distribution distribution(0.0,1.0); 23 | std::mt19937 rng(fitness_table_seed); 24 | 25 | fitness_tables.resize( number_of_variables - K + 1 ); 26 | for( int i = 0; i < fitness_tables.size(); i++ ) 27 | { 28 | fitness_tables[i].resize( 1< &variables ) 35 | { 36 | double fitness = 0; 37 | for( int i = 0; i < fitness_tables.size(); i++ ) 38 | { 39 | size_t fitness_key = 0; // integer representation of bits that are used as input to the subfunction 40 | for( int j = 0; j < K; j++ ) 41 | { 42 | int bit_index = (i + j); 43 | fitness_key = (fitness_key<<1) + variables[bit_index]; 44 | } 45 | assert((int)fitness_key < (1<(number_of_variables) 8 | { 9 | this->name = "NK Landscapes function (S=1)"; 10 | this->vtr = -1; 11 | this->use_vtr = false; 12 | this->K = K; 13 | this->fitness_table_seed = fitness_table_seed; 14 | this->initializeFitnessTables(); 15 | this->initialize(); 16 | } 17 | 18 | void NKlandscapes_t::initializeFitnessTables() 19 | { 20 | static std::uniform_real_distribution distribution(0.0,1.0); 21 | std::mt19937 rng(fitness_table_seed); 22 | 23 | fitness_tables.resize( number_of_variables - K + 1 ); 24 | for( int i = 0; i < fitness_tables.size(); i++ ) 25 | { 26 | fitness_tables[i].resize( 1< &variables ) 38 | { 39 | size_t fitness_key = 0; // integer representation of bits that are used as input to the subfunction 40 | for( int i = 0; i < K; i++ ) 41 | { 42 | int bit_index = (subfunction_index + i); 43 | fitness_key = (fitness_key<<1) + variables[bit_index]; 44 | } 45 | assert((int)fitness_key < (1< NKlandscapes_t::inputsToSubfunction( int subfunction_index ) 50 | { 51 | vec_t inputs; 52 | for( int i = 0; i < K; i++ ) 53 | inputs.push_back( (subfunction_index + i) ); 54 | return( inputs ); 55 | } 56 | 57 | }} 58 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 59 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/asymmetricDeceptiveTrapBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | asymmetricDeceptiveTrapBBO_t::asymmetricDeceptiveTrapBBO_t( int number_of_variables, int trap_size ) : BBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size < 4) 12 | throw std::runtime_error("Asymmetric deceptive trap function requires a trap size of at least 4."); 13 | this->name = "Asymmetric deceptive trap function"; 14 | this->trap_size = trap_size; 15 | this->vtr = number_of_variables; 16 | this->use_vtr = true; 17 | this->initialize(); 18 | } 19 | 20 | double asymmetricDeceptiveTrapBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 21 | { 22 | double f = 0.0; 23 | for( int i = 0; i < number_of_variables; i += trap_size ) 24 | { 25 | int unitation = 0; 26 | for( int j = 0; j < trap_size; j++ ) 27 | unitation += variables[i+j]; 28 | if( unitation == trap_size-1 && variables[i] == 0) 29 | return trap_size; 30 | else 31 | return trap_size * ((double) (trap_size - unitation))/((double) (trap_size+1)); 32 | } 33 | return f; 34 | } 35 | 36 | double asymmetricDeceptiveTrapBBO_t::getSimilarityMeasure( size_t var_a, size_t var_b ) 37 | { 38 | return var_a / trap_size == var_b / trap_size ? 1.0 : 0.0; 39 | } 40 | 41 | }} 42 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 43 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/asymmetricDeceptiveTrap_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | asymmetricDeceptiveTrap_t::asymmetricDeceptiveTrap_t( int number_of_variables, int trap_size ) : GBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size < 4) 12 | throw std::runtime_error("Asymmetric deceptive trap function requires a trap size of at least 4."); 13 | this->name = "Asymmetric deceptive trap function"; 14 | this->trap_size = trap_size; 15 | this->vtr = number_of_variables; 16 | this->use_vtr = true; 17 | this->initialize(); 18 | } 19 | 20 | int asymmetricDeceptiveTrap_t::getNumberOfSubfunctions() 21 | { 22 | return number_of_variables / trap_size; 23 | } 24 | 25 | double asymmetricDeceptiveTrap_t::subfunction( int subfunction_index, vec_t &variables ) 26 | { 27 | int trap_index = subfunction_index; 28 | int unitation = 0; 29 | vec_t inputs = inputsToSubfunction(subfunction_index); 30 | 31 | for( int ind : inputs ) 32 | unitation += variables[ind]; 33 | 34 | if( unitation == trap_size-1 && variables[inputs[0]] == 0) 35 | return trap_size; 36 | else 37 | return trap_size * ((double) (trap_size - unitation))/((double) (trap_size+1)); 38 | } 39 | 40 | vec_t asymmetricDeceptiveTrap_t::inputsToSubfunction( int subfunction_index ) 41 | { 42 | vec_t inputs; 43 | int trap_index = subfunction_index; 44 | for( int i = trap_index * trap_size; i < (trap_index+1)*trap_size; i++ ) 45 | inputs.push_back(i); 46 | return( inputs ); 47 | } 48 | 49 | }} 50 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 51 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/bimodalDeceptiveTrapBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | bimodalDeceptiveTrapBBO_t::bimodalDeceptiveTrapBBO_t( int number_of_variables, int trap_size ) : BBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size % 2 != 0) 12 | throw std::runtime_error("Bimodal deceptive trap function requires an even trap size."); 13 | if(trap_size < 4) 14 | throw std::runtime_error("Bimodal deceptive trap function requires a trap size of at least 4."); 15 | this->name = "Bimodal deceptive trap function"; 16 | this->trap_size = trap_size; 17 | this->vtr = number_of_variables; 18 | this->use_vtr = true; 19 | this->initialize(); 20 | } 21 | 22 | double bimodalDeceptiveTrapBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 23 | { 24 | double f = 0.0; 25 | for( int i = 0; i < number_of_variables; i += trap_size ) 26 | { 27 | int unitation = 0; 28 | for( int j = 0; j < trap_size; j++ ) 29 | unitation += variables[i+j]; 30 | if( unitation == 0 || unitation == trap_size ) 31 | f += trap_size; 32 | else 33 | f += trap_size - fabs(2*unitation - trap_size) - 2; 34 | } 35 | return f; 36 | } 37 | 38 | double bimodalDeceptiveTrapBBO_t::getSimilarityMeasure( size_t var_a, size_t var_b ) 39 | { 40 | return var_a / trap_size == var_b / trap_size ? 1.0 : 0.0; 41 | } 42 | 43 | }} 44 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 45 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/bimodalDeceptiveTrap_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | bimodalDeceptiveTrap_t::bimodalDeceptiveTrap_t( int number_of_variables, int trap_size ) : GBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size % 2 != 0) 12 | throw std::runtime_error("Bimodal deceptive trap function requires an even trap size."); 13 | if(trap_size < 4) 14 | throw std::runtime_error("Bimodal deceptive trap function requires a trap size of at least 4."); 15 | this->name = "Bimodal deceptive trap function"; 16 | this->trap_size = trap_size; 17 | this->vtr = number_of_variables; 18 | this->use_vtr = true; 19 | this->initialize(); 20 | } 21 | 22 | int bimodalDeceptiveTrap_t::getNumberOfSubfunctions() 23 | { 24 | return number_of_variables / trap_size; 25 | } 26 | 27 | double bimodalDeceptiveTrap_t::subfunction( int subfunction_index, vec_t &variables ) 28 | { 29 | int trap_index = subfunction_index; 30 | int unitation = 0; 31 | vec_t inputs = inputsToSubfunction(subfunction_index); 32 | 33 | for( int ind : inputs ) 34 | unitation += variables[ind]; 35 | 36 | if( unitation == 0 || unitation == trap_size ) 37 | return trap_size; 38 | else 39 | return trap_size - fabs(2*unitation - trap_size) - 2; 40 | } 41 | 42 | vec_t bimodalDeceptiveTrap_t::inputsToSubfunction( int subfunction_index ) 43 | { 44 | vec_t inputs; 45 | int trap_index = subfunction_index; 46 | for( int i = trap_index * trap_size; i < (trap_index+1)*trap_size; i++ ) 47 | inputs.push_back(i); 48 | return( inputs ); 49 | } 50 | 51 | }} 52 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 53 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/deceptiveTrapBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | deceptiveTrapBBO_t::deceptiveTrapBBO_t( int number_of_variables, int trap_size ) : BBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size < 3) 12 | throw std::runtime_error("Deceptive trap function requires a trap size of at least 3."); 13 | this->name = "Deceptive trap function"; 14 | this->trap_size = trap_size; 15 | this->vtr = number_of_variables; 16 | this->use_vtr = true; 17 | this->initialize(); 18 | } 19 | 20 | double deceptiveTrapBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 21 | { 22 | double f = 0.0; 23 | for( int i = 0; i < number_of_variables; i += trap_size ) 24 | { 25 | int unitation = 0; 26 | for( int j = 0; j < trap_size; j++ ) 27 | unitation += variables[i+j]; 28 | if( unitation == trap_size ) 29 | f += unitation; 30 | else 31 | f += trap_size - unitation - 1; 32 | } 33 | return f; 34 | } 35 | 36 | double deceptiveTrapBBO_t::getSimilarityMeasure( size_t var_a, size_t var_b ) 37 | { 38 | return var_a / trap_size == var_b / trap_size ? 1.0 : 0.0; 39 | } 40 | 41 | }} 42 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 43 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/deceptiveTrap_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | deceptiveTrap_t::deceptiveTrap_t( int number_of_variables, int trap_size ) : GBOFitnessFunction_t(number_of_variables) 8 | { 9 | if(number_of_variables % trap_size != 0) 10 | throw std::runtime_error("Number of variables must be a multiple of trap size."); 11 | if(trap_size < 3) 12 | throw std::runtime_error("Deceptive trap function requires a trap size of at least 3."); 13 | this->name = "Deceptive trap function"; 14 | this->trap_size = trap_size; 15 | this->vtr = number_of_variables; 16 | this->use_vtr = true; 17 | this->initialize(); 18 | } 19 | 20 | int deceptiveTrap_t::getNumberOfSubfunctions() 21 | { 22 | return number_of_variables / trap_size; 23 | } 24 | 25 | double deceptiveTrap_t::subfunction( int subfunction_index, vec_t &variables ) 26 | { 27 | int trap_index = subfunction_index; 28 | int unitation = 0; 29 | vec_t inputs = inputsToSubfunction(subfunction_index); 30 | 31 | for( int ind : inputs ) 32 | unitation += variables[ind]; 33 | 34 | if( unitation == trap_size ) 35 | return unitation; 36 | else 37 | return trap_size - unitation - 1.0; 38 | } 39 | 40 | vec_t deceptiveTrap_t::inputsToSubfunction( int subfunction_index ) 41 | { 42 | vec_t inputs; 43 | int trap_index = subfunction_index; 44 | for( int i = trap_index * trap_size; i < (trap_index+1)*trap_size; i++ ) 45 | inputs.push_back(i); 46 | return( inputs ); 47 | } 48 | 49 | }} 50 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 51 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/hierarchicalIfAndOnlyIfBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | hierarchicalIfAndOnlyIfBBO_t::hierarchicalIfAndOnlyIfBBO_t( int number_of_variables ) : BBOFitnessFunction_t(number_of_variables) 8 | { 9 | int symbols = number_of_variables; 10 | while( symbols > 1 ) 11 | { 12 | if( symbols % 2 != 0 ) 13 | throw std::runtime_error("Number of variables at each level must be a multiple of 2 for HIFF function."); 14 | symbols /= 2; 15 | } 16 | this->name = "Hierarchical if and only if (HIFF)"; 17 | this->vtr = computeVTR(); 18 | this->use_vtr = true; 19 | this->initialize(); 20 | } 21 | 22 | double hierarchicalIfAndOnlyIfBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 23 | { 24 | double result = 0.0; 25 | int block_size = 1; 26 | while( block_size <= number_of_variables ) 27 | { 28 | for( int i = 0; i < number_of_variables; i += block_size ) 29 | { 30 | bool same = true; 31 | for( int j = 0; j < block_size; j++ ) 32 | { 33 | if( variables[i+j] != variables[i] ) 34 | { 35 | same = false; 36 | break; 37 | } 38 | } 39 | if( same ) 40 | result += block_size; 41 | } 42 | block_size *= 2; 43 | } 44 | 45 | return result; 46 | } 47 | 48 | double hierarchicalIfAndOnlyIfBBO_t::computeVTR() 49 | { 50 | int logl = 0; 51 | int k = number_of_variables; 52 | while( k > 1 ){ 53 | logl++; 54 | k /= 2; 55 | } 56 | return (logl+1) * number_of_variables; 57 | } 58 | 59 | double hierarchicalIfAndOnlyIfBBO_t::getSimilarityMeasure( size_t var_a, size_t var_b ) 60 | { 61 | if( var_a == var_b ) 62 | return 1.0; 63 | else{ 64 | double result = 1.0; 65 | int k = 2; 66 | while( k < number_of_variables ) 67 | { 68 | if(var_a / k == var_b / k) 69 | result *= 2; 70 | k *= 2; 71 | } 72 | return result; 73 | } 74 | } 75 | 76 | }} 77 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 78 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/maxCutBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | #include 5 | 6 | namespace gomea{ 7 | namespace fitness{ 8 | 9 | maxCutBBO_t::maxCutBBO_t( std::string input_file, std::string vtr_file ) : BBOFitnessFunction_t() 10 | { 11 | this->name = "MaxCut function"; 12 | readInputFile(input_file); 13 | readVTRFile(vtr_file); 14 | this->initialize(); 15 | } 16 | 17 | void maxCutBBO_t::readInputFile( std::string input_file ) 18 | { 19 | std::ifstream inFile(input_file, std::ifstream::in); 20 | if (inFile.fail()) 21 | { 22 | throw std::runtime_error("Problem instance file does not exist!"); 23 | } 24 | int N, numEdges; 25 | inFile >> N >> numEdges; 26 | 27 | this->number_of_variables = N; 28 | for (int i = 0; i < numEdges; ++i) 29 | { 30 | int v1, v2; 31 | double w; 32 | inFile >> v1 >> v2 >> w; 33 | vec_t edge; 34 | edge.push_back(v1-1); 35 | edge.push_back(v2-1); 36 | edges.push_back(edge); 37 | edge_weights.push_back(w); 38 | } 39 | 40 | inFile.close(); 41 | } 42 | 43 | void maxCutBBO_t::readVTRFile( std::string vtr_file ) 44 | { 45 | if( vtr_file.size() > 0 ) 46 | { 47 | this->use_vtr = true; 48 | std::ifstream inFile(vtr_file, std::ifstream::in); 49 | if (inFile.fail()) 50 | { 51 | throw std::runtime_error("VTR file does not exist!"); 52 | } 53 | double vtr; 54 | inFile >> vtr; 55 | this->vtr = vtr; 56 | inFile.close(); 57 | } 58 | } 59 | 60 | double maxCutBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 61 | { 62 | double cut = 0.0; 63 | for( int i = 0; i < edges.size(); i++ ) 64 | { 65 | vec_t edge = edges[i]; 66 | if (variables[edge[0]] != variables[edge[1]]) 67 | cut += edge_weights[i]; 68 | } 69 | return cut; 70 | } 71 | 72 | }} 73 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 74 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/maxCut_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | #include 5 | 6 | namespace gomea{ 7 | namespace fitness{ 8 | 9 | maxCut_t::maxCut_t( std::string input_file, std::string vtr_file ) : GBOFitnessFunction_t() 10 | { 11 | this->name = "MaxCut function"; 12 | readInputFile(input_file); 13 | readVTRFile(vtr_file); 14 | this->initialize(); 15 | } 16 | 17 | void maxCut_t::readInputFile( std::string input_file ) 18 | { 19 | std::ifstream inFile(input_file, std::ifstream::in); 20 | if (inFile.fail()) 21 | { 22 | throw std::runtime_error("Problem instance file does not exist!"); 23 | } 24 | int N, numEdges; 25 | inFile >> N >> numEdges; 26 | 27 | this->number_of_variables = N; 28 | for (int i = 0; i < numEdges; ++i) 29 | { 30 | int v1, v2; 31 | double w; 32 | inFile >> v1 >> v2 >> w; 33 | vec_t edge; 34 | edge.push_back(v1-1); 35 | edge.push_back(v2-1); 36 | edges.push_back(edge); 37 | edge_weights.push_back(w); 38 | } 39 | 40 | inFile.close(); 41 | } 42 | 43 | void maxCut_t::readVTRFile( std::string vtr_file ) 44 | { 45 | if( vtr_file.size() > 0 ) 46 | { 47 | this->use_vtr = true; 48 | std::ifstream inFile(vtr_file, std::ifstream::in); 49 | if (inFile.fail()) 50 | { 51 | throw std::runtime_error("VTR file does not exist!"); 52 | } 53 | double vtr; 54 | inFile >> vtr; 55 | this->vtr = vtr; 56 | inFile.close(); 57 | } 58 | } 59 | 60 | int maxCut_t::getNumberOfSubfunctions() 61 | { 62 | return edges.size(); 63 | } 64 | 65 | double maxCut_t::subfunction( int subfunction_index, vec_t &variables ) 66 | { 67 | int edge_index = subfunction_index; 68 | vec_t inputs = inputsToSubfunction(subfunction_index); 69 | if( variables[inputs[0]] == variables[inputs[1]] ) 70 | return 0.0; 71 | else 72 | return edge_weights[subfunction_index]; 73 | } 74 | 75 | vec_t maxCut_t::inputsToSubfunction( int subfunction_index ) 76 | { 77 | int edge_index = subfunction_index; 78 | return( edges[edge_index] ); 79 | } 80 | 81 | 82 | }} 83 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 84 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/oneMaxBBO_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | oneMaxBBO_t::oneMaxBBO_t( int number_of_variables ) : BBOFitnessFunction_t(number_of_variables) 8 | { 9 | this->name = "OneMax function"; 10 | this->vtr = number_of_variables; 11 | this->use_vtr = true; 12 | this->initialize(); 13 | } 14 | 15 | double oneMaxBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 16 | { 17 | double result = 0.0; 18 | for( char c : variables ) 19 | result += c; 20 | return result; 21 | } 22 | 23 | }} 24 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 25 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-discrete/oneMax_t.cpp: -------------------------------------------------------------------------------- 1 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2 | #include "gomea/src/fitness/benchmarks-discrete.hpp" 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | namespace gomea{ 5 | namespace fitness{ 6 | 7 | oneMax_t::oneMax_t( int number_of_variables ) : GBOFitnessFunction_t(number_of_variables) 8 | { 9 | this->name = "OneMax function"; 10 | this->vtr = number_of_variables; 11 | this->use_vtr = true; 12 | this->initialize(); 13 | } 14 | 15 | int oneMax_t::getNumberOfSubfunctions() 16 | { 17 | return number_of_variables; 18 | } 19 | 20 | vec_t oneMax_t::inputsToSubfunction( int subfunction_index ) 21 | { 22 | vec_t vec; 23 | vec.push_back(subfunction_index); 24 | return vec; 25 | } 26 | 27 | double oneMax_t::subfunction( int subfunction_index, vec_t &variables ) 28 | { 29 | return( variables[subfunction_index] ); 30 | } 31 | 32 | }} 33 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 34 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/fitness/gbo_fitness.hpp" 4 | #include "gomea/src/fitness/bbo_fitness.hpp" 5 | #include "gomea/src/common/solution.hpp" 6 | #include "gomea/src/common/partial_solution.hpp" 7 | #include "gomea/src/common/gomea_defs.hpp" 8 | #include "gomea/src/utils/tools.hpp" 9 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 10 | 11 | namespace gomea{ 12 | namespace fitness{ 13 | 14 | class sphereFunction_t : public GBOFitnessFunction_t 15 | { 16 | public: 17 | sphereFunction_t( int number_of_variables, double vtr ); 18 | int getNumberOfSubfunctions(); 19 | vec_t inputsToSubfunction( int subfunction_index ); 20 | 21 | private: 22 | double subfunction( int subfunction_index, vec_t &variables ); 23 | }; 24 | 25 | class sphereFunctionBBO_t : public BBOFitnessFunction_t 26 | { 27 | public: 28 | sphereFunctionBBO_t( int number_of_variables, double vtr ); 29 | double objectiveFunction( int objective_index, vec_t &variables ); 30 | }; 31 | 32 | class rosenbrockFunction_t : public GBOFitnessFunction_t 33 | { 34 | public: 35 | rosenbrockFunction_t( int number_of_variables, double vtr ); 36 | int getNumberOfSubfunctions(); 37 | vec_t inputsToSubfunction( int subfunction_index ); 38 | 39 | private: 40 | double subfunction( int subfunction_index, vec_t &variables ); 41 | }; 42 | 43 | class SOREBChainStrong_t : public GBOFitnessFunction_t 44 | { 45 | public: 46 | SOREBChainStrong_t( int number_of_variables, double vtr ); 47 | ~SOREBChainStrong_t(); 48 | 49 | int getNumberOfSubfunctions(); 50 | vec_t inputsToSubfunction( int subfunction_index ); 51 | 52 | private: 53 | double subfunction( int subfunction_index, vec_t &variables ); 54 | }; 55 | 56 | class rosenbrockFunctionBBO_t : public BBOFitnessFunction_t 57 | { 58 | public: 59 | rosenbrockFunctionBBO_t( int number_of_variables, double vtr ); 60 | double objectiveFunction( int objective_index, vec_t &variables ); 61 | }; 62 | 63 | class SOREBChainStrongBBO_t : public BBOFitnessFunction_t 64 | { 65 | public: 66 | SOREBChainStrongBBO_t( int number_of_variables, double vtr ); 67 | double objectiveFunction( int objective_index, vec_t &variables ); 68 | }; 69 | 70 | class circlesInASquareBBO_t : public BBOFitnessFunction_t 71 | { 72 | public: 73 | circlesInASquareBBO_t( int number_of_variables, double vtr ); 74 | double objectiveFunction( int objective_index, vec_t &variables ); 75 | 76 | double getLowerRangeBound(int dimension); 77 | double getUpperRangeBound(int dimension); 78 | 79 | private: 80 | vec_t optima; 81 | void initializeOptima(); 82 | 83 | }; 84 | 85 | }} 86 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/SOREBChainStrongBBO_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | SOREBChainStrongBBO_t::SOREBChainStrongBBO_t( int number_of_variables, double vtr ) : BBOFitnessFunction_t(number_of_variables, vtr) 7 | { 8 | this->name = "Sum of rotated ellipsoid blocks (SOREB) with strong dependencies -- 1 overlap in chain structure"; 9 | this->initialize(); 10 | this->rotation_angle = -45; 11 | this->rotation_block_size = 2; 12 | this->rotation_matrix = initializeObjectiveRotationMatrix( this->rotation_angle, this->rotation_block_size ); 13 | } 14 | 15 | double SOREBChainStrongBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 16 | { 17 | double result = 0.0; 18 | for( int i = 0; i < number_of_variables-1; i++ ) 19 | { 20 | double vars[] = {variables[i],variables[i+1]}; 21 | double *rotated_variables = rotateVariables(&vars[0],rotation_block_size,this->rotation_matrix); 22 | for( int j = 0; j < rotation_block_size; j++) 23 | { 24 | result += pow( 10.0, 6.0*(((double) (j))/((double) (rotation_block_size-1))) )*rotated_variables[j]*rotated_variables[j]; 25 | } 26 | delete[] rotated_variables; 27 | } 28 | return result; 29 | } 30 | 31 | }} 32 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 33 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/SOREBChainStrong_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | SOREBChainStrong_t::SOREBChainStrong_t( int number_of_variables, double vtr ) : GBOFitnessFunction_t(number_of_variables,vtr) 7 | { 8 | this->name = "Sum of rotated ellipsoid blocks (SOREB) with strong dependencies -- 1 overlap in chain structure"; 9 | this->initialize(); 10 | this->rotation_angle = -45; 11 | this->rotation_block_size = 2; 12 | this->rotation_matrix = initializeObjectiveRotationMatrix( this->rotation_angle, this->rotation_block_size ); 13 | } 14 | 15 | SOREBChainStrong_t::~SOREBChainStrong_t() 16 | { 17 | for( int i = 0; i < rotation_block_size; i++ ) 18 | delete[] rotation_matrix[i]; 19 | delete[] rotation_matrix; 20 | } 21 | 22 | int SOREBChainStrong_t::getNumberOfSubfunctions() 23 | { 24 | return number_of_variables-1; 25 | } 26 | 27 | vec_t SOREBChainStrong_t::inputsToSubfunction( int subfunction_index ) 28 | { 29 | vec_t vec; 30 | vec.push_back(subfunction_index); 31 | vec.push_back(subfunction_index+1); 32 | return vec; 33 | } 34 | 35 | double SOREBChainStrong_t::subfunction( int subfunction_index, vec_t &variables ) 36 | { 37 | double vars[] = {variables[subfunction_index],variables[subfunction_index+1]}; 38 | double *rotated_variables = rotateVariables(&vars[0],rotation_block_size,this->rotation_matrix); 39 | double result = 0.0; 40 | for( int i = 0; i < rotation_block_size; i++) 41 | { 42 | result += pow( 10.0, 6.0*(((double) (i))/((double) (rotation_block_size-1))) )*rotated_variables[i]*rotated_variables[i]; 43 | } 44 | delete[] rotated_variables; 45 | return result; 46 | } 47 | 48 | }} 49 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 50 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/circlesInASquareBBO_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | circlesInASquareBBO_t::circlesInASquareBBO_t( int number_of_variables, double vtr ) : BBOFitnessFunction_t(number_of_variables) 7 | { 8 | assert( number_of_variables % 2 == 0 ); 9 | assert( number_of_variables > 2 ); 10 | this->name = "Circles in a square"; 11 | this->initialize(); 12 | this->initializeOptima(); 13 | if( number_of_variables/2 < optima.size() ) 14 | { 15 | this->use_vtr = true; 16 | this->vtr = -1*(optima[number_of_variables/2]-vtr); 17 | } 18 | } 19 | 20 | void circlesInASquareBBO_t::initializeOptima() 21 | { 22 | optima.resize(31); 23 | for( int i = 0; i < optima.size(); i++ ) 24 | optima[i] = 1e308; 25 | optima[2] = 1.414213562373; 26 | optima[3] = 1.035276180410; 27 | optima[4] = 1.000000000000; 28 | optima[5] = 0.707106781186; 29 | optima[6] = 0.600925212577; 30 | optima[7] = 0.535898384862; 31 | optima[8] = 0.517638090205; 32 | optima[9] = 0.500000000000; 33 | optima[10]= 0.421279543983; 34 | optima[11]= 0.398207310236; 35 | optima[12]= 0.388730126323; 36 | optima[13]= 0.366096007696; 37 | optima[14]= 0.348915260374; 38 | optima[15]= 0.341081377402; 39 | optima[16]= 0.333333333333; 40 | optima[17]= 0.306153985300; 41 | optima[18]= 0.300462606288; 42 | optima[19]= 0.289541991994; 43 | optima[20]= 0.286611652351; 44 | optima[21]= 0.271812255359; 45 | optima[22]= 0.267958401550; 46 | optima[23]= 0.258819045102; 47 | optima[24]= 0.254333095030; 48 | optima[25]= 0.250000000000; 49 | optima[26]= 0.238734757241; 50 | optima[27]= 0.235849528301; 51 | optima[28]= 0.230535493642; 52 | optima[29]= 0.226882900744; 53 | optima[30]= 0.224502964531; 54 | } 55 | 56 | double circlesInASquareBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 57 | { 58 | double min_dist = 1e308; 59 | for( int i = 0; i < number_of_variables; i+=2 ) 60 | { 61 | for( int j = i+2; j < number_of_variables; j+=2 ) 62 | { 63 | double dist = utils::distanceEuclidean2D(variables[i],variables[i+1],variables[j],variables[j+1]); 64 | min_dist = std::min(min_dist,dist); 65 | } 66 | } 67 | return -min_dist; 68 | } 69 | 70 | double circlesInASquareBBO_t::getLowerRangeBound( int dimension ) 71 | { 72 | return 0.0; 73 | } 74 | 75 | double circlesInASquareBBO_t::getUpperRangeBound( int dimension ) 76 | { 77 | return 1.0; 78 | } 79 | 80 | }} 81 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 82 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/rosenbrockFunctionBBO_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | rosenbrockFunctionBBO_t::rosenbrockFunctionBBO_t( int number_of_variables, double vtr ) : BBOFitnessFunction_t(number_of_variables, vtr) 7 | { 8 | this->name = "Rosenbrock function (BBO)"; 9 | this->initialize(); 10 | } 11 | 12 | double rosenbrockFunctionBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 13 | { 14 | double result = 0.0; 15 | for( int i = 0; i < number_of_variables-1; i++ ) 16 | { 17 | double x = variables[i]; 18 | double y = variables[i+1]; 19 | result += 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x); 20 | } 21 | return result; 22 | } 23 | 24 | }} 25 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 26 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/rosenbrockFunction_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | rosenbrockFunction_t::rosenbrockFunction_t( int number_of_variables, double vtr ) : GBOFitnessFunction_t(number_of_variables,vtr) 7 | { 8 | this->name = "Rosenbrock function"; 9 | this->initialize(); 10 | } 11 | 12 | int rosenbrockFunction_t::getNumberOfSubfunctions() 13 | { 14 | return number_of_variables-1; 15 | } 16 | 17 | vec_t rosenbrockFunction_t::inputsToSubfunction( int subfunction_index ) 18 | { 19 | vec_t vec; 20 | vec.push_back(subfunction_index); 21 | vec.push_back(subfunction_index+1); 22 | return vec; 23 | } 24 | 25 | double rosenbrockFunction_t::subfunction( int subfunction_index, vec_t &variables ) 26 | { 27 | double x = variables[subfunction_index]; 28 | double y = variables[subfunction_index+1]; 29 | return( 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) ); 30 | } 31 | 32 | }} 33 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 34 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/sphereFunctionBBO_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | sphereFunctionBBO_t::sphereFunctionBBO_t( int number_of_variables, double vtr ) : BBOFitnessFunction_t(number_of_variables, vtr) 7 | { 8 | this->name = "Sphere function (BBO)"; 9 | this->initialize(); 10 | } 11 | 12 | double sphereFunctionBBO_t::objectiveFunction( int objective_index, vec_t &variables ) 13 | { 14 | double result = 0.0; 15 | for( int i = 0; i < number_of_variables; i++ ) 16 | { 17 | double x = variables[i]; 18 | result += x * x; 19 | } 20 | return result; 21 | } 22 | 23 | }} 24 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 25 | -------------------------------------------------------------------------------- /gomea/src/fitness/benchmarks-rv/sphereFunction_t.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/benchmarks-rv.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | sphereFunction_t::sphereFunction_t( int number_of_variables, double vtr ) : GBOFitnessFunction_t(number_of_variables,vtr) 7 | { 8 | this->name = "Sphere function"; 9 | this->initialize(); 10 | } 11 | 12 | int sphereFunction_t::getNumberOfSubfunctions() 13 | { 14 | return number_of_variables; 15 | } 16 | 17 | vec_t sphereFunction_t::inputsToSubfunction( int subfunction_index ) 18 | { 19 | vec_t vec; 20 | vec.push_back(subfunction_index); 21 | return vec; 22 | } 23 | 24 | double sphereFunction_t::subfunction( int subfunction_index, vec_t &variables ) 25 | { 26 | double x = variables[subfunction_index]; 27 | return( x * x ); 28 | } 29 | 30 | }} 31 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 32 | -------------------------------------------------------------------------------- /gomea/src/fitness/gbo_fitness.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/fitness/fitness.hpp" 4 | #include "gomea/src/common/solution.hpp" 5 | #include "gomea/src/common/partial_solution.hpp" 6 | #include "gomea/src/common/gomea_defs.hpp" 7 | #include "gomea/src/utils/tools.hpp" 8 | 9 | namespace gomea{ 10 | namespace fitness{ 11 | 12 | template 13 | class GBOFitnessFunction_t : public fitness_t 14 | { 15 | public: 16 | GBOFitnessFunction_t(); 17 | GBOFitnessFunction_t( int number_of_parameters ); 18 | GBOFitnessFunction_t( int number_of_parameters, double vtr ); 19 | 20 | void initialize(); 21 | 22 | // Subfunctions 23 | virtual vec_t inputsToSubfunction( int subfunction_index ) = 0; 24 | virtual int getIndexOfFitnessBuffer( int subfunction_index ); 25 | virtual int getNumberOfSubfunctions() = 0; 26 | virtual int getNumberOfFitnessBuffers(); 27 | 28 | // Dependency structure 29 | void initializeSubfunctionDependencyMap(); 30 | virtual void initializeVariableInteractionGraph(); 31 | virtual double getSimilarityMeasure( size_t var_a, size_t var_b ); 32 | 33 | private: 34 | void evaluationFunction( solution_t *solution ); 35 | //void partialEvaluationFunction( solution_t *parent, partial_solution_t *solution, const std::set &dependent_subfunctions ); 36 | void partialEvaluationFunction( solution_t *parent, partial_solution_t *solution ); 37 | virtual double subfunction( int subfunction_index, vec_t &variables ) = 0; 38 | 39 | double objectiveFunction( int objective_index, solution_t *solution ); 40 | double objectiveFunction( int objective_index, partial_solution_t *solution ); 41 | virtual double objectiveFunction( int objective_index, vec_t &fitness_buffers ); 42 | 43 | double constraintFunction( solution_t *solution ); 44 | double constraintFunction( partial_solution_t *solution ); 45 | virtual double constraintFunction( vec_t &fitness_buffers ); 46 | }; 47 | 48 | }} 49 | -------------------------------------------------------------------------------- /gomea/src/fitness/py_bbo_fitness.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CPP_STANDALONE 4 | 5 | #include "gomea/src/fitness/bbo_fitness.hpp" 6 | #include "gomea/fitness.h" 7 | #include "numpy/arrayobject.h" 8 | 9 | namespace gomea{ 10 | namespace fitness{ 11 | 12 | template 13 | class pyBBOFitnessFunction_t : public BBOFitnessFunction_t 14 | { 15 | public: 16 | pyBBOFitnessFunction_t( int number_of_parameters, PyObject *obj ); 17 | pyBBOFitnessFunction_t( int number_of_parameters, double vtr, PyObject *obj ); 18 | pyBBOFitnessFunction_t( int number_of_parameters, int alphabet_size, PyObject *obj ); 19 | pyBBOFitnessFunction_t( int number_of_parameters, int alphabet_size, double vtr, PyObject *obj ); 20 | 21 | double objectiveFunction( int objective_index, vec_t &variables ); 22 | double constraintFunction( vec_t &variables ); 23 | 24 | double getLowerRangeBound( int dimension ); 25 | double getUpperRangeBound( int dimension ); 26 | 27 | double getSimilarityMeasure( size_t var_a, size_t var_b ); 28 | 29 | protected: 30 | PyObject *py_class; 31 | }; 32 | 33 | }} 34 | 35 | #endif -------------------------------------------------------------------------------- /gomea/src/fitness/py_gbo_fitness.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef CPP_STANDALONE 4 | 5 | #include "gomea/src/fitness/gbo_fitness.hpp" 6 | #include "gomea/fitness.h" 7 | #include "numpy/arrayobject.h" 8 | 9 | namespace gomea{ 10 | namespace fitness{ 11 | 12 | template 13 | class pyGBOFitnessFunction_t : public GBOFitnessFunction_t 14 | { 15 | public: 16 | pyGBOFitnessFunction_t( int number_of_parameters, PyObject *obj ); 17 | pyGBOFitnessFunction_t( int number_of_parameters, double vtr, PyObject *obj ); 18 | pyGBOFitnessFunction_t( int number_of_parameters, int alphabet_size, PyObject *obj ); 19 | pyGBOFitnessFunction_t( int number_of_parameters, int alphabet_size, double vtr, PyObject *obj ); 20 | 21 | int getNumberOfSubfunctions(); 22 | vec_t inputsToSubfunction( int subfunction_index ); 23 | double getSimilarityMeasure( size_t var_a, size_t var_b ); 24 | 25 | double objectiveFunction( int objective_index, vec_t &fitness_buffers ); 26 | double constraintFunction( int objective_index, vec_t &fitness_buffers ); 27 | int getNumberOfFitnessBuffers(); 28 | int getIndexOfFitnessBuffer( int subfunction_index ); 29 | 30 | double getLowerRangeBound( int dimension ); 31 | double getUpperRangeBound( int dimension ); 32 | 33 | protected: 34 | PyObject *py_class; 35 | double subfunction( int subfunction_index, vec_t &variables ); 36 | }; 37 | 38 | }} 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /gomea/src/fitness/your_fitness_discrete.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/your_fitness_discrete.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | yourFitnessFunctionDiscrete::yourFitnessFunctionDiscrete( int number_of_variables, int alphabet_size, double vtr ) : GBOFitnessFunction_t(number_of_variables,vtr) 7 | { 8 | this->name = "Your own fitness function (C++)"; 9 | this->vtr = vtr; 10 | this->alphabet_size = alphabet_size; 11 | assert( number_of_variables % trap_size == 0 ); 12 | this->initialize(); 13 | } 14 | 15 | int yourFitnessFunctionDiscrete::getNumberOfSubfunctions() 16 | { 17 | return number_of_variables / trap_size; 18 | } 19 | 20 | vec_t yourFitnessFunctionDiscrete::inputsToSubfunction( int subfunction_index ) 21 | { 22 | vec_t dependencies; 23 | for( int i = 0; i < trap_size; i++ ) 24 | dependencies.push_back(subfunction_index*trap_size + i); 25 | return dependencies; 26 | } 27 | 28 | double yourFitnessFunctionDiscrete::subfunction( int subfunction_index, vec_t &variables ) 29 | { 30 | int unitation = 0; 31 | for( int i = 0; i < trap_size; i++ ) 32 | unitation += variables[trap_size * subfunction_index + i]; 33 | if( unitation == trap_size ) 34 | return trap_size; 35 | return( (double) (trap_size - 1 - unitation) ); 36 | } 37 | 38 | }} -------------------------------------------------------------------------------- /gomea/src/fitness/your_fitness_discrete.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/fitness/gbo_fitness.hpp" 4 | 5 | namespace gomea{ 6 | namespace fitness{ 7 | 8 | class yourFitnessFunctionDiscrete : public GBOFitnessFunction_t 9 | { 10 | public: 11 | yourFitnessFunctionDiscrete( int number_of_variables, int alphabet_size, double vtr ); 12 | 13 | int getNumberOfSubfunctions(); 14 | vec_t inputsToSubfunction( int subfunction_index ); 15 | 16 | private: 17 | int trap_size = 5; 18 | double subfunction( int subfunction_index, vec_t &variables ); 19 | }; 20 | 21 | }} 22 | -------------------------------------------------------------------------------- /gomea/src/fitness/your_fitness_realvalued.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/fitness/your_fitness_realvalued.hpp" 2 | 3 | namespace gomea{ 4 | namespace fitness{ 5 | 6 | yourFitnessFunctionRealValued::yourFitnessFunctionRealValued( int number_of_variables, double vtr ) : GBOFitnessFunction_t(number_of_variables,vtr) 7 | { 8 | this->name = "Your own fitness function (C++)"; 9 | this->initialize(); 10 | } 11 | 12 | int yourFitnessFunctionRealValued::getNumberOfSubfunctions() 13 | { 14 | return number_of_variables-1; 15 | } 16 | 17 | vec_t yourFitnessFunctionRealValued::inputsToSubfunction( int subfunction_index ) 18 | { 19 | vec_t dependencies; 20 | dependencies.push_back(subfunction_index); 21 | dependencies.push_back(subfunction_index+1); 22 | return dependencies; 23 | } 24 | 25 | double yourFitnessFunctionRealValued::subfunction( int subfunction_index, vec_t &variables ) 26 | { 27 | double x = variables[subfunction_index]; 28 | double y = variables[subfunction_index+1]; 29 | return( 100*(y-x*x)*(y-x*x) + (1.0-x)*(1.0-x) ); 30 | } 31 | 32 | double yourFitnessFunctionRealValued::getLowerRangeBound( int dimension ) 33 | { 34 | return( -1000 ); 35 | } 36 | 37 | double yourFitnessFunctionRealValued::getUpperRangeBound( int dimension ) 38 | { 39 | return( 1000 ); 40 | } 41 | 42 | }} -------------------------------------------------------------------------------- /gomea/src/fitness/your_fitness_realvalued.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gomea/src/fitness/gbo_fitness.hpp" 4 | 5 | namespace gomea{ 6 | namespace fitness{ 7 | 8 | class yourFitnessFunctionRealValued : public GBOFitnessFunction_t 9 | { 10 | public: 11 | yourFitnessFunctionRealValued( int number_of_variables, double vtr ); 12 | 13 | int getNumberOfSubfunctions(); 14 | vec_t inputsToSubfunction( int subfunction_index ); 15 | double getLowerRangeBound( int dimension ); 16 | double getUpperRangeBound( int dimension ); 17 | 18 | private: 19 | double subfunction( int subfunction_index, vec_t &variables ); 20 | }; 21 | 22 | }} 23 | -------------------------------------------------------------------------------- /gomea/src/real_valued/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/real_valued/Config.hpp" 2 | #include "gomea/src/real_valued/rv-gomea.hpp" 3 | 4 | using gomea::realvalued::Config; 5 | using gomea::realvalued::rvg_t; 6 | int main(int argc, char **argv) 7 | { 8 | Config *config = new Config(); 9 | config->parseCommandLine(argc, argv); 10 | config->checkOptions(); 11 | //config->printVerboseOverview(); 12 | 13 | rvg_t *gomeaInstance = new rvg_t(argc, argv); 14 | 15 | try 16 | { 17 | gomeaInstance->run(); 18 | } 19 | catch (gomea::utils::terminationException &ex) 20 | {} 21 | 22 | gomeaInstance->output.writeToFile("out.dat"); 23 | //gomeaInstance->output.printMetrics(); 24 | 25 | delete gomeaInstance; 26 | delete config; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /gomea/src/real_valued/partial_solutionRV.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/real_valued/partial_solutionRV.hpp" 2 | 3 | namespace gomea{ 4 | namespace realvalued{ 5 | 6 | template 7 | partial_solution_t::partial_solution_t( vec_t &touched_variables, vec_t &sample_zs, vec_t &touched_indices ) : partial_solution_t(touched_variables,touched_indices) 8 | { 9 | this->sample_zs = sample_zs; 10 | } 11 | 12 | template 13 | void partial_solution_t::setSampleMean( vec_t &means ) 14 | { 15 | this->sample_means = means; 16 | } 17 | 18 | template class partial_solution_t; 19 | 20 | }} 21 | -------------------------------------------------------------------------------- /gomea/src/real_valued/partial_solutionRV.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | #include "src/common/gomea_defs.hpp" 5 | #include "src/common/solution.hpp" 6 | #include "src/common/partial_solution.hpp" 7 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 8 | 9 | namespace gomea{ 10 | namespace realvalued{ 11 | 12 | template 13 | class partial_solution_t : public gomea::partial_solution_t 14 | { 15 | using gomea::partial_solution_t::partial_solution_t; 16 | 17 | public: 18 | partial_solution_t( vec_t &touched_variables, vec_t &sample_zs, vec_t &touched_indices ); 19 | 20 | vec_t sample_zs; // Samples z~N(0,I), later transformed to N(mu,C) 21 | vec_t sample_means; 22 | 23 | bool is_accepted = false; 24 | bool improves_elitist = false; 25 | 26 | void setSampleMean( vec_t &means ); 27 | }; 28 | 29 | }} 30 | -------------------------------------------------------------------------------- /gomea/src/real_valued/solutionRV.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/real_valued/solutionRV.hpp" 2 | 3 | namespace gomea{ 4 | namespace realvalued{ 5 | 6 | template class solution_t; 7 | 8 | }} 9 | -------------------------------------------------------------------------------- /gomea/src/real_valued/solutionRV.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-= Section Includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4 | #include "src/common/gomea_defs.hpp" 5 | #include "src/common/solution.hpp" 6 | /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 7 | 8 | namespace gomea{ 9 | namespace realvalued{ 10 | 11 | template 12 | class solution_t : public gomea::solution_t 13 | { 14 | using gomea::solution_t::solution_t; 15 | 16 | public: 17 | int NIS = 0; // no improvement stretch 18 | }; 19 | 20 | }} 21 | -------------------------------------------------------------------------------- /gomea/src/real_valued/tools.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "gomea/src/utils/tools.hpp" 19 | 20 | namespace gomea{ 21 | namespace realvalued{ 22 | 23 | using mat = Eigen::MatrixXd; 24 | using vec = Eigen::VectorXd; 25 | 26 | template 27 | using vec_t = std::vector; 28 | template 29 | using vec_pt = std::shared_ptr>; 30 | 31 | void *Malloc( long size ); 32 | double **matrixNew( int n, int m ); 33 | double vectorDotProduct( double *vector0, double *vector1, int n0 ); 34 | double vectorNorm( double *vector0, int n0 ); 35 | double *matrixVectorMultiplication( double **matrix, double *vector, int n0, int n1 ); 36 | double **matrixMatrixMultiplication( double **matrix0, double **matrix1, int n0, int n1, int n2 ); 37 | int blasDSWAP( int n, double *dx, int incx, double *dy, int incy ); 38 | int blasDAXPY(int n, double da, double *dx, int incx, double *dy, int incy); 39 | void blasDSCAL( int n, double sa, double x[], int incx ); 40 | int linpackDCHDC( double a[], int lda, int p, double work[], int ipvt[] ); 41 | double **choleskyDecomposition( double **matrix, int n ); 42 | mat choleskyDecomposition( mat matrix ); 43 | int linpackDTRDI( double t[], int ldt, int n ); 44 | double **matrixLowerTriangularInverse( double **matrix, int n ); 45 | void eigenDecomposition( double **matrix, int n, double **D, double **Q ); 46 | void eigenDecompositionQLalgo2( int n, double **V, double *d, double *e ); 47 | double myhypot( double a, double b ); 48 | void eigenDecompositionHouseholder2( int n, double **V, double *d, double *e ); 49 | void matrixWriteToFile( FILE *file, double **matrix, int n0, int n1 ); 50 | 51 | int *mergeSort( double *array, int array_size ); 52 | void mergeSortWithinBounds( double *array, int *sorted, int *tosort, int p, int q ); 53 | void mergeSortWithinBoundsInt( int *array, int *sorted, int *tosort, int p, int q ); 54 | 55 | void mergeSortMerge( double *array, int *sorted, int *tosort, int p, int r, int q ); 56 | int *mergeSortInt( int *array, int array_size ); 57 | void mergeSortMergeInt( int *array, int *sorted, int *tosort, int p, int r, int q ); 58 | 59 | int *getRanks(double *array, int array_size ); 60 | int *getRanksFromSorted(int *sorted, int array_size ); 61 | 62 | vec random1DNormalUnitVector( int length ); 63 | 64 | int *greedyScatteredSubsetSelection( double **points, int number_of_points, int number_of_dimensions, int number_to_select ); 65 | 66 | double max( double x, double y ); 67 | double min( double x, double y ); 68 | mat pinv(const mat &a, double epsilon = std::numeric_limits::epsilon()); 69 | double normalize( double v, double min, double max ); 70 | 71 | double *matrixVectorPartialMultiplication( double **matrix, double *vector, int n0, int n1, int number_of_elements, int *element_indices ); 72 | 73 | }} 74 | -------------------------------------------------------------------------------- /gomea/src/utils/time.cpp: -------------------------------------------------------------------------------- 1 | #include "gomea/src/utils/time.hpp" 2 | 3 | namespace gomea{ 4 | namespace utils{ 5 | 6 | time_t start_time; 7 | std::unordered_map timers; 8 | 9 | void initStartTime() 10 | { 11 | start_time = getTimestamp(); 12 | } 13 | 14 | void printTimestamp( time_t timestamp ) 15 | { 16 | //std::chrono::time_point time_point; 17 | //std::time_t tc = std::chrono::high_resolution_clock::to_time_t(timestamp); 18 | //std::cout << "time: " << timestamp << std::endl; 19 | //std::cout << "time: " << std::chrono::duration_cast(timestamp.time_since_epoch()).count(); 20 | std::cout << "time: " << timestamp.time_since_epoch().count() << std::endl; 21 | } 22 | 23 | time_t getTimestamp() 24 | { 25 | //std::chrono::time_point time_point; 26 | return std::chrono::time_point_cast(std::chrono::system_clock::now()); 27 | } 28 | 29 | void addToTimer( std::string label, time_t startTimestamp ) 30 | { 31 | if( timers.count(label) == 0 ) 32 | timers[label] = 0.0; 33 | timers[label] += getElapsedTimeSeconds(startTimestamp); 34 | } 35 | 36 | void clearTimers() 37 | { 38 | timers.clear(); 39 | } 40 | 41 | double getTimer( std::string label ) 42 | { 43 | if( timers.count(label) == 0 ) 44 | return 0.0; 45 | return timers[label]; 46 | } 47 | 48 | long long getElapsedTimeMicroseconds(time_t startTimestamp) 49 | { 50 | auto timestamp_now = getTimestamp(); 51 | auto diff = std::chrono::duration_cast(timestamp_now - startTimestamp); 52 | return( diff.count() ); 53 | } 54 | 55 | double getElapsedTimeMilliseconds(time_t startTimestamp) 56 | { 57 | return( getElapsedTimeMicroseconds(startTimestamp) * 1e-3 ); 58 | } 59 | 60 | double getElapsedTimeSeconds(time_t startTimestamp) 61 | { 62 | return( getElapsedTimeMicroseconds(startTimestamp) * 1e-6 ); 63 | } 64 | 65 | double getElapsedTimeSinceStartSeconds() 66 | { 67 | return getElapsedTimeSeconds(start_time); 68 | } 69 | 70 | double getElapsedTimeSinceStartSeconds(time_t customStartTime) 71 | { 72 | return getElapsedTimeSeconds(customStartTime); 73 | } 74 | 75 | double getElapsedTimeSinceStartMilliseconds() 76 | { 77 | return getElapsedTimeMicroseconds(start_time)*1e-3; 78 | } 79 | 80 | }} 81 | 82 | -------------------------------------------------------------------------------- /gomea/src/utils/time.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace gomea{ 10 | typedef std::chrono::time_point time_t; 11 | //typedef std::chrono::high_resolution_clock::time_point time_t; 12 | namespace utils{ 13 | extern time_t start_time; 14 | 15 | void initStartTime(); 16 | void addToTimer( std::string label, time_t startTimestamp ); 17 | void clearTimers(); 18 | double getTimer(std::string label); 19 | time_t getTimestamp(); 20 | void printTimestamp( time_t timestamp ); 21 | long long getElapsedTimeMicroseconds(time_t startTimestamp); 22 | double getElapsedTimeMilliseconds(time_t startTimestamp); 23 | double getElapsedTimeSeconds(time_t startTimestamp); 24 | double getElapsedTimeSinceStartMilliseconds(); 25 | double getElapsedTimeSinceStartSeconds(); 26 | double getElapsedTimeSinceStartSeconds(time_t startTimestamp); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gomea/src/utils/tools.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "gomea/src/common/gomea_defs.hpp" 6 | 7 | namespace gomea{ 8 | namespace utils{ 9 | 10 | class terminationException : public std::runtime_error 11 | { 12 | public: 13 | terminationException(std::string message_) : std::runtime_error(message_) {} 14 | }; 15 | 16 | double **matrixMatrixMultiplication( double **matrix0, double **matrix1, int n0, int n1, int n2 ); 17 | double *matrixVectorMultiplication( double **matrix, double *vector, int n0, int n1 ); 18 | double vectorDotProduct( double *vector0, double *vector1, int n0 ); 19 | 20 | vec_t getSortedOrder( vec_t &data ); 21 | 22 | bool isPowerOfK(int n, int k); 23 | 24 | double distanceEuclidean( double *solution_a, double *solution_b, int n ); 25 | double distanceEuclidean( vec_t &x, vec_t &y ); 26 | double distanceEuclidean2D( double x1, double y1, double x2, double y2 ); 27 | 28 | vec_t randomPermutation( int size ); 29 | double randomRealUniform01(); 30 | int randomInt( int max ); 31 | 32 | void initializeRandomNumberGenerator(); 33 | void initializeRandomNumberGenerator( long long seed ); 34 | 35 | std::string toLower(std::string _str); 36 | std::string toUpper(std::string _str); 37 | 38 | extern std::mt19937 rng; 39 | extern long long random_seed; 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | build-backend = 'mesonpy' 3 | requires = ['meson-python', 'numpy>=2.0.1', 'Cython>=3.0'] 4 | 5 | [project] 6 | name = 'gomea' 7 | version = '1.1.0' 8 | description = 'Library for the use of various variants of the Gene-pool Optimal Mixing Evolutionary Algorithm (GOMEA).' 9 | readme = 'README.md' 10 | requires-python = '>=3.9' 11 | license = {file = 'LICENSE'} 12 | authors = [ 13 | {name = 'Anton Bouter', email = 'Anton.Bouter@cwi.nl'}, 14 | ] 15 | url = 'https://github.com/abouter/gomea' 16 | dependencies = ['numpy>=1.23.0','tqdm>=4.65.0'] 17 | 18 | [tool.cibuildwheel.linux] 19 | build = ["cp39-*manylinux*", "cp310-*manylinux*", "cp311-*manylinux*", "cp312-*manylinux*", "cp313-*manylinux*"] 20 | archs = ["auto64"] 21 | 22 | [tool.cibuildwheel.macos] 23 | build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*"] 24 | archs = ["auto64"] 25 | 26 | [tool.cibuildwheel.windows] 27 | build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*"] 28 | archs = ["auto64"] 29 | --------------------------------------------------------------------------------