title: Error in defining the maximum function in gekko
body: <p>I am having problem in defining the max function in gekko-python.  </p>
  
  <p>The sum function is working fine but when I create another function just replacing sum with max then its throwing the following error:</p>
  
  <p>This is the description of the script i use (with the model, some data and the results)</p>
  
  <pre class="lang-py prettyprint-override"><code>#Model
  import numpy as np
  from gekko import GEKKO
  import numpy as np
  import pandas as pd
  from pandas import ExcelWriter
  from pandas import ExcelFile
  
  m = GEKKO()  # Initialize gekko
  m.options.SOLVER = 3  # IPOPT is an NLP solver
  m.options.MAX_ITER = 10000 # maximum number of iterations
  m.options.MAX_MEMORY = 6  # (2-10) memory allocation
  
  R_sect_bin = {'W1': {'S1': 1}, 'W2': {'S1': 1, 'S2': 1, 'S4': 1}, 'W3': {'S1': 1, 'S2': 1, 'S3': 1, 'S4': 1, 'S5': 1, 'S6': 1}, 'W4': {'S4': 1}, 'W5': {'S4': 1, 'S5': 1, 'S6': 1}, 'W6': {'S6': 1}}
  Input_Services_nonZero = {'S1': {'L1': 1, 'L3': 1}, 'S2': {'L2': 1}, 'S3': {'L4': 1}, 'S4': {'L1': 1}, 'S5': {'L3': 1}, 'S6': {'L1': 1, 'L2': 1}}
  
  V = {}
  for w in R_sect_bin:
      V[w] = {}
      for s in R_sect_bin[w]:
          V[w][s] = {}
          for l in Input_Services_nonZero[s]:
              V[w][s][l] = m.Var(value=10, lb=0, ub=100)
  
  #functions:
  sum_Vws1 = {}
  def VWS1():
      global sum_Vws1
      for w in R_sect_bin:
          sum_Vws1[w] = {}
          for s in R_sect_bin[w]:
              sum_Vws1[w][s] = m.Intermediate(sum([V[w][s][l] for l in Input_Services_nonZero[s]]))
      return sum_Vws1
  vws1 = VWS1()
  
  sum_Vws2 = {}
  def VWS2():
      global sum_Vws2
      for w in R_sect_bin:
          sum_Vws2[w] = {}
          for s in R_sect_bin[w]:
              sum_Vws2[w][s] = m.Intermediate(max([V[w][s][l] for l in Input_Services_nonZero[s]]))
      return sum_Vws2
  vws2 = VWS2()
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-225-b48377242060&gt; in &lt;module&gt;
       89             sum_Vws2[w][s] = m.Intermediate(max([V[w][s][l] for l in Input_Services_nonZero[s]]))
       90     return sum_Vws2
  ---&gt; 91 vws2 = VWS2()
       92 
       93 #sum_Vws = {}
  
  &lt;ipython-input-225-b48377242060&gt; in VWS2()
       87         sum_Vws2[w] = {}
       88         for s in R_sect_bin[w]:
  ---&gt; 89             sum_Vws2[w][s] = m.Intermediate(max([V[w][s][l] for l in Input_Services_nonZero[s]]))
       90     return sum_Vws2
       91 vws2 = VWS2()
  
  ~\Anaconda3\lib\site-packages\gekko\gk_operators.py in __len__(self)
       23         return self.name
       24     def __len__(self):
  ---&gt; 25         return len(self.value)
       26     def __getitem__(self,key):
       27         return self.value[key]
  
  ~\Anaconda3\lib\site-packages\gekko\gk_operators.py in __len__(self)
      132 
      133     def __len__(self):
  --&gt; 134         return len(self.value)
      135 
      136     def __getitem__(self,key):
  
  TypeError: object of type 'int' has no len()
  </code></pre>