108

An algorithm for preventing deadly embrace

EWD108 · 1964–1967 · PDF · source transcription · Source language: Dutch. Machine translation: needs review. · Review summary; risk closure recorded; handoff recorded.

     A banker is willing to lend money to customers -in whole guilders- on the following -humane- conditions.
1) The customer must be able to guarantee that if he gets the requested money at his disposal, the project for which the loan is taken will be completed within finite time, after which the customer will return all the borrowed money to the banker.
2) The customer must specify in advance an upper limit of what he will ever need to have on loan simultaneously for this project.
3) If the customer -respecting 2)- comes to ask for an additional loan, he may not complain when he hears from the banker "At the moment I cannot provide you with the requested amount, but I guarantee you that this will be the case within finite time."
4) It is allowed -this is even encouraged!- that the customer, when he sees during the transaction that the initial (see 2.) or respectively the most recently mentioned upper limit will no longer be reached, informs the banker of the lowering of the upper limit.

     The questions are: (if the banker works with a capital of A guilders)
a) under what conditions can he accept a customer who offers himself?
b) what is the algorithm to decide whether or not to pay out, such that the banker on the one hand never postpones a payout that he could have made safely, and on the other hand never makes a payment when he can no longer guarantee under all circumstances that he will be able to meet his future obligations.

     The answer to the first question is that the banker can accept any customer whose (initial) upper limit does not exceed his total capital A.

     To decide whether he can proceed to payment upon a payment request, he reviews the situation that would arise if he were to proceed to payment. If this situation is "safe", he pays out; if it is not safe, he refuses the payment. To describe the algorithm that determines whether a situation is safe, we introduce the following terms.

     For each customer the banker keeps two amounts:
1) loan (initially = 0)
2) claim (initially = initial upper limit)

At any moment, for each customer, "loan + claim = upper limit" holds.

The initial capital A diminished by the sum of the loans we call the "cash reserve".

To investigate a situation, he arranges his customers in source order by claim, with the source formula giving claim[i] < claim[i + 1]. Then he executes:

vrij bedrag:= kasvoorraad; i:= 1;
L:  if claim[i] < vrij bedrag then
        begin vrij bedrag:= vrij bedrag + lening[i];
              if vrij bedrag < A then
              begin i:= i + 1; goto L end
                                 else veilig:= true
        end
                              else
        veilig:= false

The banker thus checks whether he "gets all his money back by waiting wisely."