Evolutionary Algorithm for Adaptive Phase Estimation  1.0.2
Public Member Functions | Public Attributes | Protected Attributes | List of all members
OptAlg Class Reference

OptAlg class contains the functions that can be used to contruct an optimization algorithm in the main function. The object needs the pointer to the problem object and the RNG object in order to instantiate. More...

#include <mpi_optalg.h>

Inheritance diagram for OptAlg:
DE PSO

Public Member Functions

 OptAlg (Problem *problem_ptr, Rng *gaussian_rng, int pop_size)
 
virtual void put_to_best ()
 
virtual void combination ()
 
virtual void selection ()
 
virtual void write_param (double *param_array)
 
virtual void read_param (double *param_array)
 
virtual void fit_to_global ()
 
virtual void find_global ()
 
void Init_population (int psize)
 
void Init_previous (double prev_dev, double new_dev, int psize, double *prev_soln)
 
void Cont_fitness (int p)
 
void Best_fitness (int p)
 
void update_popfit ()
 
void set_success (int iter, bool goal)
 
bool check_success (int t, double *current_fitarray, double *memory_fitarray, int data_size, double t_goal, bool *mem_ptype, int *numvar, int N_cut, double *memory_forT)
 
double Final_select (double *fit, double *solution, double *fitarray)
 
double avg_Final_select (double *solution, int repeat, double *soln_fit, double *fitarray)
 
void dev_gen (double *dev_array, double prev_dev, double new_dev, int cut_off)
 
int find_max (double *fit)
 

Public Attributes

Problemprob
 
bool success
 
bool policy_type
 

Protected Attributes

int num
 
int num_fit
 
Rng * gaussian_rng
 
int pop_size
 
int T
 
int t
 
Candidatepop
 
bool goal
 
int total_pop
 
int my_rank
 
int nb_proc
 

Detailed Description

OptAlg class contains the functions that can be used to contruct an optimization algorithm in the main function. The object needs the pointer to the problem object and the RNG object in order to instantiate.

Member Function Documentation

◆ avg_Final_select()

double OptAlg::avg_Final_select ( double *  solution,
int  repeat,
double *  soln_fit,
double *  fitarray 
)

A function to compute the fitness function for 10 times and find the candidate with the highest fitness value in the population

Similar to Final_select(), the function finds the solution with the highest fitness in the population. But before doing so, the fitness values were computed for 10 times (the variable is repeat).

◆ Best_fitness()

void OptAlg::Best_fitness ( int  p)

A function to compute the fitness value of the solution in best array.

A fitness value of the best array is computed, and the mean fitness value is update.

◆ check_success()

bool OptAlg::check_success ( int  t,
double *  current_fitarray,
double *  memory_fitarray,
int  data_size,
double  t_goal,
bool *  mem_ptype,
int *  numvar,
int  N_cut,
double *  memory_forT 
)

A function for checking whether the current solution/iteration satisfied the accept condition.

The condition for stopping the optimization is checked. If the condition is based on the number of iterations, T_condition() is checked. This condition doesn't change t if the condition is not met, but it reverses numvar so that the optimization process restarts from the initialization. This function can take the memory from several numvar. If the condition is based on whether the fitness value met the error condition, error_condition() is called. This function takes the data from several numvar to generate the error condition according to t_goal.

◆ combination()

virtual void OptAlg::combination ( )
inlinevirtual

This function main purpose is to prepare the population for optimization after the population is initialized and the first calculation of the fitness function.

Reimplemented in PSO, and DE.

◆ Cont_fitness()

void OptAlg::Cont_fitness ( int  p)

A function to compute the fitness value of the solution in contender array.

The mean fitness value of a contender are computed for 2 samples. The number of samples is currently fixed.

◆ dev_gen()

void OptAlg::dev_gen ( double *  dev_array,
double  prev_dev,
double  new_dev,
int  cut_off 
)

A function for generating the array that indicates the width of the Gaussian distribution for each of the variable. This array is used by Init_previous().

◆ Final_select()

double OptAlg::Final_select ( double *  fit,
double *  solution,
double *  fitarray 
)

A function to find the candidate with the highest fitness value in the population.

The fitness values are sent to the zeroth processor, where the candidate with the highest fitness value. A copy of that candidate to other processors.

◆ find_global()

virtual void OptAlg::find_global ( )
inlinevirtual

This function copies memories on best array to global array.

Reimplemented in PSO, and DE.

◆ find_max()

int OptAlg::find_max ( double *  fit)

A function to find the candidate that has the highet fitness value (for only one of the many fitness values that a candidate posseses).

◆ fit_to_global()

virtual void OptAlg::fit_to_global ( )
inlinevirtual

This function reads the search parameters that are currently in use.

Reimplemented in PSO, and DE.

◆ Init_population()

void OptAlg::Init_population ( int  psize)

A function to initialize the population using a uniform probability distribution.

This function first initialize a group of candidates for a processor uniformly over the search space. The function then compute the fitness values for each.

◆ Init_previous()

void OptAlg::Init_previous ( double  prev_dev,
double  new_dev,
int  psize,
double *  prev_soln 
)

A function to initialize the population using the solution from N-1 variables.

This function first initialize a group of candidates for a processor from a previous solution. The function then compute the fitness values for each.

◆ read_param()

virtual void OptAlg::read_param ( double *  param_array)
inlinevirtual

This function let the user specify new values to the search parameters.

Reimplemented in PSO, and DE.

◆ selection()

virtual void OptAlg::selection ( )
inlinevirtual

This function generates new candidates that competes with the existing population. This is one potential bottleneck in the communication between processors.

Reimplemented in PSO, and DE.

◆ set_success()

void OptAlg::set_success ( int  iter,
bool  goal 
)

A function to set the condition for which the optimization algorithm would accept the solution and stop.

◆ update_popfit()

void OptAlg::update_popfit ( )

A function to compute the fitness value of the solution in best array and update the mean fitness value.

The mean fitness values of the population on a processor are updated.

◆ write_param()

virtual void OptAlg::write_param ( double *  param_array)
inlinevirtual

This function performs selects the candidates for the next round of iteration.

Reimplemented in PSO, and DE.

Member Data Documentation

◆ gaussian_rng

Rng* OptAlg::gaussian_rng
protected

RNG object pointer

◆ goal

bool OptAlg::goal
protected

The variables indicating whether an accept-reject criteria is used.

◆ my_rank

int OptAlg::my_rank
protected

Variable for MPI

◆ nb_proc

int OptAlg::nb_proc
protected

Variables for MPI

◆ num

int OptAlg::num
protected

Number of variables

◆ num_fit

int OptAlg::num_fit
protected

Number of fitness values

◆ policy_type

bool OptAlg::policy_type

Variable for indicating whether the policy can be used.

◆ pop

Candidate* OptAlg::pop
protected

Pointer to population.

◆ pop_size

int OptAlg::pop_size
protected

The number of candidates on a processor.

◆ prob

Problem* OptAlg::prob

This function finds global best solution within a subset of the population and copy it to the global array.

◆ success

bool OptAlg::success

Variable for indicating whether a solution is accepted.

◆ T

int OptAlg::T
protected

The goal in number of iteration.

◆ t

int OptAlg::t
protected

Time variables

◆ total_pop

int OptAlg::total_pop
protected

The total number of candidates in the population.


The documentation for this class was generated from the following files: