00001 /******************************************************************************************************** 00002 00003 Copyright (C) 2008 Deepak Chandran 00004 contact: dchandran1@gmail.com 00005 00006 This file uses genetic algorithm optimization method to find parameters for a system of ODE such 00007 that the ODE system will have two or more stable states. 00008 00009 The objective function tries to find a saddle or unstable point in the ODE system by doing 00010 reverse time or partial-reverse time simulation. Once a saddle or unstable point is found, the algorithm 00011 solves the IVP problem starting around the unstable or saddle point, hoping to reach two stable points. 00012 00013 The unstable or saddle points are found by optimizing: 00014 00015 p (parameters of the system) and a (vector of reals) 00016 00017 where the ODE system is: 00018 00019 dx/dt = a * f(x,p) 00020 00021 where f(x,p) is the original system defined by the user. 00022 The alpha vector alters the stability of the critical points, allowing the algorithm to search 00023 for saddle points of the original system by searching for stable points of this new transformed system. 00024 00025 00026 *********************************************************************************************************/ 00027 00028 #ifndef GA_BISTABLE_H 00029 #define GA_BISTABLE_H 00030 00031 #include <stdlib.h> 00032 #include <stdio.h> 00033 #include <math.h> 00034 #include "cvodesim.h" 00035 #include "mtrand.h" 00036 #include "ga.h" 00037 00041 typedef struct 00042 { 00043 int numVars; //number of odes 00044 int numParams; //number of parameters 00045 double *params; //parameters of the model 00046 double *alphas; //coefficients for ode (part of optimization algorithm) 00047 } 00048 Parameters; 00049 00053 typedef struct 00054 { 00055 Parameters * param; //the parameters that make the system bistable 00056 double * unstable; //the unstable point 00057 double * stable1; //first stable point 00058 double * stable2; //second stable point 00059 } BistablePoint; 00060 00061 #define randnum (mtrand() * 1.0) 00062 00073 BistablePoint makeBistable(int n, int p,double* iv, int maxiter, int popsz, void (*odefnc)(double,double*,double*,void*)); 00074 00075 #endif