mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-14 15:10:16 -05:00
gnu: nomad-optimizer: Update to 4.3.1.
* gnu/packages/maths.scm (nomad-optimizer): Update to 4.3.1. [native-inputs]: Remove python-wrapper and python-cython. Add openmpi. [arguments]: Use G-expressions. Remove #:imported-modules and #:modules. <#:configure-flags>: Remove -DBUILD_INTERFACE_PYTHON=ON. <#:phases>: Remove 'fix-sources-for-build' phase. Rename 'fix-sources-for-tests' phase to 'fix-tests' and update it. Add 'mpi-setup' phase. Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
parent
67dcc64110
commit
33cbb0ca8d
1 changed files with 101 additions and 156 deletions
|
@ -2421,7 +2421,7 @@ (define-public ipopt
|
||||||
(define-public nomad-optimizer
|
(define-public nomad-optimizer
|
||||||
(package
|
(package
|
||||||
(name "nomad-optimizer")
|
(name "nomad-optimizer")
|
||||||
(version "4.2.0")
|
(version "4.3.1")
|
||||||
(source
|
(source
|
||||||
(origin
|
(origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
|
@ -2430,164 +2430,109 @@ (define-public nomad-optimizer
|
||||||
(commit (string-append "v." version))))
|
(commit (string-append "v." version))))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32 "08bxdvx8p5qzdw331xa5irc1896as4q5hajsid7f3qcxjm4nq4v3"))))
|
||||||
"1r4ygy3xn83dnppsw1451ynklsxpb238g5gk57inn84ghmdk08mj"))))
|
|
||||||
(build-system cmake-build-system)
|
(build-system cmake-build-system)
|
||||||
(native-inputs
|
(native-inputs
|
||||||
(list python-wrapper python-cython))
|
(list openmpi))
|
||||||
(arguments
|
(arguments
|
||||||
`(#:imported-modules ((guix build python-build-system)
|
(list
|
||||||
,@%cmake-build-system-modules)
|
;; Cannot build Python interface because it is incompatible with OpenMP
|
||||||
#:modules (((guix build python-build-system)
|
;; support, which is enabled by default.
|
||||||
#:select (python-version site-packages))
|
#:configure-flags
|
||||||
(guix build cmake-build-system)
|
#~(list "-DBUILD_TESTS=ON"
|
||||||
(guix build utils))
|
"-DBUILD_INTERFACE_C=ON")
|
||||||
#:configure-flags
|
#:phases
|
||||||
'("-DBUILD_INTERFACE_C=ON"
|
#~(modify-phases %standard-phases
|
||||||
"-DBUILD_INTERFACE_PYTHON=ON"
|
(add-after 'unpack 'fix-tests
|
||||||
"-DBUILD_TESTS=ON")
|
(lambda _
|
||||||
#:phases
|
(substitute* "examples/CMakeLists.txt"
|
||||||
(modify-phases %standard-phases
|
;; This test passes only sometimes.
|
||||||
(add-after 'unpack 'fix-sources-for-build
|
;; See https://github.com/bbopt/nomad/issues/72.
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(("^ +add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/advanced/library/PSDMads\\)\n")
|
||||||
(substitute* "CMakeLists.txt"
|
""))
|
||||||
;; CMAKE_INSTALL_PREFIX is accidentally hardcoded.
|
(make-file-writable
|
||||||
(("set\\(CMAKE_INSTALL_PREFIX .* FORCE\\)") "")
|
"examples/advanced/library/exampleSuggestAndObserve/cache0.txt")
|
||||||
;; Requiring GCC version 8 or later is unwarranted.
|
;; Fix the tests so they run in out-of-source builds.
|
||||||
(("message\\(FATAL_ERROR \"GCC version < 8")
|
(substitute*
|
||||||
"message(STATUS \"GCC version < 8"))
|
'("examples/basic/library/COCO/CMakeLists.txt"
|
||||||
|
"examples/basic/library/example1/CMakeLists.txt"
|
||||||
(let ((out (assoc-ref outputs "out")))
|
"examples/basic/library/example2/CMakeLists.txt"
|
||||||
(substitute* "interfaces/PyNomad/CMakeLists.txt"
|
"examples/basic/library/example3/CMakeLists.txt"
|
||||||
;; We don't want to build in-place, and anyway the install
|
"examples/basic/library/example4/CMakeLists.txt"
|
||||||
;; command further below runs build_ext as a prerequisite.
|
"examples/basic/library/single_obj_parallel/CMakeLists.txt"
|
||||||
(("COMMAND python setup_PyNomad\\.py .* build_ext --inplace\n")
|
"examples/advanced/library/FixedVariable/CMakeLists.txt"
|
||||||
"")
|
"examples/advanced/library/NMonly/CMakeLists.txt"
|
||||||
;; Don't install locally.
|
"examples/advanced/library/PSDMads/CMakeLists.txt"
|
||||||
(("COMMAND python (setup_PyNomad\\.py .* install) --user\n"
|
"examples/advanced/library/Restart/CMakeLists.txt"
|
||||||
_ args)
|
"examples/advanced/library/Restart_VNS/CMakeLists.txt"
|
||||||
(string-append "COMMAND ${CMAKE_COMMAND} -E env"
|
"examples/advanced/library/c_api/example1/CMakeLists.txt"
|
||||||
" CC=" ,(cc-for-target)
|
"examples/advanced/library/c_api/example2/CMakeLists.txt"
|
||||||
" CXX=" ,(cxx-for-target)
|
"examples/advanced/library/exampleSuggestAndObserve/CMakeLists.txt")
|
||||||
" " (which "python")
|
;; The runExampleTest.sh script is run with WORKING_DIRECTORY
|
||||||
" " args
|
;; set to CMAKE_CURRENT_SOURCE_DIR.
|
||||||
" --prefix=" out
|
;; Other scripts invoked by that script (for example
|
||||||
"\n")))
|
;; examples/advanced/batch/SuggestAndObserve/loopSuggestAndObserve.sh)
|
||||||
;; Fix erroneous assumptions about the paths of the include and
|
;; are in that same directory, but compiled examples are
|
||||||
;; library directories.
|
;; located in CMAKE_CURRENT_BINARY_DIR.
|
||||||
(substitute* "interfaces/PyNomad/setup_PyNomad.py"
|
(("(COMMAND \\$\\{CMAKE_BINARY_DIR\\}/examples/runExampleTest\\.sh )\\.(/.*)"
|
||||||
(("^( +os_include_dirs = ).*" _ prefix)
|
_ command test)
|
||||||
(string-append prefix "[\"../../src\"]\n"))
|
(string-append command "${CMAKE_CURRENT_BINARY_DIR}" test)))
|
||||||
(("^(installed_lib_dir1 = ).*" _ prefix)
|
(let ((builddir (string-append (getcwd) "/../build")))
|
||||||
(string-append prefix "\"" out "/lib\"\n"))
|
(let ((dir "examples/advanced/library/FixedVariable"))
|
||||||
(("^installed_lib_dir2 = .*") "")
|
(substitute* (string-append dir "/fixedVariable.cpp")
|
||||||
(("^ +link_args\\.append\\(\"-Wl,-rpath,\" \\+ installed_lib_dir2\\)\n")
|
(("^( +std::string sExe = ).*" _ prefix)
|
||||||
"")))))
|
(string-append prefix "\"" builddir "/" dir "/ufl.exe" "\";\n"))))
|
||||||
|
;; The BB_EXE and SURROGATE_EXE paths are interpreted relative
|
||||||
;; Fix the tests so they run in out-of-source builds.
|
;; to the configuration file provided to NOMAD.
|
||||||
;;
|
;; However, the configuration files are all in the source tree
|
||||||
;; TODO: Add support for examples/basic/batch/single_obj_MPIparallel,
|
;; rather than in the build tree (unlike the compiled
|
||||||
;; by adding openmpi to native-inputs and adjusting the example's
|
;; executables).
|
||||||
;; BB_EXE parameter.
|
(let ((fix-exe-path (lambda* (dir #:optional
|
||||||
(add-after 'fix-sources-for-build 'fix-sources-for-tests
|
(file "param.txt")
|
||||||
(lambda _
|
(exe-opt "BB_EXE"))
|
||||||
(substitute* "examples/CMakeLists.txt"
|
(substitute* (string-append dir "/" file)
|
||||||
;; This test passes only sometimes.
|
(((string-append "^" exe-opt " +"))
|
||||||
;; See https://github.com/bbopt/nomad/issues/72.
|
;; The $ prevents NOMAD from prefixing
|
||||||
(("^ +add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/advanced/library/PSDMads\\)\n")
|
;; the executable with the path of the
|
||||||
"")
|
;; parent directory of the configuration
|
||||||
;; examples/basic/batch/example3 is accidentally omitted.
|
;; file NOMAD was provided with as
|
||||||
(("^(add_subdirectory\\(\\$\\{CMAKE_CURRENT_SOURCE_DIR\\}/basic/batch/example)2(\\)\n)"
|
;; argument (param.txt or some such).
|
||||||
_ prefix suffix)
|
(string-append exe-opt " $"
|
||||||
(string-append prefix "2" suffix
|
builddir "/" dir "/"))))))
|
||||||
prefix "3" suffix))
|
(for-each
|
||||||
|
(lambda (dir)
|
||||||
;; The generated runExampleTest.sh script runs the test as part
|
(substitute* (string-append dir "/CMakeLists.txt")
|
||||||
;; of a pipeline and incorrectly (because pipefail is unset)
|
;; The install phase has not yet run.
|
||||||
;; relies on the value of the exit status immediately after the
|
(("(COMMAND.*)\\$\\{CMAKE_INSTALL_PREFIX\\}/bin/nomad\\b"
|
||||||
;; pipeline.
|
_ prefix)
|
||||||
;; (The patch-shebangs phase runs later than this one, so no
|
(string-append prefix "${CMAKE_BINARY_DIR}/src/nomad")))
|
||||||
;; need to update the path to bash here.)
|
(if (equal? dir "examples/basic/batch/single_obj_MPIparallel")
|
||||||
(("#!/bin/bash") "#!/bin/bash\nset -o pipefail"))
|
(substitute* (string-append dir "/param.txt")
|
||||||
|
(("^BB_EXE +'\\$.*mpirun \\$-np \\$4 ")
|
||||||
(substitute*
|
(string-append "BB_EXE '$" (which "mpirun") " $"
|
||||||
(map (lambda (d) (string-append "examples/" d "/CMakeLists.txt"))
|
builddir "/" dir "/")))
|
||||||
(append
|
(fix-exe-path dir))
|
||||||
(map (lambda (d) (string-append "basic/library/" d))
|
(when (equal? dir "examples/basic/batch/surrogate_sort")
|
||||||
'("example1" "example2" "example3"
|
(fix-exe-path dir "param.txt" "SURROGATE_EXE"))
|
||||||
"single_obj_parallel"))
|
(when (equal? dir "examples/advanced/batch/FixedVariable")
|
||||||
(map (lambda (d) (string-append "advanced/library/" d))
|
(fix-exe-path dir "param1.txt")
|
||||||
'("FixedVariable" "NMonly" "PSDMads" "Restart"
|
(fix-exe-path dir "param2.txt")
|
||||||
"c_api/example1" "c_api/example2"
|
(fix-exe-path dir "param3.txt")
|
||||||
"exampleSuggestAndObserve"))))
|
(fix-exe-path dir "param10.txt")))
|
||||||
;; The runExampleTest.sh script is run with WORKING_DIRECTORY
|
'("examples/basic/batch/coco_bbob-constrained"
|
||||||
;; set to CMAKE_CURRENT_SOURCE_DIR.
|
"examples/basic/batch/example1"
|
||||||
;; Other scripts invoked by that script (for example
|
"examples/basic/batch/example2"
|
||||||
;; examples/advanced/batch/SuggestAndObserve/loopSuggestAndObserve.sh)
|
"examples/basic/batch/example3"
|
||||||
;; are in that same directory, but compiled examples are
|
"examples/basic/batch/multi_obj"
|
||||||
;; located in CMAKE_CURRENT_BINARY_DIR.
|
"examples/basic/batch/multi_obj2"
|
||||||
(("(COMMAND \\$\\{CMAKE_BINARY_DIR\\}/examples/runExampleTest\\.sh )\\.(/.*)"
|
"examples/basic/batch/single_obj"
|
||||||
_ command test)
|
"examples/basic/batch/single_obj_MPIparallel"
|
||||||
(string-append command "${CMAKE_CURRENT_BINARY_DIR}" test)))
|
"examples/basic/batch/single_obj_parallel"
|
||||||
|
"examples/basic/batch/surrogate_sort"
|
||||||
;; The examples/basic/batch/example3 executable is already named
|
"examples/advanced/batch/FixedVariable"
|
||||||
;; bb3.exe.
|
"examples/advanced/batch/LHonly"))))))
|
||||||
(substitute* "examples/basic/batch/single_obj_parallel/CMakeLists.txt"
|
(add-before 'configure 'mpi-setup
|
||||||
(("bb3.exe") "bb_parallel.exe"))
|
#$%openmpi-setup))))
|
||||||
|
|
||||||
;; (Unrelated to support for out-of-source testing.)
|
|
||||||
(make-file-writable
|
|
||||||
"examples/advanced/library/exampleSuggestAndObserve/cache0.txt")
|
|
||||||
|
|
||||||
(let ((builddir (string-append (getcwd) "/../build")))
|
|
||||||
(let ((dir "examples/advanced/library/FixedVariable"))
|
|
||||||
(substitute* (string-append dir "/fixedVariable.cpp")
|
|
||||||
(("^( +std::string sExe = ).*" _ prefix)
|
|
||||||
(string-append prefix "\"" builddir "/" dir "/ufl.exe" "\";\n"))))
|
|
||||||
|
|
||||||
;; 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).
|
|
||||||
(let ((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" "example3"
|
|
||||||
"single_obj"
|
|
||||||
"single_obj_parallel"
|
|
||||||
;; "single_obj_MPIparallel"
|
|
||||||
"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"))))))))))
|
|
||||||
(home-page "https://www.gerad.ca/nomad/")
|
(home-page "https://www.gerad.ca/nomad/")
|
||||||
(synopsis "Nonlinear optimization by mesh-adaptive direct search")
|
(synopsis "Nonlinear optimization by mesh-adaptive direct search")
|
||||||
(description
|
(description
|
||||||
|
|
Loading…
Reference in a new issue