This is a short question, but google points me every time to the documentation where I can’t find the answer.
I am using scipy.optimize.minimize. It works pretty good, all things are fine. I can define a method to use, but it works even if I don’t specify the method.
Is there any way to get an output, which method was used? I know the result class, but the method isn’t mentioned there.
Here’s an example:
solution = opt.minimize(functitionTOminimize,initialGuess, constraints=cons,options={'disp':True,'verbose':2}) print(solution)
I could set the value method to something like slsqp
or cobyla
, but I want to see what the program is choosing. How can I get this information?
Advertisement
Answer
According to the scipy-optimize-minimize-docs: If no method is specified the default choice will be one of BFGS, L-BFGS-B, SLSQP, depending on whether the problem has constraints or bounds. To get more details on the methods deployement’s order, you should take a look at the scipy-optimize-minimize-source-code-line-480. From the source code the order is the following:
if method is None: # Select automatically if constraints: method = 'SLSQP' elif bounds is not None: method = 'L-BFGS-B' else: method = 'BFGS'