def as_gpconstr(self, x0):
     "Returns locally-approximating GP constraint"
     # Creating a default constraint for the first solve
     if self.x not in x0:
         return (self.y >= self.x)
     # Otherwise calls external code at the current position...
     x_star = x0[self.x]
     res = external_code(x_star)
     # ...and returns a linearized posy <= 1
     return (self.y >= res * self.x / x_star)
Esempio n. 2
0
    def as_gpconstr(self, x0):

        # Unpacking the GPkit variables
        x = self.x
        y = self.y

        # Creating a default constraint for the first solve
        if not x0:
            return (y >= x)

        # Returns constraint updated with new call to the external code
        else:
            # Unpack Design Variables at the current point
            x_star = x0["x"]

            # Call external code
            res = external_code(x_star)

        # Return linearized constraint
        return (y >= res*x/x_star)
Esempio n. 3
0
    def as_gpconstr(self, x0, substitutions=None):

        # Unpacking the GPkit variables
        x = self.x
        y = self.y

        # Creating a default constraint for the first solve
        if not x0:
            return (y >= x)

        # Returns constraint updated with new call to the external code
        else:
            # Unpack Design Variables at the current point
            x_star = x0["x"]

            # Call external code
            res = external_code(x_star)

        # Return linearized constraint
        return (y >= res*x/x_star)
Esempio n. 4
0
    def as_gpconstr(self, x0):
        "Returns locally-approximating GP constraint"

        # Unpacking the GPkit variables
        x = self.x
        y = self.y

        # Creating a default constraint for the first solve
        if not x0:
            return (y >= x)

        # Returns constraint updated with new call to the external code
        else:
            # Unpack Design Variables at the current point
            x_star = x0["x"]

            # Call external code
            res = external_code(x_star)

        # Return linearized constraint
        posynomial_constraint = (y >= res*x/x_star)
        posynomial_constraint.sgp_parent = self
        return posynomial_constraint