Legofit
infers population history from nucleotide site patterns.
diffev.h
1#ifndef ARR_DIFFEV_H
2# define ARR_DIFFEV_H
3# define MAXPOP 500
4# define MAXDIM 35
5
6# include "typedefs.h"
7# include "state.h"
8# include <assert.h>
9# include <stdbool.h>
10# include <gsl/gsl_rng.h>
11
12typedef struct TaskArg TaskArg;
13typedef struct DiffEv DiffEv;
14typedef struct DiffEvPar DiffEvPar;
15typedef enum DEStatus DEStatus;
16
17// DE sets its status to Running on entry. If status still equals
18// Running on return, something is wrong.
19// On return, status should equal one of the following:
20// ReachedGoal: DE stopped because yspread <= ytol
21// FinishedIterations: DE stopped after completing all iterations
22// Interrupted: DE stopped on a signal (SIGINT or SIGTERM)
23enum DEStatus {ReachedGoal,
24 FinishedIterations,
25 Interrupted,
26 Running,
27 NoFinitePoints};
28
29struct DiffEvPar {
30 int dim, ptsPerDim, refresh, strategy, nthreads, verbose;
31 unsigned long seed;
32 double F, CR;
33 void *jobData;
34 SimSched *simSched;
35 double ytol; // stop when yspread <= ytol
36 void *(*JobData_dup) (const void *);
37 void (*JobData_free) (void *);
38 double (*objfun) (int dim, double x[dim], void *, void *);
39
40 // Set these equal to NULL unless you want each thread to maintain
41 // state variables, which are passed to each job. This is useful,
42 // for example, if you want to allocate a random number generator
43 // that is used sequentially by all jobs executed by a single
44 // thread.
45 void *threadData;
46 void *(*ThreadState_new) (void *);
47 void (*ThreadState_free) (void *);
48 State *state;
49 PointBuff *pb;
50};
51
52DEStatus diffev(int dim, double estimate[dim], double *loCost,
53 double *yspread, DiffEvPar dep, gsl_rng * rng);
54const char *diffEvStrategyLbl(int i);
55void sighandle(int signo);
56void handleSIGTERM(int signo);
57
58#endif
void sighandle(int signo)
Signal handler.
Definition: diffev.c:182
DEStatus diffev(int dim, double estimate[dim], double *loCost, double *yspread, DiffEvPar dep, gsl_rng *rng)
The diffev optimizer.
Definition: diffev.c:624
void handleSIGTERM(int signo)
SIGTERM is translated to SIGINT.
Definition: diffev.c:187
const char * diffEvStrategyLbl(int i)
Return a const pointer to the label of the i'th strategy.
Definition: diffev.c:503
Definition: diffev.h:29
Definition: pointbuff.c:23
Holds a linked list of Stages and a mutex lock.
Definition: simsched.c:37
Definition: state.c:57
Definition: diffev.c:91
Definition: tinyexpr.c:73