Petrinet and Dynamic Programming
Petrinet and Dynamic Programming
Holger Mauch
University of Hawaii at Manoa
Dept. of Information and Computer Science
1680 East-West Road
Honolulu, HI 96822
[email protected]
ent when we survey currently existing software supporting ations of the simplex algorithm), the nonlinear solver (us-
the solution of DP problems in section 3. There seems to be ing succesive linear programming (SLP) or generalized re-
no system that can apply DP to a wide variety of problems. duced gradient (GRG) algorithms), or the branch and bound
Current software systems can only solve a narrow class of solver.
DP problems with a rather simple DP functional equation. DP software accompanying textbooks such as [2] does
The suggested model is illustrated by a simple financing not generalize well. It is usually restricted to instances of
problem to display real-world relevance. As a second exam- one problem.
ple a typical textbook type of DP problem has been chosen: Microsoft Excel and mathematical packages such as
chained matrix multiplication. Matlab and Mathematica have only limited capabilities to
solve optimization problems.
2. Previous Work
4. Introduction to Petri Nets
While there are several papers addressing the use of DP
to solve PN problems, there is little prior work addressing Petri Nets are named for Prof. Dr. Carl Adam Petri, Uni-
the use of PN to solve DP problems. versity of Hamburg, Germany, who developed schemata
Richard [8] showed that an integer linear program (ILP) that allowed the modeling of parallel and independent
can be associated with sequential timed Petri nets (STPN). events in an illustrative manner. The following formal defi-
The decision variables of the ILP correspond to the PN’s nitions follow the notation used in [7].
characteristic vector, i.e. the vector which tells how often The first definition desribes the basic syntactic properties
each transition is fired. Linearity is necessary for this model that a net, as used in the following, should have.
and it is only determined that a solution in the form of a fir-
ing sequence within the PN exists, but not how to construct Definition 4.1 (Net)
such a firing sequence. A triple N = (S, T, F ) is called a net iff
Mikolajczak and Rumbut [5] formally specify dis-
tributed DP problems with colored PNs. The examples used 1. S and T are disjoint sets and
are the optimal polygon triagulation problem and the op-
timal binary search tree problem. One of the conclusions 2. F ⊆ (S × T ) ∪ (T × S) is a binary relation called the
is that the sugested PN model allows reuse of concurrency flow relation of N.
patterns and is thus useful for problems to be computed on
distributed systems. Mathematically speaking our notion of a net is a directed
bipartite graph. For convenience we use the following nota-
tion.
3. Software Systems for Dynamic Program-
ming Problems Definition 4.2
Let N = (S, T, F ) be a net. For x ∈ S ∪ T
We briefly survey existing software system that enable •x = {y|(y, x) ∈ F } is called the preset of x,
the user to solve instances of DP problems. x• = {y|(x, y) ∈ F } is called the postset of x.
Attempts to develop general-purpose DP computer codes
have apparently been made by Hastings [1] and others.
In this paper we use a low-level PN class called
While Hasting’s “DYNACODE” is mentioned in many ref-
place/transition net.
erence lists, there is no readily available information about
it. Sniedovich characterizes these codes in [9, p.193] as
Definition 4.3 (Place/Transition Net)
problem specific and concludes that “no general-purpose
Let N denote the set of nonnegative integers, and
dynamic programming computer codes seem to be available
let ω denote an infinite capacity. A 6-tuple N =
commercially.”
(S, T, F, K, M, W ) is called a place/transition net iff
The optimization package system LINGO / LINDO
solves optimization problems across a wide problem do- 1. (S, F, T ) is a finite net,
main with a variety of solution methods. While its strength
lies in the areas of linear programming, and to some ex- 2. K : S → N ∪ {ω} gives a (possibly unlimited) capac-
tent in integer programming and nonlinear programming, it ity for each place,
is only of very limited use to tackle DP problems. After a
general specification of the optimization problem, LINGO 3. W : F → N − {0} attaches a weight to each arc of
determines whether to employ the linear solver (using vari- the net, and
4. M : S → N ∪ {ω} is the initial marking where all Here s denotes a state, f is the minimization functional,
the capacities are respected, i.e. M (s) ≤ K(s) for all a is a decision that can be made in state s, d is the decision
s ∈ S. cost function, and s(k) are the K next states, and s0 are base
case (initial condition) states. The PN model corresponding
Elements of S are called places, elements of T are called to this DP problem has
transitions.
1. a state place ps for each state s, that has, except for the
Graphically, places will be represented by circles; tran- base case state places, a unique minimization transition
sitions will be represented by squares. If p ∈ S is a place, in its preset,
then the fact that p contains k tokens is represented by writ-
ing the number k inside p’s circle. The weighted arcs of the 2. a min-in place pm for each decision a, that has a min-
flow relation are represented by weighted directed edges in imization transition in its postset, and whose initial
the bipartite graph. marking equals d(a),
The dynamic behavior of a place/transition net is de-
scribed in the following definitions. 3. a minimization transition associated with each state
place ps , except for the base case state places, that has
Definition 4.4 in its preset the min-in places for each decision a,
Let N = (S, T, F, K, M, W ) be a place/transition net. A
transition t ∈ T is activated if 4. a copy transition that transfers tokens from the state
place associated with s(k) to those min-in places whose
1. for every place p in the preset •t the number of tokens decision a involves the summand f (s(k) ).
at p is greater or equal to the weight W (p, t) of the
arrow from p to t and 5.2. The Role of Transitions in the PN Model
2. for every place p in the postset t• the number of tokens
at p plus the weight W (t, p) of the arrow from t to p Transitions serve two different purposes in the model.
does not exceed the capacity K(p) of p.
• Processing Transitions: Transitions can be considered
Definition 4.5 as processing elements. E.g. there are minimization
Let N = (S, T, F, K, M, W ) be a place/transition net. An transitions, addition transitions, multiplication transi-
activated transition t ∈ T may fire by tions, etc. In other words there are transitions repre-
senting arbitrary functions f .
1. decreasing the number of tokens for all p ∈ •t by In the examples designed so far, only minimization
W (p, t) and transitions are used. Minimization transitions have
2. increasing the number of tokens for all p ∈ t• by the advantage that they conform to the standard place-
W (t, p). transition net semantics described in section 4.
For a more detailed introduction to PNs, see [6] and [7]. • Copy Transitions: Another purpose of transitions is to
make the results of solved subproblems available to the
superproblems requesting these results. Each of these
5. Petri Net Model for Dynamic Programming special “copy transitions” distributes a result from one
“state place” to multiple “min-in places”.
The details of our suggested PN model for DP problems
are discussed in this section. The last subsection discusses 5.3. The Role of Places in the PN Model
Bellman Nets - an alternative to the suggested PN model.
There are two types of places in the PN model.
5.1. Construction of the PN Model
• State Places: Such a place represents a state encoun-
Suppose a discrete optimization problem can be solved tered during the solution process of a DP problem. Ex-
by an integer dynamic programming equation of the form cept for the base case state places, state places are the
K output places for minimization transitions.
f (s) = min{d(a) + f (s(k) )},
a • Min-in Places: These are the input places for mini-
k=1
mization transitions. They are also the output places
with nonnegative integral base cases values f (s0 ) given. for copy transitions.
5.4. The Role of Markings in the PN Model One example would be to check the PN for circularity.
Circularity is undesirable, if the PN represents a DP prob-
• Marking of State Places: Let ps be a state place. Im- lem instance, because it can cause the DP solver to loop
mediately after all minimization transition in its preset infinitely.
•ps have fired, but just before firing any of the copy
transitions in its postset ps •, the marking of a state 7. Examples
place ps representing state s contains f (s) tokens, rep-
resenting the optimal value of the subproblem associ-
ated with state s. Base case state places are initially The examples in this section were chosen to illustrate the
marked with an appropriate number of tokens as spec- basic ideas, and are not meant to reflect the class of prob-
ified in the base cases of the DP functional equation. lems that can be handled.
That is a base case state place associated with a base Two example DP problems are discussed. The first prob-
case state s0 is initially marked with f (s0 ) tokens. All lem (optimal financing) is easier than the second one in
other state places are initially marked with no tokens. the sense that an optimal solution is represented as a path
in the PN, since after each decision exactly one successor
• Marking of Min-in Places: Let pm be a min-in place. state needs to be evaluated. For these kind of problems
After all transitions in its preset •pm have fired, but a weighted directed graph representation, where states are
just before firing any transitions in its postset pm •, the nodes and edge weights represent the cost of a decision,
marking of these places corresponds to the values to be would be sufficient.
minimized by a minimization transition. Min-in places The other problem (matrix chain multiplication) has a
are initially marked with d(a) tokens. solution which is represented as a (binary) tree in the PN,
since after each decision exactly two successor states need
5.5. Bellman Nets: An Alternative PN Model to be evaluated. For these kind of problems a weighted
directed graph representation as mentioned before is obvi-
Lew describes in [3] another PN model, which is suit- ously no longer sufficient.
able as an intermediate DP problem representation: Bell- Problems with a more complex state space, such as the
man Nets. In contrast to the PN model described earlier, traveling-salesman problem, can be handled as well with
they are high-level PNs with numerically-colored tokens. the suggested PN model, but have been left out here due to
Two special types of transitions are introduced - one for paper size restrictions.
minimization, another for expression evaluation. Input to-
kens are not removed when firing a transition. To allow for 7.1. Optimal Financing Problem
standard PN semantics [4] modifies the Bellman Net model,
such that input tokens are removed unless they are replaced
For illustrative purposes we use the following simple
using self-loops.
problem instance. Suppose we need to borrow $ 6 million
The relationship between Lew’s Bellman Nets and the
in t = 0. Each of our creditors gives us several financing
specialized PNs described in this paper is still under inves-
alternatives, as shown in table 1. It is not possible to ne-
tigation. Probably, their expressional power is equivalent
gotiate other options, e.g. to request intermediate amounts
(which needs to be proven). While it is easier to trans-
not mentioned in the table. It is not possible to choose two
form Bellman nets to executable computer code, the low
alternatives from the same creditor. Alternative 0 is to not
level PN model introduced here is easier to examine with
borrow from that creditor. Creditor 1 considers larger credit
respect to consistency, and other net theoretic issues. If the
amounts as more risky and charges more interest. Credi-
equivalence of the two models can be shown, and a prac-
tor 2 has excessive amounts of cash to invest and gives us
tical transformation algorithm between the two models can
incentives to borrow larger amounts. Creditor 3 only deals
be designed, then we could take advantage of the benefits
with larger amounts. The goal is to minimize the net present
of both models.
value (NPV), denoted of our total future payments.
We present the DP approach to this problem for illus-
6. Consistency Checks on the PN Level trative purposes. It is a 3-stage decision process, since we
have to choose exactly one alternative ai where i = 1, 2, 3
As soon as a PN representation of the problem instance from each of the three creditors. Define the state x at stage
has been derived, existing PN theory can be applied to check i as the amount of money secured so far from creditors 1
static and dynamic properties. This allows for semantic through i − 1. Let y(ai ) denote the NPV of the future pay-
checks of the specification which would not easily be pos- ments to creditor i under alternative ai . Let c(ai ) denote the
sible without the PN model. principal amount of the loan from creditor i under alterna-
f3(0)
infty
6
f2(0)
min 11
f3(1)
16
infty
20
f3(2)
22
6
f2(1)
4 min 11
f3(3)
16
16
f1(0) 20
min
f3(4)
16
f2(2) 6
12 min
11
f3(5)
16
16
20
f3(6)
6
f2(3)
21 min 11
f3(7)
16
20
f3(0)
30
infty
38
f2(0)
min 1
1
f3(1)
infty
4
37 f3(2)
f2(1) 1
min
f3(3)
5
f1(0) 9
31 min
f3(4)
2
f2(2) 2
1 min
7
f3(5)
12
f3(6)
6
f2(3)
6 min 11
f3(7)
copy (1,2)
60
24 24
copy (1,3)
min
30
(1,4) 40
12 20
copy (3,4)
copy (1,2)
4
copy (1,3)
min
26
(1,4)
76 min 34 copy (2,3)
4
min
copy (2,4)
copy (3,4)
References