Добавил:
ivanov666
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Fundamentals of Operations Research. A textbook
.pdf
Distribution Problem
31
Proof.
Let
xpαq P Z
then akexists such that
unit vector. Note that
n
be an optimal solution of
`
˚
x
pαq ą 0
k
and
pc, x˚pαqq “ pc, x˚pαq ´ ekq ` ck, where
xαy
x˚pαq ´ ekis a feasible solution for
Spαq ď Spα ´ akq ` ckď max
k: akďα
, that is,
tSpα ´ akq ` cku.
On the other hand,
max
k: akďα
tSpα ´ akq ` cku “ Spα ´ aiq ` ci“ pc, x˚pα ´ aiqq ` c
“ pc, x˚pα ´ aiq ` eiq ď pc, x˚pαqq “ Spαq.
Recurrence relation (3.15) allows us to nd the optimal value
are integers. The complexity of the forward pass is
argmaxes
kpαq
to nd the optimal vector during the backward pass.
OpnAq
The Backward Pass
α :“ A,xk:“ 0
while
Spαq ą 0
x
kpαq
:“ x
α :“ α ´ a
kpαq
kpαq
for all
do
` 1
k
Spαq “ pc, x˚pαqq
. If
Spαq ą 0
ekis thek-th
xα ´ aky
, therefore,
SpAq
when all the
i
aks and
. As before, we can use the stored
A
The complexity of the backward pass is
The space used by the algorithm is
Opn ` Aq
OpAq
. So the overall time complexity is
.
OpnAq
Inverse Problems
Any distribution problem (including knapsack problems) can be converted into an
inverse
problem, which is sometimes easier to solve. We demonstrate the concept on the Unbounded
Knapsack Problem (3.13)(3.14), which we call the
direct
problem from now on. The direct
problem is to maximize the value subject to a weight constraint. The inverse one is to minimize
the weight under a value constraint:
n
ÿ
aixiÑ min
i“1
n
ÿ
cixiě C,
i“1
xPZ
,
n
`
(3.16)
(3.17)
whereCis a given value bound. As before, to solve the problem consider it within the family
txγy : γ ď Cu
, where
xγy
is the following problem:
Qpγq “ min
xPZ
n
ÿ
n
ÿ
aixi,
n
`
i“1
cixiě γ.
i“1
.

