typedef double (*benchFunc)(vector<double>); // definition of function pointer for benchmark function
// this class creates the data of objective function
{
public:
SpectrogramData
(benchFunc b,
double rang1
[2],
double rang2
[2],
int dims
[2], vector<double> fix_vec ,
unsigned dimens,
QwtDoubleInterval interval
): QwtRasterData(QwtDoubleRect
(rang1
[0], rang2
[0], rang1
[1]- rang1
[0], rang2
[1]- rang2
[0])) {
MybenchFunc = b;
valuesRange = interval; //<<<<<<<<<< here it is set manually
dim_ind[0] = dims[0]; dim_ind[1] = dims[1];
dimensions = dimens;
fix_vals = fix_vec;
}
{
return new SpectrogramData(*this);
}
virtual QwtDoubleInterval range
() const //<<<<<<<<<<< here the range will be returned {
return valuesRange;
}
virtual double value(double x, double y) const
{
vector<double> coords;
coords = vector<double>(dimensions, 0); // create a vector of size "dimensions" containing zeros
if(dimensions > 2){ // if the benchmark function has more dimensions than 2, then...
for(unsigned i=0 ; i < dimensions ; ++i){
coords[i] = fix_vals[i]; // ... copy first all fixed values into vector and then...
}
coords[dim_ind[0]] = x; // replace the values of dimensions to be visualized
coords[dim_ind[1]] = y;
}
else{
coords[dim_ind[0]] = x;
coords[dim_ind[1]] = y;
}
const double result = MybenchFunc( coords);
return result;
}
private:
benchFunc MybenchFunc; // function pointer for benchmark function
int dim_ind[2];
unsigned dimensions;
vector<double> fix_vals;
};
typedef double (*benchFunc)(vector<double>); // definition of function pointer for benchmark function
// this class creates the data of objective function
class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData(benchFunc b, double rang1[2], double rang2[2], int dims[2], vector<double> fix_vec , unsigned dimens, QwtDoubleInterval interval ):
QwtRasterData(QwtDoubleRect(rang1[0], rang2[0], rang1[1]- rang1[0], rang2[1]- rang2[0]))
{
MybenchFunc = b;
valuesRange = interval; //<<<<<<<<<< here it is set manually
dim_ind[0] = dims[0]; dim_ind[1] = dims[1];
dimensions = dimens;
fix_vals = fix_vec;
}
virtual QwtRasterData *copy() const
{
return new SpectrogramData(*this);
}
virtual QwtDoubleInterval range() const //<<<<<<<<<<< here the range will be returned
{
return valuesRange;
}
virtual double value(double x, double y) const
{
vector<double> coords;
coords = vector<double>(dimensions, 0); // create a vector of size "dimensions" containing zeros
if(dimensions > 2){ // if the benchmark function has more dimensions than 2, then...
for(unsigned i=0 ; i < dimensions ; ++i){
coords[i] = fix_vals[i]; // ... copy first all fixed values into vector and then...
}
coords[dim_ind[0]] = x; // replace the values of dimensions to be visualized
coords[dim_ind[1]] = y;
}
else{
coords[dim_ind[0]] = x;
coords[dim_ind[1]] = y;
}
const double result = MybenchFunc( coords);
return result;
}
private:
benchFunc MybenchFunc; // function pointer for benchmark function
QwtDoubleInterval valuesRange;
int dim_ind[2];
unsigned dimensions;
vector<double> fix_vals;
};
To copy to clipboard, switch view to plain text mode
Bookmarks