class_docstr: Tree structure to model a search space.
  
  Fairly elaborate unit test.
  
  >>> space = {'a': {'b0': {'c0': {'d0': {'e0': [0, 10], 'e1': [-2, -1]},
  ...                              'd1': {'e2': [-3, -1]},
  ...                              'd2': None
  ...                              },
  ...                       'c1': [0.0, 1.0],
  ...                      },
  ...                'b1': {'c2': [-2.0, -1.0]},
  ...                'b2': None
  ...               }
  ...          }
  >>> tree = SearchTree(space)
  >>> b = tree.to_box()
  >>> print(b['a'] == [0.0, 3.0] and
  ...       b['a|b0|c0'] == [0.0, 3.0] and
  ...       b['a|b0|c1'] == [0.0, 1.0] and
  ...       b['a|b1|c2'] == [-2.0, -1.0] and
  ...       b['a|b0|c0|d0|e0'] == [0, 10] and
  ...       b['a|b0|c0|d0|e1'] == [-2, -1] and
  ...       b['a|b0|c0|d1|e2'] == [-3, -1])
  True
  
  >>> d = tree.decode({'a': 2.5})
  >>> d['a'] == 'b2'
  True
  
  >>> d = tree.decode({'a': 1.5, 'a|b1|c2': -1.5})
  >>> print(d['a'] == 'b1' and
  ...       d['c2'] == -1.5)
  True
  
  >>> d = tree.decode({'a': 0.5, 'a|b0|c0': 1.7, 'a|b0|c0|d1|e2': -1.2})
  >>> print(d['a'] == 'b0' and
  ...       d['c0'] == 'd1' and
  ...       d['e2'] == -1.2)
  True
  
  >>> d = tree.decode({'a': 0.5, 'a|b0|c0': 2.7})
  >>> print(d['a'] == 'b0' and
  ...       d['c0'] == 'd2')
  True
  
  >>> d = tree.decode({'a': 0.5, 'a|b0|c0': 0.7, 'a|b0|c0|d0|e0': 2.3, 'a|b0|c0|d0|e1': -1.5})
  >>> print(d['a'] == 'b0' and
  ...       d['c0'] == 'd0' and
  ...       d['e0'] == 2.3 and
  ...       d['e1'] == -1.5)
  True
class_docstr_tok: ["Tree","structure","to","model","a","search","space",".","Fairly","elaborate","unit","test",".",">",">",">","space","=","{","'","a","'",":","{","'b0","'",":","{","'c0","'",":","{","'d0","'",":","{","'e0","'",":","[","0",",","10","]",",","'e1","'",":","[","-2",",","-1","]","}",",","...","'d1","'",":","{","'e2","'",":","[","-3",",","-1","]","}",",","...","'d2","'",":","None","...","}",",","...","'c1","'",":","[","0.0",",","1.0","]",",","...","}",",","...","'b1","'",":","{","'c2","'",":","[","-2.0",",","-1.0","]","}",",","...","'b2","'",":","None","...","}","...","}",">",">",">","tree","=","SearchTree","(","space",")",">",">",">","b","=","tree.to_box","(",")",">",">",">","print","(","b","[","'","a","'","]","==","[","0.0",",","3.0","]","and","...","b","[","'","a|b0|c0","'","]","==","[","0.0",",","3.0","]","and","...","b","[","'","a|b0|c1","'","]","==","[","0.0",",","1.0","]","and","...","b","[","'","a|b1|c2","'","]","==","[","-2.0",",","-1.0","]","and","...","b","[","'","a|b0|c0|d0|e0","'","]","==","[","0",",","10","]","and","...","b","[","'","a|b0|c0|d0|e1","'","]","==","[","-2",",","-1","]","and","...","b","[","'","a|b0|c0|d1|e2","'","]","==","[","-3",",","-1","]",")","True",">",">",">","d","=","tree.decode","(","{","'","a","'",":","2.5","}",")",">",">",">","d","[","'","a","'","]","==","'b2'","True",">",">",">","d","=","tree.decode","(","{","'","a","'",":","1.5",",","'","a|b1|c2","'",":","-1.5","}",")",">",">",">","print","(","d","[","'","a","'","]","==","'b1","'","and","...","d","[","'c2","'","]","==","-1.5",")","True",">",">",">","d","=","tree.decode","(","{","'","a","'",":","0.5",",","'","a|b0|c0","'",":","1.7",",","'","a|b0|c0|d1|e2","'",":","-1.2","}",")",">",">",">","print","(","d","[","'","a","'","]","==","'b0","'","and","...","d","[","'c0","'","]","==","'d1","'","and","...","d","[","'e2","'","]","==","-1.2",")","True",">",">",">","d","=","tree.decode","(","{","'","a","'",":","0.5",",","'","a|b0|c0","'",":","2.7","}",")",">",">",">","print","(","d","[","'","a","'","]","==","'b0","'","and","...","d","[","'c0","'","]","==","'d2","'",")","True",">",">",">","d","=","tree.decode","(","{","'","a","'",":","0.5",",","'","a|b0|c0","'",":","0.7",",","'","a|b0|c0|d0|e0","'",":","2.3",",","'","a|b0|c0|d0|e1","'",":","-1.5","}",")",">",">",">","print","(","d","[","'","a","'","]","==","'b0","'","and","...","d","[","'c0","'","]","==","'d0","'","and","...","d","[","'e0","'","]","==","2.3","and","...","d","[","'e1","'","]","==","-1.5",")","True"]
docstr: Creates a set of box constraints to define the given search space.
  
  :returns: a set of box constraints (e.g. dictionary, with box constraint values)
  
  Use these box constraints to initialize a solver, which will then implicitly work in the
  vector representation of the search space.
  
  To evaluate such vector representations, decorate the objective function with :func:`optunity.search_spaces.SearchTree.decode`
  of the same object.
docstr_tok: ["Creates","a","set","of","box","constraints","to","define","the","given","search","space",".",":","returns",":","a","set","of","box","constraints","(","e.g",".","dictionary",",","with","box","constraint","values",")","Use","these","box","constraints","to","initialize","a","solver",",","which","will","then","implicitly","work","in","the","vector","representation","of","the","search","space",".","To","evaluate","such","vector","representations",",","decorate","the","objective","function","with",":","func",":","`","optunity.search_spaces.SearchTree.decode","`","of","the","same","object","."]
code: def to_box(self):
      """
      Creates a set of box constraints to define the given search space.
  
      :returns: a set of box constraints (e.g. dictionary, with box constraint values)
  
      Use these box constraints to initialize a solver, which will then implicitly work in the
      vector representation of the search space.
  
      To evaluate such vector representations, decorate the objective function with :func:`optunity.search_spaces.SearchTree.decode`
      of the same object.
  
      """
      if not self.vectordict:
          for k, v in self:
              if type(k) is list:
                  key = DELIM.join(k)
              else:
                  key = k
              if type(v) is Options:
                  if (
                      len(v) > 1
                  ):  # options of length one aren't really options
                      self.vectordict[key] = [0.0, float(len(v))]
                      self.vectorcontent[key] = v
              elif v is None:
                  pass
              else:
                  self.vectordict[key] = v
                  self.vectorcontent[key] = v
  
      return dict([(k, v) for k, v in self.vectordict.items()])
  
imports: import functools
  import itertools
  import collections
  import math
label_desc: Use image node_id 6 for calling the SearchTree obj's underlying member method code with example usage: obj.to_box() and returns: dict