params.h) models, _ = RBPF.setup_rbpf(linsystems, params.C2, params.Q, params.R2) A = numpy.array([[0.98, 0.00, 0.00, 0.00, 0.00, 0.01, 0.00], [0.00, 0.98, 0.00, 0.01, 0.01, 0.01, 0.00], [0.01, 0.00, 0.98, 0.00, 0.00, 0.01, 0.01], [0.00, 0.00, 0.00, 0.98, 0.00, 0.01, 0.00], [0.00, 0.01, 0.00, 0.00, 0.99, 0.00, 0.00], [0.01, 0.01, 0.01, 0.01, 0.00, 0.96, 0.00], [0.00, 0.00, 0.01, 0.00, 0.00, 0.00, 0.99]]) numModels = len(models) nP = 500 # number of particles init_state = linsystems[5].op sguess = RBPF.get_initial_switches(init_state, linsystems) particles = RBPF.init_rbpf(sguess, init_state, params.init_state_covar, 2, nP) switchtrack = numpy.zeros([len(linsystems), params.N]) maxtrack = numpy.zeros([len(linsystems), params.N]) # # Setup the controllers setpoint = 0.9 H = numpy.matrix([1.0, 0.0]) controllers = [None] * len(models) # type: typing.List[LQR.Controller] for k in range(len(models)): ysp = numpy.matrix(setpoint - models[k].b[0]) # set point is set here x_off, u_off = LQR.offset(models[k].A, models[k].B, params.C2, H, ysp) K = LQR.lqr(models[k].A, numpy.matrix(models[k].B), params.QQ, params.RR) controllers[k] = LQR.Controller(K, x_off, u_off)
tend = 200 params = params.Params(tend) # Get the three linear models about the nominal operating points linsystems = params.cstr_model.get_nominal_linear_systems(params.h) # Setup the RBPF models, _ = RBPF.setup_rbpf(linsystems, params.C2, params.Q, params.R2) A = numpy.array([[0.99, 0.01, 0.00], [0.01, 0.98, 0.01], [0.00, 0.01, 0.99]]) numModels = len(models) # number of linear models (will be 3) nP = 500 # number of particles init_state = linsystems[1].op sguess = RBPF.get_initial_switches(init_state, linsystems) # prior switch distribution particles = RBPF.init_rbpf(sguess, init_state, params.init_state_covar, 2, nP) switchtrack = numpy.zeros([len(linsystems), params.N]) maxtrack = numpy.zeros([len(linsystems), params.N]) # Setup the controllers setpoint = 0.9 H = numpy.matrix([1.0, 0.0]) controllers = [None] * len(models) # type: typing.List[LQR.Controller] for k in range(len(models)): ysp = numpy.matrix(setpoint - models[k].b[0]) # set point is set here x_off, u_off = LQR.offset(models[k].A, models[k].B, params.C2, H, ysp) K = LQR.lqr(models[k].A, numpy.matrix(models[k].B), params.QQ, params.RR) controllers[k] = LQR.Controller(K, x_off, u_off)