2D fiber alignment using the simplex algorithm

307 Views Asked by At

I have been writing some code for automatically aligning my fiber (whose X, Y, Z positions are controlled by a motor) to a light source. For this I have written my axis.move_to(pos) method to move an axis to a position, and a pm.meas_power() method to measure optical power from my power meter.

My goal is to find the optimal (Y, Z) position (X is not needed at this stage) to maximise the optical power. Now, the search area is quite big compared to the light spot size, so a simple gradient search would not help if I start in an area where only noise is found, so what I do is randomly move across the search area, and move to a hill climbing algorithm as soon as I find a power higher than a certain threshold.

Problem with this, is that it's quite inefficient. A first approach to optimisation would be to search for first light in a spiral rather than randomly, but computationally it does not really improve the number of steps.

I have come across, instead, the simplex algorithm, which supposedly yields much better results than hill climbing. I found out that scipy has a optimize.linprog() method which has a simplex algorithm, but it seems to me that this works for a 1D problem only.

I tried to read the documentation and write my own code, but I know little about optimisation so I was having a hard time really understanding how that works.

I was wondering whether you could help me write an algorithm given [ystart, zstart, yend, zend], i.e. the search area limits, and my two methods axis.move_to(pos) and pm.meas_power():

from labFunctions import PowerMeter, MotorAxis

pm = PowerMeter('pm_address')
yaxis = MotorAxis('y_address')
zaxis = MotorAxis('z_address')

limits = [ystart, zstart, yend, zend] # These can be formatted differently if needed
2

There are 2 best solutions below

2
On

Unfortunately, there are two very different Simplex methods:

1
On

I think your problem is physical and thus you are asking in the wrong forum. nevertheless, i will attempt an answer.

if you are trying to match the TEM00 mode of the laser, your algorithm of hill climbing after reaching a threshold power is a very good refinement strategy, since the power profile does not have any other maxima.

Concerning the random search, I think if you are unable to physically constrain the search space, you might as well do a random search on an equidistant grid with grid points about half the laser spot size.