class_docstr: Class to handle the input domain of the function.
  The format of a input domain, possibly with restrictions:
  The domain is defined as a list of dictionaries contains a list of attributes, e.g.:
  
  - Arm bandit
  space  =[{'name': 'var_1', 'type': 'bandit', 'domain': [(-1,1),(1,0),(0,1)]},
           {'name': 'var_2', 'type': 'bandit', 'domain': [(-1,4),(0,0),(1,2)]}]
  
  - Continuous domain
  space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionality':1},
           {'name': 'var_2', 'type': 'continuous', 'domain':(-3,1), 'dimensionality':2},
           {'name': 'var_3', 'type': 'bandit', 'domain': [(-1,1),(1,0),(0,1)], 'dimensionality':2},
           {'name': 'var_4', 'type': 'bandit', 'domain': [(-1,4),(0,0),(1,2)]},
           {'name': 'var_5', 'type': 'discrete', 'domain': (0,1,2,3)}]
  
  - Discrete domain
  space =[ {'name': 'var_3', 'type': 'discrete', 'domain': (0,1,2,3)}]
           {'name': 'var_3', 'type': 'discrete', 'domain': (-10,10)}]
  
  
  - Mixed domain
  space =[{'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionality' :1},
          {'name': 'var_4', 'type': 'continuous', 'domain':(-3,1), 'dimensionality' :2},
          {'name': 'var_3', 'type': 'discrete', 'domain': (0,1,2,3)}]
  
  Restrictions can be added to the problem. Each restriction is of the form c(x) <= 0 where c(x) is a function of
  the input variables previously defined in the space. Restrictions should be written as a list
  of dictionaries. For instance, this is an example of an space coupled with a constraint
  
  space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionality' :2}]
  constraints = [ {'name': 'const_1', 'constraint': 'x[:,0]**2 + x[:,1]**2 - 1'}]
  
  If no constraints are provided the hypercube determined by the bounds constraints are used.
  
  Note about the internal representation of the vatiables: for variables in which the dimaensionality
  has been specified in the domain, a subindex is internally asigned. For instance if the variables
  is called 'var1' and has dimensionality 3, the first three positions in the internal representation
  of the domain will be occupied by variables 'var1_1', 'var1_2' and 'var1_3'. If no dimensionality
  is added, the internal naming remains the same. For instance, in the example above 'var3'
  should be fixed its original name.
  
  
  
  param space: list of dictionaries as indicated above.
  param constraints: list of dictionaries as indicated above (default, none)
