Example #1
0
 def output_incremental(self, input_var):
     input_val = value(input_var)
     if self.is_pwl:
         for A, B in pairwise(self.bid_points):
             if A[0] <= input_val <= B[0]:
                 return get_line_slope(A, B)
     else:
         return polynomial_incremental_value(self.polynomial, value(input_var))
Example #2
0
 def output_incremental_range(self):
     if self.is_pwl:
         input_range = self.discrete_input_points
         output_range = [0]
         for A, B in pairwise(self.bid_points):
             output_range.append(get_line_slope(A, B))
     else:
         input_range = np.arange(self.min_input, self.max_input, 1.0)
         output_range = [polynomial_incremental_value(self.polynomial, x)
                         for x in input_range]
     return input_range, output_range
Example #3
0
    def output_true(self, input_var, force_linear=False):
        '''true output value of bid'''
        input_val = value(input_var)

        if (self.is_pwl or force_linear) and not self.is_linear:
            if not self.is_pwl and self.bid_points is None:
                # construct the bid points
                bid_pt_outputs = map(lambda pt: polynomial_value(
                    self.polynomial, pt), self.discrete_input_points)
                self.bid_points = zip(
                    self.discrete_input_points, bid_pt_outputs)

            for A, B in pairwise(self.bid_points.values.tolist()):
                if A[0] <= input_val <= B[0]:
                    return get_line_value(A, B, input_val) + self.constant_term
        else:
            return polynomial_value(self.polynomial, input_val)