Network.xcc

Benoit Dupont de Dinechin (Benoit.Dupont-de-Dinechin@st.com).

Copyright 2002 - 2007 STMicroelectronics. Copyright 1995 - 1998 Commissariat a l'Energie Atomique.

This program is free software; you can redistribute it and/or modify it under the terms of either (at your option): the GNU General Public License (GPL) version 2; the GNU Lesser General Public License (LGPL) version 2.1; any later version of these licences as published by the Free Software Foundation.

NetArcFlag— Enumerates the NetArc flags.
typedef enum {
  NetArcFlag_Queued = 0x1,      // NetArc is in the QUEUED set of arcs.
  NetArcFlag_Active = 0x2,      // NetArc is in the ACTIVE set of arcs.
  NetArcFlag_Acyclic = 0x4,     // NetArc is in the acyclic subset of arcs.
  NetArcFlag_Longest = 0x8,     // NetArc is part of longest path.
  NetArcFlag_Useless = 0x10,    // NetArc is useless because found redundant.
  NetArcFlag_Precious = 0x20,   // NetArc to keep even if found redundant.
} NetArcFlag;
typedef unsigned NetArcFlags;
typedef uint8_t short_NetArcFlags;
NetArc— Network Arc.
struct NetArc_ {
  //@args       int32_t delay, NetArcFlags flags
  //@access TAILNODE    (NetNode)DGraphArc_TAILNODE(this)
  //@access HEADNODE    (NetNode)DGraphArc_HEADNODE(this)
  int32_t DELAY;        // Delay along this arc.
  int16_t FLOW;                 // Network flow through this NetArc.
  short_NetArcFlags FLAGS;
  //@access isQueued    ((NetArc_FLAGS(this) & NetArcFlag_Queued))
  //@access isActive    ((NetArc_FLAGS(this) & NetArcFlag_Active) != 0)
  //@access isAcyclic   ((NetArc_FLAGS(this) & NetArcFlag_Acyclic) != 0)
  //@access isLongest   ((NetArc_FLAGS(this) & NetArcFlag_Longest) != 0)
  //@access isUseless   ((NetArc_FLAGS(this) & NetArcFlag_Useless) != 0)
  //@access isPrecious  ((NetArc_FLAGS(this) & NetArcFlag_Precious) != 0)
  uint8_t TYPE;                 // Type of this NetArc.
  //@access REDUCED     NetArc_reduced(this)
};
NetArc_pretty— Pretty-print this NetArc.
bool
NetArc_pretty(NetArc this, FILE *file);
NetArc_attachTailNode— Attach this NetArc to a tail NetNode.
void
NetArc_attachTailNode(NetArc this, DGraphNode cfgNode);
#define NetArc_attachTailNode(this, node) DGraphArc_attachTailNode((DGraphArc)(this), (DGraphNode)(node))
NetArc_attachHeadNode— Attach this NetArc to a head NetNode.
void
NetArc_attachHeadNode(NetArc this, DGraphNode cfgNode);
#define NetArc_attachHeadNode(this, node) DGraphArc_attachHeadNode((DGraphArc)(this), (DGraphNode)(node))
NetArc_detachTailNode— Detach this NetArc from its tail NetNode.
void
NetArc_detachTailNode(NetArc this);
#define NetArc_detachTailNode(this) DGraphArc_detachTailNode((DGraphArc)(this))
NetArc_detachHeadNode— Detach this NetArc from its head NetNode.
void
NetArc_detachHeadNode(NetArc this);
#define NetArc_detachHeadNode(this) DGraphArc_detachHeadNode((DGraphArc)(this))
NetNode— Network Node.
struct NetNode_ {
  //@args       int require
  //@access INDEX       DGraphNode_INDEX(this)
  //@access SCANNODE    (NetNode)DGraphNode_SCANNODE(this)
  //@mutate SCANNODE    (NetNode *)DGraphNode__SCANNODE(this)
  NetArc EDGE;                  // Spanning tree edge from parent node.
  int32_t DATE;                 // Date of this node.
  int16_t REQUIRE;              // Network flow requirement.
  int16_t BALANCE;              // Network flow balance.
  struct NetNode_ *NEXT;        // Next NetNode in spanning tree thread order.
  struct NetNode_ *PREV;        // Previous NetNode in spanning tree thread order.
  int32_t DEPTH;                // Depth in the spanning tree.
  uint32_t STAMP;               // Used for cut-set identification in the dual network simplex.
  int32_t ORDER;                // Order in the topological scan.
};
NetNode_FORENTER_NetArc— Iterate over the entering NetArcs.
#define NetNode_FORENTER_NetArc(this, cfgArc) \
  DGraphNode_FORENTER(this, NetArc_, cfgArc) {
#define NetNode_ENDENTER_NetArc \
  } DGraphNode_ENDENTER;