class_docstr_tok: ["Class","to","handle","the","input","domain","of","the","function",".","The","format","of","a","input","domain",",","possibly","with","restrictions",":","The","domain","is","defined","as","a","list","of","dictionaries","contains","a","list","of","attributes",",","e.g",".",":","-","Arm","bandit","space","=","[","{","'name","'",":","'var_1","'",",","'type","'",":","'bandit","'",",","'domain","'",":","[","(","-1,1",")",",","(","1,0",")",",","(","0,1",")","]","}",",","{","'name","'",":","'var_2","'",",","'type","'",":","'bandit","'",",","'domain","'",":","[","(","-1,4",")",",","(","0,0",")",",","(","1,2",")","]","}","]","-","Continuous","domain","space","=","[","{","'name","'",":","'var_1","'",",","'type","'",":","'continuous","'",",","'domain","'",":","(","-1,1",")",",","'dimensionality':1","}",",","{","'name","'",":","'var_2","'",",","'type","'",":","'continuous","'",",","'domain","'",":","(","-3,1",")",",","'dimensionality':2","}",",","{","'name","'",":","'var_3","'",",","'type","'",":","'bandit","'",",","'domain","'",":","[","(","-1,1",")",",","(","1,0",")",",","(","0,1",")","]",",","'dimensionality':2","}",",","{","'name","'",":","'var_4","'",",","'type","'",":","'bandit","'",",","'domain","'",":","[","(","-1,4",")",",","(","0,0",")",",","(","1,2",")","]","}",",","{","'name","'",":","'var_5","'",",","'type","'",":","'discrete","'",",","'domain","'",":","(","0,1,2,3",")","}","]","-","Discrete","domain","space","=","[","{","'name","'",":","'var_3","'",",","'type","'",":","'discrete","'",",","'domain","'",":","(","0,1,2,3",")","}","]","{","'name","'",":","'var_3","'",",","'type","'",":","'discrete","'",",","'domain","'",":","(","-10,10",")","}","]","-","Mixed","domain","space","=","[","{","'name","'",":","'var_1","'",",","'type","'",":","'continuous","'",",","'domain","'",":","(","-1,1",")",",","'dimensionality","'",":1","}",",","{","'name","'",":","'var_4","'",",","'type","'",":","'continuous","'",",","'domain","'",":","(","-3,1",")",",","'dimensionality","'",":2","}",",","{","'name","'",":","'var_3","'",",","'type","'",":","'discrete","'",",","'domain","'",":","(","0,1,2,3",")","}","]","Restrictions","can","be","added","to","the","problem",".","Each","restriction","is","of","the","form","c","(","x",")","<","=","0","where","c","(","x",")","is","a","function","of","the","input","variables","previously","defined","in","the","space",".","Restrictions","should","be","written","as","a","list","of","dictionaries",".","For","instance",",","this","is","an","example","of","an","space","coupled","with","a","constraint","space","=","[","{","'name","'",":","'var_1","'",",","'type","'",":","'continuous","'",",","'domain","'",":","(","-1,1",")",",","'dimensionality","'",":2","}","]","constraints","=","[","{","'name","'",":","'const_1","'",",","'constraint","'",":","'","x","[",":",",0","]","*","*","2","+","x","[",":",",1","]","*","*","2","-","1","'","}","]","If","no","constraints","are","provided","the","hypercube","determined","by","the","bounds","constraints","are","used",".","Note","about","the","internal","representation","of","the","vatiables",":","for","variables","in","which","the","dimaensionality","has","been","specified","in","the","domain",",","a","subindex","is","internally","asigned",".","For","instance","if","the","variables","is","called","'var1","'","and","has","dimensionality","3",",","the","first","three","positions","in","the","internal","representation","of","the","domain","will","be","occupied","by","variables","'var1_1","'",",","'var1_2","'","and","'var1_3","'",".","If","no","dimensionality","is","added",",","the","internal","naming","remains","the","same",".","For","instance",",","in","the","example","above","'var3'","should","be","fixed","its","original","name",".","param","space",":","list","of","dictionaries","as","indicated","above",".","param","constraints",":","list","of","dictionaries","as","indicated","above","(","default",",","none",")"]
docstr: Rounds some value x to a feasible value in the design space.
  x is expected to be a vector or an array with a single row
docstr_tok: ["Rounds","some","value","x","to","a","feasible","value","in","the","design","space",".","x","is","expected","to","be","a","vector","or","an","array","with","a","single","row"]
code: def round_optimum(self, x):
      """
      Rounds some value x to a feasible value in the design space.
      x is expected to be a vector or an array with a single row
      """
      x = np.array(x)
      if not ((x.ndim == 1) or (x.ndim == 2 and x.shape[0] == 1)):
          raise ValueError(
              "Unexpected dimentionality of x. Got {}, expected (1, N) or (N,)".format(
                  x.ndim
              )
          )
  
      if x.ndim == 2:
          x = x[0]
  
      x_rounded = []
      value_index = 0
      for variable in self.space_expanded:
          var_value = x[
              value_index : value_index
              + variable.dimensionality_in_model
          ]
          var_value_rounded = variable.round(var_value)
  
          x_rounded.append(var_value_rounded)
          value_index += variable.dimensionality_in_model
  
      return np.atleast_2d(np.concatenate(x_rounded))
  
imports: import numpy
  import itertools
  from copy import deepcopy
  from .variables import create_variable
  from ..errors import InvalidConfigError, InvalidVariableNameError
label_desc: Use image node_id 20 for calling the Design_space obj's underlying member method code with example usage: obj.round_optimum(x) and returns: np