| 952 | lq.finalLoss.rv = RV("yt", 1, 0); |
| 953 | |
| 954 | lq.validate(); |
| 955 | |
| 956 | lq.resetTime(); |
| 957 | lq.redesign(); |
| 958 | |
| 959 | for(int k = K-1; k > 0; k--){ |
| 960 | //cout << "L: " << lq.getL() << endl; |
| 961 | lq.redesign(); |
| 962 | } |
| 963 | |
| 964 | cout << "L: " << lq.getL() << endl; |
| 965 | } |
| 966 | |
| 967 | TEST (LQGU_181_ten){ |
| 968 | /* v ????? .8189 |
| 969 | y_t = 1.81 y_{t-1} -.9 y_{t-2} + .00438 u_t + .00468 u_{t-1} |
| 970 | |
| 971 | S = y^2 + u^2/1000 |
| 972 | |
| 973 | y_r = 0 :> u_t = -69.0908 y_{t-1} + 46.8955 y_{t-2} -0.2509 u_{t-1} |
| 974 | y_r = 10 :> u_t = -69.0908 y_{t-1} + 46.8955 y_{t-2} -0.2509 u_{t-1} + 233.7581 |
| 975 | */ |
| 976 | |
| 977 | int K = 150; |
| 978 | //yr = 10.0; |
| 979 | |
| 980 | LQG_universal lq; |
| 981 | lq.rv = RV("ut", 1, 0); |
| 982 | RV rvc; |
| 983 | rvc = RV("yt", 1, -1); |
| 984 | rvc.add(RV("yt", 1, -2)); |
| 985 | rvc.add(RV("ut", 1, -1)); |
| 986 | rvc.add(RV("1", 1, 0)); |
| 987 | lq.set_rvc(rvc); |
| 988 | lq.horizon = K; |
| 989 | |
| 990 | Array<linfnEx> model(4); |
| 991 | model(0).A = mat("1.81"); |
| 992 | model(0).B = vec("0"); |
| 993 | model(0).rv = RV("yt", 1, -1); |
| 994 | model(0).rv_ret = RV("yt", 1, 0); |
| 995 | model(1).A = mat("-0.8189"); |
| 996 | model(1).B = vec("0"); |
| 997 | model(1).rv = RV("yt", 1, -2); |
| 998 | model(1).rv_ret = RV("yt", 1, 0); |
| 999 | model(2).A = mat("0.00438"); |
| 1000 | model(2).B = vec("0"); |
| 1001 | model(2).rv = RV("ut", 1, 0); |
| 1002 | model(2).rv_ret = RV("yt", 1, 0); |
| 1003 | model(3).A = mat("0.00468"); |
| 1004 | model(3).B = vec("0"); |
| 1005 | model(3).rv = RV("ut", 1, -1); |
| 1006 | model(3).rv_ret = RV("yt", 1, 0); |
| 1007 | lq.Models = model; |
| 1008 | |
| 1009 | Array<quadraticfn> qloss(2); |
| 1010 | qloss(0).Q.setCh(mat("1 -10")); |
| 1011 | qloss(0).rv = RV("yt", 1, 0); |
| 1012 | qloss(0).rv.add(RV("1", 1, 0)); |
| 1013 | qloss(1).Q.setCh(mat("0.03162")); |
| 1014 | qloss(1).rv = RV("ut", 1, 0); |
| 1015 | lq.Losses = qloss; |
| 1016 | |
| 1017 | lq.finalLoss.Q.setCh(mat("0")); |