Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class PairExchangeOperator
Note: This documentation is automatically generated.
Operator which exchanges the position of two pairs; for both pairs the first
node of the pair must be before the second node on the same path.
Possible neighbors for the paths 1 -> A -> B -> 2 -> 3 and 4 -> C -> D -> 5
(where (1, 3) and (4, 5) are first and last nodes of the paths and can
therefore not be moved, and (A, B) and (C,D) are pairs of nodes):
1 -> [C] -> [D] -> 2 -> 3, 4 -> [A] -> [B] -> 5
[[["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 PairExchangeOperator is used to exchange the positions of two pairs of nodes in a route, where the first node of each pair must precede the second node on the same path.\u003c/p\u003e\n"],["\u003cp\u003eThis operator is applicable in routing problems for creating new solutions by swapping node pairs within routes.\u003c/p\u003e\n"],["\u003cp\u003eThe operator is initialized with path variables, secondary variables (if any), a function to determine empty path start classes, and index pairs defining the node pairs to be exchanged.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003eMakeNeighbor\u003c/code\u003e to generate a neighboring solution, \u003ccode\u003eDebugString\u003c/code\u003e for debugging information, and a constructor/destructor for object management.\u003c/p\u003e\n"]]],["The `PairExchangeOperator` class exchanges the positions of two pairs of nodes within paths. Each pair's first node must precede the second. This operator's `MakeNeighbor` method attempts to create a new solution where node pairs are swapped, returning a boolean indicating success. The constructor `PairExchangeOperator` takes variables, secondary variables, a function defining empty path classes, and index pairs as input. `DebugString` provides a string representation of the operation. There is a destructor `~PairExchangeOperator` for cleanup.\n"],null,["# PairExchangeOperator\n\nC++ Reference: class PairExchangeOperator\n=========================================\n\n\nNote: This documentation is automatically generated.\nOperator which exchanges the position of two pairs; for both pairs the first node of the pair must be before the second node on the same path. Possible neighbors for the paths 1 -\\\u003e A -\\\u003e B -\\\u003e 2 -\\\u003e 3 and 4 -\\\u003e C -\\\u003e D -\\\u003e 5 (where (1, 3) and (4, 5) are first and last nodes of the paths and can therefore not be moved, and (A, B) and (C,D) are pairs of nodes): 1 -\\\u003e \\[C\\] -\\\u003e \\[D\\] -\\\u003e 2 -\\\u003e 3, 4 -\\\u003e \\[A\\] -\\\u003e \\[B\\] -\\\u003e 5\n\n| Method ||\n|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`DebugString`](https://github.com/google/or-tools/blob/v9.4/ortools/constraint_solver/routing_neighborhoods.h#L227) | Return type: `std::string ` \u003cbr /\u003e |\n| [`MakeNeighbor`](https://github.com/google/or-tools/blob/v9.4/ortools/constraint_solver/routing_neighborhoods.h#L226) | Return type: `bool ` \u003cbr /\u003e |\n| [`PairExchangeOperator`](https://github.com/google/or-tools/blob/v9.4/ortools/constraint_solver/routing_neighborhoods.h#L220) | \u003cbr /\u003e Arguments: `const std::vector\u003cIntVar*\u003e& vars, const std::vector\u003cIntVar*\u003e& secondary_vars, std::function\u003cint(int64_t)\u003e start_empty_path_class, const RoutingIndexPairs& index_pairs` \u003cbr /\u003e |\n| [`~PairExchangeOperator`](https://github.com/google/or-tools/blob/v9.4/ortools/constraint_solver/routing_neighborhoods.h#L224) | \u003cbr /\u003e |"]]