NetNode_FORLEAVE_NetArc— Iterate over the leaving NetArcs.
#define NetNode_FORLEAVE_NetArc(this, cfgArc) \
  DGraphNode_FORLEAVE(this, NetArc_, cfgArc) {
#define NetNode_ENDLEAVE_NetArc \
  } DGraphNode_ENDLEAVE;
NetNode_pretty— Pretty-print this NetNode.
bool
NetNode_pretty(NetNode this, FILE *file);
Network— Network over a DGraph.
struct Network_;
#define Network_node(this, number) (NetNode)DGraph_node(Network_DGRAPH(this), number)
#define Network_access(this, index) (NetNode)DGraph_access(Network_DGRAPH(this), index)
Network_memory— This Network Memory.
static inline Memory
Network_memory(Network this)
{
  return Network_MEMORY(this);
}
Network_dgraph— This Network DGraph.
static inline DGraph
Network_dgraph(Network this)
{
  return Network_DGRAPH(this);
}
Network_rootNode— This Network root node.
static inline NetNode
Network_rootNode(Network this)
{
  return Network_ROOTNODE(this);
}
Network_nodeCount— This Network node count.
static inline int32_t
Network_nodeCount(Network this)
{
  return Network_NODECOUNT(this);
}
Network_FOREACH_NetNode— Iterate over this Network NetNodes.
#define Network_FOREACH_NetNode(this, node) \
  DGraph_FOREACH(Network_dgraph(this), NetNode_, node)
#define Network_ENDEACH_NetNode \
  DGraph_ENDEACH;
