diff options
Diffstat (limited to 'gnu/packages/maths.scm')
-rw-r--r-- | gnu/packages/maths.scm | 280 |
1 files changed, 230 insertions, 50 deletions
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm index e7f82341e8..90996a1f6d 100644 --- a/gnu/packages/maths.scm +++ b/gnu/packages/maths.scm @@ -47,6 +47,7 @@ ;;; Copyright © 2021 Philip McGrath <philip@philipmcgrath.com> ;;; Copyright © 2021 Paul A. Patience <paul@apatience.com> ;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru> +;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me> ;;; ;;; This file is part of GNU Guix. ;;; @@ -1800,6 +1801,154 @@ large-scale nonlinear optimization. It provides C++, C, and Fortran interfaces.") (license license:epl2.0))) +(define-public nomad-optimizer + (package + (name "nomad-optimizer") + (version "4.1.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/bbopt/nomad/") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0w386d8r5ldbvnv0c0g7vz95pfpvwdxis26vaalk2amsa5akl775")))) + (build-system cmake-build-system) + (native-inputs + `(("python" ,python-wrapper) + ("python-cython" ,python-cython))) + (arguments + `(#:imported-modules ((guix build python-build-system) + ,@%cmake-build-system-modules) + #:modules (((guix build python-build-system) + #:select (python-version site-packages)) + (guix build cmake-build-system) + (guix build utils)) + #:configure-flags + '("-DBUILD_INTERFACES=ON" + "-DBUILD_TESTS=ON") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'fix-sources-for-build + (lambda* (#:key outputs #:allow-other-keys) + (substitute* "CMakeLists.txt" + ;; CMAKE_INSTALL_PREFIX is accidentally hardcoded. + (("set\\(CMAKE_INSTALL_PREFIX .* FORCE\\)") "") + ;; Requiring GCC version 8 or later is unwarranted. + (("message\\(FATAL_ERROR \"GCC version < 8") + "message(STATUS \"GCC version < 8")) + + (let ((out (assoc-ref outputs "out"))) + (substitute* "interfaces/PyNomad/CMakeLists.txt" + ;; We don't want to build in-place, and anyway the install + ;; command further below runs build_ext as a prerequisite. + (("COMMAND python setup_PyNomad\\.py .* build_ext --inplace\n") + "") + ;; Don't install locally. + (("COMMAND python (setup_PyNomad\\.py .* install) --user\n" + _ args) + (string-append "COMMAND ${CMAKE_COMMAND} -E env" + " CC=" ,(cc-for-target) + " CXX=" ,(cxx-for-target) + " " (which "python") + " " args + " --prefix=" out + "\n"))) + ;; Fix erroneous assumptions about the paths of the include and + ;; library directories. + (substitute* "interfaces/PyNomad/setup_PyNomad.py" + (("^( +os_include_dirs = ).*" _ prefix) + (string-append prefix "[\"../../src\"]\n")) + (("^(installed_lib_dir = ).*" _ prefix) + (string-append prefix "\"" out "/lib\"\n")))) + #t)) + + ;; Fix the tests so they run in out-of-source builds. + (add-after 'fix-sources-for-build 'fix-sources-for-tests + (lambda _ + (substitute* + (map (lambda (d) (string-append "examples/" d "/CMakeLists.txt")) + (append + (map (lambda (d) (string-append "basic/library/" d)) + '("example1" "example2" "example3" + "single_obj_parallel")) + (map (lambda (d) (string-append "advanced/library/" d)) + '("FixedVariable" "NMonly" "PSDMads" "Restart" + "c_api/example1" "c_api/example2" + "exampleSuggestAndObserve")))) + ;; The built examples are assumed to be in the source tree + ;; (which isn't the case here). + (("(COMMAND \\$\\{CMAKE_BINARY_DIR\\}/examples/runExampleTest\\.sh )\\.(/.*)" + _ command test) + (string-append command "${CMAKE_CURRENT_BINARY_DIR}" test))) + ;; (Unrelated to support for out-of-source testing.) + (make-file-writable + "examples/advanced/library/exampleSuggestAndObserve/cache0.txt") + + (let* ((builddir (string-append (getcwd) "/../build")) + ;; The BB_EXE and SURROGATE_EXE paths are interpreted + ;; relative to the configuration file provided to NOMAD. + ;; However, the configuration files are all in the source + ;; tree rather than in the build tree (unlike the compiled + ;; executables). + (fix-exe-path (lambda* (dir #:optional + (file "param.txt") + (exe-opt "BB_EXE")) + (substitute* (string-append dir "/" file) + (((string-append "^" exe-opt " +")) + ;; The $ prevents NOMAD from prefixing + ;; the executable with the path of the + ;; parent directory of the configuration + ;; file NOMAD was provided with as + ;; argument (param.txt or some such). + (string-append exe-opt " $" + builddir "/" dir "/")))))) + (for-each + (lambda (dir) + (let ((dir (string-append "examples/" dir))) + (substitute* (string-append dir "/CMakeLists.txt") + ;; The install phase has not yet run. + (("COMMAND \\$\\{CMAKE_INSTALL_PREFIX\\}/bin/nomad ") + "COMMAND ${CMAKE_BINARY_DIR}/src/nomad ")) + (fix-exe-path dir) + (when (equal? dir "examples/basic/batch/surrogate_sort") + (fix-exe-path dir "param.txt" "SURROGATE_EXE")))) + (append (map (lambda (d) (string-append "basic/batch/" d)) + '("example1" "example2" + "single_obj" "single_obj_parallel" + "surrogate_sort")) + '("advanced/batch/LHonly"))) + + (let ((dir "examples/advanced/batch/FixedVariable")) + (substitute* (string-append dir "/runFixed.sh") + ;; Hardcoded path to NOMAD executable. + (("^\\.\\./\\.\\./\\.\\./\\.\\./bin/nomad ") + (string-append builddir "/src/nomad "))) + (for-each + (lambda (f) (fix-exe-path dir f)) + '("param1.txt" "param2.txt" "param3.txt" "param10.txt")))) + #t)) + + ;; The information in the .egg-info file is not kept up to date. + (add-after 'install 'delete-superfluous-egg-info + (lambda* (#:key inputs outputs #:allow-other-keys) + (delete-file (string-append + (site-packages inputs outputs) + "PyNomad-0.0.0-py" + (python-version (assoc-ref inputs "python")) + ".egg-info")) + #t))))) + (home-page "https://www.gerad.ca/nomad/") + (synopsis "Nonlinear optimization by mesh-adaptive direct search") + (description + "NOMAD is a C++ implementation of the mesh-adaptive direct search (MADS) +algorithm, designed for difficult blackbox optimization problems. These +problems occur when the functions defining the objective and constraints are +the result of costly computer simulations.") + (license license:lgpl3+))) + (define-public cbc (package (name "cbc") @@ -3553,31 +3702,32 @@ processor cores.") (synopsis "Parallel adaptive mesh refinement on forests of octrees"))) (define-public gsegrafix + ;; This is an old and equally dead "experimental fork" of the longer-dead + ;; original. At least it no longer requires the even-deader libgnomeprint{,ui} + ;; libraries, instead rendering plots with Pango. (package (name "gsegrafix") - (version "1.0.6") + (version "1.0.7.2") (source (origin - (method url-fetch) - (uri (string-append "mirror://gnu/" name "/" name "-" - version ".tar.gz")) - (sha256 - (base32 - "1b13hvx063zv970y750bx41wpx6hwd5ngjhbdrna8w8yy5kmxcda")))) + (method url-fetch) + (uri (string-append "mirror://savannah/gsegrafix-experimental/" + "gsegrafix-experimental-" version ".tar.gz")) + (sha256 + (base32 "0fwh6719xy2zasmqlp0vdx6kzm45hn37ga88xmw5cz0yx7xw4j6f")))) (build-system gnu-build-system) (arguments - `(#:configure-flags '("LDFLAGS=-lm"))) + `(#:configure-flags + (list "--disable-static"))) (inputs - `(("libgnomecanvas" ,libgnomecanvas) - ("libbonoboui" ,libbonoboui) - ("libgnomeui" ,libgnomeui) - ("libgnomeprintui" ,libgnomeprintui) - ("popt" ,popt))) + `(("glib" ,glib) + ("gtk+" ,gtk+))) (native-inputs `(("pkg-config" ,pkg-config))) (home-page "https://www.gnu.org/software/gsegrafix/") (synopsis "GNOME application to create scientific and engineering plots") - (description "GSEGrafix is an application which produces high-quality graphical + (description + "GSEGrafix is an application which produces high-quality graphical plots for science and engineering. Plots are specified via simple ASCII parameter files and data files and are presented in an anti-aliased GNOME canvas. The program supports rectangular two-dimensional plots, histograms, @@ -4033,7 +4183,7 @@ access to BLIS implementations via traditional BLAS routine calls.") (define-public openlibm (package (name "openlibm") - (version "0.6.0") + (version "0.7.4") (source (origin (method git-fetch) @@ -4042,11 +4192,12 @@ access to BLIS implementations via traditional BLAS routine calls.") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 - (base32 "08wfchmmr5200fvmn1kwq9byc1fhsq46hn0y5k8scdl74771c7gh")))) + (base32 "1azms0lpxb7vxb3bln5lyz0wpwx6jnzbffkclclpq2v5aiw8d14i")))) (build-system gnu-build-system) (arguments `(#:make-flags - (list (string-append "prefix=" (assoc-ref %outputs "out"))) + (list (string-append "prefix=" (assoc-ref %outputs "out")) + ,(string-append "CC=" (cc-for-target))) #:phases ;; no configure script (modify-phases %standard-phases (delete 'configure)) @@ -4461,40 +4612,75 @@ revised simplex and the branch-and-bound methods.") (define-public dealii (package (name "dealii") - (version "9.2.0") + (version "9.3.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/dealii/dealii/releases/" "download/v" version "/dealii-" version ".tar.gz")) (sha256 - (base32 - "0fm4xzrnb7dfn4415j24d8v3jkh0lssi86250x2f5wgi83xq4nnh")) + (base32 "1f0sqvlxvl0myqcn0q6xrn1vnp5pgx143lai4a4jkh1dmdv4cbx6")) (modules '((guix build utils))) (snippet - ;; Remove bundled sources: UMFPACK, TBB, muParser, and boost '(begin + ;; Remove bundled boost, muparser, TBB and UMFPACK. (delete-file-recursively "bundled") #t)))) (build-system cmake-build-system) + (outputs '("out" "doc")) + (native-inputs + ;; Required to build the documentation. + `(("dot" ,graphviz) + ("doxygen" ,doxygen) + ("perl" ,perl))) (inputs - `(("tbb" ,tbb) - ("zlib" ,zlib) - ("boost" ,boost) - ("p4est" ,p4est) + `(("arpack" ,arpack-ng) ("blas" ,openblas) + ("gfortran" ,gfortran) ("lapack" ,lapack) - ("arpack" ,arpack-ng) ("muparser" ,muparser) - ("gfortran" ,gfortran) - ("suitesparse" ,suitesparse))) ;for UMFPACK + ("zlib" ,zlib))) + (propagated-inputs + ;; Some scripts are installed into share/deal.II/scripts that require + ;; perl and python, but they are not executable (and some are missing the + ;; shebang line) and therefore must be explicitly passed to the + ;; interpreter. + ;; Anyway, they are meant to be used at build time, so rather than adding + ;; the interpreters here, any package depending on them should just add + ;; the requisite interpreter to its native inputs. + `(("boost" ,boost) + ("hdf5" ,hdf5) + ("suitesparse" ,suitesparse) ; For UMFPACK. + ("tbb" ,tbb))) (arguments - `(#:build-type "DebugRelease" ;only supports Release, Debug, or DebugRelease + `(#:build-type "DebugRelease" ; Supports only Debug, Release and DebugRelease. + ;; The tests take too long and must be explicitly enabled with "make + ;; setup_tests". + ;; See https://www.dealii.org/developer/developers/testsuite.html. + ;; (They can also be run for an already installed deal.II.) + #:tests? #f #:configure-flags - ;; Work around a bug in libsuitesparseconfig linking - ;; see https://github.com/dealii/dealii/issues/4745 - '("-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON"))) - (home-page "https://www.dealii.org") + (let ((doc (string-append (assoc-ref %outputs "doc") + "/share/doc/" ,name "-" ,version))) + `("-DDEAL_II_COMPONENT_DOCUMENTATION=ON" + ,(string-append "-DDEAL_II_DOCREADME_RELDIR=" doc) + ,(string-append "-DDEAL_II_DOCHTML_RELDIR=" doc "/html") + ;; Don't compile the examples because the source and CMakeLists.txt + ;; are installed anyway, allowing users to do so for themselves. + "-DDEAL_II_COMPILE_EXAMPLES=OFF" + ,(string-append "-DDEAL_II_EXAMPLES_RELDIR=" doc "/examples"))) + #:phases + (modify-phases %standard-phases + (add-after 'install 'remove-build-logs + ;; These build logs leak the name of the build directory by storing + ;; the values of CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. + (lambda* (#:key outputs #:allow-other-keys) + (let ((doc (string-append (assoc-ref outputs "doc") + "/share/doc/" ,name "-" ,version))) + (for-each delete-file (map (lambda (f) (string-append doc "/" f)) + '("detailed.log" "summary.log")))) + #t))))) + (home-page "https://www.dealii.org/") (synopsis "Finite element library") (description "Deal.II is a C++ program library targeted at the computational solution @@ -4505,30 +4691,24 @@ in finite element programs.") (license license:lgpl2.1+))) (define-public dealii-openmpi - (package (inherit dealii) + (package/inherit dealii (name "dealii-openmpi") (inputs - `(("mpi" ,openmpi) - ;;Supported only with MPI: - ("hdf5" ,hdf5-parallel-openmpi) ;TODO: have petsc-openmpi propagate? + `(("arpack" ,arpack-ng-openmpi) + ("metis" ,metis) + ("scalapack" ,scalapack) + ,@(alist-delete "arpack" (package-inputs dealii)))) + (propagated-inputs + `(("hdf5" ,hdf5-parallel-openmpi) + ("mpi" ,openmpi) ("p4est" ,p4est-openmpi) ("petsc" ,petsc-openmpi) ("slepc" ,slepc-openmpi) - ("metis" ,metis) ;for MUMPS - ("scalapack" ,scalapack) ;for MUMPS - ("mumps" ,mumps-metis-openmpi) ;configure supports only metis orderings - ("arpack" ,arpack-ng-openmpi) - ,@(fold alist-delete (package-inputs dealii) - '("p4est" "arpack")))) + ,@(alist-delete "hdf5" (package-propagated-inputs dealii)))) (arguments (substitute-keyword-arguments (package-arguments dealii) - ((#:configure-flags cf) - `(cons "-DDEAL_II_WITH_MPI:BOOL=ON" - ,cf)) - ((#:phases phases '%standard-phases) - `(modify-phases ,phases - (add-before 'check 'mpi-setup - ,%openmpi-setup))))) + ((#:configure-flags flags) + `(cons "-DDEAL_II_WITH_MPI=ON" ,flags)))) (synopsis "Finite element library (with MPI support)"))) (define-public flann |