GeneticAlgorithm::GeneticAlgorithm(double* dataSet, int dataSetLength, int nPopulation, double scaleFactor, double crossingProbability, int order, double xHL, double yHL, double zHL, double density, int nMissing){ totalTime = 0; // for timing things QueryPerformanceFrequency(&freq); _nPopulation = nPopulation; initializeRandomNumberGenerators(); _nMissing = nMissing; _order = order; _R = 3 * (order+1) * (order+2) * (order+3) / 6; _xHL = xHL; _yHL = yHL; _zHL = zHL; _density = density; _basisPop = new int[8]; for(int i = 0; i < 8; i++){ _basisPop[i] = 0; } _basis = createBasis(order, _basisPop); initialiseMatrices(); initializeParameters(dataSet, dataSetLength, nPopulation, scaleFactor, crossingProbability); }
bool redraw(bool bClear = true) { double minX,maxX,minY,maxY; double zeroX,zeroY; double lineWidth; if (!computeMinMax(minX,maxX,minY,maxY)) { cerr << "Could not compute the minmax" << endl; return false; } // lineWidth = 2.0*Utils::min(double(maxX-minX)/width(),double(maxY-minY)/height()); lineWidth = 1.0; zeroX = (-double(minX)*(width()-1.0)/(maxX-minX)); zeroY = (-double(minY)*(height()-1.0)/(maxY-minY)); int basis; basis=createBasis(zeroX,zeroY,(width()-1.0)/double(maxX-minX),(height()-1.0)/double(maxY-minY)); for (int i=0;i<mFunctions.size();i++) { Functions *f = &mFunctions[i]; Surface *surface = new Surface(*f->pFunction,f->minX,f->minY,f->maxX-f->minX,f->maxY-f->minY); addDrawable(basis,surface,false); } for (int i=0;i<mLines.size();i++) { for (int j=1;j<mLines[i].xs.size();j++) { Line *line = new Line(mLines[i].xs[j-1],mLines[i].ys[j-1],mLines[i].xs[j],mLines[i].ys[j],lineWidth); addDrawable(basis,line,false); } } for (int i=0;i<mRectangles.size();i++) { // Rectangle *rect = new Rectangle(mRectangles[i].x,mRectangles[i].y,mRectangles[i].w,mRectangles[i].h,lineWidth,mRectangles[i].color); // addDrawable(basis,rect,false); } if (bClear) clear(); flip(); return true; }