# Define problem scaling obj_scale = -1.0 constr_scale = np.ones(problem.ncons) var_constr_scale = problem.unpack_constraints(constr_scale) var_constr_scale['innovation'][:] = 1e3 dec_scale = np.ones(problem.ndec) var_scale = problem.variables(dec_scale) var_scale['isRp_tril'][:] = 1e-2 with problem.ipopt(dec_bounds, constr_bounds) as nlp: nlp.add_str_option('linear_solver', 'ma57') nlp.add_num_option('ma57_pre_alloc', 10.0) nlp.add_num_option('tol', 1e-5) nlp.add_int_option('max_iter', 10000) nlp.set_scaling(obj_scale, dec_scale, constr_scale) decopt, info = nlp.solve(dec0) opt = problem.variables(decopt) xopt = opt['x'] A = opt['A'] B = opt['B'] C = opt['C'] D = opt['D'] L = opt['L'] W = np.diag(opt['W_diag']) ybias = opt['ybias'] isRp = symfem.tril_mat(ny, opt['isRp_tril']) yopt = xopt @ C.T + u @ D.T + ybias eopt = opt['e']
decopt, info = nlp.solve(dec0) opt = problem.variables(decopt) xopt = opt['x'] Ac = opt['Ac'] Bc = opt['Bc'] A = opt['A'] B = opt['B'] C = opt['C'] D = opt['D'] Ln = opt['Ln'] Kn = opt['Kn'] ybias = opt['ybias'] pred_orth = opt['pred_orth'] corr_orth = opt['corr_orth'] sRp = symfem.tril_mat(opt['sRp_tril']) sPp = symfem.tril_mat(opt['sPp_tril']) sPc = symfem.tril_mat(opt['sPc_tril']) sQ = symfem.tril_mat(opt['sQ_tril']) sQc = symfem.tril_mat(opt['sQc_tril']) sR = symfem.tril_mat(opt['sR_tril']) yopt = xopt @ C.T + u @ D.T + ybias enopt = opt['en'] Pc = sPc @ sPc.T Pp = sPp @ sPp.T Rp = sRp @ sRp.T Q = sQ @ sQ.T Qc = sQc @ sQc.T R = sR @ sR.T
# Define problem scaling obj_scale = -1.0 constr_scale = np.ones(problem.ncons) var_constr_scale = problem.unpack_constraints(constr_scale) var_constr_scale['innovation'][:] = 1e2 dec_scale = np.ones(problem.ndec) var_scale = problem.variables(dec_scale) var_scale['sRp_tril'][:] = 1e2 var_scale['Ln'][:] = 1e2 with problem.ipopt(dec_bounds, constr_bounds) as nlp: nlp.add_str_option('linear_solver', 'ma57') nlp.add_num_option('ma57_pre_alloc', 25.0) nlp.add_num_option('tol', 1e-6) nlp.add_int_option('max_iter', 1000) nlp.set_scaling(obj_scale, dec_scale, constr_scale) decopt, info = nlp.solve(dec0) opt = problem.variables(decopt) xopt = opt['x'] A = opt['A'] B = opt['B'] C = opt['C'] D = opt['D'] Ln = opt['Ln'] ybias = opt['ybias'] sRp = symfem.tril_mat(opt['sRp_tril']) yopt = xopt @ C.T + u @ D.T + ybias enopt = opt['en']
opt = problem.variables(decopt) xopt = opt['x'] Ac = opt['Ac'] Bc = opt['Bc'] Qc = opt['Qc'] A = opt['A'] B = opt['B'] C = opt['C'] D = opt['D'] L = opt['L'] Kn = opt['Kn'] ybias = opt['ybias'] pred_orth = opt['pred_orth'] corr_orth = opt['corr_orth'] sR = symfem.tril_mat(ny, opt['sR_tril']) sRp = symfem.tril_mat(ny, opt['sRp_tril']) isRp = symfem.tril_mat(ny, opt['isRp_tril']) sPp = symfem.tril_mat(nx, opt['sPp_tril']) sPc = symfem.tril_mat(nx, opt['sPc_tril']) sQ = symfem.tril_mat(nx, opt['sQ_tril']) yopt = xopt @ C.T + u @ D.T + ybias eopt = opt['e'] Pc = sPc @ sPc.T Pp = sPp @ sPp.T Rp = sRp @ sRp.T Q = sQ @ sQ.T R = sR @ sR.T