32
Dynamic Programming
Denote the optimal solution of the problem as
us to the relations:
where
Lemma 3.1.
Proof.
x ´ y “ maxt0, x ´ yu
Function
Let
γ2ą γ1. Obviously,
pa, x0pγ2qq ě Qpγ1q
Theorem 3.2
A, γ ě 0u
problem, and
Proof.
Denote
problems
(On the relation between direct and inverse problems).Let
. Then the solution of the inverse problem
SpAq “ ˜γ
S˚“ SpAq
xAy
and
Qp0q “ 0, Qpγq “ min
.
Qpγq
dened by (3.18) is non-decreasing.
.
.
. Since
xS˚y
, the inequalities hold:
x0pγ2q
x˚pAq
k“1,...,n
is a feasible solution of
is a feasible solution for both the direct and the inverse
QpS˚q ď pa, x˚pAqq ď A.
From the inequality
QpS˚q ď A
and the denition of˜γfollows the relation
On the other hand, the optimal solution
solution for
xAy
:
pa, x0p˜γqq “ Qp˜γq ď A.
x0pγq
. An argument similar to those above leads
tQpγ ´ ckq ` aku, 0 ď γ ď C,
xγ1y
. Therefore,
˜γ “ maxtγ : Qpγq ď
x0p˜γq
x0p˜γq
of the inverse problem
is also a solution of the direct
˜γ ě S˚.
x˜γy
(3.18)
Qpγ2q “
is a feasible
Therefore,
˜γ ď pc, x0p˜γqq ď pc, x˚pAqq “ S˚,
and
˜γ “ S˚, pc, x0p˜γqq “ SpAq.
Corollary 2.
Let all the values
ckbe integers. Then
S˚“ mintγ : A ă Spγ ` 1q, γ “ 0, 1, . . . u.
This observation gives us a method to solve the problem (3.13)(3.14) when all
1. Using the relations (3.18) calculate
Qp˜γq ď A,
The value˜γequals the optimal value of the problem:
2. Apply the backward pass for
x˜γy
Qpγq
for
γ “ 0, 1, . . .
and
Qp˜γ ` 1q ą A.
to nd the solution
until for some
SpAq “ ˜γ
x0p˜γq
.
, which is also a solution of the
ckP Z`:
γ “ ˜γ
holds:
direct problem.
The complexity of the method is
and it is better then
OpnAq
solve the inverse problem instead of the direct one, when the values
all the
ckP Z`.
when
OpnS˚q
, where
S˚“ SpAq ď A max
k
c
k
a
k
cks are relatively small and
,
S˚ď A
. It is also reasonable to
akare not all integers, but
Now we give without the proof the statements that allow to switch from the inverse problem
to the direct one when needed.

Distribution Problem
33
Theorem 3.3.
x˚p˜αq
is also a solution of the inverse problem, and
Corollary 3.
Let
˜α “ mintα : Spαq ě C, α ě 0u
Let all the values
akbe integers. Then
. Then the solution of the direct problem
QpCq “ ˜α
.
Q˚“ QpC q “ mintα : C ą Qpα ` 1q, γ “ 0, 1, . . . u,
and the inverse problem (3.16)(3.17) is solvable in
˜α “ QpCq ď C max
Example 3.4.
weights (
ai) and values (
Solve the following instance of the 0-1 Knapsack Problem:
ci) are given in the table below.
i
1 2 3 4 5 6
c
6 5 4 3 2 1
i
Op˜αnq
a
k
k
c
k
time, where
.
n “ 6,A “ 110
ai45 33 28 16 13 9
Solve the inverse problem to avoid lling a huge
110 ˆ 6
table. Observations similar to those
above give us the following recurrence relations for the inverse boolean problem:
$
0, y “ 0, x1pyq “ 0,
&
Q1pyq “
Qkpyq “ min
a1, 0 ă y ď c1, x1pyq “ 1,
%
`8, y ą c1.
"
Q
pyq, xkpyq “ 0,
k´1
ak` Q
py ´ ckq, xkpyq “ 1.
k´1
*
, k “ 2, . . . , n.
,
Calculate
Qkpyq
until˜yfound such that
Q6p˜yq ď 110
and
Q6p˜y ` 1q ą 110
y Q1{x1Q2{x2Q3{x3Q4{x4Q5{x5Q6{x
0 0/0 0/0 0/0 0/0 0/0 0/0
1 45/1 33/1 28/1 16/1 13/1 9/1
2 45/1 33/1 28/1 16/1 13/1 13/0
3 45/1 33/1 28/1 16/1 16/0 16/0
4 45/1 33/1 28/1 28/1 28/0 25/1
5 45/1 33/1 33/1 33/1 29/1 29/0
6 45/1 45/1 45/1 44/1 41/1 38/1
7 - 78/1 61/1 44/1 44/0 44/0
8 - 78/1 61/1 49/1 49/0 49/0
9 - 78/1 61/1 61/0 57/1 57/0
10 - 78/1 73/1 73/0 62/1 62/0
11 - 78/1 78/0 77/1 74/1 71/1
12 - - 106/1 77/1 77/0 77/0
13 - - 106/1 89/1 89/0 86/1
14 - - 106/1 94/1 90/1 90/0
15 - - 106/1 106/0 101/1 99/1
16 - - - 122/1 107/1 107/0
17 - - - - 119/1 116/1
.
6

34
Dynamic Programming
As we see from the table,
a knapsack of capacity 110 is 16, and the 6-th item should not be taken (
˜y “ 16
, that means the maximum value that can be packed into
x6p16q “ 0
). That
implies, the value 16 can be achieved within the set of the rst ve items, and we turn to cell
(16,5). The fth item is taken (
accumulated by the rst four items. Go to cell (14,4),
and so on. When the process is nished, we have the solution
x5p16q “ 1
) and the remaining value
x4p14q “ 1
, then to cell (
x˚“ p1, 1, 0, 1, 1, 0q
16 ´ c5“ 14
14 ´ c4“ 11
of value 16
must be
,3),
and weight 107.
3.2. The Nearest Neighbor Problem
In this section we consider a problem of optimal partitioning a linear object into segments,
known as
a nonnegative function
servicing a segment
that minimizes the total service costs:
the Nearest Neighbor Problem
fpx, yq,0 ď x ď y ď M
tx, . . . , yu Ď I
, and a number
n
ÿ
fpx
i“1
0 “ x0ď x1ď ¨ ¨ ¨ ď xn“ M.
(NNP). Given an integer interval
, that expresses expenses associated with
, xiq Ñ min
i´1
n ď M
n`1
xPZ
`
. SplitIintonsegments in a way
,
I “ t0, 1, 2, . . . , M u
(3.19)
(3.20)
,
Again, to solve the problem, introduce a family
where a
xk, my
-problem looks as follows:
Skpmq “ min
xPZ
n`1
`
txk, my : k “ 1, . . . , n, m “ 0, 1, . . . , M u
k
ÿ
fpx
i“1
i´1
, xiq,
0 “ x0ď x1ď ¨ ¨ ¨ ď xk“ m.
Note that:
•ifk “ 1
•ifk ě 2
into
, then
S1pmq “ fp0, mq
for each
m ď M
;
and we know the cost of optimal partition of each subinterval
k ´ 1
segments, then the cost of partition of
t0, . . . , yu
t0, . . . , xu,x ď y
can be easily calculated by
enumerating all possible penultimate points of the split.
These observations lead us to the recurrence relations of the forward pass of DP-algorithm:
S1pmq “ fp0, mq, m “ 0, 1, . . . , M,
Skpmq “ min
xkpmq “ argmin
0ďxďm
0ďxďm
tS
pxq ` fpx, mqu,
k´1
tS
pxq ` fpx, mqu, m “ 0, 1, . . . , M, k “ 2, . . . , n.
k´1
(3.21)
(3.22)
(3.23)
,
,
When the optimum
stored values
have to ll a
xkpmq
n ˆ M
SnpMq
is calculated, the points of the optimal partition can be found using
in a backward pass. The complexity of the algorithm is
table, each element of which needs up to
M
operations to be calculated.
OpnM2q
, for we

The Nearest Neighbor Problem
35
Another version of the problem is to nd the least expensive partition when the number of
subintervals is not given in advance and must be determined:
n
ÿ
fpx
i“1
0 “ x0ă x1ă ¨ ¨ ¨ ă xn“ M.
, xiq Ñ min
i´1
ně1, xPZ
n`1
`
,
(3.24)
(3.25)
Of course, since we can split the interval in integer points only, the problem (3.24)(3.24) can
be solved by solvingMproblems (3.19)(3.19), for each
to solve just one problem with
n “ M
). The complexity of this approach is
n “ 1, 2, . . . , M
(in fact, it is sucient
OpM3q
. But, as
with the Unbounded Knapsack, the problem can be solved much easier when considered within
another family. Let˜Spmq
˜
Sp0q “ 0,
˜
Spmq “ min
x“0,1,...,m´1
be the cost of the optimal partition of
t0, 1, . . . , mu
. Easy to see that
t˜Spxq ` fpx, mqu “˜Spxpmqq ` fpxpmq, mq, m “ 0, 1, . . . , M.
(3.26)
(3.27)
Using these relations, the problem can be solved with
Example 3.5.
Solve the following instance of NNP:
OpM2q
M “ 8
time complexity.
, the cost function
fpx, yq
in a table below.
xzy
0 1 2 3 4 5 6 7 8
0 0 3 19 24 41 42 63 66 83
1 0 6 18 26 39 48 56 77
2 0 11 19 35 44 55 56
3 0 13 25 27 45 53
4 0 3 15 24 37
5 0 3 16 27
6 0 12 21
7 0 16
8 0
The number of segments is: a)
n “ 4
, b) arbitrary.
a) To solve the problem with given number of segments, ll a table with values
xkpmq,k “ 1, 4,m “ 0, 8
, using relations (3.21)(3.23).
m S1{x1S2{x2S3{x3S4{x
4
0 0 0/0 0/0 0/0
1 3 3/0 3/0 3/0
2 19 9/1 9/1 9/1
3 24 21/1 20/2 20/2
4 41 29/1 28/2 28/2
5 42 42/0 32/4 31/4
6 63 45/5 44/4 35/5
7 66 58/5 53/4 48/5
8 83 69/5 65/2 59/5
if given
Skpmq
and

36
Dynamic Programming
The optimal partition cost is
S4p8q “ 59
. The partition itself is easily found, since each cell
of the table contains a pointer to the previous split-point. In our case, from point 8 we must
move to 5, then to 4, to 1, and nally to 0. Thus, the optimal four-segment partition is
r0, 1s Y r1, 4s Y r4, 5s Y r5, 8s
, and its cost is 59.
b) Now solve the problem with arbitrary number of segments. At the forward pass, we calculate
values˜Spmq
The optimal cost is˜Sp8q “ 55
above and includes 6 segments:
and
xpmq
m
˜
S{x
for each
m “ 0, 8
using relations (3.26)(3.27).
0 1 2 3 4 5 6 7 8
0 3/0 9/1 20/2 28/2 31/4 34/5 46/6 55/6
. The partition is constructed in the way similar to described
r0, 1s Y r1, 3s Y r3, 4s Y r4, 5s Y r5, 6s Y r6, 8s
.
At the end of the section, we make some additional remarks.
Remark
3.1.It is said that a two-variable function
fpx, yq : t0, 1, . . . , Mu2Ñ R
satises the
Glebov's condition, if
fpx1, x2q ` fpy1, y2q ě fpx1, y2q ` fpy1, x2q
for each
x1, x2, y1, y2P t0, 1, . . . , Mu:x1ď y1ď y2ď x2.
In work [9], the properties of NNP with Glebovian cost function are investigated. It is
demonstrated that the complexity of the problem's solution in this case can be signicantly
reduced.
Remark
3.2.The Nearest Neighbor Problem admits some other important formulations, besides
those that are considered in this section. For example, the one where the number of segments
is not xed but lies within a given interval,
n1ď n ď n2. The method to solve such problem is
described in [8].
Remark
(3.21)(3.23). To calculate the values
step. Therefore we may not store the whole table and reduce the use of space to
doing so we also lost the values
the optimal partition we need to perform
the penultimate point
and so on. As a result, the time complexity rises up to
3.3.Relaxation DP-approach can also be applied to solve NNP. Consider relations
xnpMq
Skpmq
xkpmq
, so the backward pass become inexecutable. To construct
, then, for
we need to know only the values from the previous
OpM q
pn´1q
xn ´ 1, xnpMqy
forward passes: rst, for problem
to nd the third to last,
Opn2M2q
.
xn, M y
x
n´1pxn
. By
to nd
pMqq
3.3. Production and Inventory Problem
In this section, we discuss methods to solve the Production and Inventory Problem. Recall
that the problem is to nd ann-day production plan that satises given consumers' demands
with minimum costs. A mathematical programming formulation of the problem was given in
Chapter 1 (see example 1.4):
$
n
ř
’
’
’
’
&
’
’
’
’
%
pptxt` htst` ftytq Ñ min
t“1
s
` xt“ dt` st, t “ 1, . . . , n,
t´1
xtď M yt, t “ 1, . . . , n,
s0“ sn“ 0, s P R
x,y,s
,
(3.28)
n`1
`
, x P R
n
, y P Bn,
`
,

