def dsprog(prog): params = {"one":0.999999, \ "eps":0.4, \ "T": 1.0, \ "xd": 1.024, \ "xs": 0.4, \ "X0": 1.025, \ "B0": 0.0 } ampl = 1.0 freq = 0.5 prog_util.build_oscillator(prog,ampl,freq,"dummy","U") params['ieps'] = 1.0/params['eps'] params['Tieps'] = params['ieps']*params['T'] params['nieps'] = -params['ieps'] params['xds'] = params['xd'] - params['xs'] params['nxd'] = -params['xd'] dX = "{nieps}*X3 + {ieps}*(X) + {nieps}*(B)" dB = "{one}*X + {nxd} + {xds}*U*U" prog.decl_var("X3", "(X*X)*(X)") prog.decl_stvar("X", dX, "{X0}", params); prog.decl_stvar("B", dB, "{B0}", params); prog.emit("{one}*X","HEARTBEAT",params); # 4.37 khz prog.interval("X",-3.0,3.0) prog.interval("B",-3.0,3.0)
def dsprog(prog): params = {'meas_noise': 0.6, 'proc_noise': 2.0, 'one': 0.9999} ampl = 0.7 freq = 0.2 prog_util.build_oscillator(prog, ampl, freq, "VSIG", "SIG") ampl = 0.3 freq = 3.0 #prog_util.build_oscillator(prog,ampl,freq,"VNZ","NZ") params['Rinv'] = 1.0 / params['proc_noise'] params['X0'] = 0.0 params['P0'] = 0.0 params['Q'] = params['meas_noise'] #prog.decl_var("INP", "SIG+NZ") #E = "INP+(-X)" E = "SIG+(-X)" dX = "{one}*RP*E" dP = "{Q}+(-RP)*P" prog.decl_var("RP", "{Rinv}*P", params) prog.decl_var("E", E, params) prog.decl_stvar("X", dX, "{X0}", params) prog.decl_stvar("P", dP, "{P0}", params) prog.emit("{one}*X", "STATE", params) prog.interval("X", -1.0, 1.0) prog.interval("P", 0, 1.0)
def dsprog(prob): params = {"initial": 0.0, "one": 0.99999} ampl = 1.0 freq = 0.5 prog_util.build_oscillator(prob, ampl, freq, "VSIG", "SIG") prob.max_time = 300 #params['negTarget'] = -params['target'] PLANT = "CTRL+{one}" ERROR = "PLANT+{one}*(-SIG)" CONTROL = "2.0*(-ERR)+8.0*(-INTEG)" INTEGRAL = "{one}*ERR+0.3*(-INTEG)" #prob.decl_var("SIG",SIG,params) prob.decl_var("ERR", ERROR, params) prob.decl_var("CTRL", CONTROL, params) prob.decl_stvar("INTEG", INTEGRAL, "{initial}", params) prob.decl_stvar("PLANT", PLANT, "{initial}", params) #prob.emit("{one}*PLANT","TrackedSig",params) #prob.emit("{one}*ERR","TrackingError",params) prob.emit("{one}*CTRL", "Controlled", params) for v in ['PLANT', 'CTRL', 'ERR', 'INTEG']: prob.interval(v, -2.0, 2.0) print(prob) prob.check()
def dsprog(prog): K = 1.0 params = { 'a2': 15.6, #'a1': 156.25, 'a1': 15.62, #'K' : 0.000029618, 'K': K, 'nu': 2.0015, 'beta': 2.5, 'gamma': 1.0, 'U0': 0.0, 'V0': 0.0, 'kdeg': 0.99999999, 'one': 0.99999 } #reparametrization # derived parameters params['invK'] = 1.0 / params['K'] params['negNu'] = -params['nu'] params['one'] = 0.999999 params['halfK'] = K / 2.0 ampl = params['halfK'] freq = 0.9999999 prog_util.build_oscillator(prog, ampl, freq, "VPERT", "PERT") prog.decl_var("IPTG", "{halfK} + PERT", params) #prog.decl_lambda("umod","(1+max(X,0)*{invK})^{negNu}",params) prog.decl_lambda("utf", "{a1}/(1+max(X,0)^{beta})", params) #prog.decl_lambda("vtf", "{a2}/(1+max(X,0)^{gamma})",params) prog.decl_lambda("umodvtf", "{a2}/(1+max(((1+max(X,0)*{invK})^{negNu}),0)^{gamma})", params) #prog.decl_var("FNUMOD", "umod(IPTG)",params) #prog.interval("FNUMOD",0,1.2) #prog.decl_var("UMODIF", "U*({one}*FNUMOD)",params) #prog.interval("UMODIF",0,0.40) prog.decl_var("UTF", "utf(V)", params) prog.interval("UTF", 0.0, 16.0) #prog.decl_var("VTF", "vtf(FNUMOD)",params) prog.decl_var("VTF", "umodvtf(IPTG)", params) prog.interval("VTF", 0.0, 16.0) dV = "{one}*VTF + {kdeg}*(-V)" dU = "{one}*UTF + {kdeg}*(-U)" # this is a dummy output so that we can flip the sign. #prog.decl_var("fU","U"); prog.decl_stvar("V", dV, "{V0}", params) prog.decl_stvar("U", dU, "{U0}", params) prog.emit("{one}*V", "compV", params) prog.interval("V", 0, 16.0) prog.interval("U", 0, 1.2) return
def dsprog(prog): rel_time = 5.0 mu = 0.2 params = { 'mu': rel_time*mu, 'Y0': 0.0, 'X0': -0.5, 'one':0.9999, 'tc':1.0*rel_time } ampl,freq = 1.0,1.0 prog_util.build_oscillator(prog,freq,ampl,"VW","W") dY = '{tc}*W+Y*{mu}*(1.0+(-X)*X)+{tc}*(-X)' dX = '{tc}*Y' prog.decl_stvar("Y",dY,"{Y0}",params) prog.decl_stvar("X",dX,"{X0}",params) prog.emit("{one}*X","OSC",params) prog.interval("X",-2.2,2.2) prog.interval("Y",-2.2,2.2) prog.check() return prog
def dsprog(prog): params = {'meas_noise': 1.0, 'proc_noise': 0.9999, 'one': 0.9999} ampl = 1.0 freq = 0.3 prog_util.build_oscillator(prog, ampl, freq, "dummy", "SIG") params['Rinv'] = 1.0 / params['proc_noise'] params['nRinv'] = -1.0 / params['proc_noise'] params['X0'] = 0.0 params['P0'] = 0.0 params['Q'] = params['meas_noise'] #E = "SIG+{one}*(-X)" E = "SIG+(-X)" dX = "{one}*RP*E" dP = "{Q}+(-RP)*P" prog.decl_var("RP", "{Rinv}*P", params) prog.decl_var("E", E, params) prog.decl_stvar("X", dX, "{X0}", params) prog.decl_stvar("P", dP, "{P0}", params) prog.emit("{one}*X", "STATE", params) prog.interval("X", -1.0, 1.0) prog.interval("P", 0, 1.0)