def param_reduction(param, amount, base_list): t_param = np.array(base_control.paramset) t_param[base_control.pdict[param]] *= (1 - amount) tbase = pBase(base_control.model, t_param, base_list[-1].y0) try: tbase.approxY0(tout=1000, tol=1E-5) tbase.solveBVP() assert tbase.findstationary() == 0 base_list += [tbase] except Exception: pass
def _create_limitcycle_class(self): """ Creates self.limitcycle object from finished collocation solve """ from CommonFiles.pBase import pBase # get guess for [y0,T] y0 = self.NLPdata['x_opt'][0].tolist() y0 += [self.NLPdata['TF']] self.limitcycle = pBase(self.model, self.NLPdata['p_opt'], y0)
def create_class(): from .. import pBase return pBase(model(), paramset, y0in)
ode[2] = k2t * y2 - k3t * y3 - k3d * y3 ode[3] = f2 - k4d * y4 ode[4] = k5b * y4 - k5d * y5 - k5t * y5 + k6t * y6 ode[5] = k5t * y5 - k6t * y6 - k6d * y6 + k7a * y7 - k6a * y6 ode[6] = k6a * y6 - k7a * y7 - k7d * y7 ode = cs.vertcat(ode) fn = cs.SXFunction(cs.daeIn(t=t, x=y, p=symparamset), cs.daeOut(ode=ode)) fn.setOption("name", "Sabine Model (from stephanie)") return fn def create_class(): from .. import pBase return pBase(model(), paramset, y0in) if __name__ == "__main__": from CommonFiles.pBase import pBase try: new = pBase(model(), paramset, np.ones(NEQ + 1)) new.calcY0() print new.y0 except Exception as ex: print ex print new.y0
else: ax.set_xticks(find_labels(NP)) if __name__ == '__main__': from CommonFiles.pBase import pBase from CommonFiles.tyson2statemodel import model, y0in, paramset nk = 10 maxrelerror = 0.15 maxsyserror = 0.10 np.random.seed(1) orig = pBase(model(), paramset, y0in) orig.limitCycle() ts = np.linspace(0, 24., nk, endpoint=False) sol = orig.lc(ts * y0in[-1] / 24.) A = np.eye(orig.NEQ) def get_random(shape): return (np.random.rand(*shape) - 0.5) y_exact = np.array([A.dot(sol[i]) for i in xrange(len(sol))]) y_error = (y_exact * (1 + maxrelerror * get_random(y_exact.shape) + maxsyserror * y_exact.max(0) * get_random(y_exact.shape))) errors = (maxrelerror * y_exact + maxsyserror * y_exact.max(0))
def create_class(): from CommonFiles.pBase import pBase return pBase(model(), paramset, y0in)
opt = 'load' if opt == 'load': with open('data/single_simulation_results.p', 'rb') as f: traj_dict = pickle.load(f) ts_c = traj_dict['ts'] traj_control = traj_dict['control'] traj_vac1p = traj_dict['vac1p'] traj_vdcn = traj_dict['vdcn'] vdcn_y0 = traj_dict['vdcn_y0'] vdcn_p = traj_dict['vdcn_p'] vac1p_y0 = traj_dict['vac1p_y0'] vac1p_p = traj_dict['vac1p_p'] base_vdcn = pBase(base_control.model, vdcn_p, vdcn_y0) base_vac1p = pBase(base_control.model, vac1p_p, vac1p_y0) else: # Similar to the cluster script, we have to first calculate the limit # cycle solutions to the models at a variety of different knockdown # strengths def param_reduction(param, amount, base_list): t_param = np.array(base_control.paramset) t_param[base_control.pdict[param]] *= (1 - amount) tbase = pBase(base_control.model, t_param, base_list[-1].y0) try: tbase.approxY0(tout=1000, tol=1E-5) tbase.solveBVP() assert tbase.findstationary() == 0
kdy = cs.ssym("kdy") k2 = cs.ssym("k2") Km = cs.ssym("Km") KI = cs.ssym("KI") symparamset = cs.vertcat([k1,Kd,P,kdx,ksy,kdy,k2,Km,KI]) # Time Variable t = cs.ssym("t") ode = [[]]*NEQ ode[0] = k1*(Kd**P)/((Kd**P) + (Y**P)) - kdx*X ode[1] = ksy*X - kdy*Y - k2*Y/(Km + Y + KI*Y**2) ode = cs.vertcat(ode) fn = cs.SXFunction(cs.daeIn(t=t, x=y, p=symparamset), cs.daeOut(ode=ode)) fn.setOption("name","Tyson 2 State Model") return fn def create_class(): from CommonFiles.pBase import pBase return pBase(model(), paramset, y0in) if __name__ == "__main__": from CommonFiles.pBase import pBase test_base = pBase(model(), paramset, y0in)