PanPalitta / phase_estimation

This project apply reinforcement learning algorithms based on DE and PSO to optimize adaptive quantum-phase estimation.
http://panpalitta.github.io/phase_estimation/
GNU General Public License v3.0
9 stars 5 forks source link

Reorganize mpi_optalg #26

Closed peterwittek closed 8 years ago

peterwittek commented 8 years ago

Once #16 is closed, we need to reorganize the optimization classes a bit.

Move all of these functions to an aux_functions.cpp file, they have nothing to do with the class variables:

double rand_Gaussian(double mean, double dev);
void dev_gen(double *dev_array, double prev_dev, double new_dev, int cut_off);
int find_max(double *fit, int total_pop);
bool check_policy(double error, double sharp);//specific to phase estimation
//calculating linear regression
void linear_fit(int data_size, double *x, double *y, double *slope, double *intercept, double *mean_x);
double error_interval(double *x, double *y, double mean_x, int data_size, double *SSres, double slope, double intercept);
double error_update(int old_size, double *SSres, double *mean_x, double slope, double intercept, double *y, double *x);
//calculating quantile
double quantile(double p);
inline double inv_erf(double x);
inline int sgn(double x);

find_max is just an ordinary arg_max function, make it look like one.

These variables should be protected: int num, num_fit;

Create these new protected variables:

int my_rank, psize, int total_pop, int nb_proc

Initialize them in the constructor, which should pick them up from its parameters. Remove these variables from any other method's parameter list in every optimization class.

PanPalitta commented 8 years ago
  1. Functions that are involved in the accept reject criteria are now moved to aux_functions.cpp. However, there are still functions in optalg that call on some of those functions. I think we should try to untangle them further when we reorganize main.cpp.
  2. int my_rank, psize, int total_pop, int nb_proc are now protected variables in the class.
  3. int num, num_fit are now protected variables.
  4. find_max now have only one input variable: the fit array.