You are on page 1of 9

c),

Computers d Chemical Engineering, Vol. 3, pp. 363-371, 1979 0098-1354/79/040363-09E02.00/0


Printed in Great Britain. All rights reserved. Copyright © 1981 Pergamon Press Ltd.

Paper 6B.2

A NEW ALGORITHM FOR PROCESS FLOWSHEETING


R. HERNANDEZ and R. W. H. SARGENT*
Imperial College, Department ofChemical Engineering and Chemical Technology, Prince Consort Road,
London SW7, England

(Received 3 November 1979)

Abstract—A new algorithm is described for organizing the computations in a process


flowsheeting system designed to handle mixed systems of equations and procedures. It is
essentially a depth-first implicit enumeration algorithm based on partitioning and tearing
techniques, but also uses automatic algebraic manipulation to take further advantage of the
structure.

Scope—Process design or simulation gives rise to the need for solving large sets of nonlinear
algebraic equations. For steady-state calculations the equations are naturally algebraic, at least
for lumped-parameter models of individual units, while dynamic problems involve mixed
systems of algebraic and differential equations whose solution in turn involves repetitive
solution of algebraic systems.
Typically problems give rise to sets of several thousand equations, but each equation will
usually involve only a dozen or so variables, and this sparsity must be exploited for efficient
solution. The equations have a definite structure, reflecting the structure of the process units
and the topology of the process flow-diagram, but this structure varies from problem to
problem and does not conform to a fixed sparsity pattern, as occurs for example in the
numerical solution of partial differential equations. Thus the solution procedure must include
means for detecting the sparsity pattern and appropriate means of compact storage of the data
for arbitrary sparsity patterns.
Large sparse systems of this type can usually be decomposed, or 'partitioned' into a set of
smaller problems which can then be processed sequentially, results from one problem
providing data for the next. There are then two basic approaches to solving these sub-
problems, either simultaneous solution or the use of further decomposition by `tearing'—the
choice of a certain subset of variables, whose values are adjusted in an outer loop, such that the
subset of equations determining the remaining variables can be further partitioned, usually into
a sequence of single-variable problems.
In both approaches one is left with residual sets of nonlinear algebraic equations to solve,
which are most effectively dealt with by either Newton's method or a quasi-Newton method.
These methods require the solution of systems of simultaneous linear equations involving the
Jacobian matrix of the system or an approximation to it, and hence the generation of its inverse
or its factorization. In the simultaneous solution approach this matrix reflects the sparsity
pattern of the underlying nonlinear system, and if the storage problem is not to get out of hand
solution techniques must be used which minimize the increase of density, or fill-in of non-zero
elements, in the inverse or factorization.
In spite of the development of these general techniques for large systems of equations over
the last fifteen years, the parallel development of chemical process flowsheeting systems has
made little use of them. Most flowsheeting systems rely on the building up of a library of
special-purpose routines for the design or simulation of the various units used in chemical
processes, with an executive programme which uses the topology of the process flow-diagram
to link these routines into a computable sequence. Again tearing techniques are used to deal
with recycle streams or other information loops arising from controls or design specifications.
There are obviously great advantages to be gained from writing special-purpose routines for
standard units. Not only can the sparsity-pattern of their describing equations be exploited,
but also their algebraic structure, and account can even be taken of numerical conditioning,
derived from the known physical behaviour of the unit. However the rigid structure of the unit
routines in general makes the composite solution for the whole process less effective,
particularly for design or dynamic simulation. The relative computational advantages of the two
approaches is still a subject of debate, but the great drawback of procedure-based flowsheeting
systems is the effort involved in building up a sufficiently comprehensive library of routines,
and the inevitability of the occurrence of many special units, with the consequent need for much
one-off programming for any particular problem.
Of course an equation-oriented flowsheeting system also needs a library of models for
standard units, the difference being that these are merely sets of describing equations which are

* Author to whom correspondence should be addressed.


363
364 R. HERNANDEZ and R. W. H. SARGENT

assembled by the executive, again using the process flow-diagram. Thus the models are easier
to write and debug, and no expert knowledge of numerical methods is required, since these are
built into the main executive programme. However, although automatic algebraic
manipulation has made great strides in recent years, making possible some exploitation of
algebraic structure, it would at present be prohibitive in computing costs to provide for
automatic sensitivity analysis of the assembled system of equations. Hence a practical flow-
sheeting package ought to be capable of dealing with mixed systems of procedures
(subroutines) and equations, so that special-purpose routines can be used for subsets of
equations known to be ill-conditioned. Such a system of course also has the advantage that
existing libraries of routines, both for process units and for physical property calculations, can
be incorporated if desired.
Sargent [1] has given a review of the techniques now available for partitioning and tearing of
both systems of procedures and systems of equations, and outlines an algorithm for dealing
with mixed systems. Duff [2] gives a more detailed review of sparse matrix techniques, and Lin
& Mah [3,4] describe the implementation of their own 'hierarchical partitioning' algorithm
for the simultaneous solution of the sparse irreducible subsets obtained after partitioning. The
present paper describes the implementation of the algorithm for mixed systems outlined by
Sargent [1], and discusses the more extended use of automatic algebraic manipulation. To
explain the motivation for the algorithm some general properties of systems of equations are
summarized in Section 1, the algorithm is described in Section 2, and the problems associated
with its implementation are discussed in Section 3.
Conclusions and Signifiance—A number of problems exist in the implementation of the
previously outlined algorithm. Their solution by the use of standard programs for algebraic
manipulation appears promising. However, with present programs such use will be expensive
in computing time but significant savings can be made by special-purpose coding. We need• to
have a clearer idea of the benefits of this approach before undertaking it.

1. SYSTEMS OF EQUATIONS example the resulting subproblems are irreducible, in


1.1 Partitioning and tearing the sense that none of them can be further partitioned.
In this section we consider only 'square' systems, It is well known (see [1] for a proof) that the partition
containing the same number of equations and vari- of a square system into a sequence of irreducible
ables, and assume that the system has a solution. subsets is unique to within permutations of disjoint
Let us first consider the following example: subsets (i.e. subsets of equations with no variables in
common other than those occurring in earlier subsets
fl (Xl, X2, X5, X6) =0 of the sequence).
12 (X19 X3) =0 The irreducible subsystems can be further de-
composed by 'tearing'. For example, in the first
A (X i, X2, X3, X4, X6) = 0 (1.1) subsystem of Fig. 1(b) we could guess x3, compute x4
f4 x3) =o from Eq. (4), and then a new value of x3 from Eq. (2),
which can be used to revise the estimate of x3 in order
A (xi, x2, x4, xs, x6) = 0 to repeat the iteration. Similarly in the last subsystem
f6 (x 1, x3, x 5) = 0. we could guess x6, then compute x2 from Eq. (1), x4
from Eq. (3), and finally a new value of x6 from Eq. (5).
These six equations in six unknowns could in principle Thus the system has been decomposed into a sequence
be solved simultaneously. However, instead we could of one-variable problems. Each equation is solved for a
start by solving the second and fourth equations for x i certain variable (its 'output variable'), and the guessed
and x3, then the last equation for x5, and finally the (or 'torn') variables form outer iteration loops linking
remaining three equations for x2, x4 and x6. Such a all the variables and equations in their subset. In Fig.
decomposition saves both storage and computation 1(b) the variables have been ordered so that the output
time. variable for each equation lies on the diagonal of the
Analyses of decompositions like this are made more occurrence matrix.
easily by use of the occurrence matrix M of the system, The approach to developing algorithms for par-
which has a row for each equation, a column for each titioning and tearing has been to start by finding a
variable, and elements defined by feasible assignment of output variables to equations.
Each equation then becomes a 'procedure' for calculat-
1 if variable j occurs in equation i ing its output variable from the other variables
Mu = (1.2)
0 otherwise occurring in it, taken as inputs, and standard algor-
ithms for partitioning and tearing of directed graphs
The occurrence matrix for system (2.1) is given in Fig. may then be used, as described by Sargent [1].
1(a). However these algorithms are not trivial, and the
finding of an output set is itself not a trivial task.
The above decomposition into a sequence of sub- Moreover, although the partitioning is unique, and
problems is equivalent to reordering the rows and hence obtained from any feasible output set, the
columns of the occurrence matrix to put it into block conditioning of each subproblem and the minimum
triangular form, as shown in Fig. 1(b), and this process number of torn variables required for complete de-
is known as 'partitioning' the system. In the above composition both depend on the choice of output set,
New algorithm for process flowsheeting 365

Variables Variables
I 2 3 4 5 6 I 3 5 2 4 6

I I I I I 4 0 I

N
2 1 I 2 I 0
0 3 1 I I I i
C
0 6 I I 0
0
cr
w 4 1 I
S
L
cr I I I C) I
5 1 I I I I 3 I I I 0 I
6 I I I 5 I I I I 0
(a) (b)
Fig. 1. Occurrence matrix and partitioning.

and the computing requirements for analysing each be less than the minimum number for the complete
subproblem for all possible output sets become decomposition of any subset, and we shall use this
prohibitive. result later.
Further difficulties are illustrated in the example in
Fig. 2, which gives an occurrence matrix already in
partitioned form. A possible solution procedure for the 1.2 Rectangular systems
first block is to guess variables 1 and 2, compute So far we have considered only square systems, with
variables 3-5 in turn from Eqs. (1)—(3) respectively, the same number of variables and equations. However
then use the residuals of Eqs. (4) and (5) to correct the most design problems yield rectangular systems, with
guesses. However this scheme does not use a feasible many more variables than equations. The additional
output assignment, since variable 1 does not occur in degrees of freedom may be taken up by heuristic
either of Eqs. (4) or (5) ! Thus even if we analyse the choices of some variable values on the part of the
system for all possible output sets, we shall still miss a designer, and clearly a judicious choice of the variables
whole class of feasible solution schemes—which could so fixed could simplify the analysis of the remaining
well contain the optimum scheme! square system—for example by decreasing the size of
Each block in Fig. 2 requires at least two torn the irreducible subsets and the number of tears re-
variables for complete decomposition of the block, quired for complete decomposition. On the other hand
making four torn variables for the whole system. the choice is not completely arbitrary—for example we
However we could start by guessing variables 6 and 7, cannot independently fix all mole fractions in a
then compute variables 8, 9,1 and 2-5 in turn as output mixture since their sum must be unity.
variables of Eqs. (6)—(9) and (1)—(3) respectively, finally For a system of m equations in n variables (n m),
using the residuals of Eqs. (4) and (5) to correct the we can imagine the extra (n — m) degrees of freedom
guesses. Hence the minimum tear set for the un- taken up by adding (n — m) extra equations, each
partitioned system is smaller than the union of the containing all the variables. We then have a square
minimum tear sets for the partitioned blocks, and it is system, for which we know there is a unique partition,
not necessarily optimal to partition first and then and since the extra equations contain all the variables
analyse the individual blocks! they must be in the last block. Hence these equations
Of course the minimum number of torn variables for can be permuted to the last (n — m) rows and then
the unpartitioned system cannot exceed the sum of the deleted, leaving a unique partition of the original
minimum numbers for each block (since their union is rectangular system. The situation is illustrated in Fig. 3
a feasible tear set for the whole system). Sargent [1] has for 5 equations in 7 variables.
also shown that the number of torn variables for We see that the free 'decision variables' fixed by the
complete decomposition of the whole system cannot designer must be taken from the last block, and a

Variables

I 2 3 4 5 6 7 8 9
Variables

0
-

I
I 2 3 4 5 6 7
0
C\Ir+)

I I

I I 0 I I I

2 I I ;
,

I I I
tIn

1 i
I I 0 3 I L P
I
0 1
6 I I 0 3
0"
4 II I I
I ■ I I I
7 I I 0 5 I
-I I I :I 1 I I I
8 I I I I
-I I III I I I
9 I I I I I

Fig. 2. Tearing. Fg. 3. Rectangular system.


366 R. HERNANDEZ and R. W. H. SARGENT

judicious choice may permit further partitioning of We can now compare the solution of the un-
this block, as indeed happens in Fig. 3. partitioned system with that obtained by partitioning
Alternatively, the rectangular system of equations into two subproblems. Using the above properties, and
may form equality constraints in a mathematical with an obvious notation, we may then write
programming problem. Partitioning and tearing may m = mi + m2, e ei + e2
then be used to solve for some of the variables, thus (1.4)
N N 1, N N2.
reducing the effective size of this programming prob-
lem. Specifically we choose 'decision Assuming the equations are ordered according to the
variables', yielding a sequence of (n — d) one-variable partition, we then have
equations to solve for the remaining variables, and a m,
set of (d — n + m) residual equations as equality C — (C, + C2) = N(ae + E — N i(ae, + E r,
constraints in the reduced problem. From the above it i=1
is clear that (n — m) of the decision variables must be
taken from the last block ; the other decision variables — N 2(ae2 + E
and the residual equations arise from the complete i=+1 ri)
decomposition of the resulting set of square
subsystems. N(ae + E ri) — N(ae, + iE ri
i 1
m
1.3 Computing costs — N(ae2 + E ri
It is clear from the results of Section 1.1 that the 1=m,
commonly accepted strategy of partitioning, followed Na(e — el — e2) 0.
by complete decomposition using the minimum
Since one of the inequalities in (1.4) will usually be
number of torn variables within each subset, is not strict, it thus follows that under the given assumptions
necessarily optimal, and in this section we attempt a
it will usually be advantageous to partition the system.
more detailed examination of computing costs. We
Since the same argument applies in turn to each of the
shall assume that the one-variable problems and sets
subproblems, the cost will usually be minimized by
of nonlinear equations are solved by a quasi-Newton
partitioning into irreducible subsets and solving these
method. Such a method starts with estimated values of sequentially.
the variables, and at each iteration requires the
When a system is completely decomposed by tear-
computation of the residuals of the equations, from
ing, the approximate Jacobian matrix for the outer-
which new estimates are obtained by solving an
loop iteration on the torn variables is usually full, and
approximating linear system. The coefficient matrix of
hence e = where t is the number of torn variables.
this linear system may be regarded as an approxima-
The residuals for this system are the residuals of the
tion to the Jacobian matrix, and has the same occur-
last t equations, after substituting the results from the
rence matrix as the nonlinear system itself ; it is best
(m — t) one variable problems. Thus the cost of com-
stored in factored form to conserve sparsity and
puting the solution may be written
facilitate the solution of the linear equations. The
residuals are also used to update the factors of this
approximate Jacobian at each iteration, and the work C= E Cate + E riNij , (1.5)
i=1 1=1
involved both for this update and for the generation of
the new estimates of the variables is proportional to where N, is the number of iterations required to solve
the number of non-zero elements (e) in the factors. The equation i during the jth outer iteration, with Nu = 1
cost of computing the solution is then for the last t equations. We also have N1 = 1 if
equation i is linear (hence explicit) in its output
C = N(ae + E (1.3) variable ; otherwise N1 depends on the conditioning of
i= the equation, and also on the distance of the initial
value from the solution, which in turn depends on the
where N is the number of quasi-Newton iterations, a is
rate of convergence of the outer loop. However it is
a constant depending on the quasi-Newton method
reasonable to suppose that N is a non-decreasing
used, and ri is the cost of evaluating the residual of the function of t, and that we may write
ith equation. The constant a and the ri can be obtained
N
by operation counts.
It is worth noting that (1.3) applies to a rectangular E Nu = piN, pi Z 1, (1.6)
1=
system, provided that the additional degrees of free-
dom are taken up by specifying values of an ap- where pi, if not constant, is only a slowly varying
propriate number of variables; the additional work function of t. Using (1.6), the cost in (1.5) may then be
affects only the values of the ri. written
We first consider the simultaneous solution of a
sparse set of equations. Whatever form of factorization C = N(at2 + E (1.7)
is used, the fill-in is usually a convex function of the i=
number of non-zero elements in the original matrix. The justification of tearing is based on the assumption
Thus if we assume that each equation contains ap- that the increased work in solving the one-variable
proximately the same number of variables, the number problems at each iteration is more than compensated
of non-zero elements is proportional to m and hence e by the reduction in the number of iterations, and to a
is a convex function of m. Similarly N tends to increase lesser extent by the reduced work in the update for the
with the size of problem, and it is not unreasonable to smaller outer-loop problem. This reasoning naturally
assume it is a non-decreasing function of m. leads to the choice of the minimum number of tears to
New algorithm for process flow sheeting 367

achieve the decomposition. However it is not obvious Then from (1.7) and (1.12), with appropriate ordering
from (1.5) or (1.7) that this will generally be optimal. It of the equations :
will obviously be so if the first term in (1.7) is much
larger than the second, or if N is a strongly increasing C — (C 1 + C2) = Na(t2 — ti —
function of t, but neither of these situations is likely to
be common. If rip; is unduly large for any equation i, E rAP. (Pi)i) + N E
+N ri(Pi (P1)2)> 0,
it could well be that a net reduction in C will occur i----- 1 1=m1+1
by using i to compute a residual rather than using it
in a one-variable problem, even if this increases t. and the result follows.
Nevertheless, the basic assumption does not seem too Finally there is the question of whether tearing is
unreasonable if there are no very large values of r1 or pi. preferable to the simultaneous solution of the irreduc-
Accepting the strategy of choosing the minimum ible subsets, which involves comparing Eqs. (1.3) and
tear set, we can again examine the desirability of (1.7). First, if we consider pivot selection procedures of
partitioning into two subproblems. Recalling the the type used by Lin & Mah [3] it is easy to conclude
properties of minimum tear sets given at the end of that e > 12. In the general case we are then left, as in the
Section 1.1, and using the above assumed property of choice of the tear set, with the balance between the
N, we have increased work of iteration on the one-variable prob-
lems and the resulting decrease in the number of outer
m = ml + m2, t < ti + t2, iterations. However, in the special case where most of
t t2, (1.8) the one-variable equations are explicit in their output
variables (i.e. p, = 1), it is clear that we shall gain
N N 1, N N2.
advantage from tearing.
We shall also assume that the p1 are constants. This reasoning would seem to indicate that if we can
Let us first consider the case where all one-variable reduce the number of torn variables by isolating and
problems are of approximately the same difficulty, and solving subsets of linear variables, rather than de-
assume composing these to one-variable problems, we shall
also gain in computing costs.
pi = p, ict T; r1 = r, all i, (1.9) However the considerations are different for a
completely linear system. Here pi = 1 for all i, and with
where T denotes the appropriate minimum tear set. Of e > t2 tearing gives somewhat less work per iteration
course we have Nu = 1 and hence pi = 1 for i e T. than simultaneous solution. However, simultaneous
From (1.7) and (1.9) we have solution is a direct method, and if the initial matrix is
C = N(at2 + rp(m — t) + rt), (1.10) the correct Jacobian matrix the solution will be
obtained in one 'iteration'. On the other hand, if
and hence, using (1.8): Broyden's method [5] is used with an arbitrary initial
matrix the convergence is only superlinear. Solution
C — (C, + C2) = N{at2 + rpm — rt(p — 1)}
by tearing is in any case an iterative method, and it is
—N,{ati + rpm, — rti(p — 1)) well known that such methods are less efficient than
direct methods when the correct Jacobian is available ;
— N2{ati + rpm2 — rt2(p — 1)}
when it is not, it is impossible to draw general
Na(t2 — t?— ti) conclusions about the relative efficiency of the two
(1.11) methods.
+ Nr(p — 1)(t 1 + t2 — t).
It follows from (1.8) that the second term here is non-
2. THE ALGORITHM
negative, but unfortunately we can draw no conclu-
sions about the sign of the first term. However, it is From the discussion in the last section it would seem
usually the case that t = t + t2, and then (1.11) desirable to develop an algorithm which will partition
confirms that C > C1 + C2 and partitioning to ir- an arbitrary rectangular system of equations into a
reducible subsets is advantageous. sequence of irreducible subproblems, and then identify
The only failing case is illustrated in Fig. 2; it a minimum tear set for each of these subproblems to
requires in general that the two blocks are disjoint reduce them to a sequence of either one-variable
except for the torn variables in block one, and some of problems or linear subsets. We also need to in-
these must occur in block 2 in lower-triangular corporate the treatment of procedures in this
pattern. Even when this occurs we shall usually have t algorithm.
close to (t1 + t2), so that t2 > ti + ti and the conclu-
sion still follows.
Normally we have T = T, v T2, and even in the 2.1 Minimum tear sets
above failing case we can choose the minimum tear sets We start by considering the problem of finding a
so that T c T, u T2. It turns out that this condition, minimum tear set to reduce any system of equations to
together with the condition t2 > t? -1- ti suffices to a sequence of one-variable problems. First we note
prove that partitioning is advantageous without the that any permutation of the equations represents a
special assumptions of (1.9), for we have from (1.8): computable sequence. For each equation in the
sequence we simply guess all except one of the new
If i e : Pi =1 variables occurring in it and solve for the remaining
variable. If we encounter an equation which introduces
If ie T2 : Pi (P1)2 = 1 (1.12) no new variables (henceforth called a 'covered' equa-
Ifi T, u T2: Pi = (Pal = (P1)2 Z 1. tion), its residual can be evaluated and serves to correct
368 R. HERNANDEZ and R. W. H. SARGENT

a previously guessed variable. At the end of the equations must contain no new variables not in e, and
sequence, the number of residuals computed will be again we have case (b) above.
equal to the number of variables guessed (torn), Thus the rule is proved.
provided that the system of equations is consistent. The first rule above will be effective in eliminating
Of course the number of torn variables can be sequences if the first sequence in lexicographical order
counted, and the covered equations identified, simply has a small number of torn variables. A good strategy
from the occurrence matrix, without actually carrying is to number the equations by choosing the first to have
out the computations. Thus in principle it suffices to the smallest number of variables, and then at each
generate all possible permutations, evaluate each of point to add the equation which introduces fewest new
them, and pick out the one yielding the minimum variables. In fact this often yields immediately the
number of torn variables. In practice however it is by optimum sequence.
no means necessary to carry out such an exhaustive
enumeration. 2.2 Partitioning
First we note that the number of torn variables It is easy to modify this algorithm to partition the
increases monotonically as we progress along the system at the same time. At any point in evaluating a
sequence. Thus if at any point in the evaluation the sequence we normally have more variables than
number of torn variables exceeds the total number equations. However if we encounter a covered equa-
found for a previously evaluated complete sequence, tion, this increases the equation count without increas-
there is no point in continuing, and all sequences ing the variable count, and if at any point the two
starting with this partial sequence can be rejected. counts become equal we have clearly found an in-
Secondly, if we encounter a covered equation, or one dependent subset. At this point the system can be
that introduces only one new variable, the number of partitioned, and the two subsystems subsequently
torn variables is not increased, and one cannot im- analysed independently.
prove on this choice. Thus all completing sequences Such a partition greatly decreases the number (and
with a different equation in this position can be length) of permutations to be examined, and it is
rejected. therefore worthwhile modifying the algorithm to
Hence we carry out a 'depth-first' search of all search for partitions, rather than wait for them to arise.
possible permutations, generating these in lexico- This can be done by 'deleting' the variables from all
graphical order and abandoning partial sequences succeeding equations as they are introduced, and
according to the above two rules. At each stage we keeping a count of remaining variables in each of the
keep a record of the best complete sequence so far remaining equations as this is done. Then any covered
evaluated. equations found are immediately added to the partial
In additibn we also have the following rule for sequence in preference to the normal lexicographical
abandoning partial sequences : rule (abandoning all other completing sequences). If
these covered equations complete a block, then the
The Tack-track Rule' Suppose at some stage equ- system is partitioned as described above. If more
ation e is added to a sequence of s equations, yielding covered equations are found than are required to
t„1 torn variables, and later after back-tracking in the complete the block, then the additional covered
lexicographical order, e is added after the first r equations are either redundant or inconsistent ; the
equations of the same sequence (r < s), yielding algorithm treats them as redundant and eliminates
t, ts+ torn variables. Then e is removed, them, giving a warning message since an extra
and all completing sequences with e in this position degree of freedom has been created for each equation
are abandoned. eliminated.
To prove that the rule works we need to consider It should be noted that if partitioning is sought, one-
four cases : variable equations should not be given any special
(a) Suppose that equation e is covered by the first r preference as suggested in Section 2.1. This is because a
equations. In this case the second rule above applies, one-variable equation may not be part of the current
and the back-track rule is not applied. incomplete block, but will necessarily be included if
(b) Suppose that in the original partial sequence one other completing sequences are abandoned. The back-
of the extra (s — r) equations contained no new vari- track rule still applies however, since it is only
ables not in e. Then this equation is either covered by operative on permutations within an irreducible
the first r equations —and hence, by the second rule subset.
above, this should be in position (r+ 1) rather than
e —or its output variable is contained in e, in 2.3 Mixed systems
which case there will be one fewer torn variables if it The algorithm is easily extended to deal with a
precedes e. mixture of procedures and equations. A procedure
(c) Suppose that each of the extra (s — r) equations computes a given set of output variables from a given
contains just one new variable not in e. Then with e in set of input variables. Thus, if it is inserted into a
position (r + 1) these equations should all follow e sequence of equations at any point, any of its input
immediately, by the second rule above, and of course variables not previously evaluated must be guessed;
the number of torn variables remains at t, 1 . But this is on execution the procedure then yields the values of all
just a permutation of the original (s + 1) equations the output variables, and thus counts as a block of one-
yielding t,,1 1 , so that any completing sequence variable equations equal in number to the output
based on it cannot improve on the original sequence. variables. It may of course happen that any one of the
(d) Finally, suppose that one of the extra (s — r) output variables has been previously evaluated, in
equations contains more than one new variable not in which case the difference between this previous value
e. Then since t„ is ,, at least one of the other extra and the value given by the procedure provides a
New algorithm for process flowsheeting 369

residual, and hence counts as a covered equation There are several situations when we are left with an
instead. No other changes in the algorithm are incomplete (rectangular) linear subset, in which case it
required. is necessary to guess enough variables in it to render it
square. Again application of the algorithm will yield
2.4 Linear subsets the appropriate partition, and hence a permissible set
Finally we consider the extension necessary to of candidates for guessing, as illustrated in Fig. 3. This
identify linear subsets of equations. Here we count situation can arise on completion of a sequence, on
separately the linear variables and the equations in the detecting a partition, or when the next equation or
current linear subset, as well as the total variable and procedure determines so many variables that fewer
equation counts as before. Again, equality of the linear variables than equations are left in the linear subset.
variable and equation counts identifies a linear subset, This last situation does not force a return to the
while equality of the total counts indicates a partition rectangular system, since we could, as above, move up
of the whole system. this last equation, select a square system from the
The procedure is illustrated by the example in Fig. 4. linear subset (preferably one which gives maximum
In this figure L denotes a linearly occurring variable, N partitioning) and leave the others as covered equa-
a nonlinear variable and X a previously determined tions. However, this treatment is never better than
variable. decomposing the rectangular system, leaving the last
equation to follow it.
To illustrate this situation, suppose Eq. (5) also
Variables Total Linear involved variables 6 and 7 nonlinearly. Then, moving
I 2 3 4 5 6 78 E V E V up Eq. (5), we should guess two of the three nonlinear
variables in it and solve for the remaining one, leaving
I L L N L L I 5 I 4
Eqs. (1), (2) and (4) involving only variable 1; Eq. (2)
2 L X L N 2 7 2 5 could be solved explicitly for variable 1, leaving Eqs. (1)
0 3 L N X 3 7 2 3 and (4) as covered equations. On the other hand,
0 4 L X X L L X 4 8 3 4 leaving Eq. (5) in place, Eqs. (1), (2) and (4) involve
cr
w 5 X X X N 5 8 3 3 variables 1, 5, 6 and 7. Guessing variable 7, we can
6 X X X X 6 8 0 0 solve Eq. (1) for variable 6, Eq. (2) for variable 1, and
Eq. (4) for variable 5, in each case explicitly, leaving Eq.
Fig. 4. Finding linear subsets. (5) as a covered equation. Note that if only variables 5
and 7 had occurred in Eq. (5) the score would have
been even, but no pattern in Eq. (5) can actually reverse
The counts for Eqs. 1 and 2 are self-evident ; the the scores.
nonlinear variables 4 and 8 will have to be guessed in It should be noted that the isolation of linear subsets
any case, but for the present both equations are as above reduces the number of partial sequences to be
retained as possible members of a linear subset. In Eq. examined. In the example of Fig. 4 the same result
(3) there is only one linear variable, so this is chosen as would have been obtained with any permutation of
output variable in preference to the new nonlinear Eqs. (1)–(5) in which Eq. (5) occurs later than Eq. (3).
variable 3, which is guessed. Since Eqs. (1) and (2) are More generally, in the block of equations from the first
still retained as possible candidates for a linear subset, to the last of the linear subset, any permutation which
this effectively moves Eq. (3) to the head of the preserves the order of the non-members of the subset in
sequence, with variables 2 and 3 known there- the sequence will yield the same result, and hence need
after—hence the linear subset contains two equations not be examined.
and three variables. Equation (4) adds a new equation For simplicity of explanation, it was assumed in the
and a new variable to the linear subset. Equation (5) above examples that the variables were already typed
contains one new nonlinear variable, which therefore as linear or nonlinear, but in practice such preanalysis
becomes its output variable, and it too is effectively cannot be done. Consider for example the equations :
moved to the top of the list after Eq. (3). Since its
1. x2x2x3 + x i x2 + x2x3 + x3x4 = 0
output variable was previously in the linear subset, the
latter's variable count is reduced by one, leaving a 2. x2x3 + x3x4 = 0 (2.1)
complete linear subset —Eqs. (1), (2) and (4), determin-
3. xix3 + X2X4 = 0.
ing variables 1, 6 and 7. Finally Eq. (6) is a covered
equation, serving as an equality constraint on the If none of the variables are known and the equations
values of the decision variables 3, 4, 8. If in fact Eq. (5) are processed in this order, the optimum solution is to
had been a procedure to determine variables 3 and 5 guess variables x 1 and x3, since Eqs. 1 and 2 then yield
given variables 2 and 4, then the only change would a linear subset in variables x2 and x4, with Eq. (3)
have been that the difference between the guessed covered. On the other hand, if the equations are
variable 3 (Eq. 3) and its value computed by the processed in the order 1, 3, 2, the optimum solution is
procedure would provide an additional residual and to guess variables x2 and x3, yielding a linear subset in
equality constraint. Of course in general a procedure x, and x4 followed by a covered equation. Any other
must be regarded as nonlinear in its input variables, choice gives more torn variables in each case.
and explicit in its output variables. Of course the situation would be essentially un-
Note that the linear subset in this example is in fact changed if x3 were known beforehand. Similarly, if x2
irreducible, but in general the linear subsets may be were known and the equations were processed in the
partitioned into smaller linear subsets, and of course order 1, 2, 3, one would guess x3, rendering Eq. (1)
the basic algorithm may be applied to them to achieve linear in x, and x4. Then Eq. (2) involves both of these
this. variables nonlinearly, so one would return to equation
370 R. HERNANDEZ and R. W. H. SARGENT

1, guessing either x, or x4 and solving for the other; greater or lesser degree, and this greatly restricts the
Eqs. (2) and (3) thus become covered equations. With choice. We experimented with SCHOONSCHIP [9]
x4 fixed beforehand, two more variables must be fixed and SYMBOLANG [10], both implemented on
in Eq. (1) to render it linear, and in fact any pair leaves CDC6000 series machines, but rapidly concluded that
the equation linear in the remaining variable, with 2 SYMBOLANG was better suited to our purpose. In
and 3 as covered equations. contrast to SCHOONSCHIP, which is written in
This simple example shows that each sequence must assembly code, SYMBOLANG is a set of
be analysed independently, and at each stage all FORTRAN-callable routines, mostly written in
possible sets of torn variables which produce a linear FORTRAN and based on the SLIP list-processing
subset must be retained. package. This is doubly advantageous, since the
resulting code is FORTRAN compatible, and the
2.5 Initial sequence SLIP facilities are otherwise useful for dealing with
When the search for linear subsets is included, the sparse systems. SYMBOLANG also proved to be
initial sequence described at the end of Section 2.1 is more flexible, and considerably more efficient in both
not very effective. What is needed is a heuristic method storage and computing time, for the particular kinds of
which produces clusters of equations containing as analysis involved.
many linear variables as possible. It has been found The essential algebraic step in finding linear subsets
that the following approach is reasonably successful : is to identify for each equation the tear sets which
Step 1. For each Eq. (i) determine the minimum render it linear, and the resulting linear variables, given
number of variables which must be fixed to render the the current set of previously determined variables. It
equation linear in the remainder. Compute a weight would be perfectly feasible to write a subroutine in
(w1) as the ratio of the nonlinear (fixed) variables to the SYMBOLANG to carry out this task, and then call it
linear variables, classifying the equations as follows : as each equation is added to a given partial sequence in
the implicit enumeration algorithm. However such a
I 1 5 wi 5 3, II wi > 3, III Iv; < 1.
routine involves substantial algebraic manipulation,
Step 2. Put the classes in order I—III with the and hence is quite expensive in computing time, so that
equations within each class in order of decreasing its repeated use in this way would be quite prohibitive.
weight. Fortunately much of the analysis of each equation
Step 3. If any Class III equation contains a non- can be made once and for all, and the results stored as
linear variable which is not nonlinear in any other FORTRAN arrays, so that no SYMBOLANG code
Class III equation, then move this equation to the end need actually be imbedded in the enumeration routine.
of the sequence. To explain how this is done, it is necessary to give a
Step 4. Treating all variables in the Class I equ- brief description of how algebraic expressions are
ations as known, recompute the weights of the Class H stored in SYMBOLANG; a complete description of
equations. the language will be found in [10].
(a) Reclassify these as necessary, putting the new An algebraic 'expression' is a sum of 'terms', stored
Class I equations below the existing ones and the new as a SLIP list. Each term has a signed numerical
Class III equations above the existing ones. coefficient multiplied by a product of 'factors', each
(b) Transfer any equations in Class II containing no raised to an 'exponent', where a factor is a variable or
linear variables to the end of the sequence. function, and an exponent is a signed number or an
Step 5. Repeat from Step 3 if any equations were 'expression'. A function has a list of arguments which
reclassified in Step 4. are themselves 'expressions'. It will be seen that the
Since procedures cannot provide equations to com- definitions are recursive, but will be finite for any
plete linear subsets but do provide their output practical expression, and the various components are
variables explicitly, it seems reasonable to insert them stored as a tree of sub-lists to the main list.
in the sequence as soon as all their input variables are A variable or a function can be defined to be any
known. This can conveniently be done in Step 4 where expression, in the latter case the expression being in
the fixed variables are identified for the purpose of terms of dummy arguments of the function. However
recomputing weights, and of course the output vari- undefined functions can also be included.
ables of the procedure are then assumed known below Subroutines are available for converting a
its insertion point. FORTRAN expression into a SYMBOLANG expres-
sion list and vice versa, and this in itself provides a
3. IMPLEMENTATION AND EXTENSIONS significant part of the analysis. From the
The tearing and partitioning algorithms of Sections SYMBOLANG lists for a given equation it is a
2.1-2.3 use only information contained in the occur- straightforward matter to identify 'simple' terms,
rence matrix of the system, but the isolation of linear which are a function of only one variable, and to check
subsets involves analysis of the algebraic structure of whether such terms are linear or nonlinear in the
the equations, and hence automatic algebraic manipu- variable concerned. For the remaining 'complex' terms
lation by the computer. it is also easy to check whether they are linear or
There is now a considerable number of packages nonlinear in each of the variables involved, and if the
available for this purpose, and useful surveys have term contains a function its input (nonlinear) variables
been published by Sammet [6], Engeli [7] & and output (linear) variables can be identified. The
Moses [8]. The packages serve a wide variety of variables, classified into these categories, are stored on
purposes, and provide a corresponding variety of SLIP lists during the analysis, but once this is complete
facilities, so that it is necessary to choose a package the number of elements in each list is known and the
which is well adapted to the purpose in hand. data can be re-packed into FORTRAN arrays.
However, most packages are machine dependent to a Further savings are achieved by numbering the variab-
New algorithm for process flow sheeting 371

les as they are read, thus providing integer identifiers mathematical programming problem it provides the
for the variables and avoiding reference to them by constraint gradients, as required by efficient mathema-
name in the above analysis. tical programming algorithms.
The final FORTRAN arrays are thus integer arrays, At the level of the nonlinear one-variable problems,
and the repetitive analysis of each equation in the the derivatives permit the use of cubic interpolation for
enumeration algorithm when it is added to different the solution. At the pre-processing stage they could
partial sequences can be carried out by simple also be evaluated using the initial estimates of the
FORTRAN instructions. variables, and put in order of decreasing magnitude for
This is sufficient to execute the algorithm as de- each equation to provide a priority list for the choice of
scribed in Section 3, but with SYMBOLANG facilities output variable based on numerical conditioning.
available a number of other useful operations can be The automatic provision of consistent derivative
carried out, which further exploit the algebraic formulae is a great boon, not only because of the direct
structure. saving of coding time, but because it is easy to make
Probably the most powerful of these is the simplifi- mistakes in the algebra and the coding, and incon-
cation of the system of equations by substituting a sistency of the derivative values is the commonest
simple variable for any repeated expressions ; a new cause of failure of numerical routines which require
equation is then created, equating the expression to them.
this new variable. Not only does this ensure that such Nevertheless it has to be said that automatic
repeated expressions are evaluated only once, which is algebraic manipulation is at present very expensive in
a direct saving of computation, but the total number of computing time, especially using standard packages
variables in the equations concerned is reduced, and which provide a wide range of facilities. The operations
the number of linearly occurring variables increased, described above use only a fraction of the
so that the decomposition is more effective. A similar SYMBOLANG facilities, and it is certain that con-
effect is obtained by treating each function as a simple siderable savings could be made by writing code
variable, with its definition treated as an additional specifically for these operations. This is in itself a large
equation; it is important to note that the function is a task, and we need to have a clearer idea of the benefits
different variable, with a corresponding distinct defin- of this approach before undertaking it. At present we
ing equation, for each distinct set of actual arguments have very little numerical experience, and are still very
which occur in the equations. much at the exploratory stage.
Obviously such simplifications are carried out be-
fore decomposition, but having obtained the optimal
computational sequence it is clearly advantageous REFERENCES
to convert as many as possible of the one-variable 1. R. W. H. Sargent, The decomposition of procedures and
subproblems to a formula which explicitly evaluates algebraic equations. (Ed.) G. A Watson Numerical
the output variable. If the equation is linear in its Analysis—Proc., Biennial Conf., Dundee 1977, Lecture
output variable the operation is trivial, but often more Notes in Mathematics 630, 158-178, Springer-Verlag,
complex expressions can be reduced by the use of Berlin (1978).
inverse functions, as illustrated by the following 2. I. S. Duff, A survey of sparse matrix research. AERE
Harwell Rep. CSS28 (1976).
example:
3. T. D. Lin & R. S. H. Mah, Hierarchical partition—a new
x1F(x2) - x2 exp (xixi + x2) = 0. (3.1) optimal pivoting algorithm. Math. Programming 12(2),
260 (1977).
If x3 is the output variable, this is clearly a nonlinear 4. T. D. Lin & R. S. H. Mah, A sparse computation system
equation, but straightforward manipulation yields the for process design and simulation. Part I AIChE J. 24(5),
explicit FORTRAN expression : 830 (1978); Part II AIChE J. 24(5), 839 (1978).
5. C. G. Broyden, A class of methods for solving nonlinear
x3 = SQRT((ALOG(xi F(xs)/x2**2) — x2)/xi). (3.2) simultaneous equations. Math. Comp. 19, 577 (1965).
The general principle for explicit solutign is that at 6. J. E. Sammet, Survey of formula manipulation.
Communications of the Association of Computing
each level of expression the output variable occurs in a
Machinery 9(8), 555 (1966).
single term of the argument of an invertible function, 7. M. E. Engeli, Achievements and problems in formula
and a single term of the equation itself. manipulation. Proc. IF IP Congress 79, North Holland
Finally, SYMBOLANG provides routines for the (1968).
symbolic differentiation of expressions, so that explicit 8. J. Moses, The evolution of algebraic manipulation algor-
formulae for partial derivatives, gradients and ithms. Information Processing 74,483 (1974).
Jacobian matrices can be generated from the equ- 9. H. Strubbe, Manual for Schoonschip a CDC6000/7000
ations. When tearing is used, expressions for the Program for Symbolic evaluation of algebraic expres-
Jacobian of the residual equations with respect to the sions. Computer Physics Communications 8, 1 (1974).
10. H. J. Bernstein, The algebraic manipulation package
torn variables can then be generated by the chain rule. SYMBOLANG, in N. V. Findler, J. L. Pfaltz and H. J.
This Jacobian is then available for solution of the Bernstein. Four High-Level Extensions of FORTRAN IV :
outer-loop iterations by Newton's method, or if these SHP, AM PPL-II, TREETRAN, SYMBOIANG.
residual equations are treated as constraints in a Spartan Books New York (1972).

You might also like