Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
flow_problem.proto
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// Protobuf representing a flow problem on a graph. It supports several problem
15// types. Depending on the type, the message is interpreted differently as
16// explained under each type description below.
17//
18// LINEAR_SUM_ASSIGNMENT: the algorithm computes the minimum-cost perfect
19// matching if there is one.
20// - Arcs are assumed to be from a left node to a right node. In particular
21// the id space of the left and right nodes can be the same. That is an arc
22// from the left node 0 to the right node 0 will be coded as (0, 0).
23// - If a perfect matching does not exist, the problem is not feasible.
24// - Capacity and supply values are ignored.
25//
26// MAX_FLOW: The algorithm computes the maximum flow under the arc capacity
27// constraints.
28// - Only one source (with supply > 0) and one sink (with supply < 0), the
29// supply values are not important. Only the signs are.
30// - The costs are ignored.
31//
32// MIN_COST_FLOW: the algorithm computes the flow of minimum cost. If a feasible
33// flow does not exist (in particular if the sum of supplies is not 0), the
34// problem is not feasible.
35
36syntax = "proto2";
37
38package operations_research;
39
40option java_package = "com.google.ortools.graph";
41option java_multiple_files = true;
42option csharp_namespace = "Google.OrTools.Graph";
43message FlowArcProto {
44 // A directed arc goes from a tail node to a head node.
45 // Node ids must be non-negative (>= 0).
46 optional int64 tail = 1;
47 optional int64 head = 2;
48
49 // Capacity of the arc. Must be non-negative (>= 0). If the capacity is zero,
50 // it is equivalent to not including the arc in the FlowModelProto.
51 optional int64 capacity = 3 [default = 1];
52
53 // Cost of this arc per unit of flow.
54 // Note that it can take any positive, negative or null value.
55 optional int64 unit_cost = 4 [default = 0];
56}
57
58message FlowNodeProto {
59 // The ids must be non-negative (>= 0). They should be dense for good
60 // performance. Note that it is not mandatory to include nodes with no supply
61 // in a FlowModelProto.
62 optional int64 id = 1;
63
64 // The supply can be positive or negative in which case it means demand.
65 // The sum of the supplies over all nodes must always be 0.
66 optional int64 supply = 2 [default = 0];
67}
68
69// Holds a flow problem, see NodeProto and ArcProto for more details.
70message FlowModelProto {
71 repeated FlowNodeProto nodes = 1;
72 repeated FlowArcProto arcs = 2;
73
74 // The type of problem to solve.
75 enum ProblemType {
76 LINEAR_SUM_ASSIGNMENT = 0;
77 MAX_FLOW = 1;
78 MIN_COST_FLOW = 2;
79 }
80 optional ProblemType problem_type = 3;
81}