Production and Inventory Problem
0
3
2
...
n
1
p
1
x
1
p
2
x
2
p
3
x
3
p
n
x
n
h
1
s
1
h
2
s
2
h
3
s
3
h
n−1
s
n−1
d
1
d
2
d
3
d
n
...
n
where
M “
ř
dt.
t“1
37
First, notice that the problem can be translated in terms of network ows. Consider a
weighted network
•
a source node0that produces
•
nodes
1, 2, . . . , n
the source is connected with each
represents per-unit production costs in thet-th day and equals
each node
ow can be stored and consumed later; the ow cost of the arc
per-unit storing costs in dayt,
•
a sink node to which the ow comes from each
sponding arc is
G “ pV, Aq
that consists of
M
units of ow;
that correspond to days of the plan period:
t P t1, . . . , nu
t P t1, . . . , n ´ 1u
is connected with
t ` 1
ht;
t P t1, . . . , nu
dtthat ensures that all demands are satised.
, the ow cost of the arc
p0, tq
pt;
that represents the fact that the
pt, t ` 1q
equals
; the capacity of the corre-
The network is represented in g.3.1. The ow generated in0propagates through the incident
arcs into nodes
and the next node (variables
arc
p0, tq
. The problem is to nd a minimum-cost feasible ow.
t P t1, . . . , nu
(variables
st, costs
xt, costs
ptxt), then it redistributes between the sink
htst). Also, the xed costs
ftare incurred, if
xtą 0
for
Figure 3.1: Network representation of the Production and Inventory Problem
Optimal solutions of the problem possess two important properties, we state them in
Lemma 3.2.
There exists an optimal solution of (3.28) such that:
1. production takes place only when the stock is zero:
s
“ 0, t “ 1, . . . , n;
t´1xt
2. if production takes place, the amount produced exactly satises the demand of several
subsequent days:
xtą 0 ñ xk“
t`k
ÿ
difor some
i“t
k ě 0.

38
Dynamic Programming
Proof.
Consider an optimal ow. Easy to see that the set of arcs with positive ow forms a
tree (or can be transformed into a tree without increase in costs).
Indeed, assume a cycle exists, e.g.
If
p
ě pt` st, then
t`1
p0, t ` 1q
p0, t ` 1q
. If
p
. Both of the transitions remove the cycle and do not increase the total cost.
Therefore, for each
that is,
s
t´1xt
t`1
“ 0
x
ow units can be transported through
t`1
ď pt` st, then ow
t P t1, . . . , nu
. The second statement then follows immediately.
p0, tq Y pt, t ` 1q Y p0, t ` 1q
mintst, xtu
can be switched from
only one of the arcs arriving intcan have a positive ow,
These properties allow us to derive a DP algorithm for (3.28).
Denote
dit“
t
ř
dj. Then
j“i
st“
t
ř
´d1t, so variables
i“1
stcan be eliminated. The objective
transforms into
n
ÿ
pptxt` htst` ftytq “
t“1
n
where
ct“ pt`
Let
Hpkq
satisfying demands in period
place in optimal solution (i.e.
ř
hi.
i“t
be the minimum value of expression
1, 2, . . . , k ď n
xt“ dtk), then the production plan for days
also be optimal and its cost must be
n
ÿ
t“1
n
ÿ
“
t“1
. If
Hpt ´ 1q
«
ptxt` h
pctxt` ftytq ´
ř
t“1
t ď k
. This observation gives recurrence relations:
˜
t
ÿ
i“1
´d
n
ÿ
t
htdit,
t“1
k
pctxt` ftytq
is the last day when the production takes
, such that
p0, tq Y pt, t ` 1q
xt, x
, stą 0
t`1
instead of
p0, tq Y pt, t ` 1q
¸
` fty
1t
ff
t
, which represents the cost of
1, . . . , t ´ 1
must
.
to
Hp0q “ 0,
Hpkq “ min
In the forward pass, values
optimal value
tHpt ´ 1q ` ft` ctdtku “ Hptpkq ´ 1q ` f
1ďtďk
Hpnq
Hpkq
and the last production day
and
tpkq
are calculated. At the end of the pass, we know the
tpnq,x
tpnq
tpkq
“ d
` c
tpnq,n
days are easily found during the backward pass using stored values
Opn2q
Example 3.6.
First, calculate
operations and uses
Solve the following instance of the Production and Inventory Problem:
c “ p8, 7, 5, 4q,pd11, d12, d13, d14q “ p2, 6, 11, 12q
Opnq
memory units.
t
1 2 3 4
d
2 4 5 1
p
3 3 3 3
h
1 2 1 1
f
12 20 16 8
tpkqdtpkq,t
, k “ 1, . . . , n.
. The remaining production
tpkq
. The algorithm performs
n
, and
ř
htd1t“ 37
t“1
. Then,

