Commit 0bacc1bd authored by cully's avatar cully
Browse files

remove some warnings, make limbo compatible with GCC 4.6 and cpp0x

parent d596bfb0
......@@ -139,7 +139,7 @@ namespace limbo {
<< std::endl;
for (auto x : p_data)
pareto_data << std::get<1>(x).transpose() << std::endl;
for (int i = 0; i < opt.observations().size(); ++i)
for (size_t i = 0; i < opt.observations().size(); ++i)
obs << opt.observations()[i].transpose() << " "
<< opt.samples()[i].transpose()
<< std::endl;
......
......@@ -46,7 +46,7 @@ namespace limbo {
void operator()(const F& feval, Opt& opt) const {
for (int i = 0; i < Params::init::nb_samples(); i++) {
Eigen::VectorXd new_sample(F::dim);
for (int i = 0; i < F::dim; i++)
for (size_t i = 0; i < F::dim; i++)
new_sample[i] =
int(((double) (Params::init::nb_bins() + 1) * rand())
/ (RAND_MAX + 1.0)) / double(Params::init::nb_bins());
......
......@@ -41,7 +41,7 @@ namespace limbo {
double *fitvals;
double fbestever = 0, *xbestever = NULL;
double fmean;
int i, irun, lambda = 0, countevals = 0;
int irun, lambda = 0, countevals = 0;
char const * stop;
boundary_transformation_t boundaries;
double lowerBounds[] = {0.0}; // TODO put this into params?
......
......@@ -13,18 +13,33 @@
namespace par {
#ifdef USE_TBB
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template <typename X>// old fashion way to create template alias (for GCC 4.6...)
struct vector
{
typedef tbb::concurrent_vector<X> type;
};
#else
template <typename X>
using vector = tbb::concurrent_vector<X>;
using vector = tbb::concurrent_vector<X>; // Template alias (for GCC 4.7 and later)
#endif
template<typename V>
std::vector<typename V::value_type> convert_vector(const V& v) {
std::vector<typename V::value_type> v2(v.size());
std::copy(v.begin(), v.end(), v2.begin());
return v2;
}
#else
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template <typename X> // old fashion way to create template alias (for GCC 4.6...)
struct vector
{
typedef std::vector<X> type;
};
#else
template <typename X>
using vector = std::vector<X>;
using vector = std::vector<X>; // Template alias (for GCC 4.7 and later)
#endif
template<typename V>
V& convert_vector(const V& v) {
......
......@@ -86,7 +86,11 @@ namespace pareto {
// O(n^2) procedure, for > 2 objectives
template<int K, typename T>
T pareto_set_std(const T& p) {
par::vector<typename T::value_type> pareto;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
typename par::vector<typename T::value_type>::type pareto; // old fashion way to create template alias (for GCC 4.6...)
#else
par::vector<typename T::value_type> pareto; // Using Template alias (for GCC 4.7 and later)
#endif
par::loop(0, p.size(), [&](size_t i) {
if (i % 10000 == 0) {
std::cout << i << '[' << p.size() << "] ";
......
......@@ -56,7 +56,7 @@ inline double c2(double x) {
inline Eigen::VectorXd t_osz(const Eigen::VectorXd& x) {
Eigen::VectorXd r = x;
for (size_t i = 0; i < x.size(); i++)
for (int i = 0; i < x.size(); i++)
r(i) = sign(x(i)) * exp(hat(x(i)) + 0.049 * sin(c1(x(i)) * hat(x(i)))
+ sin(c2(x(i)) * hat(x(i))));
return r;
......@@ -87,7 +87,7 @@ struct Rastrigin {
static constexpr size_t dim = 4;
double operator()(const Eigen::VectorXd& x) const {
double f = 10 * x.size();
for (size_t i = 0; i < x.size(); ++i)
for (int i = 0; i < x.size(); ++i)
f += x(i) * x(i) - 10 * cos(2 * M_PI * x(i));
return -f;
}
......@@ -318,7 +318,7 @@ int main(int argc, char **argv) {
par::replicate(nb_replicates, [&] () {
Opt_t opt;
opt.optimize(GoldenPrice());
double s_max = -log(3);
// double s_max = -log(3);
Eigen::Vector2d s_val(0.5, 0.25);
double x_opt = GoldenPrice()(s_val);
add_to_results("Golden Price", results, std::make_pair(x_opt, opt.best_observation()));
......
......@@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(random_sampling) {
for (size_t j = 0; j < opt.samples().size() - 1; ++j) {
const Eigen::VectorXd& x = opt.samples()[j];
std::cout << x.transpose() << std::endl;
for (size_t i = 0; i < x.size(); ++i) {
for (int i = 0; i < x.size(); ++i) {
BOOST_CHECK(x[i] >= 0);
BOOST_CHECK(x[i] <= 1);
}
......@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(random_sampling_grid) {
for (size_t j = 0; j < opt.samples().size() - 1; ++j) {
const Eigen::VectorXd& x = opt.samples()[j];
std::cout << x.transpose() << std::endl;
for (size_t i = 0; i < x.size(); ++i) {
for (int i = 0; i < x.size(); ++i) {
BOOST_CHECK(x[i] >= 0);
BOOST_CHECK(x[i] <= 1);
BOOST_CHECK(x[i] == 0 || x[i] == 0.25 || x[i] == 0.5 || x[i] == 0.75 || x[i] == 1.0);
......@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(grid_sampling) {
for (size_t j = 0; j < opt.samples().size() - 1; ++j) {
const Eigen::VectorXd& x = opt.samples()[j];
std::cout << x.transpose() << std::endl;
for (size_t i = 0; i < x.size(); ++i) {
for (int i = 0; i < x.size(); ++i) {
BOOST_CHECK(x[i] >= 0);
BOOST_CHECK(x[i] <= 1);
BOOST_CHECK(x[i] == 0 || x[i] == 0.25 || x[i] == 0.5 || x[i] == 0.75 || x[i] == 1.0);
......
......@@ -37,7 +37,7 @@ def configure(conf):
cxxflags = conf.env['CXXFLAGS']
conf.check_boost(lib='serialization timer filesystem \
system unit_test_framework program_options \
graph mpi thread',
graph thread',
min_version='1.35')
conf.check_eigen()
conf.check_tbb()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment