NET file format: network flow models

CPLEX supports the NET file format.

The NET file format is an ASCII file format specific to CPLEX for network-flow problems. It is the file format for representing pure network problems within CPLEX. This format is supported by Concert Technology, by the Callable Library, and by the Interactive Optimizer. In particular, it works with CPXNETptr objects (not CPXLPptr objects).

Comments

This is a free-format file; that is, line breaks or column positions are irrelevant to the interpretation of the file. The only exceptions to this convention are comments: anything from a backslash (\) character to the end of a line is a comment and does not contribute to the network specified by the file. Comments are allowed anywhere in the file.

Keywords

The NET format recognizes the following keywords in a file:

  • MAXIMIZE

  • MINIMIZE

  • NETWORK

  • ENDNETWORK

  • SUPPLY

  • DEMAND

  • ARCS

  • BOUNDS

  • OBJECTIVE

  • INFINITY

  • FREE

Keywords are independent of character case. Keywords must be separated by white space from other symbols in the file.

White space

White space consists of one or more of the following characters:

  • the space character

  • the tab character (\t),

  • the new line character (\n)

  • a comment (that is, all characters following a backslash to the end of a line)

Abbreviations of keywords

Also, the NET format recognizes the abbreviations summarized in Table 1.
Table 1. Abbreviations of Keywords in NET File Format
Keyword Abbreviation
INFINITY INF
MINIMIZE MIN
MAXIMIZE MAX

Start of a NET file

A NET file must start with one of the following keywords:

  • MAXIMIZE NETWORK

  • MINIMIZE NETWORK

Both may be followed optionally by the name of a problem. If no name is specified, the filename will be used instead. This part of a NET file is referred to as the start of a NET file.

Names in a NET file

Names must follow the same conventions as they do for CPLEX LP format files. They must consist of a sequence of alphanumeric characters (a-z, A-Z, or 0-9) or one of the symbols: ! " # $ % & ( ) / , . ; @ _ ’ ‘ { } | ~. However, the first character may not be a digit or period (.). No names corresponding to the keywords are allowed. There is no restriction on the number of characters in a name within a NET file.

End of a NET file

The network specification of a NET file must end with the keyword ENDNETWORK. Anything following the keyword ENDNETWORK will be ignored. This keyword is referred to as the end of a NET file.

Sections of a NET file

Between its start and end, a NET file is divided into sections. Each section is introduced by its keyword and continues until the next section begins or the NET file ends. The keywords introducing sections are SUPPLY, DEMAND, ARCS, BOUNDS, and OBJECTIVE. Each section keyword may appear more than once in a NET file. They need not be in any order.

The SUPPLY section

In this section, supply values for nodes are specified. Each supply value is specified with the following sequence:

node-name : value

where node-name specifies the name of the node for which to set a supply value, and value is the value that will be assigned to node node-name as its supply value. If a node with this name does not already exist, a new node will be created with this name. If the node has been previously assigned a supply value, the new value overrides the previous value, and a warning will be issued.

The DEMAND section

This section corresponds to the SUPPLY section except that it specifies demand values instead of supply values. That is, instead of specifying a supply value s in the SUPPLY section, you can specify the negative of s in the DEMAND section and vice versa. The format for doing so is exactly the same: node-name: value. There is no requirement to use both a SUPPLY and a DEMAND section in a given model. You can fully specify any model using either of the section types alone by correctly using positive and negative values. The availability of either or both section types simply offers flexibility in model formulation.

The ARCS section

In this section, the arcs from-node (or tail) and to-node (or head) are specified. For each arc, the format is:

arc-name : from-node -> to-node

where arc-name specifies the name for the arc from from-node to to-node. If arc-name already exists, a warning message is issued, and the specified nodes override the previous ones. The nodes are referred to by node names. If a node does not yet exist, a new node with this name will be created with supply value 0 (zero). Otherwise, the existing node of the specified name will be used.

The OBJECTIVE section

This section is used to assign objective values to arcs in the format:

arc-name : value

where arc-name must be the name of an arc that has previously been specified in an ARCS section. This arc will be assigned the objective value indicated by value. If an arc is assigned an objective value more than once, a warning message will be issued, and the most recently assigned objective value for that arc in the file will be used. If no objective value is specified for an arc, 0 (zero) will be used by default.

The BOUNDS section

In this section, bounds on the flow through an arc are specified in a variety of ways, similar to specifying bounds on variables in LP format. The general format is:

value1 <= arc-name <= value2

That general statement assigns a lower bound of value1 and an upper bound of value2 to the arc named arc-name. This arc must have previously been defined in an ARCS section.

Only one bound at a time may be specified for an arc. That is, the following items are valid input: value <=arc-name to set the lower bound of the specified arc to value or arc-name <= value to set the upper bound of the specified arc to value. If the upper and lower bound for an arc are identical, you can write arc-name = value instead.

Bound values may be INFINITY or -INFINITY. An arc with lower bound -INFINITY and upper bound INFINITY may be entered as FREE, like this: arc-name free

If a bound is not specified for an arc, 0 (zero) will be used as the default lower bound and infinity as the default upper bound.

Example of NET file format


\ Except for this comment, this is the example network file
\ created by netex1.c
\
MINIMIZE NETWORK netex1
SUPPLY
      n1 : 20
      n4 : -15
      n5 : 5
      n8 : -10
ARCS
      a1 :       n1 ->       n2
      a2 :       n2 ->       n3
      a3 :       n3 ->       n4
      a4 :       n4 ->       n7
      a5 :       n7 ->       n6
      a6 :       n6 ->       n8
      a7 :       n5 ->       n8
      a8 :       n5 ->       n2
      a9 :       n3 ->       n2
     a10 :       n4 ->       n5
     a11 :       n4 ->       n6
     a12 :       n6 ->       n4
     a13 :       n6 ->       n5
     a14 :       n2 ->       n6
OBJECTIVE
      a1 : 3
      a2 : 3
      a3 : 4
      a4 : 3
      a5 : 5
      a6 : 6
      a7 : 7
      a8 : 4
      a9 : 2
     a10 : 6
     a11 : 5
     a12 : 4
     a13 : 3
     a14 : 6
BOUNDS
18 <= a1  <= 24
 0 <= a2  <= 25
      a3   = 12
 0 <= a4  <= 10
 0 <= a5  <= 9
      a6     free
 0 <= a7  <= 20
 0 <= a8  <= 10
 0 <= a9  <= 5
 0 <= a10 <= 15
 0 <= a11 <= 10
 0 <= a12 <= 11
 0 <= a13 <= 6
ENDNETWORK