Comments (6)
@mattapattu the problem is not about private members, rather it seems like your Qfunc
class does not satisfy all the requirements of a user-defined problem. The requirements are listed here:
https://esa.github.io/pagmo2/docs/cpp/problem.html
Every UDP must implement at least the following two methods: [...]
from pagmo2.
I have defined fitness and get_bounds methods in Qfunc class:
class Qfunc {
private:
// Declare the data members that are needed for the function
Rcpp::List& inputWeightArrayList;
const Eigen::MatrixXd probMatrix;
const Rcpp::DataFrame binned_spiketrain;
const std::vector<Eigen::MatrixXd> log_xi;
const Eigen::MatrixXd log_gamma;
const int curr_state;
const int next_state;
const int n_observations;
const int n_states;
public:
// Constructor to initialize the data members
Qfunc(Rcpp::List& inputWeightArrayList_,
const Eigen::MatrixXd probMatrix_,
const Rcpp::DataFrame& binned_spiketrain_,
const std::vector<Eigen::MatrixXd> log_xi_,
const Eigen::MatrixXd log_gamma_,
const int curr_state_,
const int next_state_,
const int n_observations_,
const int n_states_);
pagmo::vector_double fitness(const pagmo::vector_double &) const;
std::pair<pagmo::vector_double, pagmo::vector_double> get_bounds() const;
Eigen::VectorXd derivateQfunc(const Eigen::VectorXd x);
double computeQval(const Eigen::VectorXd x);
Eigen::MatrixXd getProbMatrix();
double Evaluate(const arma::mat& x);
double EvaluateWithGradient(const arma::mat& x, arma::mat& g);
};
Two mandatory functions are defined like this (as dummy functions):
vector_double Qfunc::fitness(const vector_double &x) const
{
return {x};
}
std::pair<vector_double, vector_double> Qfunc::get_bounds() const
{
return {{-10, -10, -10, -10}, {10, 10, 10, 10}};
}
from pagmo2.
@mattapattu user-defined problems must also satisfy a few other requirements, see the is_udp
type trait:
https://esa.github.io/pagmo2/docs/cpp/miscellanea/type_traits.html#_CPPv4I0EN5pagmo6is_udpE
Your Qfunc
does not appear to have a default constructor.
from pagmo2.
Thanks, adding a default constructor fixed the issue. But now when I run archipelago.evolve I get a seg fault:
problem prob{Qfunc(inputWeightArrayList, eigen_ProbMatrix, binned_spiketrain, eigen_log_xi, eigen_log_gamma, curr_state, next_state, n_observations, n_states)};
pagmo::algorithm algo{sade(100)};
archipelago archi{16u, algo, prob, 20u};
archi.evolve(10);
archi.wait_check();
for (const auto &isl : archi) {
std::cout << "champion:" <<isl.get_population().champion_f()[0] << '\n';
}
It gives below error:
*** caught segfault ***
address 0x30, cause 'memory not mapped'
Error during wrapup: getAttrib: invalid type (double) for TAG
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Browse[2]> Error: bad value
Warning: stack imbalance in 'lazyLoadDBfetch', 87 then 86
Warning: stack imbalance in '<-', 84 then 83
Warning: stack imbalance in '{', 80 then 79
Warning: stack imbalance in 'if', 78 then 77
Error during wrapup: bad value
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
*** caught segfault ***
address 0x6, cause 'memory not mapped'
Error during wrapup: long vectors not supported yet: ../../src/include/Rinlinedfuns.h:537
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Browse[2]>
*** caught segfault ***
address (nil), cause 'memory not mapped'
I tried running the same code with the builtin "problem prob{schwefel(30)};" and it works fine. However, when I use my own UDP, I get a segmentation fault. I am not sure what is causing this error, as I have used DE from Ensmallen package successfully on the same objective function before. Is it possible to debug where the error is happening ?
from pagmo2.
@mattapattu archipelagos use multithreading, which requires your problem to be thread-safe. My guess would be that your problem implementation is using internally some global state that is being modified concurrently by multiple problem instances.
In order to confirm this, you should try to create an archipelago with a single island (instead of 16) and see if this keeps on crashing.
from pagmo2.
Thanks for the clarification, this could be an issue with R which I using to load input files for optimization. R seems to call gc() automatically and therefore is not recommended to use in multithreads.
from pagmo2.
Related Issues (20)
- Installl erro HOT 1
- install problem HOT 6
- [BUG] mhaco asserts if initial population does not verify constraints
- MinGW installation problem HOT 1
- how to run pagmo2 in parallel cluster? HOT 1
- [BUG] redundant code in moead.cpp HOT 2
- [BUG] Could NOT find pagmo_IPOPT (missing: PAGMO_IPOPT_INCLUDE_DIR) HOT 1
- [BUG] No 2.19.0 tag HOT 2
- [BUG] moead_gen is not documented HOT 2
- [FEATURE] PAGMO_VERSION HOT 2
- Scaling of design variables and
- How to optimize with algorithms::ipopt? HOT 2
- [BUG] Maximize function with Ipopt: incorrect population returned HOT 2
- [BUG] Compilation problem with IPOPT HOT 7
- Question: Use of Hessian with Ipopt
- pagmo-devel 2.19 build 3 not found by meson build system HOT 5
- Uninitialized variables may be used in cec2014 problem
- MPI Island class for cluster computing HOT 1
- Avoid multiple definitions of mathematical constants
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagmo2.