Evolutionary Algorithm for Adaptive Phase Estimation  1.0.2
phase_loss_opt.h
1 #ifndef PHASE_LOSS_H
2 #define PHASE_LOSS_H
3 
4 #include <complex>
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 
9 #define DEV_N 0.0 //level of noise in operator
10 //Normal and Hat noise parameters
11 #define THETA_DEV 1.41421356237//M_PI;//phase noise level
12 //RTN parameter
13 #define Ps 0.5 //probability of telegraph noise
14 //SND parameter
15 #define RATIO 1.176959769 //ratio between alpha and sigma
16 //Lognormal parameters
17 #define MU 2.2214//variance
18 #define THETA 0.2715 //skewness, variance
19 
20 
21 #include "problem.h"
22 #include "rng.h"
23 #include "aux_functions.h"
24 
25 typedef complex<double> dcmplx;
26 
33 class Phase: public Problem {
34  public:
35  Phase(const int numvar, Rng *gaussian_rng, Rng *uniform_rng);
36  ~Phase();
37 
38  void fitness(double *soln, double *fitarray);
39  void avg_fitness(double *soln, const int K, double *fitarray);
40  bool T_condition(double *fitarray, int *numvar, int N_cut, bool *mem_ptype, double *memory_forT);
41  bool error_condition(double *current_fitarray, double *memory_fitarray, int data_size, double goal);
42  void boundary(double *can1);
43 
44  private:
45  double lower; //The lower bound of the variables
46  double upper; //The upper bound of the variables
47  double loss; //The photon loss rate
48 
49  Rng *gaussian_rng, *uniform_rng;
50 
51  //variables for WK state generation
52  dcmplx *input_state; //The array containing the WK state
53  double *sqrtfac_mat; //matrix to keep values of square roots of factorials
54  double *overfac_mat; //matrix to keep values of one over factorials
55  double *sqrt_cache; //array to avoid calculation of expensive sqrt calls for integers
56  double tan_beta;
57 
58  dcmplx *state; //state for use with measurement
59  dcmplx *update0; //variables for noise_output function
60  dcmplx *update1;
61 
62  //functions to generate WK_state
63  inline void sqrtfac(double *fac_mat); //A function for calculating square root of factorials for state generation.
64  inline void one_over_fac(double *over_mat); //A function for calculating one over square root of factorials for state generation.
65  inline double cal_spart(const int n, const int k, const int N);//N is the same as total number of photon 'num'.
66  void WK_state(); //A funtion generating the WK state
67  //Measurement functions
68  inline bool noise_outcome(const double phi, const double PHI, const int N); //A function for simulating a photon going through a noisy Mach-Zehnder interferometer.
69  inline void state_loss(const int N); //A function for simulating state change under loss of a photon.
70  inline double mod_2PI(double PHI); //A function to perform modulo 2PI on phase.
71 
72  bool check_policy(double error, double sharp); //A function for checking whether the policy is resilient to loss. This is called by the T_condition().
73 
74  double rand_Gaussian(double mean, double dev);
75  double rand_Hat(double PHI, double dev);
76  //lognormal-distribution noise
77  inline double inv_erf(double x);
78  inline int sgn(double x);
79  double Lognormal(double mu, double sigma, double peak);
80  //Random telegraph noise
81  double rand_RTN(double PHI,double ps,double dev);
82  //Skewed normal noise
83  double rand_skewed(double mean, double dev, double ratio);
84 
85  };
86 #endif // PHASE_H
Phase class for the problem of adaptive interferometric phase estimation including noise and loss.
Definition: phase_loss_opt.h:33
Problem class contains the prototype of the functions in the optimization problem that OptAlg class n...
Definition: problem.h:9
Phase(const int numvar, Rng *gaussian_rng, Rng *uniform_rng)
Definition: phase_loss_opt.cpp:10