I'm trying to run a basin-hopping simulation 3 times and save each tuple of x and f(x) into an array of 1x2, below code is my best attempt so far. I don't need detailed information on results, just tuples in numbers, how can I get such an array in a way that I can also use them for further process (select the minimum of different runs for example)
from math import *
from math import ceil
from math import floor
import time
from decimal import *
import numpy as np
from scipy.optimize import basinhopping
minimizer_kwargs = {"method": "BFGS"}
def f(x):
b = 5306246123
estimator1=(sqrt(b)+x[0])
estimator2=(sqrt(b)+x[1])
d=abs(estimator1*estimator2-b)
return d
b = 5306246123
results = []
for x in range(3): results.append(basinhopping(f, [1,1], minimizer_kwargs=minimizer_kwargs,
niter=1000, stepsize=sqrt(sqrt(b))))
print(results)
part of (1/3) example output (I only need -6403.48941568, 7020.65333737 and 2 other instance of this tuple for example):
[ fun: 2.86102294921875e-06
lowest_optimization_result: fun: 2.86102294921875e-06
hess_inv: array([[ 0.13347587, -0.13347587],
[-0.13347587, 0.13347587]])
jac: array([ 79872., 66432.])
message: 'Desired error not necessarily achieved due to precision loss.'
nfev: 463
nit: 2
njev: 113
status: 2
success: False
x: array([-6403.48941568, 7020.65333737])
message: ['requested number of basinhopping iterations completed successfully']