def main(args): fd = open(args.input, 'r') dataset = fd.readlines() #print "Sending tuples for a total of %d seconds, with a wait time of %0.4f ms" % (args.test_time, args.wait_time) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((args.server_host, args.server_port)) s.listen(1) conn, addr = s.accept() print 'Connected to SDMS:', addr i = 0 for tput in xrange(args.lower_tput, args.upper_tput, args.step_size): window_sent = 0 p = cp.calc_parameters(tput) wait_time = p['wait_time'] / 1000.0 #convert ms->s batch_size = p['batch_size'] window_sent = 0 print "Sending %d tuples/sec (wait_time=%0.2f ms, batch_size=%d)" % (tput, wait_time*1000, batch_size) start = time.time() now = start while now - start < args.ramp_window: time.sleep(wait_time) now = time.time() for k in xrange(batch_size): ts = "TS-%d" % int(now*1000) conn.send("%s %s" % (ts, dataset[i % len(dataset)])) sent_tuples.append(ts) i += 1 window_sent += 1 print "%0.4f Average Sending Throughput %0.4f tuples/sec" % (time.time(), (window_sent / (now-start))) conn.close() s.close() fd = open('sent_tuples.txt', 'w') for st in sent_tuples: fd.write(st + "\n") fd.close()
def set_defaults(self): self.page = 1 self.nm = 3 self.r_mouth = 0.001 self.omega_d = pi / 2 self.Gamma = 1e-4 self.p = 0.015 self.r_folds = 0.002 self.r_back = 0.002 self.fs = 3. #time sampling frequency self.T = 500. #total time self.t = np.arange(0, self.T, 1/self.fs) self.t1 = 0 self.t2 = len(self.t) self.s = cp.calc_spatial_evs(r_mouth=self.r_mouth/L, nm=self.nm, num_seeds=500, max_x=20, max_y=2) self.params = cp.calc_parameters(self.p, self.r_folds, self.r_folds, self.omega_d, self.Gamma, self.s.imag, self.s.real, self.nm) fp1, fp2 = calc_fixed_points(self.params)
A.shape = (nm,) B.shape = (nm,) return (radiation, shedding, vocal_fold_friction, dissipation, elastic, linear, quadratic, cubic) if __name__ == "__main__": nm = 3 p = 0.01 r_front = 0.002 r_back = 0.002 r_mouth = 0.00001 zeta = 0 s = cp.calc_spatial_evs(r_mouth=r_mouth / L, nm=nm, num_seeds=100, max_x=20, max_y=3) params = cp.calc_parameters(p, r_front, r_back, s.imag, s.real, nm, zeta) nm, p, mu, gamma, zeta, alpha, omega, beta, A, B, M = params fs = 10.0 # time sampling frequency T = 1000.0 # total time t = np.arange(0, T, 1 / fs) fp1, fp2 = calc_fixed_points(params) # q0 = fp1 + 1e-3 * abs(np.random.rand(2*nm+1)) q0 = np.zeros(2 * nm + 1) q = integrate.odeint(flow, q0, t, args=(params,)) radiation = np.dot(M, (beta * q[:, nm + 1 :]).T).T elastic = np.dot(M, ((omega ** 2 - alpha ** 2) * (q[:, 1 : nm + 1])).T).T B.shape = (nm, 1) A.shape = (nm, 1) shedding = (B * gamma / mu ** 2 * q[:, 0] * sum(q[:, nm + 1 :], 1)).T vocal_fold_friction = (B * zeta / mu ** 2 * sum(q[:, nm + 1 :], 1)).T dissipation = radiation + shedding + vocal_fold_friction
def on_push(self): self.params = cp.calc_parameters(self.p, self.r_folds, self.r_folds, self.omega_d, self.Gamma, self.s.imag, self.s.real, self.nm) self.run_simulation() self.update_plots()