def singlepopulationfitness(singlepopulation): geophysicsbase = GeoPhysicsBase(matrix_size, 0.25) geophysicsbase.g[0] = singlepopulation['population_properties'][0] + geophysicsbase.g[0] geophysicsbase.g[1] = singlepopulation['population_properties'][1] + geophysicsbase.g[1] geophysicsbase.g[2] = singlepopulation['population_properties'][2] + geophysicsbase.g[2] svd_regularization = SVDRegularization(geophysicsbase.A, geophysicsbase.g) f = svd_regularization.reconstruct_with_tikhonov(1E-11) return svd_regularization.getGCValue(geophysicsbase.A, geophysicsbase.g, f)
def singlepopulationfintessleastsquare(singlepopulation): geophysicsbase = GeoPhysicsBase(matrix_size, 0.25) geophysicsbase.g[0] = singlepopulation['population_properties'][0] + geophysicsbase.g[0] geophysicsbase.g[1] = singlepopulation['population_properties'][1] + geophysicsbase.g[1] geophysicsbase.g[2] = singlepopulation['population_properties'][2] + geophysicsbase.g[2] leastsquare = TReg(geophysicsbase.A, geophysicsbase.g, 1E-11) f = leastsquare.getf() ro = np.dot(geophysicsbase.A, f) ro = LA.norm(ro - geophysicsbase.g)**2 return ro
def plot_tsvd_plot(matrix_size): geophysics = GeoPhysicsBase(matrix_size, 0.25) geophysics.g[0] = geophysics.g[0] interation = CGLS(geophysics.A, geophysics.g) x = np.arange(matrix_size) plt.plot(x, geophysics.fexact, 'r', linewidth=2, label='pre defined f') plt.plot(x, interation.x, 'bs', linewidth=2, label='reconstructed f') plt.tick_params(axis='both', which='major', labelsize=18) plt.legend(loc='upper right', shadow=True, fontsize='18') plt.show()