Open Ulfgard opened 3 years ago
In the meanrtime, i have run the comparisons using the following code in run.py:
def func_to_minimize(x):
global fevals
# new_point ensures points are valid within bounds and constraints.
x_projected,penalty=new_point(x,bounds=bounds)
result=[]
for avg_gates in common_voltages:
QPC.set_all_pixels(x_projected+avg_gates)
result.append(QPC.transmission())
def deriv_metric(staircase):
res = 0
for i in range(len(staircase) - 1):
res += np.sqrt(np.abs(staircase[i+1] - staircase[i]))
res /= np.sqrt(np.max(staircase) - np.min(staircase))
return res
metric = deriv_metric(result)
# metric = stairs.histogram(result)
return pfactor*penalty+metric
comparison. old result:
new result:
That looks good to me, seems smoother with flatter plateaus indeed. Just a quick point: we want the plateaus to be at integer values (though that does not guarantee we are seeing QPC physics).
Is it physically possible to have the plateaus on non-integer values? Or is this an issue in the simulation? We could try to inverse x/y axis and put more weight near the integer positions to make this happen.
i have tried putting more emphasis on the dervatives around y=1,2,3... it changed it a little bit, but not so much. I did it by adding weight terms depending on the y-values:
def weighted_deriv_metric(staircase):
res = 0
sumw = 0
for i in range(len(staircase) - 1):
y= (staircase[i+1] + staircase[i])/2
wi = 1+np.cos(2*np.pi*y)
sumw +=wi
res += wi* np.sqrt(np.abs(staircase[i+1] - staircase[i]))
res /= np.sqrt(np.max(staircase) - np.min(staircase)) * sumw
return res
Finally, i tried some approach which is similar to what you tried. I am mapping the y-values to the 0-1 interval by subtracrting the next integer (rounding down) from it. then the optimal stair should be the solution that maximizes the variance of the mapped values (producing either value s0 or 1 which would be the values of the nearest plateaus on both sides)
def var_metric(staircase):
data=np.fmod(staircase,1)
var=np.var(data)
return 1/var
result is pretty similar to what you have gotten:
We still might need to put some work into finding a good metric and do a proper comparison.
From Teams: