예제 #1
0
 def do_pack(D):
     for v in D.itervalues():
         # type checking
         if isinstance(v, OrderedDict):
             do_pack(v)  # recursion!
             continue
         elif not isinstance(v, valid_types):
             continue
         elif np.rank(v) > 2:
             continue
         # make column vectors
         v = atleast_2d_col(v)
         # handle output type
         if vector:
             # unravel into 1d vector
             v = v.ravel(order='F')
         else:
             # check array size
             size[0] = size[0] or v.shape[
                 0]  # updates size once on first array
             if v.shape[0] != size[0]:
                 #warn ('array size mismatch, skipping. all values in data must have same number of rows for array packing',RuntimeWarning)
                 continue
         # dump to list
         M.append(v)
예제 #2
0
파일: Objective.py 프로젝트: jiaxu825/VyPy
 def function(self,x):
     
     x = self.variables.scaled.unpack_array(x)
     
     func = self.evaluator.function
     tag  = self.tag
     scl  = self.scale
     
     result = func(x)[tag]
     
     result = atleast_2d_col(result)
     
     result = result / scl
     
     return result
예제 #3
0
    def function(self, x):

        x = self.variables.scaled.unpack_array(x)

        func = self.evaluator.function
        tag = self.tag
        scl = self.scale

        result = func(x)[tag]

        result = atleast_2d_col(result)

        result = result / scl

        return result
예제 #4
0
    def function(self, x):

        x = self.variables.scaled.unpack_array(x)

        func = self.evaluator.function
        tag = self.tag
        scl = self.scale

        if x.keys() == ['vector']:
            x = x['vector']

        result = func(x)

        if isinstance(result, dict):
            result = result[tag]

        result = atleast_2d_col(result)

        result = result / scl

        return result
예제 #5
0
 def function(self,x):
     
     x = self.variables.scaled.unpack_array(x)
     
     func = self.evaluator.function
     tag  = self.tag
     scl  = self.scale
     
     if x.keys() == ['vector']:
         x = x['vector']
         
     result = func(x)
     
     if isinstance(result,dict):
         result = result[tag]
     
     result = atleast_2d_col(result)
     
     result = result / scl
     
     return result
예제 #6
0
 def do_pack(D):
     for v in D.itervalues():
         # type checking
         if isinstance( v, OrderedDict ): 
             do_pack(v) # recursion!
             continue
         elif not isinstance( v, valid_types ): continue
         elif np.ndim(v) > 2: continue
         # make column vectors
         v = atleast_2d_col(v)
         # handle output type
         if vector:
             # unravel into 1d vector
             v = v.ravel(order='F')
         else:
             # check array size
             size[0] = size[0] or v.shape[0] # updates size once on first array
             if v.shape[0] != size[0]: 
                 #warn ('array size mismatch, skipping. all values in data must have same number of rows for array packing',RuntimeWarning)
                 continue
         # dump to list
         M.append(v)