475 std::vector<CIndividual>
Ind;
555 CGA(std::string filename,
const T& model);
640 bool SetProperty(
const std::string &varname,
const std::string &value);
649 bool SetProperties(
const std::map<std::string,std::string> &arguments);
701 void Setminmax(
int a,
double minrange,
double maxrange,
int prec);
Genetic Algorithm optimizer for global parameter estimation.
double MaxFitness
Maximum fitness value in current population.
void fillfitdist()
Fill fitness distribution for roulette wheel selection.
bool SetProperty(const std::string &varname, const std::string &value)
Set GA property from string key-value pair.
std::vector< std::vector< int > > outcompare
Output comparison indices (legacy, may be unused)
std::vector< int > params
Parameter indices being optimized.
int maxfitness()
Find index of individual with maximum fitness.
T * Model
Pointer to the model being optimized.
void assignrank()
Assign ranks to individuals based on fitness.
int get_time_series(int i)
Get time series index for parameter.
double avg_actual_fitness()
Calculate average of actual (untransformed) fitness values.
void SetRunTimeWindow(ProgressWindow *_rtw)
Set progress window for GUI updates.
int optimize(int nGens, char DefOutPutFileName[])
Optimize for specified number of generations.
CGA(std::string filename, const T &model)
Constructor from configuration file and model.
std::vector< double > minval
Lower bounds for each parameter.
bool SetProperties(const std::map< std::string, std::string > &arguments)
Set multiple GA properties from map.
GA_Tweaking_parameters GA_params
GA algorithm configuration parameters.
std::vector< double > final_params
Final optimized parameter values.
void shake()
Apply shake/perturbation to population.
virtual ~CGA()
Destructor.
std::vector< CIndividual > Ind
Current population of individuals.
std::vector< int > to_ts
Time series index for each parameter (if applicable)
double sumfitness
Sum of all fitness values in current population.
GADistribution fitdist
Fitness distribution for parent selection.
CGA operator=(CGA &C)
Assignment operator.
std::vector< double > calc_output_percentiles
Percentiles to calculate for output distributions.
void setnumpop(int n)
Set population size.
double evaluateforward()
Evaluate model forward (compute predictions)
std::vector< std::string > paramname
Names of parameters being optimized.
void Setminmax(int a, double minrange, double maxrange, int prec)
Set parameter bounds and precision.
double avg_inv_actual_fitness()
Calculate average of inverse actual fitness.
void crossoverRC()
Real-coded crossover operation.
CGA()
Default constructor.
std::vector< T > Models
Copies of model for parallel fitness evaluation.
void assignfitnesses()
Evaluate fitness for all individuals in population.
void setnparams(int n)
Set number of parameters.
std::string last_error
Last error message from GA execution.
int current_generation
Current generation counter.
int optimize()
Main optimization loop.
T Model_out
Output model configured with best parameters.
std::vector< double > fixedinputvale
Fixed values for non-optimized parameters.
void getinifromoutput(std::string filename)
Initialize population from previous output file.
double stdfitness()
Calculate standard deviation of population fitness.
double evaluateforward_mixed(std::vector< double > v)
Evaluate model with mixed parameters.
int getparamno(int i, int ts)
Get parameter index for variable and time series.
void fitnessdistini()
Initialize fitness distribution for selection.
void mutate(double mu)
Apply mutation to population.
double Gradient_Descent(std::vector< double > inp)
Perform gradient descent local search.
std::vector< CIndividual > Ind_old
Previous generation's population.
void initialize()
Initialize GA structures and allocate memory.
void crossover()
Perform crossover operation on population.
std::vector< bool > apply_to_all
Flags indicating if parameter applies to all entities.
void getfromfile(char filename[])
Read population from file.
int numberOfThreads
Number of threads for parallel fitness evaluation.
std::vector< std::vector< double > > initial_pop
Initial population loaded from file.
std::vector< double > maxval
Upper bounds for each parameter.
double variancefitness()
Calculate variance of population fitness.
std::vector< int > loged
Flags indicating if parameters are log-transformed.
ProgressWindow * rtw
Pointer to progress window for GUI updates.
int get_act_paramno(int i)
Get active parameter number.
double getfromoutput(std::string filename)
Read best solution from previous output file.
void write_to_detailed_GA(std::string s)
Write detailed GA information to file.
void InitiatePopulation()
Create initial population.
void assignfitness_rank(double N)
Assign fitness using rank-based scheme.
void getinitialpop(std::string filename)
Read initial population from file.
double avgfitness()
Calculate average fitness of population.
void assignfixedvalues()
Assign fixed values to non-optimized parameters.
_filenames filenames
File paths for GA input/output.
Configuration parameters for Genetic Algorithm optimization.
int nGen
Number of generations to evolve.
bool RCGA
Use Real-Coded Genetic Algorithm.
char fitnesstype
Fitness function type identifier.
double shakescalered
Reduction factor for shake scale over generations.
int maxpop
Maximum population size (number of individuals)
int no_bins
Number of bins for fitness distribution.
int num_enh
Current enhancement iteration counter.
double pmute
Mutation probability per gene.
double shakescale
Scale factor for shake/perturbation operation.
bool sens_out
Output sensitivity analysis results.
int cross_over_type
Crossover operator type.
int totnumparams
Total number of parameters in the optimization problem.
int numenhancements
Number of enhancement iterations.
double N
Selection pressure parameter for rank-based selection.
bool Steepest_Descent
Apply steepest descent local search.
double exponentcoeff
Exponent coefficient for fitness scaling.
bool readfromgafile
Read initial population from file.
int nParam
Number of parameters (may be subset of totnumparams)
double pcross
Crossover probability.
File paths for Genetic Algorithm input/output operations.
std::string getfromfilename
Path to file for reading previous GA results.
std::string outputfilename
Path to main output file for GA results.
std::string initialpopfilemame
Path to file containing initial population.
std::string pathname
Directory path for output files.