-
Notifications
You must be signed in to change notification settings - Fork 1
/
hillclimbing.h
86 lines (65 loc) · 2.51 KB
/
hillclimbing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef HILLCLIMBING_H
#define HILLCLIMBING_H
#include "hmm.h"
#include "baumwelch.h"
#include <nlopt.hpp>
//Random search default values
#define MAX_ITERATIONS 10000
#define WINDOW_INT 4000
#define WINDOW_EXT 2000
#define WINDOW_LONGEXT 4000
#define MAX_WINDOW_SHRINKAGE 500
#define WINDOW_LERATE 0.2
#define DEFAULT_OPT_TOLERANCE 0.0001
enum{
IDX_STAY_INTERNAL = 0,
IDX_STAY_EXTERNAL,
IDX_STAY_LONG_INTERNAL,
IDX_LERATE
};
class hillClimbing
{
private:
nlopt::opt *mOpt;
obsSequence *mObsSequence;
modelProb *mModelProb;
modelProb *mModelProbTemp;
hmmResults *mHmmResults;
hmmResults *mHmmResultsTemp;
hmm *mHmm;
baumWelch *mBaumWelch;
double mConverThrld;
double mOptTolerance; //Tolerance de fin d'optimisation
const char* logFileName;
void optimisationBaumWelch(modelProb *model, hmmResults *results, int max_iteration);
public:
//hillClimbing();
hillClimbing(const char* sequenceFile, const char* configFile,
double lengthInternal, double lengthExternal,
double probFixDInternal, double probFixDExternal,
double externalUlindiDerivedProb);
hillClimbing(const char* sequenceFile, const char* configFile,
double lengthInternal, double lengthExternal,
double lengthLongExternal, double LongExternalrate,
double probFixDInternal, double probFixDExternal,
double externalUlindiDerivedProb);
~hillClimbing();
void setLogFileName(const char*);
void hmmOnly();
void hmmOnly3states();
//void randomSearch(int maxIteration);
//void randomSearch(int maxIteration, double windowInt, double windowExt);
void randomSearch( double converThrld, int maxIteration = MAX_ITERATIONS,
double windowInt = WINDOW_INT,
double windowExt = WINDOW_EXT,
double maxWindowShrinkage = MAX_WINDOW_SHRINKAGE);
void randomSearch3states( double converThrld, int maxIteration = MAX_ITERATIONS,
double windowInt = WINDOW_INT,
double windowExt = WINDOW_EXT,
double windowLongExt = WINDOW_LONGEXT,
double windowLErate = WINDOW_LERATE,
double maxWindowShrinkage = MAX_WINDOW_SHRINKAGE);
double nelderMeadSimplex(double converThrld);
double likelihoodFunction(const std::vector<double> &x, std::vector<double> &grad, void* f_data);
};
#endif // HILLCLIMBING_H