Case Study: Optimizing a Legal Partnership Restructuring

Solving a real estate partnership restructuring with computational mathematics

Daniel Furman
4 min readDec 13, 2023
Photo by Tingey Injury Law Firm on Unsplash

Introduction

Consider a real estate business restructuring assets into majority ownerships among partners. Before restructuring, each partner holds a particular debt and value stake in the business, uneven shares which reflect the overall ownership distribution. This real estate business approached a law firm to advise on the restructuring, which is when I was brought onto the project — to leverage data science to redistribute majority assets while preserving current-state ownerships. This approach was planned to minimize potential taxes incurred from more significant shifts in asset ownerships.

To solve this problem, we developed a search algorithm to exhaustively examine the restructuring combinations. In this case, we have 3 partners sharing 11 assets. Applying exhaustive search to this problem equates to searching over 200 million hypothetical restructuring states.

Search Algorithm

We explored restructuring scenarios by transforming the problem into a system of matrix operations, using computational methods to permute across majority ownership scenarios. First, we took an NxM matrix encoding the restructured shares; for example, partner N1 gets 100% of asset M1, 0% of asset M2, and so on. The algorithm was ran over several initial split states, so to locate an optimal state near the global minimum. Each row in this matrix represents a partner, whereas each column represents an asset. As expected, each column sums to one.

We then multiplied this NxM probability matrix with an Mx2 matrix encoding each asset’s total value and debt. This result is subtracted from the current ownership stakes (a Nx2 matrix), ensuring that the rows matched up to the correct partner in the NxM probability matrix. Finally, we took the absolute values of the difference matrix (direction of change not important) and summed the entries. Our result encoded the cumulative difference between the restructured partnership and the original one. The for loop then iterated through all possible scenarios by shuffling the columns, recording cumulative stake changes across the M! potential restructurings. We then take the minimum stake change as the optimal solution surfaced by the algorithm.

System of matrix operations for a partnership with 6 assets and 3 partners. The first matrix is the probability matrix, the second is the values/debts of each asset, and the third is the partner’s total current ownership values and debts.

Algorithm Flexibility

The search algorithm approach is by nature a brute force method, as we were testing across a massive number of possible scenarios. The for loops decompose to a O(n) time complexity. Furthermore, the algorithm is certainly not flexible to any scenario. For example, consider a simplified case: two partners share three assets evenly yet the assets’ values (and debts) are equivalent. Therefore, there is no way to split up the assets into majority ownerships with minimal stake change.

Run-time complexity analysis for the restructuring algorithm (in log/log space). The power law relationship exhibits a n ~ 0.996 slope, indicating the linearity in the algorithm’s time complexity (i.e., O(n)).

Results

Applying our search algorithm to the real estate restructuring case (3 parters x 11 assets) enabled us to locate a restructuring strategy with an acceptably small stake change. At test time, we ran the search algorithm across several initial ownership scenarios, changing the total number of assets each partner received. For example, the optimal state was found by giving 4 properties to partner 1, 3 to partner 2, and 4 to partner 3, which was the fifth such scenario tested. The optimal solution that was surfaced incurred a mere 2.9MM cumulative stake change against 159MM in total business assets, an acceptably small magnitude (<2% debt and value change) that allowed the business to effectively avoid significant restructuring taxes.

Code

### Libraries ###
import numpy as np
from sympy.utilities.iterables import multiset_permutations
import time

### Data I/O ###
restructure_probabilities = np.genfromtext(...) # probability matrix
assets_value_debt = np.genfromtext(...) # asset value/debt df
previous_stake = np.genfromtext(...) # previous asset value/debt df
num_assets = len(assets_value_debt[:,0]) # num of assets to restructure, M
n_factorial = np.math.factorial(num_assets) # num of scenarios, M!

### Algorithm ###
start = time.time()
permutations = np.zeros((n_factorial, num_assets))
index = np.arange(0, num_assets)
iter = 0
# store all M permutations
for p in multiset_permutations(index):
permutations[iter,:] = p
iter+=1
permutations = permutations.astype(int)
results = np.zeros(n_factorial)
for iter in np.arange(0, n_factorial):
# shuffle columns
probabilities_looped = restructure_probabilities[:, permutations[iter,:]]
# mat multiplication
results_lopped = np.matmul(probabilities_looped, assets_value_debt)
# difference between partnership states
final_differences = np.abs(results_lopped - previous_stake)
results[iter] = np.sum(final_differences)

print(np.min(results)) # the optimal restructuring difference
print(np.argmin(results))
end = time.time()
print(f"Runtime of the program is {end - start}")

--

--