Network_FORSCAN_NetNode— Iterate over this Network NetNodes.
#define Network_FORSCAN_NetNode(this, node) { \
  NetNode node = Network_rootNode(this); \
  Except_CHECK(NetNode_SCANNODE(node) != NULL); \
  for (; node != NULL; node = NetNode_SCANNODE(node)) {
#define Network_ENDSCAN_NetNode \
  } \
}
Network_FORNEXT_NetNode— Iterate over the spanning tree in forward thread order.
#define Network_FORNEXT_NetNode(this, node) { \
  NetNode Network_ROOTNODE = Network_rootNode(this); \
  NetNode node = NetNode_NEXT(Network_ROOTNODE); \
  for (; node != Network_ROOTNODE; node = NetNode_NEXT(node)) {
#define Network_ENDNEXT_NetNode \
  } \
}
Network_FORPREV_NetNode— Iterate over the spanning tree in backward thread order.
#define Network_FORPREV_NetNode(this, node) { \
  NetNode Network_ROOTNODE = Network_rootNode(this); \
  NetNode node = NetNode_PREV(Network_ROOTNODE); \
  for (; node != Network_ROOTNODE; node = NetNode_PREV(node)) {
#define Network_ENDPREV_NetNode \
  } \
}
Network_makeNode— Make a NetNode in this Network.
NetNode
Network_makeNode(Network this, int require);
Network_makeArc— Make a NetArc in this Network.
NetArc
Network_makeArc(Network this, NetNode t_node, NetNode h_node, int32_t delay, NetArcFlags flags);
Network_activate— Fill this Network ACTIVE arcs.
void
Network_activate(Network this);
Network_active— This Network ACTIVE PtrSeq.
static inline PtrSeq
Network_active(Network this)
{
  return Network_ACTIVE(this);
}
Network_ACTIVE_FOREACH_NetArc— Iterate over this Network ACTIVE arcs.
#define Network_ACTIVE_FOREACH_NetArc(this, arc) { \
  PtrSeq Network_ACTIVE = Network_active(this); \
  PtrSeq_FOREACH(Network_ACTIVE, NetArc, arc) {
#define Network_ACTIVE_ENDEACH_NetArc \
  } PtrSeq_ENDEACH \
}
Network_active— This Network QUEUED IQueue.
static inline IQueue
Network_queued(Network this)
{
  return Network_QUEUED(this);
}
Network_QUEUED_FOREACH_NetArc— Iterate over this Network QUEUED arcs.
#define Network_QUEUED_FOREACH_NetArc(this, arc) { \
  IQueue Network_QUEUED = Network_queued(this); \
  IQueue_FOREACH(Network_QUEUED, NetArc, Network__ARC) { \
    NetArc arc = *Network__ARC;
#define Network_QUEUED_ENDEACH_NetArc \
  } IQueue_ENDEACH \
}
Network_circuit— This Network CIRCUIT PtrSeq.
static inline PtrSeq
Network_circuit(Network this)
{
  return Network_CIRCUIT(this);
}
Network_pretty— Pretty-print this Network nodes and arcs.
bool
Network_pretty(Network this, FILE *file);
Network_prettyTree— Pretty-print this Network spanning tree.
bool
Network_prettyTree(Network this, FILE *file);
Network_checkTree— Check this Network spanning tree.
bool
Network_checkTree(Network this, bool flows);
Network_checkPrimal— Check this Network is primal solved.

A network is primal solved when all arc flows are non-negative.

bool
Network_checkPrimal(Network this);
Network_checkDual— Check this Network is dual solved.

A network is dual solved when it has valid node potentials. In our case this means that no dependence is violated, that is, the tail and head nodes have DATEs whose difference is no smaller than the dependence DELAY.

bool
Network_checkDual(Network this);
Network_checkSolved— Check this Network is primal and dual solved.
bool
Network_checkSolved(Network this);
Network_doTSO— Topological Sort Ordering of the Acyclic NetArc(s).
void
Network_doTSO(Network this);
Network_doFLP— Forward Longest Path.

Build the longest-path spanning tree over the forward dependence graph in two steps. First step is to grow the spanning tree in increasing topological order of the forward dependence graph. This computes the longest path on the forward dependence graph in linear-time. Second step is to set the spanning tree indices (DEPTH, PREV, NEXT). The topological ordering must have been computed before in the SCANNODE by calling Network_doTSO.

void
Network_doFLP(Network this);
Network_doSLC— Simplex Label Correcting algorithm.

See "Efficient Shortest Path Simplex Algorithms" by D. Goldfarb, J. Hao, S.-R. Kai, in Operations Research, Vol. 38, No. 4, July-August 1990.

void
Network_doSLC(Network this, bool refill);
Network_doCNP— Compute Node Potentials from scratch, given a spanning tree.

The spanning tree is traversed top-down using the NEXT indices.

void
Network_doCNP(Network this);
Network_doCEF— Compute Edge Flows from scratch, given a spanning tree.

The tree is traversed bottom-up using the PREV indices.

void
Network_doCEF(Network this);
Network_dualSolve— Network simplex dual solver.
void
Network_dualSolve(Network this);
Network_primalSolve— Network simplex primal solver.
void
Network_primalSolve(Network this, bool refill);
Network_updateDelay— Update an arc delay and the node dates.
void
Network_updateDelay(Network this, NetArc q, int32_t delay, bool queue);