The minCostFlow action calculates the minimum-cost network flow of a graph. The minimum-cost network flow problem is a fundamental network optimization problem that involves finding the cheapest way to send a certain amount of flow through a network in order to satisfy demands at certain nodes from available supplies at other nodes.
| Parameter | Description |
|---|---|
| deterministic | When set to True, ensures that each invocation (with the same machine configuration and parameter settings) produces the same final result. |
| direction | Specifies whether to consider the input graph as directed or undirected. |
| display | Specifies a list of results tables to send to the client for display. |
| distributed | When set to True, uses a distributed graph. |
| graph | Specifies the in-memory graph to use. |
| indexOffset | Specifies the index offset for identifiers in the log and results output data tables. |
| links | Specifies the input data table that contains the graph link information. |
| linksVar | Specifies the data variable names for the links table. |
| logFreq | Specifies the frequency for displaying iteration logs for minimum-cost network flow calculations that use the network simplex algorithm. |
| logFreqTime | Controls the frequency n (in seconds) for displaying iteration logs for some algorithms. |
| logLevel | Controls the amount of information that is displayed in the SAS log. |
| maxTime | Specifies the maximum amount of time for the algorithm to spend. |
| multiLinks | When set to True, includes multilinks when an input graph is read. |
| nodes | Specifies the input data table that contains the graph node information. |
| nodesVar | Specifies the data variable names for the nodes table. |
| nThreads | Specifies the maximum number of threads to use for multithreaded processing. |
| outGraphList | Specifies the output data table to contain summary information about in-memory graphs. |
| outLinks | Specifies the output data table to contain the graph link information along with any results from the algorithms that calculate metrics on links. |
| outNodes | Specifies the output data table to contain the graph node information along with any results from the algorithms that calculate metrics on nodes. |
| outputTables | Lists the names of results tables to save as CAS tables on the server. |
| selfLinks | When set to True, includes self-links when an input graph is read. |
| standardizedLabels | When set to True, specifies that the input graph data are in a standardized format. |
| standardizedLabelsOut | When set to True, requests that the output graph data include standardized format. |
| timeType | Specifies whether to use CPU time or real time for the maximum time limit. |
The following DATA step creates the arc data table `arc_data` for a simple minimum-cost network flow problem. The data table contains the source and sink nodes for each link, the link capacity, and the unit cost for sending flow through the link.
| 1 | DATA mycas.arc_data; |
| 2 | INFILE DATALINES delimiter=','; |
| 3 | INPUT from $ to $ capacity cost; |
| 4 | DATALINES; |
| 5 | 1,4,15,1 |
| 6 | 2,1,10,2 |
| 7 | 2,3,10,1 |
| 8 | 2,6,10,6 |
| 9 | 3,4,10,5 |
| 10 | 3,5,10,4 |
| 11 | 4,7,25,2 |
| 12 | 5,6,20,1 |
| 13 | 5,7,10,7 |
| 14 | 6,8,10,8 |
| 15 | 7,8,15,9 |
| 16 | ; |
| 17 |
This example uses the minCostFlow action to find the minimum-cost network flow for a directed graph. The nodes table `node_data` specifies the supply and demand for each node, and the links table `arc_data` specifies the link capacities and costs. The problem is defined by a directed graph G=(N,E).
| 1 | PROC CAS; |
| 2 | ACTION optNetwork.minCostFlow / |
| 3 | direction = "DIRECTED" |
| 4 | links = {name = 'arc_data' vars={lower='0'}} |
| 5 | nodes = {name = 'node_data'} |
| 6 | outLinks = {name = 'out' replace=true} |
| 7 | linksVar = {from = 'from' to='to' upper='capacity' weight='cost'} |
| 8 | nodesVar = {node='_node_' lower='lower' upper='upper'}; |
| 9 | RUN; |
| 10 | PRINT cas.out; |
| 11 | QUIT; |