Commit 10b854f2 authored by Jean-Baptiste Mouret's avatar Jean-Baptiste Mouret
Browse files

cleaning (gcc warnings)

parent 0b1cbb13
......@@ -38,7 +38,7 @@ struct zdt1 {
Eigen::VectorXd res(2);
double f1 = x(0);
double g = 1.0;
for (size_t i = 1; i < x.size(); ++i)
for (int i = 1; i < x.size(); ++i)
g += 9.0 / (x.size() - 1) * x(i);
double h = 1.0f - sqrtf(f1 / g);
double f2 = g * h;
......@@ -54,7 +54,7 @@ struct zdt2 {
Eigen::VectorXd res(2);
double f1 = x(0);
double g = 1.0;
for (size_t i = 1; i < x.size(); ++i)
for (int i = 1; i < x.size(); ++i)
g += 9.0 / (x.size() - 1) * x(i);
double h = 1.0f - pow((f1 / g), 2.0);
double f2 = g * h;
......@@ -70,7 +70,7 @@ struct zdt3 {
Eigen::VectorXd res(2);
double f1 = x(0);
double g = 1.0;
for (size_t i = 1; i < x.size(); ++i)
for (int i = 1; i < x.size(); ++i)
g += 9.0 / (x.size() - 1) * x(i);
double h = 1.0f - sqrtf(f1 / g) - f1 / g * sin(10 * M_PI * f1);
double f2 = g * h;
......
......@@ -16,6 +16,7 @@ sys.argv.pop(0)
for i in sys.argv:
data = np.loadtxt(i)
plot(data[:, 0], data[:, 1], '-', label=i)
plot(data[:, 0], data[:, 1], 'o', label=i)
if data.shape[1] > 2:
plot(data[:,0] - data[:,2]*100000, data[:,1] - data[:,3]*100000, '-', label='p')
......
......@@ -14,7 +14,7 @@ def build(bld):
'PAREGO ZDT3 DIM6',
'NS_EGO ZDT1 DIM30',
'NS_EGO ZDT2 DIM30',
'NS_EGO ZDT3 DIM30'
'NS_EGO ZDT3 DIM30',
'NS_EGO ZDT1 DIM6',
'NS_EGO ZDT2 DIM6',
'NS_EGO ZDT3 DIM6'
......
......@@ -30,7 +30,7 @@ struct zdt2 {
Eigen::VectorXd res(2);
double f1 = x(0);
double g = 1.0;
for (size_t i = 1; i < x.size(); ++i)
for (int i = 1; i < x.size(); ++i)
g += 9.0 / (x.size() - 1) * x(i) * x(i);
double h = 1.0f - pow((f1 / g), 2.0);
double f2 = g * h;
......
......@@ -160,7 +160,7 @@ namespace limbo {
size_t dim = this->_samples[0].size();
std::vector<std::vector<double> > uni_obs(nb_objs());
for (size_t i = 0; i < this->_observations.size(); ++i)
for (size_t j = 0; j < this->_observations[i].size(); ++j)
for (int j = 0; j < this->_observations[i].size(); ++j)
uni_obs[j].push_back(this->_observations[i][j]);
std::vector<model_t> models(nb_objs(), model_t(dim));
_models = models;
......
......@@ -32,7 +32,7 @@ namespace limbo {
_observations.resize(observations.size());
_noise = noise;
for (size_t i = 0; i < _observations.size(); ++i)
for (int i = 0; i < _observations.size(); ++i)
_observations(i) = observations[i];
_mean_vector.resize(_samples.size());
......@@ -93,8 +93,8 @@ namespace limbo {
void _compute_kernel() {
// O(n^2) [should be negligible]
_kernel.resize(_observations.size(), _observations.size());
for (size_t i = 0; i < _observations.size(); i++)
for (size_t j = 0; j < _observations.size(); ++j)
for (int i = 0; i < _observations.size(); i++)
for (int j = 0; j < _observations.size(); ++j)
_kernel(i, j) = _kernel_function(_samples[i], _samples[j]) + _noise;
// O(n^3)
......@@ -108,19 +108,14 @@ namespace limbo {
}
double _mu(const Eigen::VectorXd& v, const Eigen::VectorXd& k) const {
return _mean_function(v) + k.transpose() * _alpha;
return _mean_function(v)
+ (k.transpose() * _inverted_kernel * (_obs_mean))[0];
// return _mean_function(v)
// + (k.transpose() * _inverted_kernel * (_obs_mean))[0];
}
double _sigma(const Eigen::VectorXd& v, const Eigen::VectorXd& k) const {
Eigen::VectorXd z = _llt.matrixL().solve(k);
return _kernel_function(v, v) - z.dot(z);
return _kernel_function(v, v) - (k.transpose() * _inverted_kernel * k)[0];
// return _kernel_function(v, v) - (k.transpose() * _inverted_kernel * k)[0];
}
Eigen::VectorXd _compute_k(const Eigen::VectorXd& v) const {
Eigen::VectorXd k(_samples.size());
......
......@@ -28,7 +28,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] = misc::rand<double>(0, 1);
std::cout << "random sample:" << new_sample.transpose() << std::endl;
opt.add_new_sample(new_sample, feval(new_sample));
......
......@@ -61,7 +61,7 @@ namespace limbo {
for (i = 0; i < cmaes_Get(&evo, "popsize"); ++i) {
boundary_transformation(&boundaries, pop[i], x_in_bounds, dim);
for (size_t j = 0; j < v.size(); ++j)
for (int j = 0; j < v.size(); ++j)
v(j) = x_in_bounds[j];
fitvals[i] = -acqui(v);
}
......@@ -76,7 +76,7 @@ namespace limbo {
xbestever = cmaes_GetInto(&evo, "xbestever", xbestever); /* alloc mem if needed */
}
const double *xmean = cmaes_GetPtr(&evo, "xmean");
for (size_t j = 0; j < v.size(); ++j)
for (int j = 0; j < v.size(); ++j)
v(j) = xmean[j];
if ((fmean = -acqui(v)) < fbestever) {
......
......@@ -31,7 +31,7 @@ namespace limbo {
// this is hack to test wether we need a bound
pareto.erase(std::remove_if(pareto.begin(), pareto.end(),
[](const pareto_point_t& x) {
for (size_t i = 0; i < std::get<1>(x).size(); ++i)
for (int i = 0; i < std::get<1>(x).size(); ++i)
if (std::get<1>(x)(i) > 1)
return true;
return false;
......
......@@ -52,7 +52,7 @@ namespace pareto {
compare_objs_lex() {}
template<typename T>
bool operator()(const T& i1, const T& i2) const {
for (size_t i = 0; i < std::get<1>(i1).size(); ++i)
for (int i = 0; i < std::get<1>(i1).size(); ++i)
if (std::get<1>(i1)(i) > std::get<1>(i2)(i))
return true;
else if (std::get<1>(i1)(i) < std::get<1>(i2)(i))
......
......@@ -29,7 +29,7 @@ namespace rprop {
Eigen::VectorXd best_params = params;
double best = log(0);
for (size_t i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) {
double lik = func(params);
Eigen::VectorXd grad = -grad_func(params);
grad_old = grad_old.cwiseProduct(grad);
......
......@@ -41,7 +41,7 @@ def configure(conf):
common_flags += " -DUSE_TBB "
if conf.is_defined('USE_SFERES'):
common_flags += " -DUSE_SFERES "
common_flags += " -DUSE_SFERES -DSFERES_FAST_DOMSORT"
# release
opt_flags = common_flags + ' -O3 -msse2 -ggdb3 -g'
......
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