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