Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <piecewise_linear_function.h>
Public Member Functions | |
bool | InDomain (int64_t x) const |
Returns if x is in the domain of the function. | |
bool | IsConvex () const |
bool | IsNonDecreasing () const |
Returns true if the piecewise linear function is non-decreasing. | |
bool | IsNonIncreasing () const |
Returns true if the piecewise linear function is non-increasing. | |
int64_t | Value (int64_t x) const |
Returns the value of the piecewise linear function for x. | |
int64_t | GetMaximum () const |
Returns the maximum value of all the segments in the function. | |
int64_t | GetMinimum () const |
Returns the minimum value of all the segments in the function. | |
int64_t | GetMaximum (int64_t range_start, int64_t range_end) const |
int64_t | GetMinimum (int64_t range_start, int64_t range_end) const |
std::pair< int64_t, int64_t > | GetSmallestRangeGreaterThanValue (int64_t range_start, int64_t range_end, int64_t value) const |
std::pair< int64_t, int64_t > | GetSmallestRangeLessThanValue (int64_t range_start, int64_t range_end, int64_t value) const |
std::pair< int64_t, int64_t > | GetSmallestRangeInValueRange (int64_t range_start, int64_t range_end, int64_t value_min, int64_t value_max) const |
void | AddConstantToX (int64_t constant) |
void | AddConstantToY (int64_t constant) |
void | Add (const PiecewiseLinearFunction &other) |
void | Subtract (const PiecewiseLinearFunction &other) |
std::vector< PiecewiseLinearFunction * > | DecomposeToConvexFunctions () const |
const std::vector< PiecewiseSegment > & | segments () const |
std::string | DebugString () const |
Static Public Member Functions | |
static PiecewiseLinearFunction * | CreatePiecewiseLinearFunction (std::vector< int64_t > points_x, std::vector< int64_t > points_y, std::vector< int64_t > slopes, std::vector< int64_t > other_points_x) |
static PiecewiseLinearFunction * | CreateStepFunction (std::vector< int64_t > points_x, std::vector< int64_t > points_y, std::vector< int64_t > other_points_x) |
static PiecewiseLinearFunction * | CreateFullDomainFunction (int64_t initial_level, std::vector< int64_t > points_x, std::vector< int64_t > slopes) |
static PiecewiseLinearFunction * | CreateOneSegmentFunction (int64_t point_x, int64_t point_y, int64_t slope, int64_t other_point_x) |
Builds a function consisting of one segment. | |
static PiecewiseLinearFunction * | CreateRightRayFunction (int64_t point_x, int64_t point_y, int64_t slope) |
static PiecewiseLinearFunction * | CreateLeftRayFunction (int64_t point_x, int64_t point_y, int64_t slope) |
static PiecewiseLinearFunction * | CreateFixedChargeFunction (int64_t slope, int64_t value) |
static PiecewiseLinearFunction * | CreateEarlyTardyFunction (int64_t reference, int64_t earliness_slope, int64_t tardiness_slope) |
static PiecewiseLinearFunction * | CreateEarlyTardyFunctionWithSlack (int64_t early_slack, int64_t late_slack, int64_t earliness_slope, int64_t tardiness_slope) |
Static Public Attributes | |
static const int | kNotFound = -1 |
In mathematics, a piecewise linear function is a function composed of straight-line, non overlapping sections.
Definition at line 96 of file piecewise_linear_function.h.
void operations_research::PiecewiseLinearFunction::Add | ( | const PiecewiseLinearFunction & | other | ) |
Adds the function to the existing one. The domain of the resulting function is the intersection of the two domains. The overflows and the underflows are sticky.
Definition at line 637 of file piecewise_linear_function.cc.
void operations_research::PiecewiseLinearFunction::AddConstantToX | ( | int64_t | constant | ) |
Adds 'constant' to the 'x' of all segments. If the argument is positive, the translation is to the right and when it's negative, to the left. The overflows and the underflows are sticky.
Definition at line 623 of file piecewise_linear_function.cc.
void operations_research::PiecewiseLinearFunction::AddConstantToY | ( | int64_t | constant | ) |
Adds 'constant' to the 'y' of all segments. If the argument is positive, the translation is up and when it's negative, down. The overflows and the underflows are sticky.
Definition at line 630 of file piecewise_linear_function.cc.
|
static |
Builds an earliness-tardiness two-segment piecewise linear cost function. The reference specifies the point where the cost is zero. Before the reference, the cost increases with the earliness slope and after the reference, it increases with the tardiness slope. The absolute values of the slopes are given.
Definition at line 385 of file piecewise_linear_function.cc.
|
static |
Builds an earliness-tardiness three-segment piecewise linear cost function with a slack period around the due date. The early slack is the point before which the cost increases with the ealiness slope specified. The late slack is the point after which the cost increases with the late slope specified. Between the early and the late slack point, the cost is zero. The absolute values of the slopes are given.
Definition at line 396 of file piecewise_linear_function.cc.
|
static |
Builds a two-segment fixed charge piecewise linear cost function. For values less than zero, the cost is zero. For values greater than zero, cost follows the line specified by the slope and the value given as arguments. The slope and value are positive.
Definition at line 375 of file piecewise_linear_function.cc.
|
static |
Builds a multiple-segment piecewise linear function with domain from from kint64min to kint64max with n points and n+1 slopes. Each slope stops at the point with the corresponding index apart from the last one which stops at kint64max. The first slope stops at the first point at the level specified.
Definition at line 328 of file piecewise_linear_function.cc.
|
static |
Builds a function consisting of one ray starting at the specified x and y coordinates with the specified slope.
Definition at line 368 of file piecewise_linear_function.cc.
|
static |
Builds a function consisting of one segment.
Visual studio 2013: We cannot inline the vector in the PiecewiseLinearFunction ctor.
Definition at line 352 of file piecewise_linear_function.cc.
|
static |
This API provides a factory for creating different families of Piecewise Linear Functions based on specific properties of each family. The PiecewiseLinearFunction is composed by a set of PiecwiseSegments and upon creation is not modifiable but with the provided function operations. The object returned by any of these builders in the factory is owned by the client code. Builds the most generic form of multiple-segment piecewise linear function supporting domain holes. For a fixed index i the elements in points_x[i] points_y[i], slopes[i], other_points_x[i] represent a segment. The point (points_x[i], points_y[i]) represents one of the endpoints of the segment and the other_points_x[i] represents the x coordinate of the other endpoint which may precede, follow or coincide with points_x[i]. The segments represented by these vectors should not be overlapping. Common endpoints are allowed.
Definition at line 295 of file piecewise_linear_function.cc.
|
static |
Builds a function consisting of one ray starting at the specified x and y coordinates with the specified slope.
Definition at line 361 of file piecewise_linear_function.cc.
|
static |
Builds a multiple-segment step function with continuous or non continuous domain. The arguments have the same semantics with the generic builder of the piecewise linear function. In the step function all the slopes are 0.
Definition at line 312 of file piecewise_linear_function.cc.
std::string operations_research::PiecewiseLinearFunction::DebugString | ( | ) | const |
Definition at line 679 of file piecewise_linear_function.cc.
std::vector< PiecewiseLinearFunction * > operations_research::PiecewiseLinearFunction::DecomposeToConvexFunctions | ( | ) | const |
Decomposes the piecewise linear function in a set of convex piecewise linear functions. The objects in the vector are owned by the client code.
The segment belongs to the convex sub-function formulated up to now.
Definition at line 646 of file piecewise_linear_function.cc.
int64_t operations_research::PiecewiseLinearFunction::GetMaximum | ( | ) | const |
Returns the maximum value of all the segments in the function.
Definition at line 513 of file piecewise_linear_function.cc.
int64_t operations_research::PiecewiseLinearFunction::GetMaximum | ( | int64_t | range_start, |
int64_t | range_end ) const |
Returns the maximum endpoint value of the segments in the specified range. If the range is disjoint from the segments in the function, it returns kint64max.
Definition at line 445 of file piecewise_linear_function.cc.
int64_t operations_research::PiecewiseLinearFunction::GetMinimum | ( | ) | const |
Returns the minimum value of all the segments in the function.
Definition at line 517 of file piecewise_linear_function.cc.
int64_t operations_research::PiecewiseLinearFunction::GetMinimum | ( | int64_t | range_start, |
int64_t | range_end ) const |
Returns the minimum endpoint value of the segments in the specified range. If the range is disjoint from the segments in the function, it returns kint64max.
Definition at line 479 of file piecewise_linear_function.cc.
std::pair< int64_t, int64_t > operations_research::PiecewiseLinearFunction::GetSmallestRangeGreaterThanValue | ( | int64_t | range_start, |
int64_t | range_end, | ||
int64_t | value ) const |
Returns the smallest range within a given range containing all values greater than a given value.
Definition at line 522 of file piecewise_linear_function.cc.
std::pair< int64_t, int64_t > operations_research::PiecewiseLinearFunction::GetSmallestRangeInValueRange | ( | int64_t | range_start, |
int64_t | range_end, | ||
int64_t | value_min, | ||
int64_t | value_max ) const |
Returns the smallest range within a given range containing all values greater than value_min and less than value_max.
Definition at line 597 of file piecewise_linear_function.cc.
std::pair< int64_t, int64_t > operations_research::PiecewiseLinearFunction::GetSmallestRangeLessThanValue | ( | int64_t | range_start, |
int64_t | range_end, | ||
int64_t | value ) const |
Returns the smallest range within a given range containing all values less than a given value.
Definition at line 529 of file piecewise_linear_function.cc.
bool operations_research::PiecewiseLinearFunction::InDomain | ( | int64_t | x | ) | const |
Returns if x is in the domain of the function.
Definition at line 409 of file piecewise_linear_function.cc.
bool operations_research::PiecewiseLinearFunction::IsConvex | ( | ) | const |
Determines whether the piecewise linear function is convex or non-convex and returns true when the function is convex.
Definition at line 420 of file piecewise_linear_function.cc.
bool operations_research::PiecewiseLinearFunction::IsNonDecreasing | ( | ) | const |
Returns true if the piecewise linear function is non-decreasing.
Definition at line 425 of file piecewise_linear_function.cc.
bool operations_research::PiecewiseLinearFunction::IsNonIncreasing | ( | ) | const |
Returns true if the piecewise linear function is non-increasing.
Definition at line 430 of file piecewise_linear_function.cc.
|
inline |
Definition at line 233 of file piecewise_linear_function.h.
void operations_research::PiecewiseLinearFunction::Subtract | ( | const PiecewiseLinearFunction & | other | ) |
Subtracts the function to the existing one. The domain of the resulting function is the intersection of the two domains. The overflows and the underflows are sticky.
Definition at line 641 of file piecewise_linear_function.cc.
int64_t operations_research::PiecewiseLinearFunction::Value | ( | int64_t | x | ) | const |
Returns the value of the piecewise linear function for x.
Definition at line 435 of file piecewise_linear_function.cc.
|
static |
Definition at line 98 of file piecewise_linear_function.h.