Exercises
3
21
28 48
41 12
0
4
60
100
108
46
83
90
39
calculate values
Hpkq
:
Hp0q “ 0;
Hp1q “ f1` c1d11“ 12 ` 8 ¨ 2 “ 28, tp1q “ 1;
Hp2q “ mintHp0q ` f1` c1d12, Hp1q ` f2` c2d2u
“ mint12 ` 8 ¨ 6, 28 ` 20 ` 7 ¨ 4u “ 60, tp2q “ 1;
Hp3q “ mintHp0q ` f1` c1d13, Hp1q ` f2` c2d23, Hp2q ` f3` c3d3u
“ mint12 ` 8 ¨ 11, 28 ` 20 ` 7 ¨ 9, 60 ` 16 ` 5 ¨ 5u “ 100 tp4q “ 3;
Hp3q “ mintHp0q ` f1` c1d14, Hp1q ` f2` c2d24, Hp2q ` f3` c3d34, Hp3q ` f4`c4d4u
“ mint12 ` 8 ¨ 12, 28 ` 20 ` 7 ¨ 10, 60 ` 16 ` 5 ¨ 6, 100 ` 8 ` 4 ¨ 1u “ 106, tp4q “ 3.
4
Thus, the optimal value is
tp4q “ 3
x3“ d3` d4“ 6
the rst day (
plan is:
, the third day is the last when the production occurs:
. Looking at the period of
tp2q “ 1
), that means
x “ p6, 0, 6, 0q,y “ p1, 0, 1, 0q,s “ p4, 0, 1, 0q
Hp4q ´
ř
htd1t“ 106 ´ 37 “ 69
t“1
. Find the production plan. Since
x4“ y4“ 0,y3“ 1
t1, 2u
we see that the production was stopped at
x2“ y2“ 0,y1“ 1,x1“ d1` d2“ 6
.
, and
. So, the optimal
Notice that the problem can also be reduced to a shortest path problem. Consider a weighted
directed graph with nodes
weight of arc
an
i ` 1
pi, jq
equals
and satisfying the demands during the period
the length of the shortest
t0, 1, . . . , nu
f
` c
i`1
0 ´ n
i`1di`1,j
path in the graph, and nodes of this path correspond to days
and arcs connecting each pairi,jsuch that
i ă j
and represents the cost of starting the production
ti ` 1, . . . , ju
. Obviously,
Hpnq
. The
equals
after which the production starts. Since the graph is acyclic, the shortest path can be found in
Opn2q
-time.
Figure 3.2 shows the graph for example 3.6. The shortest path is drawn bold.
Figure 3.2: Example 3.6. The shortest path representation
The length of the path is 106, it consists of two arcs:
the production starts at1and3:
s “ pd2, 0, d4, 0q “ p4, 0, 1, 0q
.
y “ p1, 0, 1, 0q,x “ pd1` d2, 0, d3` d4, 0q “ p6, 0, 6, 0q
3.4. Exercises
3.1.
Solve the Distribution Problem (3.2)(3.4) with functions:
a)
fipxq “
2
x
,
c
i
cią 0,i “ 1, . . . , n
; b)
fipxq “ fpxq
p0, 2q
and
p2, 4q
. That means,
a strictly convex dierentiable function.
,

40
3.2.
Solve the Unbounded Knapsack Problem with continuous variables.
3.3.
Solve the following instance of the 0-1 Knapsack Problem:
weights (
ai) are given in the table below.
i
1 2 3 4 5 6 7 8
n “ 8,A “ 55
ci4 2 3 1 5 2 10 8
ai2 8 17 4 26 2 23 9
3.4.
A facility manufactures
n “ 4
types of goods from a resource. Denote as
of the resource required to producexunits of thei-th product, and as
a unit of thei-th product. Given
Y “ 50
units of the resource, nd a production plan that
maximizes the total income.
i
1 2 3 4
ci2 3 1 1
Dynamic Programming
, values (
gipxq
ci) and
the amount
cithe income from selling
x g1g2g3g
4
0 0 0 0 0
1 15 20 20 15
2 25 30 21 18
3 35 35 22 20
4 44 40 23 23
5 48 50 28 25
3.5.
Solve the following instance of the Nearest Neighbor Problem:
function
fpx, yq
if given in the table below.
xzy
0 1 2 3 4 5 6 7 8
0 0 0 14 21 95 77 58 81 83
1 0 7 8 26 100 59 60 98
2 0 9 5 1 88 98 64
3 0 0 8 1 78 97
4 0 1 9 10 82
5 0 2 0 0
6 0 0 8
7 0 8
8 0
M “ 8,n ď 4
, the cost
3.6.
Consider the weighted rooted tree from the gure below. Node weights are given beside
each node. Find a maximum-weight subtree rooted at 1.
Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]
