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

Move functions that set boundaries to within problem object #13

Closed PanPalitta closed 8 years ago

PanPalitta commented 9 years ago

This problems arises because the first version of the code assume that the values we are optimizing over only have to fall within certain boundaries. There are cases such as the optimization of input state state that the values must also comply to the normalization condition. The current code does not allow us to use both condition without active rewriting some lines.

peterwittek commented 9 years ago

Could you pinpoint where this normalization condition is defined?

PanPalitta commented 9 years ago

The codes are currently in problem.h as Problem::modulo() and Problem::normalize(). We are only currently using modulo(). I think we should change it to one virtual function that points to the operation needed to bound the search space in the derived class.

peterwittek commented 9 years ago

I did a quick static code analysis and I support the idea of declaring these two functions as virtual. They are not performance critical.

PanPalitta commented 9 years ago

I have made this change and make the two function a virtual function called boundary in problem.h (which also eliminate the need for a problem.cpp). This change is currently in the pan-edit branch with the unit tested phase_loss_opt.since the class is tested but not refactored.

peterwittek commented 9 years ago

It might not be a good idea to declare the avg_fitness and fitness functions as virtual. I am concerned that declaring them as such will have an impact on the performance. Could you run some quick performance benchmarks to see if there is any difference? The boundary function is perfectly fine as virtual.