class_docstr: Test SLSQP algorithm using Example 14.4 from Numerical Methods for
  Engineers by Steven Chapra and Raymond Canale.
  This example maximizes the function f(x) = 2*x*y + 2*x - x**2 - 2*y**2,
  which has a maximum at x=2, y=1.
class_docstr_tok: ["Test","SLSQP","algorithm","using","Example","14.4","from","Numerical","Methods","for","Engineers","by","Steven","Chapra","and","Raymond","Canale",".","This","example","maximizes","the","function","f","(","x",")","=","2","*","x","*","y","+","2","*","x","-","x","*","*","2","-","2","*","y","*","*","2",",","which","has","a","maximum","at","x=2",",","y=1","."]
code: def test_nested_minimization(self):
      class NestedProblem:
          def __init__(self):
              self.F_outer_count = 0
  
          def F_outer(self, x):
              self.F_outer_count += 1
              if self.F_outer_count > 1000:
                  raise Exception(
                      "Nested minimization failed to terminate."
                  )
              inner_res = minimize(self.F_inner, (3, 4), method="SLSQP")
              assert_(inner_res.success)
              assert_allclose(inner_res.x, [1, 1])
              return x[0] ** 2 + x[1] ** 2 + x[2] ** 2
  
          def F_inner(self, x):
              return (x[0] - 1) ** 2 + (x[1] - 1) ** 2
  
          def solve(self):
              outer_res = minimize(
                  self.F_outer, (5, 5, 5), method="SLSQP"
              )
              assert_(outer_res.success)
              assert_allclose(outer_res.x, [0, 0, 0])
  
      problem = NestedProblem()
      problem.solve()
  
imports: from __future__ import division, print_function, absolute_import
  import pytest
  from numpy.testing import assert_, assert_array_almost_equal, assert_allclose, assert_equal
  from pytest import raises
  import numpy
  from scipy.optimize import fmin_slsqp, minimize, NonlinearConstraint, Bounds
label_desc: Use image node_id 44 for calling the TestSLSQP obj's underlying member method code with example usage: obj.test_nested_minimization() and returns: unknown, unknown