@@ -74,7 +74,7 @@ ScipyMinimizer::ScipyMinimizer() : BasicMinimizer()
7474 fOptions .SetMinimizerType (" Scipy" );
7575 fOptions .SetMinimizerAlgorithm (" L-BFGS-B" );
7676 PyInitialize ();
77- fHessianFunc = nullptr ;
77+ fHessianFunc = nullptr ;
7878 // set extra options
7979 SetAlgoExtraOptions ();
8080 fConstraintsList = PyList_New (0 );
@@ -239,13 +239,13 @@ bool ScipyMinimizer::Minimize()
239239
240240 if (GetVariableSettings (i, varsettings)) {
241241 if (varsettings.HasLowerLimit ()) {
242- foundBounds= true ;
242+ foundBounds = true ;
243243 PyList_SetItem (pylimits_lower, i, PyFloat_FromDouble (varsettings.LowerLimit ()));
244244 } else {
245245 PyList_SetItem (pylimits_lower, i, PyFloat_FromDouble (-NPY_INFINITY));
246246 }
247247 if (varsettings.HasUpperLimit ()) {
248- foundBounds= true ;
248+ foundBounds = true ;
249249 PyList_SetItem (pylimits_upper, i, PyFloat_FromDouble (varsettings.UpperLimit ()));
250250 } else {
251251 PyList_SetItem (pylimits_upper, i, PyFloat_FromDouble (NPY_INFINITY));
@@ -255,35 +255,32 @@ bool ScipyMinimizer::Minimize()
255255 }
256256 }
257257 PyObject *pybounds = Py_None;
258- if (foundBounds)
259- {
258+ if (foundBounds) {
260259 PyTuple_SetItem (pybounds_args, 0 , pylimits_lower);
261260 PyTuple_SetItem (pybounds_args, 1 , pylimits_upper);
262261 pybounds = PyObject_CallObject (fBoundsMod , pybounds_args);
263262 }
264-
263+
265264 // minimize(fun, x0, args=(), method=None, jac=None, hess=None, hessp=None, bounds=None, constraints=(), tol=None,
266265 // callback=None, options=None)
267266 PyObject *args = Py_BuildValue (" (OO)" , fTarget , x0);
268- PyObject *kw = Py_BuildValue (" {s:s,s:O,,s:O,s:O,s:O,s:d,s:O}" , " method" , method.c_str (), " jac" , fJacobian , " hess" ,
269- fHessian , " bounds" , pybounds," constraints" ,fConstraintsList , " tol" , Tolerance (),
270- " options" , pyoptions);
271- if (PrintLevel ()>0 )
272- {
273- std::cout<<" ========Minimizer Parameters========\n " ;
267+ PyObject *kw =
268+ Py_BuildValue (" {s:s,s:O,,s:O,s:O,s:O,s:d,s:O}" , " method" , method.c_str (), " jac" , fJacobian , " hess" , fHessian ,
269+ " bounds" , pybounds, " constraints" , fConstraintsList , " tol" , Tolerance (), " options" , pyoptions);
270+ if (PrintLevel () > 0 ) {
271+ std::cout << " ========Minimizer Parameters========\n " ;
274272 PyPrint (kw);
275- std::cout<< " ====================================\n " ;
273+ std::cout << " ====================================\n " ;
276274 }
277275 PyObject *result = PyObject_Call (fMinimize , args, kw);
278276 if (result == NULL ) {
279277 PyErr_Print ();
280278 return false ;
281279 }
282- if (PrintLevel ()>0 )
283- {
284- std::cout<<" ========Minimizer Results========\n " ;
280+ if (PrintLevel () > 0 ) {
281+ std::cout << " ========Minimizer Results========\n " ;
285282 PyPrint (result);
286- std::cout<< " =================================\n " ;
283+ std::cout << " =================================\n " ;
287284 }
288285 Py_DECREF (pybounds);
289286 Py_DECREF (args);
@@ -323,8 +320,10 @@ bool ScipyMinimizer::Minimize()
323320 std::cout << " === Status: " << status << std::endl;
324321 std::cout << " === Message: " << message << std::endl;
325322 std::cout << " === Function calls: " << nfev << std::endl;
326- if (success) fStatus =0 ;
327- else fStatus = status; // suggested by Lorenzo.
323+ if (success)
324+ fStatus = 0 ;
325+ else
326+ fStatus = status; // suggested by Lorenzo.
328327
329328 Py_DECREF (result);
330329 return success;
0 commit comments