I am using python-3.x and I have tow loops first one which is number of runs (3 times) the second one to generate solutions (2 times)
what I want to do is: Collect the best solution from the second loop and append it to an array or list. The next run which is the first loop will run the second loop again, and it will collect the best solution from the second loop and append it to the same array or list. Which I will have two solutions in each run the total will be six solutions.
the problem is: I want to append the "best solution" to same index location for the next run.
in my case, the array will end up with a size of 6, but I want it to be a size of 3 where each index will include two values (best solution)
run 1: result inside the array: index 0 "The first best solution." index 1 "The second best solution."
run 2: result inside the array: index 0 "The first best solution." "The first best solution."
index 1 "The second best solution." "The second best solution."
If you take a look at the code and the result it will be more clear what I am trying to do? any advice or help you could provide would be much appreciated
import matplotlib.pyplot as plt
import math
import random
import numpy as np
import pylab
from numpy import median
import os
import subprocess as sp
run = 3
best_solutions = [np.empty(0)]
del best_solutions[0]
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
for i in range (run):
lower = 300
upper = 500
number_of_solutions = 50
generate_solutions = 2
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
for ii in range (generate_solutions):
list_of_solutions = np.random.uniform(lower, upper, number_of_solutions)
best_solutions.append(min(list_of_solutions))
lower = lower - 30.4323434
upper = upper - 90.634555
del (number_of_solutions)
del (lower)
np.random.uniforma stand-in for heavy computation?