From eeb6ff8b21f67ebedf0e05cfb98f0825a8dad1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Mon, 18 Aug 2025 20:00:53 +0200 Subject: [PATCH 1/8] Dingo SB implementation --- .python-version | 1 + dingo/bindings/bindings.cpp | 4 ++++ dingo/bindings/bindings.h | 1 + dingo/volestipy.pyx | 2 +- eigen | 2 +- tests/shake_and_bake_test.py | 39 ++++++++++++++++++++++++++++++++++++ volesti | 2 +- 7 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .python-version create mode 100644 tests/shake_and_bake_test.py diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..143c2f5 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.8.19 diff --git a/dingo/bindings/bindings.cpp b/dingo/bindings/bindings.cpp index 0e3a62f..a45975e 100644 --- a/dingo/bindings/bindings.cpp +++ b/dingo/bindings/bindings.cpp @@ -134,6 +134,10 @@ double HPolytopeCPP::apply_sampling(int walk_len, } else if (strcmp(method, "vaidya_walk")) { // vaidya walk uniform_sampling(rand_points, HP, rng, walk_len, number_of_points, starting_point, number_of_points_to_burn); + } else if (strcmp(method, "shake_and_bake_walk") == 0) { // shake and bake walk + auto [boundary_pt, facet_idx] = compute_boundary_point(HP, rng, static_cast(1e-4)); + shakeandbake_sampling(rand_points,HP, rng, walk_len,number_of_points, + boundary_pt,number_of_points_to_burn, facet_idx); } else if (strcmp(method, "mmcs")) { // vaidya walk MT S; int total_ess; diff --git a/dingo/bindings/bindings.h b/dingo/bindings/bindings.h index 553ea99..43f38d9 100644 --- a/dingo/bindings/bindings.h +++ b/dingo/bindings/bindings.h @@ -34,6 +34,7 @@ #include #include "sampling/sampling.hpp" #include "ode_solvers/ode_solvers.hpp" +#include "preprocess/feasible_point.hpp" // for rounding #include "preprocess/min_sampling_covering_ellipsoid_rounding.hpp" diff --git a/dingo/volestipy.pyx b/dingo/volestipy.pyx index 6e8d3a9..9c64d00 100644 --- a/dingo/volestipy.pyx +++ b/dingo/volestipy.pyx @@ -85,7 +85,7 @@ cdef extern from "bindings.h": # Lists with the methods supported by volesti for volume approximation and random walk volume_methods = ["sequence_of_balls".encode("UTF-8"), "cooling_gaussian".encode("UTF-8"), "cooling_balls".encode("UTF-8")] walk_methods = ["uniform_ball".encode("UTF-8"), "CDHR".encode("UTF-8"), "RDHR".encode("UTF-8"), "gaussian_ball".encode("UTF-8"), \ - "gaussian_CDHR".encode("UTF-8"), "gaussian_RDHR".encode("UTF-8"), "uniform_ball".encode("UTF-8"), "billiard".encode("UTF-8")] + "gaussian_CDHR".encode("UTF-8"), "gaussian_RDHR".encode("UTF-8"), "uniform_ball".encode("UTF-8"), "billiard".encode("UTF-8"),"shake_and_bake".encode("UTF-8") ] rounding_methods = ["min_ellipsoid".encode("UTF-8"), "svd".encode("UTF-8"), "max_ellipsoid".encode("UTF-8")] # Build the HPolytope class diff --git a/eigen b/eigen index 02f4200..5e8edd2 160000 --- a/eigen +++ b/eigen @@ -1 +1 @@ -Subproject commit 02f420012a169ed9267a8a78083aaa588e713353 +Subproject commit 5e8edd21863b8321fc6b9c82322e6cc8cfc47c14 diff --git a/tests/shake_and_bake_test.py b/tests/shake_and_bake_test.py new file mode 100644 index 0000000..5fc7251 --- /dev/null +++ b/tests/shake_and_bake_test.py @@ -0,0 +1,39 @@ +import numpy as np +from dingo import PolytopeSampler + +# Definišemo kocku [-1,1]^3: +A = np.array([ + [ 1, 0, 0], + [-1, 0, 0], + [ 0, 1, 0], + [ 0,-1, 0], + [ 0, 0, 1], + [ 0, 0,-1] +], dtype=float) +b = np.array([1, 1, 1, 1, 1, 1], dtype=float) + +# Napravi sampler direktno iz (A, b) + +# Generiši uzorke (na primer billiard_walk) +samples = PolytopeSampler.sample_from_polytope_no_multiphase( + A, b, method = 'cdhr', n=1000, burn_in=100, thinning=1, variance=1.0, bias_vector=None, solver=None, ess=0 + ) + +print("Oblik matrice uzoraka:", samples.shape) +print("Min po osi:", samples.min(axis=1)) +print("Max po osi:", samples.max(axis=1)) + +# Ako hoćeš plot +try: + import matplotlib.pyplot as plt + from mpl_toolkits.mplot3d import Axes3D # noqa: F401 + fig = plt.figure() + ax = fig.add_subplot(111, projection="3d") + ax.scatter(samples[0,:], samples[1,:], samples[2,:], s=4, alpha=0.3) + ax.set_xlabel("x") + ax.set_ylabel("y") + ax.set_zlabel("z") + ax.set_title("Samples iz [-1,1]^3 kocke") + plt.show() +except ImportError: + pass diff --git a/volesti b/volesti index c3109bb..a33e5f4 160000 --- a/volesti +++ b/volesti @@ -1 +1 @@ -Subproject commit c3109bba06a9b623446bdde4c5fadb02722de876 +Subproject commit a33e5f450a8badb506384d7a619344dca855fe75 From 3b47c5ef31775eb198665a8aab2eb4d88896245d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Mon, 18 Aug 2025 20:01:45 +0200 Subject: [PATCH 2/8] Ignore virtual environment folder --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 23c482e..d8e930b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ volestipy.egg-info venv lp_solve_5.5/ .devcontainer/ -.github/dependabot.yml \ No newline at end of file +.github/dependabot.yml.venv/ From 7c4f4ddd16ec50fd25ee01ed34a7b9a5ab301d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Mon, 18 Aug 2025 20:02:54 +0200 Subject: [PATCH 3/8] Added .venv in gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d8e930b..cf0beec 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ venv lp_solve_5.5/ .devcontainer/ .github/dependabot.yml.venv/ +.venv/ From 1712a7a2c6d7f4d4d12d7c0af0883e70f18ee665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Sat, 23 Aug 2025 16:08:43 +0200 Subject: [PATCH 4/8] First version --- dingo/PolytopeSampler.py | 16 ++++++++-------- dingo/bindings/bindings.cpp | 8 ++++++-- dingo/volestipy.pyx | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/dingo/PolytopeSampler.py b/dingo/PolytopeSampler.py index 27f3785..1d5b21b 100644 --- a/dingo/PolytopeSampler.py +++ b/dingo/PolytopeSampler.py @@ -53,12 +53,12 @@ def get_polytope(self): """ if ( - self._A == [] - or self._b == [] - or self._N == [] - or self._N_shift == [] - or self._T == [] - or self._T_shift == [] + self._A is None + or self._b is None + or self._N is None + or self._N_shift is None + or self._T is None + or self._T_shift is None ): ( @@ -166,7 +166,7 @@ def generate_steady_states_no_multiphase( """A member function to sample steady states. Keyword arguments: - method -- An MCMC method to sample, i.e. {'billiard_walk', 'cdhr', 'rdhr', 'ball_walk', 'dikin_walk', 'john_walk', 'vaidya_walk', 'gaussian_hmc_walk', 'exponential_hmc_walk', 'hmc_leapfrog_gaussian', 'hmc_leapfrog_exponential'} + method -- An MCMC method to sample, i.e. {'billiard_walk', 'cdhr', 'rdhr', 'ball_walk', 'dikin_walk', 'john_walk', 'vaidya_walk', 'gaussian_hmc_walk', 'exponential_hmc_walk', 'hmc_leapfrog_gaussian', 'hmc_leapfrog_exponential', 'shake_and_bake', 'billiard_shake_and_bake'} n -- the number of steady states to sample burn_in -- the number of points to burn before sampling thinning -- the walk length of the chain @@ -223,7 +223,7 @@ def sample_from_polytope_no_multiphase( Keyword arguments: A -- an mxn matrix that contains the normal vectors of the facets of the polytope row-wise b -- a m-dimensional vector, s.t. A*x <= b - method -- An MCMC method to sample, i.e. {'billiard_walk', 'cdhr', 'rdhr', 'ball_walk', 'dikin_walk', 'john_walk', 'vaidya_walk', 'gaussian_hmc_walk', 'exponential_hmc_walk', 'hmc_leapfrog_gaussian', 'hmc_leapfrog_exponential'} + method -- An MCMC method to sample, i.e. {'billiard_walk', 'cdhr', 'rdhr', 'ball_walk', 'dikin_walk', 'john_walk', 'vaidya_walk', 'gaussian_hmc_walk', 'exponential_hmc_walk', 'hmc_leapfrog_gaussian', 'hmc_leapfrog_exponential', 'shake_and_bake', 'billiard_shake_and_bake'} n -- the number of steady states to sample burn_in -- the number of points to burn before sampling thinning -- the walk length of the chain diff --git a/dingo/bindings/bindings.cpp b/dingo/bindings/bindings.cpp index a45975e..072b655 100644 --- a/dingo/bindings/bindings.cpp +++ b/dingo/bindings/bindings.cpp @@ -134,10 +134,14 @@ double HPolytopeCPP::apply_sampling(int walk_len, } else if (strcmp(method, "vaidya_walk")) { // vaidya walk uniform_sampling(rand_points, HP, rng, walk_len, number_of_points, starting_point, number_of_points_to_burn); - } else if (strcmp(method, "shake_and_bake_walk") == 0) { // shake and bake walk - auto [boundary_pt, facet_idx] = compute_boundary_point(HP, rng, static_cast(1e-4)); + } else if (strcmp(method, "shake_and_bake") == 0) { // shake and bake walk + auto [boundary_pt, facet_idx] = compute_boundary_point(HP, rng, static_cast(1e-10)); shakeandbake_sampling(rand_points,HP, rng, walk_len,number_of_points, boundary_pt,number_of_points_to_burn, facet_idx); + } else if (strcmp(method, "billiard_shake_and_bake") == 0) { // billiard shake and bake walk + auto [boundary_pt, facet_idx] = compute_boundary_point(HP, rng, static_cast(1e-10)); + billiard_shakeandbake_sampling(randPoints, P, rng, walkL,nreflections, numpoints, + StartingPoint, nburns, facet_index); } else if (strcmp(method, "mmcs")) { // vaidya walk MT S; int total_ess; diff --git a/dingo/volestipy.pyx b/dingo/volestipy.pyx index 9c64d00..0274195 100644 --- a/dingo/volestipy.pyx +++ b/dingo/volestipy.pyx @@ -85,7 +85,7 @@ cdef extern from "bindings.h": # Lists with the methods supported by volesti for volume approximation and random walk volume_methods = ["sequence_of_balls".encode("UTF-8"), "cooling_gaussian".encode("UTF-8"), "cooling_balls".encode("UTF-8")] walk_methods = ["uniform_ball".encode("UTF-8"), "CDHR".encode("UTF-8"), "RDHR".encode("UTF-8"), "gaussian_ball".encode("UTF-8"), \ - "gaussian_CDHR".encode("UTF-8"), "gaussian_RDHR".encode("UTF-8"), "uniform_ball".encode("UTF-8"), "billiard".encode("UTF-8"),"shake_and_bake".encode("UTF-8") ] + "gaussian_CDHR".encode("UTF-8"), "gaussian_RDHR".encode("UTF-8"), "uniform_ball".encode("UTF-8"), "billiard".encode("UTF-8"),"shake_and_bake".encode("UTF-8"),"billiard_shake_and_bake".encode("UTF-8") ] rounding_methods = ["min_ellipsoid".encode("UTF-8"), "svd".encode("UTF-8"), "max_ellipsoid".encode("UTF-8")] # Build the HPolytope class From aaa228bbb14e11dd535fa512e10d90c29857af19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Sat, 23 Aug 2025 16:20:12 +0200 Subject: [PATCH 5/8] Remove tests/shake_and_bake_test.py --- tests/shake_and_bake_test.py | 39 ------------------------------------ 1 file changed, 39 deletions(-) delete mode 100644 tests/shake_and_bake_test.py diff --git a/tests/shake_and_bake_test.py b/tests/shake_and_bake_test.py deleted file mode 100644 index 5fc7251..0000000 --- a/tests/shake_and_bake_test.py +++ /dev/null @@ -1,39 +0,0 @@ -import numpy as np -from dingo import PolytopeSampler - -# Definišemo kocku [-1,1]^3: -A = np.array([ - [ 1, 0, 0], - [-1, 0, 0], - [ 0, 1, 0], - [ 0,-1, 0], - [ 0, 0, 1], - [ 0, 0,-1] -], dtype=float) -b = np.array([1, 1, 1, 1, 1, 1], dtype=float) - -# Napravi sampler direktno iz (A, b) - -# Generiši uzorke (na primer billiard_walk) -samples = PolytopeSampler.sample_from_polytope_no_multiphase( - A, b, method = 'cdhr', n=1000, burn_in=100, thinning=1, variance=1.0, bias_vector=None, solver=None, ess=0 - ) - -print("Oblik matrice uzoraka:", samples.shape) -print("Min po osi:", samples.min(axis=1)) -print("Max po osi:", samples.max(axis=1)) - -# Ako hoćeš plot -try: - import matplotlib.pyplot as plt - from mpl_toolkits.mplot3d import Axes3D # noqa: F401 - fig = plt.figure() - ax = fig.add_subplot(111, projection="3d") - ax.scatter(samples[0,:], samples[1,:], samples[2,:], s=4, alpha=0.3) - ax.set_xlabel("x") - ax.set_ylabel("y") - ax.set_zlabel("z") - ax.set_title("Samples iz [-1,1]^3 kocke") - plt.show() -except ImportError: - pass From d881edab145d02e2f54185a1f458837ccdc9cdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Sat, 23 Aug 2025 17:18:53 +0200 Subject: [PATCH 6/8] Small fix --- .gitignore | 1 - dingo/PolytopeSampler.py | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index cf0beec..d8e930b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,3 @@ venv lp_solve_5.5/ .devcontainer/ .github/dependabot.yml.venv/ -.venv/ diff --git a/dingo/PolytopeSampler.py b/dingo/PolytopeSampler.py index 1d5b21b..012355f 100644 --- a/dingo/PolytopeSampler.py +++ b/dingo/PolytopeSampler.py @@ -53,12 +53,12 @@ def get_polytope(self): """ if ( - self._A is None - or self._b is None - or self._N is None - or self._N_shift is None - or self._T is None - or self._T_shift is None + self._A == [] + or self._b == [] + or self._N == [] + or self._N_shift == [] + or self._T == [] + or self._T_shift == [] ): ( From 6ea096d054c953474f4a1bfe870a4966a6e4653c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Sat, 23 Aug 2025 17:27:45 +0200 Subject: [PATCH 7/8] . --- pyproject.toml | 2 +- setup.py | 91 +++++++++++++++++++++----------------------------- 2 files changed, 39 insertions(+), 54 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d0cdf08..ca7f473 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,5 +23,5 @@ networkx = "3.1" [tool.poetry.dev-dependencies] [build-system] -requires = ["poetry-core>=1.0.0", "cython", "numpy==1.20.1"] +requires = ["poetry-core>=1.0.0", "setuptools", "wheel", "cython", "numpy==1.20.1"] build-backend = "poetry.core.masonry.api" diff --git a/setup.py b/setup.py index 77ec7ec..77bb0e3 100755 --- a/setup.py +++ b/setup.py @@ -6,38 +6,29 @@ # Licensed under GNU LGPL.3, see LICENCE file -# This is the setup Python script for building the dingo library - -from distutils.core import setup -from distutils.core import Extension +from setuptools import setup, Extension from Cython.Build import cythonize from os.path import join import numpy -import os -# information about the dingo library version = "0.1.0" -license = ("LGPL3",) packages = ["dingo"] description = "A python library for metabolic networks sampling and analysis" author = "Apostolos Chalkis" author_email = "tolis.chal@gmail.com" name = "dingo" - source_directory_list = ["dingo", join("dingo", "bindings")] compiler_args = ["-std=c++17", "-O3", "-DBOOST_NO_AUTO_PTR", "-ldl", "-lm", "-fopenmp"] -lp_solve_compiler_args = ["-DYY_NEVER_INTERACTIVE", "-DLoadInverseLib=0", "-DLoadLanguageLib=0", -"-DRoleIsExternalInvEngine", "-DINVERSE_ACTIVE=3", "-DLoadableBlasLib=0"] - +lp_solve_compiler_args = [ + "-DYY_NEVER_INTERACTIVE", "-DLoadInverseLib=0", "-DLoadLanguageLib=0", + "-DRoleIsExternalInvEngine", "-DINVERSE_ACTIVE=3", "-DLoadableBlasLib=0" +] link_args = ["-O3", "-fopenmp"] extra_volesti_include_dirs = [ - # include binding files join("dingo", "bindings"), - # the volesti code uses some external classes. - # external directories we need to add join("eigen"), join("boost_1_76_0"), join("boost_1_76_0", "boost"), @@ -49,7 +40,6 @@ join("lp_solve_5.5", "shared"), join("volesti", "external"), join("volesti", "external", "minimum_ellipsoid"), - # include and add the directories on the "include" directory join("volesti", "include"), join("volesti", "include", "convex_bodies"), join("volesti", "include", "random_walks"), @@ -58,50 +48,45 @@ join("volesti", "include", "cartesian_geom"), ] -src_files = ["lp_solve_5.5/bfp/bfp_LUSOL/lp_LUSOL.c" - , "lp_solve_5.5/bfp/bfp_LUSOL/LUSOL/lusol.c" - , "lp_solve_5.5/colamd/colamd.c" - , "lp_solve_5.5/ini.c" - , "lp_solve_5.5/shared/commonlib.c" - , "lp_solve_5.5/shared/mmio.c" - , "lp_solve_5.5/shared/myblas.c" - , "lp_solve_5.5/lp_crash.c" - , "lp_solve_5.5/lp_Hash.c" - , "lp_solve_5.5/lp_lib.c" - , "lp_solve_5.5/lp_matrix.c" - , "lp_solve_5.5/lp_MDO.c" - , "lp_solve_5.5/lp_mipbb.c" - , "lp_solve_5.5/lp_MPS.c" - , "lp_solve_5.5/lp_params.c" - , "lp_solve_5.5/lp_presolve.c" - , "lp_solve_5.5/lp_price.c" - , "lp_solve_5.5/lp_pricePSE.c" - , "lp_solve_5.5/lp_report.c" - , "lp_solve_5.5/lp_scale.c" - , "lp_solve_5.5/lp_simplex.c" - , "lp_solve_5.5/lp_SOS.c" - , "lp_solve_5.5/lp_utils.c" - , "lp_solve_5.5/lp_wlp.c" - , "dingo/volestipy.pyx" - , "dingo/bindings/bindings.cpp"] +src_files = [ + "lp_solve_5.5/bfp/bfp_LUSOL/lp_LUSOL.c", + "lp_solve_5.5/bfp/bfp_LUSOL/LUSOL/lusol.c", + "lp_solve_5.5/colamd/colamd.c", + "lp_solve_5.5/ini.c", + "lp_solve_5.5/shared/commonlib.c", + "lp_solve_5.5/shared/mmio.c", + "lp_solve_5.5/shared/myblas.c", + "lp_solve_5.5/lp_crash.c", + "lp_solve_5.5/lp_Hash.c", + "lp_solve_5.5/lp_lib.c", + "lp_solve_5.5/lp_matrix.c", + "lp_solve_5.5/lp_MDO.c", + "lp_solve_5.5/lp_mipbb.c", + "lp_solve_5.5/lp_MPS.c", + "lp_solve_5.5/lp_params.c", + "lp_solve_5.5/lp_presolve.c", + "lp_solve_5.5/lp_price.c", + "lp_solve_5.5/lp_pricePSE.c", + "lp_solve_5.5/lp_report.c", + "lp_solve_5.5/lp_scale.c", + "lp_solve_5.5/lp_simplex.c", + "lp_solve_5.5/lp_SOS.c", + "lp_solve_5.5/lp_utils.c", + "lp_solve_5.5/lp_wlp.c", + "dingo/volestipy.pyx", + "dingo/bindings/bindings.cpp", +] -# Return the directory that contains the NumPy *.h header files. -# Extension modules that need to compile against NumPy should use this -# function to locate the appropriate include directory. extra_include_dirs = [numpy.get_include()] ext_module = Extension( - "volestipy", + "dingo.volestipy", # Use package-relative name language="c++", sources=src_files, include_dirs=extra_include_dirs + extra_volesti_include_dirs, extra_compile_args=compiler_args + lp_solve_compiler_args, extra_link_args=link_args, ) -print("The Extension function is OK.") - -ext_modules = cythonize([ext_module], gdb_debug=False) -print("The cythonize function ran fine!") setup( version=version, @@ -109,7 +94,7 @@ author_email=author_email, name=name, packages=packages, - ext_modules=ext_modules, -) - -print("Installation of dingo completed.") + ext_modules=cythonize([ext_module], gdb_debug=False), + description=description, + install_requires=["numpy", "cython"], +) \ No newline at end of file From aec145148100ea652360ad5857650a87bc12d16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iva=20Jankovi=C4=87?= Date: Sat, 23 Aug 2025 17:43:49 +0200 Subject: [PATCH 8/8] Revert pyproject.toml & setup.py to upstream/develop versions --- pyproject.toml | 2 +- setup.py | 91 +++++++++++++++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ca7f473..d0cdf08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,5 +23,5 @@ networkx = "3.1" [tool.poetry.dev-dependencies] [build-system] -requires = ["poetry-core>=1.0.0", "setuptools", "wheel", "cython", "numpy==1.20.1"] +requires = ["poetry-core>=1.0.0", "cython", "numpy==1.20.1"] build-backend = "poetry.core.masonry.api" diff --git a/setup.py b/setup.py index 77bb0e3..77ec7ec 100755 --- a/setup.py +++ b/setup.py @@ -6,29 +6,38 @@ # Licensed under GNU LGPL.3, see LICENCE file -from setuptools import setup, Extension +# This is the setup Python script for building the dingo library + +from distutils.core import setup +from distutils.core import Extension from Cython.Build import cythonize from os.path import join import numpy +import os +# information about the dingo library version = "0.1.0" +license = ("LGPL3",) packages = ["dingo"] description = "A python library for metabolic networks sampling and analysis" author = "Apostolos Chalkis" author_email = "tolis.chal@gmail.com" name = "dingo" + source_directory_list = ["dingo", join("dingo", "bindings")] compiler_args = ["-std=c++17", "-O3", "-DBOOST_NO_AUTO_PTR", "-ldl", "-lm", "-fopenmp"] -lp_solve_compiler_args = [ - "-DYY_NEVER_INTERACTIVE", "-DLoadInverseLib=0", "-DLoadLanguageLib=0", - "-DRoleIsExternalInvEngine", "-DINVERSE_ACTIVE=3", "-DLoadableBlasLib=0" -] +lp_solve_compiler_args = ["-DYY_NEVER_INTERACTIVE", "-DLoadInverseLib=0", "-DLoadLanguageLib=0", +"-DRoleIsExternalInvEngine", "-DINVERSE_ACTIVE=3", "-DLoadableBlasLib=0"] + link_args = ["-O3", "-fopenmp"] extra_volesti_include_dirs = [ + # include binding files join("dingo", "bindings"), + # the volesti code uses some external classes. + # external directories we need to add join("eigen"), join("boost_1_76_0"), join("boost_1_76_0", "boost"), @@ -40,6 +49,7 @@ join("lp_solve_5.5", "shared"), join("volesti", "external"), join("volesti", "external", "minimum_ellipsoid"), + # include and add the directories on the "include" directory join("volesti", "include"), join("volesti", "include", "convex_bodies"), join("volesti", "include", "random_walks"), @@ -48,45 +58,50 @@ join("volesti", "include", "cartesian_geom"), ] -src_files = [ - "lp_solve_5.5/bfp/bfp_LUSOL/lp_LUSOL.c", - "lp_solve_5.5/bfp/bfp_LUSOL/LUSOL/lusol.c", - "lp_solve_5.5/colamd/colamd.c", - "lp_solve_5.5/ini.c", - "lp_solve_5.5/shared/commonlib.c", - "lp_solve_5.5/shared/mmio.c", - "lp_solve_5.5/shared/myblas.c", - "lp_solve_5.5/lp_crash.c", - "lp_solve_5.5/lp_Hash.c", - "lp_solve_5.5/lp_lib.c", - "lp_solve_5.5/lp_matrix.c", - "lp_solve_5.5/lp_MDO.c", - "lp_solve_5.5/lp_mipbb.c", - "lp_solve_5.5/lp_MPS.c", - "lp_solve_5.5/lp_params.c", - "lp_solve_5.5/lp_presolve.c", - "lp_solve_5.5/lp_price.c", - "lp_solve_5.5/lp_pricePSE.c", - "lp_solve_5.5/lp_report.c", - "lp_solve_5.5/lp_scale.c", - "lp_solve_5.5/lp_simplex.c", - "lp_solve_5.5/lp_SOS.c", - "lp_solve_5.5/lp_utils.c", - "lp_solve_5.5/lp_wlp.c", - "dingo/volestipy.pyx", - "dingo/bindings/bindings.cpp", -] +src_files = ["lp_solve_5.5/bfp/bfp_LUSOL/lp_LUSOL.c" + , "lp_solve_5.5/bfp/bfp_LUSOL/LUSOL/lusol.c" + , "lp_solve_5.5/colamd/colamd.c" + , "lp_solve_5.5/ini.c" + , "lp_solve_5.5/shared/commonlib.c" + , "lp_solve_5.5/shared/mmio.c" + , "lp_solve_5.5/shared/myblas.c" + , "lp_solve_5.5/lp_crash.c" + , "lp_solve_5.5/lp_Hash.c" + , "lp_solve_5.5/lp_lib.c" + , "lp_solve_5.5/lp_matrix.c" + , "lp_solve_5.5/lp_MDO.c" + , "lp_solve_5.5/lp_mipbb.c" + , "lp_solve_5.5/lp_MPS.c" + , "lp_solve_5.5/lp_params.c" + , "lp_solve_5.5/lp_presolve.c" + , "lp_solve_5.5/lp_price.c" + , "lp_solve_5.5/lp_pricePSE.c" + , "lp_solve_5.5/lp_report.c" + , "lp_solve_5.5/lp_scale.c" + , "lp_solve_5.5/lp_simplex.c" + , "lp_solve_5.5/lp_SOS.c" + , "lp_solve_5.5/lp_utils.c" + , "lp_solve_5.5/lp_wlp.c" + , "dingo/volestipy.pyx" + , "dingo/bindings/bindings.cpp"] +# Return the directory that contains the NumPy *.h header files. +# Extension modules that need to compile against NumPy should use this +# function to locate the appropriate include directory. extra_include_dirs = [numpy.get_include()] ext_module = Extension( - "dingo.volestipy", # Use package-relative name + "volestipy", language="c++", sources=src_files, include_dirs=extra_include_dirs + extra_volesti_include_dirs, extra_compile_args=compiler_args + lp_solve_compiler_args, extra_link_args=link_args, ) +print("The Extension function is OK.") + +ext_modules = cythonize([ext_module], gdb_debug=False) +print("The cythonize function ran fine!") setup( version=version, @@ -94,7 +109,7 @@ author_email=author_email, name=name, packages=packages, - ext_modules=cythonize([ext_module], gdb_debug=False), - description=description, - install_requires=["numpy", "cython"], -) \ No newline at end of file + ext_modules=ext_modules, +) + +print("Installation of dingo completed.")