Commit 8444ab2d authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Ran clang-format on whole repo

parent 95967d51
......@@ -56,9 +56,8 @@
#define ERROR(x) fprintf(stderr, x), fprintf(stderr, "\n"), exit(1)
int Dominates(double point1[], double point2[], int noObjectives)
/* returns true if 'point1' dominates 'points2' with respect to the
/* returns true if 'point1' dominates 'points2' with respect to the
to the first 'noObjectives' objectives */
{
int i;
......@@ -71,17 +70,17 @@ int Dominates(double point1[], double point2[], int noObjectives)
return (i >= noObjectives && betterInAnyObjective);
} /* Dominates */
void Swap(double *front[], int i, int j)
void Swap(double* front[], int i, int j)
{
double *temp;
double* temp;
temp = front[i];
front[i] = front[j];
front[j] = temp;
} /* Swap */
int FilterNondominatedSet(double *front[], int noPoints, int noObjectives)
/* all nondominated points regarding the first 'noObjectives' dimensions
int FilterNondominatedSet(double* front[], int noPoints, int noObjectives)
/* all nondominated points regarding the first 'noObjectives' dimensions
are collected; the points referenced by 'front[0..noPoints-1]' are
considered; 'front' is resorted, such that 'front[0..n-1]' contains
the nondominated points; n is returned */
......@@ -115,26 +114,27 @@ int FilterNondominatedSet(double *front[], int noPoints, int noObjectives)
return n;
} /* FilterNondominatedSet */
double SurfaceUnchangedTo(double *front[], int noPoints, int objective)
/* calculate next value regarding dimension 'objective'; consider
double SurfaceUnchangedTo(double* front[], int noPoints, int objective)
/* calculate next value regarding dimension 'objective'; consider
points referenced in 'front[0..noPoints-1]' */
{
int i;
double minValue, value;
if (noPoints < 1) ERROR("run-time error");
if (noPoints < 1)
ERROR("run-time error");
minValue = front[0][objective];
for (i = 1; i < noPoints; i++) {
value = front[i][objective];
if (value < minValue) minValue = value;
if (value < minValue)
minValue = value;
}
return minValue;
} /* SurfaceUnchangedTo */
int ReduceNondominatedSet(double *front[], int noPoints, int objective,
int ReduceNondominatedSet(double* front[], int noPoints, int objective,
double threshold)
/* remove all points which have a value <= 'threshold' regarding the
/* remove all points which have a value <= 'threshold' regarding the
dimension 'objective'; the points referenced by
'front[0..noPoints-1]' are considered; 'front' is resorted, such that
'front[0..n-1]' contains the remaining points; 'n' is returned */
......@@ -151,7 +151,7 @@ int ReduceNondominatedSet(double *front[], int noPoints, int objective,
return n;
} /* ReduceNondominatedSet */
double CalculateHypervolume(double *front[], int noPoints,
double CalculateHypervolume(double* front[], int noPoints,
int noObjectives)
{
int n;
......@@ -167,7 +167,8 @@ double CalculateHypervolume(double *front[], int noPoints,
noNondominatedPoints = FilterNondominatedSet(front, n, noObjectives - 1);
tempVolume = 0;
if (noObjectives < 3) {
if (noNondominatedPoints < 1) ERROR("run-time error");
if (noNondominatedPoints < 1)
ERROR("run-time error");
tempVolume = front[0][0];
}
else
......@@ -181,7 +182,7 @@ double CalculateHypervolume(double *front[], int noPoints,
return volume;
} /* CalculateHypervolume */
int ReadFront(double **frontPtr[], FILE *file, int noObjectives)
int ReadFront(double** frontPtr[], FILE* file, int noObjectives)
{
int noPoints;
int i;
......@@ -190,16 +191,20 @@ int ReadFront(double **frontPtr[], FILE *file, int noObjectives)
/* check file and count points */
noPoints = 0;
while (!feof(file)) {
for (i = 0; i < noObjectives && fscanf(file, "%lf", &value) != EOF; i++);
if (i > 0 && i < noObjectives) ERROR("data in file incomplete");
for (i = 0; i < noObjectives && fscanf(file, "%lf", &value) != EOF; i++)
;
if (i > 0 && i < noObjectives)
ERROR("data in file incomplete");
noPoints++;
}
/* allocate memory */
*frontPtr = malloc(noPoints * sizeof(double *));
if (*frontPtr == NULL) ERROR("memory allocation failed");
*frontPtr = malloc(noPoints * sizeof(double*));
if (*frontPtr == NULL)
ERROR("memory allocation failed");
for (i = 0; i < noPoints; i++) {
(*frontPtr)[i] = malloc(noObjectives * sizeof(double));
if ((*frontPtr)[i] == NULL) ERROR("memory allocation failed");
if ((*frontPtr)[i] == NULL)
ERROR("memory allocation failed");
}
/* read data */
rewind(file);
......@@ -211,14 +216,16 @@ int ReadFront(double **frontPtr[], FILE *file, int noObjectives)
else
break;
}
if (i > 0 && i < noObjectives) ERROR("data in file incomplete");
if (i > 0 && i < noObjectives)
ERROR("data in file incomplete");
noPoints++;
}
if (noPoints < 1) ERROR("file contains no data");
if (noPoints < 1)
ERROR("file contains no data");
return noPoints;
} /* ReadFront */
int MergeFronts(double **frontPtr[], double *front1[], int sizeFront1,
int MergeFronts(double** frontPtr[], double* front1[], int sizeFront1,
double* front2[], int sizeFront2, int noObjectives)
{
int i, j;
......@@ -226,11 +233,13 @@ int MergeFronts(double **frontPtr[], double *front1[], int sizeFront1,
/* allocate memory */
noPoints = sizeFront1 + sizeFront2;
*frontPtr = malloc(noPoints * sizeof(double *));
if (*frontPtr == NULL) ERROR("memory allocation failed");
*frontPtr = malloc(noPoints * sizeof(double*));
if (*frontPtr == NULL)
ERROR("memory allocation failed");
for (i = 0; i < noPoints; i++) {
(*frontPtr)[i] = malloc(noObjectives * sizeof(double));
if ((*frontPtr)[i] == NULL) ERROR("memory allocation failed");
if ((*frontPtr)[i] == NULL)
ERROR("memory allocation failed");
}
/* copy points */
noPoints = 0;
......
#ifndef HYPERVOL_H__
#define HYPERVOL_H__
extern "C"{
int FilterNondominatedSet(double *front[], int noPoints, int noObjectives);
double CalculateHypervolume(double *front[], int noPoints, int noObjectives);
extern "C" {
int FilterNondominatedSet(double* front[], int noPoints, int noObjectives);
double CalculateHypervolume(double* front[], int noPoints, int noObjectives);
}
#endif
......@@ -93,7 +93,6 @@ namespace limbo {
boost::parameter::optional<tag::stopcrit>,
boost::parameter::optional<tag::modelfun>> bo_multi_signature;
// clang-format off
template <class Params,
class A1 = boost::parameter::void_,
......
......@@ -40,7 +40,6 @@ namespace limbo {
// nothing here !
};
// clang-format on
}
}
}
......
......@@ -26,8 +26,9 @@ namespace limbo {
<< std::get<1>(x).transpose() << std::endl;
}
}
protected:
template<typename BO>
template <typename BO>
pareto_t _pareto_data(const BO& bo)
{
std::vector<Eigen::VectorXd> v(bo.samples().size());
......
#ifndef LIMBO_OPT_HPP
#define LIMBO_OPT_HPP
///@defgroup opt_defaults
///@defgroup opt
......
......@@ -4,7 +4,6 @@
///@defgroup stop
///@defgroup stop_defaults
#include <limbo/stop/chain_criteria.hpp>
#include <limbo/stop/max_iterations.hpp>
#include <limbo/stop/max_predicted_value.hpp>
......
......@@ -58,7 +58,6 @@ namespace limbo {
return res;
}
template <typename T>
inline constexpr int signum(T x, std::false_type is_signed)
{
......
......@@ -90,7 +90,7 @@ int main(int argc, char** argv)
// write the data to a file (useful for plotting)
std::ofstream ofs_data("data.dat");
for (int i = 0; i < samples.size(); ++i)
for (size_t i = 0; i < samples.size(); ++i)
ofs_data << samples[i].transpose() << " " << observations[i].transpose() << std::endl;
return 0;
}
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