chiark / gitweb /
autoconfiscated, and got to compile
[nlopt.git] / stogo / global.h
1 #ifndef GLOBAL_H
2 #define GLOBAL_H
3
4 #include <queue>
5 //#include "function.h"
6 #include "tools.h"
7 using namespace std;
8
9 typedef void dom(RTBox) ;
10 typedef dom* Pdom ;
11
12 typedef double obj(RCRVector) ;
13 typedef obj* Pobj ;
14
15 typedef void grad(RCRVector,RVector&) ;
16 typedef grad* Pgrad ;
17
18 typedef enum { OBJECTIVE_ONLY, GRADIENT_ONLY, OBJECTIVE_AND_GRADIENT } whichO;
19
20 typedef double objgrad(RCRVector,RCRVector,whichO) ;
21 typedef objgrad* Pobjgrad ;
22
23 class GlobalParams {
24 public:
25   long int maxtime, maxeval;
26   double eps_cl, mu, rshift;
27   int det_pnts, rnd_pnts;
28 };
29
30 class Global: public GlobalParams {
31 public:
32   // Problem specification
33   int dim ;
34   Pobj  Objective ;
35   Pgrad Gradient ;
36   long int numeval;
37
38   virtual double ObjectiveGradient(RCRVector xy, RVector&grad, whichO which){
39        ++numeval;
40        switch (which) {
41            case OBJECTIVE_AND_GRADIENT:
42                 Gradient(xy, grad);
43            case OBJECTIVE_ONLY:
44                 return Objective(xy);
45            case GRADIENT_ONLY:
46                 Gradient(xy, grad);
47        }
48        return 0.0;
49   }
50                                    
51   Global(RTBox, Pobj, Pgrad, GlobalParams);
52 //  Global& operator=(const Global &);
53
54   void Search(int, RCRVector);
55   void DispMinimizers();
56   double OneMinimizer(RCRVector);
57   bool NoMinimizers();
58   void SetDomain(RTBox);
59   void GetDomain(RTBox);
60   double GetMinValue();
61   void SetMinValue(double);
62   void ClearSolSet();
63   void AddPoint(RCRVector, double);
64
65   long int GetTime();
66   bool InTime();
67
68 private:
69   list<Trial> SolSet;
70   list<Trial>::const_iterator titr;
71   priority_queue<TBox> CandSet;
72   priority_queue<TBox> Garbage;
73
74   double fbound;
75   TBox Domain;
76
77   void FillRegular(RTBox, RTBox);
78   void FillRandom(RTBox, RTBox);
79   double NewtonTest(RTBox, int, RCRVector, int*);
80   void ReduceOrSubdivide(RTBox, int, RCRVector);
81 };
82 #endif
83