def jacobian(self, m): ieqcons = [] if len(self.config.params['controls']) == 2: # If the controls consists of the the friction and the positions, then we need to first extract the position part assert (len(m) % 3 == 0) m_pos = m[len(m) / 3:] else: m_pos = m for i in range(len(m_pos) / 2): x = m_pos[2 * i] y = m_pos[2 * i + 1] primes = numpy.zeros(len(m)) try: primes[2 * i] = function_eval(self.feasible_area_grad[0], (x, y)) primes[2 * i + 1] = function_eval(self.feasible_area_grad[1], (x, y)) except RuntimeError: primes[2 * i] = 2 * (x - self.attraction_center[0]) primes[2 * i + 1] = 2 * (y - self.attraction_center[1]) ieqcons.append(primes) return -numpy.array(ieqcons)
def function(self, m): ieqcons = [] if len(self.config.params['controls']) == 2: # If the controls consists of the the friction and the positions, then we need to first extract the position part assert (len(m) % 3 == 0) m_pos = m[len(m) / 3:] else: m_pos = m for i in range(len(m_pos) / 2): x = m_pos[2 * i] y = m_pos[2 * i + 1] try: ieqcons.append(function_eval(self.feasible_area, (x, y))) except RuntimeError: print "Warning: a turbine is outside the domain" ieqcons.append((x - self.attraction_center[0])**2 + (y - self.attraction_center[1])** 2) # Point is outside domain arr = -numpy.array(ieqcons) if any(arr <= 0): log( INFO, "Domain restriction inequality constraints (should be >= 0): %s" % arr) return arr
def jacobian(self, m): ieqcons = [] if len(self.config.params['controls']) == 2: # If the controls consists of the the friction and the positions, then we need to first extract the position part assert(len(m) % 3 == 0) m_pos = m[len(m) / 3:] else: m_pos = m for i in range(len(m_pos) / 2): x = m_pos[2 * i] y = m_pos[2 * i + 1] primes = numpy.zeros(len(m)) try: primes[2 * i] = function_eval(self.feasible_area_grad[0], (x, y)) primes[2 * i + 1] = function_eval(self.feasible_area_grad[1], (x, y)) except RuntimeError: primes[2 * i] = 2 * (x - self.attraction_center[0]) primes[2 * i + 1] = 2 * (y - self.attraction_center[1]) ieqcons.append(primes) return -numpy.array(ieqcons)
def function(self, m): ieqcons = [] if len(self.config.params['controls']) == 2: # If the controls consists of the the friction and the positions, then we need to first extract the position part assert(len(m) % 3 == 0) m_pos = m[len(m) / 3:] else: m_pos = m for i in range(len(m_pos) / 2): x = m_pos[2 * i] y = m_pos[2 * i + 1] try: ieqcons.append(function_eval(self.feasible_area, (x, y))) except RuntimeError: print "Warning: a turbine is outside the domain" ieqcons.append((x - self.attraction_center[0]) ** 2 + (y - self.attraction_center[1]) ** 2) # Point is outside domain arr = -numpy.array(ieqcons) if any(arr <= 0): log(INFO, "Domain restriction inequality constraints (should be >= 0): %s" % arr) return arr