def objective(val, Pyx=Pyx, x=x, y=y, nx=nx, ny=ny): global C_nonequal, x_in, y_out, Px_in xinputs = val[0:nx] ydividers = val[nx:] xinputs.sort() ydividers.sort() Pyx_sub, x_sub, y_sub = blahut.quantize(Pyx, x, y, xinputs, ydividers) C, Px = blahut.blahut_arimoto(Pyx_sub, tolerance=1e-7, iterations = 1000) if C > C_nonequal[ix, iy]: C_nonequal[ix, iy] = C x_in[ix][iy] = xinputs y_out[ix][iy] = ydividers Px_in[ix][iy] = Px data = dict(C_nonequal=C_nonequal, x_in = x_in, y_out = y_out, Px_in = Px_in) savez('./../npz/C_nonequal_optimized.npz', data=data) print '\nC:', C print 'x:', nx, xinputs print 'y:', ny, ydividers return -C
def objective(val, Pyx=Pyx, x=x, y=y, nx=nx, ny=ny): global C_equal, C_equal_bounds xmin, xmax, ymin, ymax = val xinputs = linspace(xmin, xmax, nx) ydividers = linspace(ymin, ymax, ny+1) ydividers = ydividers[1:-1] Pyx_sub, x_sub, y_sub = blahut.quantize(Pyx, x, y, xinputs, ydividers) C, Px = blahut.blahut_arimoto(Pyx_sub, tolerance=1e-7, iterations = 100) if C > C_equal[ix, iy]: C_equal[ix, iy] = C C_equal_bounds[ix, iy, :] = (xmin, xmax, ymin, ymax) data = dict(C_equal=C_equal, C_equal_bounds=C_equal_bounds) savez('./../npz/C_equal_optimized.npz', data=data) print '\nC:', C print 'nx:', nx, xmin, xmax print 'ny:', ny, ymin, ymax return -C
def objective(val, Pyx=Pyx, x=x, y=y, idx=idx): xinputs = val xinputs.sort() Pyx_sub, x_sub, y_sub = blahut.quantize(Pyx, x, y, xinputs, ydividers=None) C, Px = blahut.blahut_arimoto(Pyx_sub, tolerance=1e-4, iterations = 100) result = {'C_in':C, 'Px_in':Px, 'x_in':xinputs} helpers.add_to_database( result=result, index=idx, goal=('C_in', 'max'), filename=filename ) print '\nC:', C print 'x_in:', xinputs print 'idx:', idx return -C