Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
RL_experience.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 @author: Peter Rakyta, Ph.D.
18 */
23 #ifndef RLEXPERIENCE_H
24 #define RLEXPERIENCE_H
25 
26 #include "matrix_real.h"
27 #include "Gates_block.h"
28 #include <map>
29 #include <cstdlib>
30 #include <time.h>
31 #include <ctime>
32 #include <random>
33 
34 
39 
40 
41 public:
42 
43  // learning rate of the RL_experience algorithm
44  double eta;
45 
46 
47 //protected:
48 
51 
52  // the number of iterations used during the training
53  unsigned long long iteration_num;
54 
57 
58  // array containing the probabilities of which parameter to choose in the next turn of the optimization. Element (i,j) means that after the i-th parameter the j-th parameter would be chosen with probability of A_ij.
60 
61 
64 
67 
70 
71 
72 
73  std::vector<int> history;
74 
75 
78 
79 
80 
81 public:
82 
87 
92 RL_experience( Gates_block* gates_in, unsigned long long iteration_num_in );
93 
99 RL_experience(const RL_experience& experience );
100 
106 int draw( const int& curent_index, std::mt19937& gen );
107 
108 
112 virtual ~RL_experience();
113 
114 
118 void reset();
119 
120 
126 RL_experience& operator= (const RL_experience& experience );
127 
128 
134 
138 void update_probs( );
139 
140 
141 void export_probabilities();
142 
143 
144 void import_probabilities();
145 
146 };
147 
148 
149 #endif //RL_experience
matrix_base< int > total_counts
total counts in one row of parameter_counts — reset when probabilites are updated ...
Definition: RL_experience.h:66
A class for RL_experience optimization according to https://towardsdatascience.com/how-to-implement-a...
Definition: RL_experience.h:38
void import_probabilities()
???????????
Matrix_real parameter_probs
Definition: RL_experience.h:59
int parameter_num
number of involved parameters
Definition: RL_experience.h:50
double exploration_rate
Definition: RL_experience.h:77
Header file for a class responsible for grouping gates into subcircuits. (Subcircuits can be nested) ...
std::vector< int > history
Definition: RL_experience.h:73
void reset()
?????????????
RL_experience copy()
Call to make a copy of the current instance.
RL_experience()
Nullary constructor of the class.
RL_experience & operator=(const RL_experience &experience)
Assignment operator.
matrix_base< unsigned long long > total_counts_probs
total counts used to evasluate one row in parameter_probs
Definition: RL_experience.h:69
Gates_block * gates
attribute stroing the gate structure
Definition: RL_experience.h:56
int draw(const int &curent_index, std::mt19937 &gen)
Call to draw the next index.
A class responsible for grouping two-qubit (CNOT,CZ,CH) and one-qubit gates into layers.
Definition: Gates_block.h:41
unsigned long long iteration_num
Definition: RL_experience.h:53
virtual ~RL_experience()
Destructor of the class.
void update_probs()
Call to update the trained probabilities and reset the counts.
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:39
void export_probabilities()
???????????
matrix_base< int > parameter_counts
array containing the counts of successive parameters used in the optimization. Element (i...
Definition: RL_experience.h:63