GitHub

@@ -432,11 +432,12 @@ arr = np.arange(m+n)

432432

```{code-cell} ipython3

433433

sol_found = []

434434

cost = []

435+

rng = np.random.default_rng()

435436436437

# simulate 1000 times

437438

for i in range(1000):

438439439-

np.random.shuffle(arr)

440+

rng.shuffle(arr)

440441

res_shuffle = linprog(C_vec, A_eq=A[arr], b_eq=b[arr])

441442442443

# if find a new solution

@@ -709,18 +710,18 @@ Locations are assigned randomly.

709710

def build_nodes_of_one_type(group='p', n=100, seed=123):

710711711712

nodes = []

712-

np.random.seed(seed)

713+

rng = np.random.default_rng(seed)

713714714715

for i in range(n):

715716716717

if group == 'p':

717718

m = 1/n

718-

x = np.random.uniform(-2, 2)

719-

y = np.random.uniform(-2, 2)

719+

x = rng.uniform(-2, 2)

720+

y = rng.uniform(-2, 2)

720721

else:

721722

m = betabinom.pmf(i, n-1, 2, 2)

722-

x = 0.6 * np.random.uniform(-1.5, 1.5)

723-

y = 0.6 * np.random.uniform(-1.5, 1.5)

723+

x = 0.6 * rng.uniform(-1.5, 1.5)

724+

y = 0.6 * rng.uniform(-1.5, 1.5)

724725725726

name = group + str(i)

726727

nodes.append(Node(x, y, m, group, name))

Read the original on github.com ↗