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_inconsistent_linearization(self):
      # SLSQP must be able to solve this problem, even if the
      # linearized problem at the starting point is infeasible.
  
      # Linearized constraints are
      #
      #    2*x0[0]*x[0] >= 1
      #
      # At x0 = [0, 1], the second constraint is clearly infeasible.
      # This triggers a call with n2==1 in the LSQ subroutine.
      x = [0, 1]
      f1 = lambda x: x[0] + x[1] - 2
      f2 = lambda x: x[0] ** 2 - 1
      sol = minimize(
          lambda x: x[0] ** 2 + x[1] ** 2,
          x,
          constraints=(
              {"type": "eq", "fun": f1},
              {"type": "ineq", "fun": f2},
          ),
          bounds=((0, None), (0, None)),
          method="SLSQP",
      )
      x = sol.x
  
      assert_allclose(f1(x), 0, atol=1e-8)
      assert_(f2(x) >= -1e-8)
      assert_(sol.success, sol)
  
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 36 for calling the TestSLSQP obj's underlying member method code with example usage: obj.test_inconsistent_linearization() without return types