Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class CapacityProfile
Note: This documentation is automatically generated.
This class is used by the no_overlap_2d constraint to maintain the envelope
of a set of rectangles. This envelope is not the convex hull, but the exact
polyline (aligned with the x and y axis) that contains all the rectangles
passed with the AddRectangle() call.
Returns the profile of the function:
capacity(x) = max(y_max of rectangles overlapping x) - min(y_min of
rectangle overlapping x) - sum(y_height of mandatory rectangles
overlapping x) where a rectangle overlaps x if x_min <= x < x_max.
Note the profile can contain negative heights in case the mandatory part
exceeds the range on the y axis.
Note that it adds a sentinel (kMinIntegerValue, 0) at the start. It is
useful when we reverse the direction on the x axis.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eCapacityProfile\u003c/code\u003e class in C++ is used to manage the envelope of a set of rectangles, outlining a precise polyline rather than a convex hull.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to add rectangles, define mandatory consumption areas, and calculate the residual capacity profile.\u003c/p\u003e\n"],["\u003cp\u003eThe residual capacity profile represents the difference between the maximum and minimum y-values of overlapping rectangles, considering mandatory consumption.\u003c/p\u003e\n"],["\u003cp\u003eUsers can obtain the bounding area of the entire shape and clear the stored data as needed.\u003c/p\u003e\n"]]],["The `CapacityProfile` class, used within the `no_overlap_2d` constraint, manages the envelope of rectangles. Key actions include `AddRectangle` to define a rectangle's bounds, and `AddMandatoryConsumption` to specify mandatory usage subtracted from the profile. `BuildResidualCapacityProfile` calculates the capacity profile, and `GetBoundingArea` computes the bounding polyline's area. The `Clear` method resets the profile, and the `Rectangle` method is used to manage rectangle with a given start and height.\n"],null,["C++ Reference: class CapacityProfile\n\n\nNote: This documentation is automatically generated.\nThis class is used by the no_overlap_2d constraint to maintain the envelope of a set of rectangles. This envelope is not the convex hull, but the exact polyline (aligned with the x and y axis) that contains all the rectangles passed with the AddRectangle() call.\n\n| Method ||\n|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`AddMandatoryConsumption`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L195) | Return type: `void ` Arguments: `IntegerValue x_min, IntegerValue x_max, IntegerValue y_height` Adds a mandatory profile consumption. All mandatory usages will be subtracted from the y_max-y_min profile to build the residual capacity. |\n| [`AddRectangle`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L190) | Return type: `void ` Arguments: `IntegerValue x_min, IntegerValue x_max, IntegerValue y_min, IntegerValue y_max` Adds a rectangle to the current shape. |\n| [`BuildResidualCapacityProfile`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L208) | Return type: `void ` Arguments: `std::vector\u003cRectangle\u003e* result` Returns the profile of the function: capacity(x) = max(y_max of rectangles overlapping x) - min(y_min of rectangle overlapping x) - sum(y_height of mandatory rectangles overlapping x) where a rectangle overlaps x if x_min \\\u003c= x \\\u003c x_max. Note the profile can contain negative heights in case the mandatory part exceeds the range on the y axis. Note that it adds a sentinel (kMinIntegerValue, 0) at the start. It is useful when we reverse the direction on the x axis. |\n| [`Clear`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L187) | Return type: `void ` \u003cbr /\u003e |\n| [`GetBoundingArea`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L213) | Return type: `IntegerValue ` Returns the exact area of the bounding polyline of all rectangles added. Note that this will redo the computation each time. |\n| [`Rectangle`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/diffn_util.h#L175) | \u003cbr /\u003e Arguments: `IntegerValue start, IntegerValue height` \u003cbr /\u003e |"]]