def dsprog(prog): xd = 1.024 xcontract = 0.4 params = {"one":0.999999, \ "eps":0.4, \ "T": 1.0, \ "xd": xd, \ "xs": xd-xcontract, \ "X0": xd, \ "B0": 0.0 } sensor_util.decl_external_input(prog, "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 + {Tieps}*(X) + {nieps}*(B)" dB = "{one}*X + {xds}*(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) # 7 khz tc = sensor_util.siggen_time_constant('heart-normal') #prog.speed(0.98*tc,tc*1.02) prog.interval("X", -3.0, 3.0) prog.interval("B", -3.0, 3.0)
def dsprog(prog): params = { 'meas_noise': 0.3, 'proc_noise': 0.5, 'X0': 1.0, 'V0': 0.0, 'P0': 1.0, 'one': 0.9999 } params['Q'] = params['meas_noise'] params['Rinv'] = 1.0 / params['proc_noise'] params['nRinv'] = -1.0 / params['proc_noise'] dX = "{one}*V + {Rinv}*P11*E" dV = "{one}*(-X) + {Rinv}*P12*E" dP11 = "2.0*P12 + {Q} + {nRinv}*P11*P11" dP12 = "{one}*P22+{one}*(-P11) +{Q} + {nRinv}*P11*P12" dP22 = "2.0*(-P12) + {Q} + {nRinv}*P12*P12" sensor_util.decl_external_input(prog, "U") prog.decl_var("E", "{one}*U+{one}*(-X)", params) prog.decl_stvar("X", dX, "{X0}", params) prog.decl_stvar("V", dV, "{V0}", params) prog.decl_stvar("P11", dP11, "{P0}", params) prog.decl_stvar("P12", dP12, "{P0}", params) prog.decl_stvar("P22", dP22, "{P0}", params) prog.emit("{one}*X", "MODEL", params) prog.interval("X", -1.0, 1.0) prog.interval("V", -1.0, 1.0) prog.interval("W", -1.0, 1.0) for cov in ['11', '12', '22']: prog.interval("P%s" % cov, -1.2, 1.2)
def dsprog(prog): params = { "charge": 0.3, "deg": 0.8, 'thresh': -0.1, "deltc": 0.6, "one": 0.99999 } dX = "{charge}*U + {deg}*(-X)" #ERROR = "X+{thresh}" sensor_util.decl_external_input(prog, "U") prog.decl_stvar("X", dX, "0.0", params) #prog.decl_stvar("DEL1",dDEL1,"1.0",params) #prog.decl_stvar("DEL2",dDEL2,"1.0",params) #prog.decl_stvar("DEL3",dDEL3,"1.0",params) #prog.decl_var("ERROR",ERROR,params) ''' TODO: debug threshold, end goal is to have sane trigger work. ''' prog.interval("X", -1.0, 1.0) #prog.interval("DEL1",-1.0,1.0) #prog.interval("DEL2",-1.0,1.0) #prog.interval("DEL1",0.0,1.0) #prog.emit("{one}*X","DETECTOR",params); prog.emit("{one}*X", "DETECTOR", params) tau = sensor_util.siggen_time_constant('anomaly-bias') prog.speed(tau * 0.95, tau * 1.05)
def dsprog(prog): params = {"one": 0.999999, "coeff": 0.5} sensor_util.decl_external_input(prog, "X") prog.decl_var("Y", "0.5*X") E = "Y+{one}*X*(-Z)" prog.decl_stvar("Z", E, "0.0", params) prog.interval("Z", 0.0, 4.0) prog.emit("{one}*Z", "OUT", params)
def dsprog(prog): params = { "charge":0.6, "deg":0.8, "one":0.99999 } IN = "{one}*U" dX = "{charge}*IN*IN + {deg}*(-X)" #ERROR = "X+{thresh}" sensor_util.decl_external_input(prog,"U"); prog.decl_var("IN",IN,params) prog.decl_stvar("X",dX,"0.0",params) prog.interval("X",-1.0,1.0) prog.emit("{one}*X","DETECTOR",params); tau = sensor_util.siggen_time_constant('anomaly-ampl') prog.speed(tau*0.95,tau*1.05)
def dsprog(prog): params = { "charge":0.35, "deg":0.8, "deltc":0.15, "one":0.99999, "two":1.99999, "X0": 0.0, "Q0": 0.0, "D0":1.0 } E = "{one}*X - {one}*U" dX = "{one}*U - {deg}*X" dQ = "{two}*E*E + {deg}*(-Q)" sensor_util.decl_external_input(prog,"U"); prog.decl_stvar("X", dX,"{X0}",params) prog.decl_var("E", E, params) prog.decl_stvar("Q", dQ, "{Q0}",params) prog.emit("{one}*Q","DETECTOR",params); prog.interval("X",-2.0,2.0) prog.interval("Q",-2.0,2.0) tau = sensor_util.siggen_time_constant('anomaly-freq') prog.speed(tau*0.95,tau*1.05)
def dsprog(prog): params = { 'one':0.9999999 } sensor_util.decl_external_input(prog,"X"); prog.emit("X","OUT",params);
def dsprog(prog): sensor_util.decl_external_input(prog, "X") prog.decl_var("Y", "0.5*X") prog.emit("Y", "OUT")
def dsprog(prog): params = {"one": 0.99999} sensor_util.decl_external_input(prog, "X") prog.decl_var("Y", "{one}*X+{one}*(-X)", params) prog.interval("Y", -1, 1) prog.emit("Y", "OUT", params)