Coder Social home page Coder Social logo

Comments (9)

ypan1988 avatar ypan1988 commented on August 16, 2024

Dear Sacha Epskamp

It is quite weird and I have no clue at moment either. There is no need to comment out lines 82-85. It seems that when you call "opt.minimize(rb, x);" on line 106 and somehow this error has been triggered. Could you please check g++ version you're using on Windows (or the Rtools version)? And also could you please attach the figure of compile information on terminal(as we may find additional information over there).

Thanks!

from roptim.

SachaEpskamp avatar SachaEpskamp commented on August 16, 2024

Hi Yi Pan,

Thank you for your quick reply! I installed Rtools35 which should be the latest, and apparently have G++ 4.9.3 (that seems low, I have a much higher version on Linux). See below for a screenshot:

2020-03-26_13-48-00

Best, Sacha

from roptim.

ypan1988 avatar ypan1988 commented on August 16, 2024

Dear Sacha Epskamp

I have tried to compile your package on linux and it is okay. Actually it is quite hard for me to reproduce the error currently -- I left my only windows PC in the office, and obviously I cannot go back now. Could you please simply try the following change on your PC (as I get the feeling that "control" is somehow not regarded as data member in your case):

roptim.h:
Change

line 86: } control;

to

};
RoptimControl control;

I write the following simple code which might be helpful to find a solution to the problem:
test.cpp:

#include <Rcpp.h>

template <typename T>
class A {
  T val = 10;
public:
  struct Inner{
    int trace = 0;
  };
  Inner control;
  void fun(T v) {
    val = v;
    if (control.trace > 0)
      Rcpp::Rcout << "val = " << val << std::endl;
  }
};

// [[Rcpp::export]]
void test_A()
{
  A<int> a;
  a.control.trace = 1;
  a.fun(20);
}

And run the following in R:

library(Rcpp)
sourceCpp("~/test.cpp") # You may need to change the directory
test_A()

If you are able to get the function test_A() above working, then it also means that we have fixed the problem.

Thanks!

from roptim.

ypan1988 avatar ypan1988 commented on August 16, 2024

By the way, the version of Rtools you're using is definitely okay. And that's something I don't understand -- I was using the same Rtools and roptim in my package on Windows while there was no error.

from roptim.

SachaEpskamp avatar SachaEpskamp commented on August 16, 2024

Thanks! The test_A() function works regardless of changing that line in roptim.h, but changing the line did not fix the problem in building the package.

from roptim.

ypan1988 avatar ypan1988 commented on August 16, 2024

Hi, Sacha

I managed to reproduce the error on windows vm and found that the following change may fix the problem:
roptim.h:
Change

int trace = 0;

to

std::size_t trace = 0;

Change

if (control.trace < 0)
    Rcpp::warning("read the documentation for 'trace' more carefully");
else if (method_ == "SANN" && control.trace && control.REPORT == 0)
    Rcpp::stop("'trace != 0' needs 'REPORT >= 1'");

to

if (method_ == "SANN" && control.trace && control.REPORT == 0)
    Rcpp::stop("'trace != 0' needs 'REPORT >= 1'");

Let me know if it also works for you. Thanks a lot!

from roptim.

SachaEpskamp avatar SachaEpskamp commented on August 16, 2024

Yes this worked! Thank you so much for the quick work on this!

from roptim.

ypan1988 avatar ypan1988 commented on August 16, 2024

It seems that it is a bug of the compiler. But I am still quite confused about this error -- I was doing something similar in my another package and I should get this error message long time ago.

Anyway I will aim to update the package this weekend and afterwards you can specify the minimum roptim version required in the DESCRIPTION file for safe. Thanks.

from roptim.

SachaEpskamp avatar SachaEpskamp commented on August 16, 2024

That is great, thank! Of note, I obtained a similar error on a Linux high performance cloud that was also fixed with this code.

from roptim.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.