title: Can not find Maximum value when use scipy optimize
body: <p>I've a problem when find a maximum value using below formula:</p>
  <p>Objective:
  TotalG = Sum(G1+G2+...+Gn)</p>
  <p>ColD (Max Value): D1, D2,..., Dn
  ColE (Min Value): E1, E2,..., En</p>
  <p>Constraints:
  E1 =&lt; G1 &lt;= D1
  E2 =&lt; G2 &lt;= D2
  ...
  En =&lt; Gn &lt;= Dn</p>
  <p>1.96* Sum((G1/totalG)^2 + (G2/totalG)^2 + ... + (Gn/totalG)^2) * totalG &lt;= 23000000000</p>
  <p>I try to run the solver function on Excel it will sugget total value maximum. However, i recieved a very small value when i used the scipy. Please use this file to run my example code
  <a href="https://github.com/scipy/scipy/files/7696745/solver.xlsx" rel="nofollow noreferrer">(example file)</a></p>
  <p>Reproducing Code Example</p>
  <pre><code>import numpy as np
  from scipy.optimize import minimize, NonlinearConstraint
  
  import cvxpy as cp
  import numpy as np
  import pandas as pd
  from pulp import *
  # import cvxopt
  # import mosek
  from helper import convert_excel
  import pandas as pd
  
  print(cp.installed_solvers())
  
  pathFile = 'testdata/solver.xlsx'
  dataFromExcel = convert_excel.handleDataFromExcel(pathFile, '', &quot;ABC&quot;)
  divNum = 1
  dicData = {}
  lengthData = 0
  listName = []
  for iData in dataFromExcel[&quot;data&quot;]:
      if iData[&quot;Historical EADi Min&quot;] is None or iData[&quot;Historical EADi Max&quot;] is None:
          continue
      else:
          listName.append(str(iData[&quot;Customer ID&quot;]))
      # if lengthData &gt; 2: continue
      lengthData+=1
      for key in iData:
          vData = iData[key]
          if key != 'Historical EADi Min' and key != 'Historical EADi Max':
              continue
          if key in dicData:
              listData = dicData[key]
          else:
              listData = []
          if vData is not None:
              listData.append(vData / divNum)
          dicData[key] = listData
  
  K4 = 23000000000 / divNum
  
  colE = np.array(dicData['Historical EADi Min']) # G &gt; E
  colD = np.array(dicData['Historical EADi Max']) # G &lt; D
  
  
  
  def objective(x):
      sumG =  sum(x)
      temp = sumG * -1
      return temp
  
  bnds = ()
  for i in range(lengthData):
      exx = colE[i]
      dxx = colD[i]
      bnds += ((exx, dxx),)
  
  def checkTotal(x):
      try:
          sumSquare = 0
          sumG = sum(x)
          listSquare = []
          for xi in x:
              div = xi / sumG  if sumG &gt; 0 else 0
              square = pow(div, 2)
              listSquare.append(square)
          sumSquare = sum(listSquare)
          # 1.96 * sumJ * sumG &lt;= K4
          afterMinus = K4 - sumSquare * 1.96 * sumG
          return afterMinus
      except Exception as e:
          print(e)
          return 0
  
  def checkX(x):
      totalCheck = 0
      for xi in x:
          totalCheck += xi % 1
      return totalCheck
      # =1.96*SUM(J2:J51)*SUM(G2:G51) &lt;= K4
      # J = (G/sumG)^2
      
  
      # return sum(x) - 30094995354
      #  30094995353
  
  
  # con0 = lambda x: x[1] - x[0]
  
  # nlc = NonlinearConstraint(con0, -np.inf, 2)
  x0 = np.zeros(lengthData)
  con1 = {'type': 'ineq', 'fun': checkTotal}
  con2 = {'type': 'eq', 'fun': checkX}
  cons = [con2, con1]
  sol = minimize(objective, x0, method='SLSQP', bounds = bnds, constraints = cons)
  
  print('SUM: ', sum(sol.x))
  
  df = pd.DataFrame({'colG': sol.x, 'colD': colD, 'colE': colE})
  df.to_excel(excel_writer = &quot;test.xlsx&quot;)
  print(&quot;END&quot;)
  </code></pre>