/* Multi Dimensional Global Search. Author: Steinn Gudmundsson Email: steinng@hotmail.com This program is supplied without any warranty whatsoever. NB The RNGs seed should be initialized using some timer */ #include #include #include #include #include #include "config.h" #include "global.h" #include "local.h" // Timer stuff time_t StartTime; double MacEpsilon ; int FC=0, GC=0;//, NSP = 0 ; Global::Global(RTBox D, Pobj o, Pgrad g, GlobalParams P): Domain(D) { dim=Domain.GetDim(); Objective=o; Gradient=g; // Initialize parameters maxtime=P.maxtime; eps_cl=P.eps_cl; mu=P.mu; rshift=P.rshift; det_pnts=P.det_pnts; rnd_pnts=P.rnd_pnts; fbound=DBL_MAX; } Global& Global::operator=(const Global &G) { // Copy the problem info and parameter settings Domain=G.Domain; Objective=G.Objective; Gradient=G.Gradient; maxtime=G.maxtime; eps_cl=G.eps_cl; mu=G.mu; rshift=G.rshift; det_pnts=G.det_pnts; rnd_pnts=G.rnd_pnts; return *this; } void Global::FillRegular(RTBox SampleBox, RTBox box) { // Generation of regular sampling points double w; int i, flag, dir; Trial tmpTrial(dim); RVector m(dim), x(dim); if (det_pnts>0) { // Add midpoint box.Midpoint(m) ; tmpTrial.xvals=m ; tmpTrial.objval=DBL_MAX ; SampleBox.AddTrial(tmpTrial) ; // Add the rest i=1 ; flag=1 ; dir=0 ; x=m ; w=box.Width(dir) ; while (i 2500 ) rnd_pnts = 1; tmpTrial.objval=DBL_MAX; for (int i=1 ; i<=rnd_pnts ; i++) { for (int dir=0 ; dir(cout)); } bool Global::NoMinimizers() { return SolSet.empty(); } void Global::ClearSolSet() { SolSet.erase(SolSet.begin(), SolSet.end()) ; } void Global::AddPoint(RCRVector x, double f) { Trial T(dim); T.xvals=x; T.objval=f; Domain.AddTrial(T); SolSet.push_back(T); }