资源简介
CEC2010,用于测试高维优化问题的测试函数集,有MATLAB,C,Java版本
代码片段和文件信息
#include “Benchmarks.h“
Benchmarks::Benchmarks(){
dimension = 1000;
nonSeparableGroupSize = 50;
MASK = ((L(1)) << (L(48))) - (L(1));
m_havenextGaussian = false;
if (dimension cerr<<“ERROR: In configuration file dimension is smaller than the non-separable part“< exit(-1);
}
// allocate the memory
anotherz = new double[dimension];
anotherz1= new double[nonSeparableGroupSize];
anotherz2= new double[dimension - nonSeparableGroupSize];
// Runtime Parameters setting
setOvectorToZero = false;
functionInitRandomSeed = L(0);
m_seed= functionInitRandomSeed;
M = 0x5DEECE66D;
A = 0xB;
minX = -100;
maxX = 100;
}
void Benchmarks::setMinX(int inVal){
minX = inVal;
}
void Benchmarks::setMaxX(int inVal){
maxX = inVal;
}
void Benchmarks::setSeed(int64_t inVal){
functionInitRandomSeed = inVal;
}
void Benchmarks::setDimension(int inVal){
dimension = inVal;
}
void Benchmarks::setNonSeparableGroupSize(int inVal){
nonSeparableGroupSize = inVal;
}
Benchmarks::~Benchmarks(){
delete[] anotherz;
delete[] anotherz1;
delete[] anotherz2;
}
int Benchmarks::next(int bits) {
int64_t s;
int64_t result;
m_seed = s = (((m_seed * M) + A) & MASK);
result = (s >> (L(48 - bits)));
return((int)result);
}
int Benchmarks::nextInt(int n) {
int bits val;
if ((n & (-n)) == n) {
return((int) ((n * L(next(31))) >> L(31)));
}
do {
bits = next(31);
val = bits % n;
} while (bits - val + (n - 1) < 0);
return(val);
}
double Benchmarks::nextDouble(){
return ((((L(next(26))) <<
(L(27))) + (L(next(27)))) / (double) ((L(1)) << (L(53))));
}
double Benchmarks::nextGaussian(){
double multiplier v1 v2 s;
if (m_havenextGaussian) {
m_havenextGaussian = false;
return(m_nextGaussian) ;
}
do {
v1 = ((D(2.0) * nextDouble()) - D(1.0));
v2 = ((D(2.0) * nextDouble()) - D(1.0));
s = ((v1 * v1) + (v2 * v2));
} while ((s >= D(1.0)) || (s <= D(0.0)));
multiplier = sqrt(D(-2.0) * log(s) / s);
m_nextGaussian = (v2 * multiplier);
m_havenextGaussian = true;
return (v1 * multiplier);
}
double* Benchmarks::createShiftVector(int dim double mindouble max) {
double* d;
double hw middle;
double s;
int i;
hw = (D(0.5) * (max - min));
middle = (min + hw);
//d = (double*)malloc(sizeof(double) * dim);
d = new double[dim];
// printf(“middle = %1.20E\n“middle);
// printf(“hw = %1.20E\n“hw);
for (i = (dim - 1); i >= 0; i--) {
if (setOvectorToZero == true){
d[i] = 0;
}else{
do {
double tempGauss = nextGaussian();
s = (middle + (tempGauss * hw));
// printf(“nextGaussian = %1.20E\n“tempGauss);
/*
s = (middle + (nextGaussian() * hw));
*/
} while ((s < min) || (s > max));
d[i] = s;
// printf(“shift vector = %1.20E\n“ d[i]);
}
}
return(d);
}
int* Benchmarks::createPermVector(int dim){
int* d;
int i j k t;
//d = (int*)malloc(sizeof(int) * dim);
d = new int[dim];
for (i = (dim - 1); i >= 0; i--) {
d[i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-11-08 16:33 lsgo_benchmark\
目录 0 2011-10-28 14:20 lsgo_benchmark\C++ version\
文件 13911 2011-10-28 14:20 lsgo_benchmark\C++ version\Benchmarks.cpp
文件 2772 2011-10-28 14:20 lsgo_benchmark\C++ version\Benchmarks.h
文件 2202 2011-10-28 14:20 lsgo_benchmark\C++ version\demo.cpp
文件 1335 2011-10-28 14:20 lsgo_benchmark\C++ version\F1.cpp
文件 180 2011-10-28 14:20 lsgo_benchmark\C++ version\F1.h
文件 1784 2011-10-28 14:20 lsgo_benchmark\C++ version\F10.cpp
文件 197 2011-10-28 14:20 lsgo_benchmark\C++ version\F10.h
文件 1914 2011-10-28 14:20 lsgo_benchmark\C++ version\F11.cpp
文件 197 2011-10-28 14:20 lsgo_benchmark\C++ version\F11.h
文件 1545 2011-10-28 14:20 lsgo_benchmark\C++ version\F12.cpp
文件 197 2011-10-28 14:20 lsgo_benchmark\C++ version\F12.h
文件 1773 2011-10-28 14:20 lsgo_benchmark\C++ version\F13.cpp
文件 198 2011-10-28 14:20 lsgo_benchmark\C++ version\F13.h
文件 2960 2011-10-28 14:20 lsgo_benchmark\C++ version\F14.cpp
文件 228 2011-10-28 14:20 lsgo_benchmark\C++ version\F14.h
文件 2899 2011-10-28 14:20 lsgo_benchmark\C++ version\F15.cpp
文件 227 2011-10-28 14:20 lsgo_benchmark\C++ version\F15.h
文件 2894 2011-10-28 14:20 lsgo_benchmark\C++ version\F16.cpp
文件 228 2011-10-28 14:20 lsgo_benchmark\C++ version\F16.h
文件 2840 2011-10-28 14:20 lsgo_benchmark\C++ version\F17.cpp
文件 228 2011-10-28 14:20 lsgo_benchmark\C++ version\F17.h
文件 2716 2011-10-28 14:20 lsgo_benchmark\C++ version\F18.cpp
文件 228 2011-10-28 14:20 lsgo_benchmark\C++ version\F18.h
文件 1185 2011-10-28 14:20 lsgo_benchmark\C++ version\F19.cpp
文件 199 2011-10-28 14:20 lsgo_benchmark\C++ version\F19.h
文件 1210 2011-10-28 14:20 lsgo_benchmark\C++ version\F2.cpp
文件 193 2011-10-28 14:20 lsgo_benchmark\C++ version\F2.h
文件 1197 2011-10-28 14:20 lsgo_benchmark\C++ version\F20.cpp
文件 198 2011-10-28 14:20 lsgo_benchmark\C++ version\F20.h
............此处省略109个文件信息
评论
共有 条评论