Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source(test-all.R) failed on centos8_x86_64 #81

Closed
Tom-python0121 opened this issue Nov 22, 2021 · 2 comments
Closed

source(test-all.R) failed on centos8_x86_64 #81

Tom-python0121 opened this issue Nov 22, 2021 · 2 comments

Comments

@Tom-python0121
Copy link

hello,I meet a problem:source(test-all.R) failed on centos8_x86_64

Steps to reproduce the issue

[root@localhost tests]#Rscript test-all.R
Loading required package: nloptr
[1] 1.000000 4.743006 3.821141 1.379409
[1] 1.000000 4.743000 3.821150 1.379408
== Failed tests =============================================================================================================================================================================================
-- Failure (test-hs071.R:98:5): Test HS071. ------------------------------------
res$solution not equal to `solution.opt`.
3/4 mismatches (average diff: 5.54e-06)
[2] 4.74 - 4.74 ==  6.69e-06
[3] 3.82 - 3.82 == -8.73e-06
[4] 1.38 - 1.38 ==  1.21e-06

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 46 ]
Error: Test failures
Execution halted
[root@localhost tests]#R
> source("test-all.R")
Loading required package: nloptr
[1] 1.000000 4.743006 3.821141 1.379409
[1] 1.000000 4.743000 3.821150 1.379408
Called from: eval(code, test_env)
Browse[1]> debug(expect_equal)
Browse[1]> expect_equal(res$solution, solution.opt, tolerance = 1e-6)
debugging in: expect_equal(res$solution, solution.opt, tolerance = 1e-06)
debug: {
    act <- quasi_label(enquo(object), label, arg = "object")
    exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
    if (edition_get() >= 3) {
        expect_waldo_equal("equal", act, exp, info, ..., tolerance = tolerance)
    }
    else {
        if (!is.null(tolerance)) {
            comp <- compare(act$val, exp$val, ..., tolerance = tolerance)
        }
        else {
            comp <- compare(act$val, exp$val, ...)
        }
        expect(comp$equal, sprintf("%s not equal to %s.\n%s",
            act$lab, exp$lab, comp$message), info = info)
        invisible(act$val)
    }
}
Browse[4]> c
Error: res$solution not equal to `solution.opt`.
3/4 mismatches (average diff: 5.54e-06)
[2] 4.74 - 4.74 ==  6.69e-06
[3] 3.82 - 3.82 == -8.73e-06
[4] 1.38 - 1.38 ==  1.21e-06

Can you tell me why this problem happened?

@jyypma
Copy link
Collaborator

jyypma commented Nov 22, 2021 via email

@Tom-python0121
Copy link
Author

Tom-python0121 commented Nov 23, 2021

@jyypma how is tolerance calculated?I want to know.My problem has been fixed according to your method. The patch is as follows:
diff --git a/tests/testthat/test-hs071.R b/tests/testthat/test-hs071.R
index 3cb3fb8..d1cea50 100644
--- a/tests/testthat/test-hs071.R
+++ b/tests/testthat/test-hs071.R
@@ -94,7 +94,7 @@ test_that( "Test HS071.", {
opts = opts )

 # Run some checks on the optimal solution.
  • expect_equal(res$solution, solution.opt, tolerance = 1e-6)
  • expect_equal(res$solution, solution.opt, tolerance = 1e-5)
    expect_true(all(res$solution >= lb))
    expect_true(all(res$solution <= ub))
    the result:
    image
    Can this patch be incorporated into the latest version?

@astamm astamm closed this as completed in 4d6631a Jan 8, 2022
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 11, 2023
# nloptr 2.0.3

* Improved compatibility on RHEL/CentOS by first searching for a
`cmake3` binary on the `PATH` (#104).

* Improved backward compatibility with older versions of `cmake` (#119).

# nloptr 2.0.2

This is a patch version in which:

* I link to the `nlopt` library via `nlopt/lib/libnlopt.a` instead of
`-Lnlopt/lib -lnlopt` when building `nlopt` from included sources to avoid
potential mess where `-lnlopt` could look for the `nlopt` library in other
places and possibly link with an existing too old system build of `nlopt`.

Additionally, we contacted Simon Urbanek for updating the `nlopt` recipe for
macOS users so that it does now match the latest `v2.7.1`, which should avoid
`nlopt` to be built on the fly on CRAN machines.

# nloptr 2.0.1

This is a release mainly for increasing direct compatibility with most
user cases. In details, here is the list of changes that have been
made:

* Update `SystemRequirements` description to make it clearer which
  minimal versions of `cmake` (`>= 3.15.0`) and `nlopt` (`>= 2.7.0`)
  are required (#100, @HenrikBengtsson).

* End configuration sooner and louder if `cmake` is missing when
  needed with clearer message (#103, @eddelbuettel).

* Ensure system-wide installation of `cmake` in the list of
  suggestions to install it when missing.

* Update GHA scripts to latest versions.
* Configure git to always use LF line endings for configure.ac file.
* Add CI for R-devel on Windows with Rtools42.
* Fix for compatibility with versions of R anterior to `4.0` (#111).

* Look for a `cmake3` binary in the current path before `cmake` for
  increasing compatibility with most RHEL/CentOS users (#104,
  @bhogan-mitre @HenrikBengtsson).

# nloptr 2.0.0

## Major changes

* Use [CMake](https://cmake.org) to build `nlopt` from included
  sources on macOS and on Linux if no system build of NLopt (>= 2.7.0)
  is found.

* Update included sources of NLopt to latest version (2.7.1).


* Put back the ability on Linux platforms to re-use an existing
  external build of NLopt instead of building from the included
  sources (contributed by Dirk Eddelbuettel, #88).

* Now builds using NLopt from `rwinlib` on Windows current release
  (contributed by Jeroen Ooms, #92), or NLopt from `Rtools42` on
  Windows devel (contributed by Tomas Kalibera).

## Minor changes

* Added a `NEWS.md` file to track changes to the package.
* Use markdown in Roxygen documentation.

* Added a logo and a proper [**nloptr**
  website](https://astamm.github.io/nloptr/).

* Added coverage.
* Switch from Travis to Github Actions for CI.
* Use Catch for unit testing C/C++ code.
* Now tracking code coverage.

* Update NLopt-related URLs following migration of [NLopt
  website](https://nlopt.readthedocs.io/en/latest/).

* Fixed bug to avoid linking issues when using the C API via `#include
  <nloptrAPI.h>` in several source files.

* Fix precision issue in test example `hs071` (astamm/nloptr#81,
  @Tom-python0121).

* Made NLopt algorithm `NLOPT_GN_ESCH` available from R interface
  (contributed by Xiongtao Dai).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants