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