41 #include "../../App/ApplicationTools.h" 51 if (find(names_.begin(), names_.end(), name) != names_.end())
throw Exception(
"ParameterGrid::addDimension(). A dimension with name '" + name +
"' already exists in the grid.");
52 if (values.size() == 0)
throw Exception(
"ParameterGrid::addDimension(). Empty vector given! The dimension should at least contain one point.");
53 names_.push_back(name);
54 grid_.push_back(values);
59 for(
unsigned int i = 0; i < names_.size(); i++)
60 if (names_[i] == name)
62 throw Exception(
"ParameterGrid::getPointsForDimension(). No dimension with name '" + name +
"' was found in the grid.");
67 if (i >= names_.size())
throw IndexOutOfBoundsException(
"ParameterGrid::getPointsForDimension().", i, 0, names_.size() - 1);
73 if (grid_.size() == 0)
return 0;
75 for (
size_t i = 0; i < grid_.size(); i++)
85 size_t n = grid.getNumberOfDimensions();
87 if(n == 0)
return data;
94 for(
unsigned int i = 0; i < n; i++)
98 unsigned int currentDimension = 0;
99 vector<unsigned int> currentPointInDimension(n);
100 vector<double> row(n + 1);
101 size_t nbPoints = grid.getTotalNumberOfPoints();
103 for (
unsigned int i = 0; true ; i++)
107 for (
unsigned int j = 0; j < n; j++)
108 row[j] = pl[j].getValue();
109 row[n] =
function.f(pl);
110 data->push_back(row);
113 bool dimensionChanged =
false;
114 while (currentDimension < n && currentPointInDimension[currentDimension] == points[currentDimension].size() - 1)
117 dimensionChanged =
true;
120 if (currentDimension == n)
break;
122 currentPointInDimension[currentDimension]++;
123 if (dimensionChanged)
125 for (
unsigned int j = 0; j < currentDimension; j++)
126 currentPointInDimension[j] = 0;
127 currentDimension = 0;
131 for (
unsigned int j = 0; j < points.size(); j++)
133 pl.
setParameterValue(grid.getDimensionName(j), points[j][currentPointInDimension[j]]);
virtual ParameterList subList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
This class allows to perform a correspondence analysis.
This is the function abstract class.
virtual void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
The parameter list object.
This class is a data structure to specify a set of parameter values (most likely for evaluation by a ...
size_t getTotalNumberOfPoints() const
std::vector< double > Vdouble
Index out of bounds exception class.
const Vdouble & getPointsForDimension(unsigned int i) const
void addDimension(const std::string &name, const Vdouble &values)
Add a new dimension (parameter name + corresponding values).
std::vector< Vdouble > VVdouble