From patchwork Fri Jul 9 03:43:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul A. Patience" X-Patchwork-Id: 31246 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C001027BC81; Fri, 9 Jul 2021 04:45:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2608C27BC78 for ; Fri, 9 Jul 2021 04:45:14 +0100 (BST) Received: from localhost ([::1]:48910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1hRx-0005bD-5Y for patchwork@mira.cbaines.net; Thu, 08 Jul 2021 23:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1hRn-0005YX-7Q for guix-patches@gnu.org; Thu, 08 Jul 2021 23:45:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1hRm-0004UF-Dz for guix-patches@gnu.org; Thu, 08 Jul 2021 23:45:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m1hRm-00008t-9r for guix-patches@gnu.org; Thu, 08 Jul 2021 23:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49476] [PATCH] gnu: Add nomad-optimizer. Resent-From: "Paul A. Patience" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 09 Jul 2021 03:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49476 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49476@debbugs.gnu.org X-Debbugs-Original-To: "guix-patches@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.1625802244465 (code B ref -1); Fri, 09 Jul 2021 03:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Jul 2021 03:44:04 +0000 Received: from localhost ([127.0.0.1]:58029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1hQh-00006t-Jr for submit@debbugs.gnu.org; Thu, 08 Jul 2021 23:44:04 -0400 Received: from lists.gnu.org ([209.51.188.17]:34574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1hQf-00006k-I9 for submit@debbugs.gnu.org; Thu, 08 Jul 2021 23:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1hQf-0004LF-9E for guix-patches@gnu.org; Thu, 08 Jul 2021 23:43:53 -0400 Received: from mail-4323.protonmail.ch ([185.70.43.23]:22001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1hQb-0003ZP-2n for guix-patches@gnu.org; Thu, 08 Jul 2021 23:43:52 -0400 Date: Fri, 09 Jul 2021 03:43:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apatience.com; s=protonmail3; t=1625802226; bh=gBYiOZjcyhCWCKk5ERfT95aJ1O/uNQVqttKz/UClW3g=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=s91nJNVs5C4Q3WiHdzuDWdfBMmRuOdP2/Z+M9jWcQqkDYGu+Ujp+lJEGSorYGkOjC xYv6PQCj9jkw8AtsLJiT+ur6svRYVdZro7I+7+O7iEsnSSFm2UASFFM0TbhLFoYi9p yvduhQ5ljAnPYOJli0wwizsu7FiE4F8w2Hc1Io/tD+/9QOXNdpUmWDIVQEOmqZuuJx HuxuLhYqaV8tWZjhv0uDH/8po8KIZXDWFHd18P/Um6X2DKXRVxnA5scKPZQXQHj5Q9 HEE3fRj+Xax0L++a08P5LqZSsY+PxgIBSuh4HXIhSw3nujUk5qA1134wwC1z9OSaGU 4N4jnvmDU2b9g== From: "Paul A. Patience" Message-ID: In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=185.70.43.23; envelope-from=paul@apatience.com; helo=mail-4323.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: "Paul A. Patience" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches On Thursday, July 8th, 2021 at 23:29, Paul A. Patience wrote: > The attached patch adds the nomad-optimizer package. I forgot to run guix lint. Here is the updated patch. Unfortunately, guix lint complains about a long line, but forcing it to wrap would cause it to become more unreadable, in my opinion. Best regards, Paul From 34a15bce446a401a5c6be60d1b6c8ce641709007 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Thu, 8 Jul 2021 23:38:51 -0400 Subject: [PATCH] gnu: Add nomad-optimizer. * gnu/packages/maths.scm (nomad-optimizer): New variable. --- gnu/packages/maths.scm | 148 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm index b8e9a31be7..6f761f9498 100644 --- a/gnu/packages/maths.scm +++ b/gnu/packages/maths.scm @@ -1798,6 +1798,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") -- 2.32.0