0

I've got the following numpy array b:

final_simplex: (array([[6.61602214e-02, 6.69343316e+07],
[6.61602040e-02, 6.69343227e+07],
[6.61601744e-02, 6.69343254e+07]]), array([9.31454751, 9.31454757, 9.31454764]))
fun: 9.314547514760456

message: 'Maximum number of iterations has been exceeded.'
nfev: 81
nit: 30
status: 2
success: False
x: array(\[6.61602214e-02, 6.69343316e+07\])

Now I would like to extract for example x and save it into a new variable. Like c = b.x, but I get an error message 'numpy.ndarray' object has no attribute 'x'. I dont know if it's important to know numpy.shape(b) gives ().

b has been created like this:

res= minimize(fun, x0,callback=callbackF, method='Nelder-Mead', bounds=bnds,  options={'disp': True,'maxiter': 30})

with open('loesung.pickle', 'wb') as handle:
    pickle.dump(res, handle, protocol=pickle.HIGHEST_PROTOCOL)
    
with open('loesung.pickle', 'rb') as handle:
    b = pickle.load(handle)

There was a similar question How to save scipy.optimize.OptimizeResult result object to a file in a pythonic way for easy access later? but I don't understand how the asking person made it work.

0 Answers0