optNetwork

minCostFlow

Description

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.

optNetwork.minCostFlow <result=results> <status=rc> / <deterministic=TRUE | FALSE>, <direction="DIRECTED" | "UNDIRECTED">, <display={displayTables}>, <distributed=TRUE | FALSE>, <graph=integer>, <indexOffset=integer>, <links={castable}>, <linksVar={linksVarOpt}>, <logFreq=integer>, <logFreqTime=integer>, <logLevel="AGGRESSIVE" | "BASIC" | "MODERATE" | "NONE">, <maxTime=double>, <multiLinks=TRUE | FALSE>, <nodes={castable}>, <nodesVar={nodesVarOpt}>, <nThreads=integer>, <outGraphList={casouttable}>, <outLinks={casouttable}>, <outNodes={casouttable}>, <outputTables={outputTables}>, <selfLinks=TRUE | FALSE>, <standardizedLabels=TRUE | FALSE>, <standardizedLabelsOut=TRUE | FALSE>, <timeType="CPU" | "REAL">;
Settings
ParameterDescription
deterministicWhen set to True, ensures that each invocation (with the same machine configuration and parameter settings) produces the same final result.
directionSpecifies whether to consider the input graph as directed or undirected.
displaySpecifies a list of results tables to send to the client for display.
distributedWhen set to True, uses a distributed graph.
graphSpecifies the in-memory graph to use.
indexOffsetSpecifies the index offset for identifiers in the log and results output data tables.
linksSpecifies the input data table that contains the graph link information.
linksVarSpecifies the data variable names for the links table.
logFreqSpecifies the frequency for displaying iteration logs for minimum-cost network flow calculations that use the network simplex algorithm.
logFreqTimeControls the frequency n (in seconds) for displaying iteration logs for some algorithms.
logLevelControls the amount of information that is displayed in the SAS log.
maxTimeSpecifies the maximum amount of time for the algorithm to spend.
multiLinksWhen set to True, includes multilinks when an input graph is read.
nodesSpecifies the input data table that contains the graph node information.
nodesVarSpecifies the data variable names for the nodes table.
nThreadsSpecifies the maximum number of threads to use for multithreaded processing.
outGraphListSpecifies the output data table to contain summary information about in-memory graphs.
outLinksSpecifies the output data table to contain the graph link information along with any results from the algorithms that calculate metrics on links.
outNodesSpecifies the output data table to contain the graph node information along with any results from the algorithms that calculate metrics on nodes.
outputTablesLists the names of results tables to save as CAS tables on the server.
selfLinksWhen set to True, includes self-links when an input graph is read.
standardizedLabelsWhen set to True, specifies that the input graph data are in a standardized format.
standardizedLabelsOutWhen set to True, requests that the output graph data include standardized format.
timeTypeSpecifies whether to use CPU time or real time for the maximum time limit.
Data Preparation View data prep sheet
Creating the Arc Data Table

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.

Copied!
1DATA mycas.arc_data;
2 INFILE DATALINES delimiter=',';
3 INPUT from $ to $ capacity cost;
4 DATALINES;
51,4,15,1
62,1,10,2
72,3,10,1
82,6,10,6
93,4,10,5
103,5,10,4
114,7,25,2
125,6,20,1
135,7,10,7
146,8,10,8
157,8,15,9
16;
17 

Examples

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).

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC 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;
11QUIT;
Result :
The action outputs a table named 'out' which contains the computed minimum-cost flow for each link in the graph. This table includes columns for the source node ('from'), sink node ('to'), the flow on each link, and other link attributes.

FAQ

What is the purpose of the minCostFlow action?
What are the primary input tables for the minCostFlow action?
How can I specify the graph's directionality?
What does the 'logLevel' parameter control?
What are the main output tables for this action?
How can I handle multiple links between the same two nodes?