Overview
Comment: | Various changes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
12e17795c643aa7f7c896888d509458a |
User & Date: | gawthrop@users.sourceforge.net on 2002-05-13 16:11:09 |
Other Links: | branch diff | manifest | tags |
Context
2002-05-13
| ||
22:46:30 | Plant can now have multiple inputs. check-in: 2d5df8ac83 user: geraint@users.sourceforge.net tags: origin/master, trunk | |
16:11:09 | Various changes check-in: 12e17795c6 user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
16:01:10 | Addes Q weighting matrix check-in: 302ba43d9c user: gawthrop@users.sourceforge.net tags: origin/master, trunk | |
Changes
Modified mttroot/mtt/lib/rep/nppp_rep.sh from [149fe751d7] to [dd3ac0c981].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #! /bin/sh ## nppp_rep.sh ## DIY representation "nppp" for mtt # Copyright (C) 2002 by Peter J. Gawthrop sys=$1 rep=nppp lang=$2 target=${sys}_${rep}.${lang} ## Make the _nppp.m file make_nppp() { filename=${sys}_${rep}.m echo Creating ${filename} cat > ${filename} <<EOF function [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, extras) | > > | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #! /bin/sh ## nppp_rep.sh ## DIY representation "nppp" for mtt # Copyright (C) 2002 by Peter J. Gawthrop sys=$1 rep=nppp lang=$2 mtt_parameters=$3 parameters=$4 target=${sys}_${rep}.${lang} ## Make the _nppp.m file make_nppp() { filename=${sys}_${rep}.m echo Creating ${filename} cat > ${filename} <<EOF function [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, extras) ## usage: [y,u,t] = ${sys}_nppp (last, ppp_names, par_names, extras) ## ## last last time in run ## ppp_names Column vector of names of ppp params ## par_names Column vector of names of estimated params ## extras Structure containing additional info ##Sanity check if nargin<2 printf("Usage: [y,u,t] = ${sys}_nppp(N, ppp_names[, par_names, extras])\n"); return endif if nargin<4 ## Set up optional parameters extras.criterion = 1e-3; extras.emulate_timing = 0; extras.max_iterations = 15; extras.simulate = 1; extras.v = 1e-6; extras.verbose = 0; extras.visual = 1; endif ## System info [n_x,n_y,n_u,n_z,n_yz] = ${sys}_def; sympar = ${sys}_sympar; simpar = ${sys}_simpar; sympars = s${sys}_sympar; |
︙ | ︙ | |||
60 61 62 63 64 65 66 | printf("Open-loop interval %3.2f \n", simpar.last); printf(" -- using info in ${sys}_simpar.txt\n"); printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last); printf(" -- using info in s${sys}_simpar.txt\n"); endif t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]'; | | < < | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | printf("Open-loop interval %3.2f \n", simpar.last); printf(" -- using info in ${sys}_simpar.txt\n"); printf("PPP optimisation from %3.2f to %3.2f\n", simpars.first, simpars.last); printf(" -- using info in s${sys}_simpar.txt\n"); endif t_horizon = [simpars.first+simpars.dt:simpars.dt:simpars.last]'; w = zeros(n_y,1); w(1) = 1 w_s = ones(size(t_horizon))*w'; ## Setup the indices of the adjustable stuff if nargin<2 i_ppp = [] else i_ppp = ppp_indices (ppp_names,sympar,sympars); # Parameters endif n_ppp = length(i_ppp(:,1)); if nargin<3 i_par = [] else i_par = ppp_indices (par_names,sympar,sympars); # Parameters endif ## Specify basis functions A_w = zeros(1,1); A_u = ppp_aug(A_w,laguerre_matrix(n_ppp-1,2.0)); ## Weights Q = [1;0] if extras.visual # Do some simulations ## System itself par = ${sys}_numpar; x_0_ol = ${sys}_state(par); [y_ol,x_ol, t_ol] = ${sys}_sim(x_0_ol, par, simpar, ones(1,n_u)); simpar_OL = simpar; simpar_OL.last = simpars.last; [y_OL,x_OL, t_OL] = ${sys}_sim(x_0_ol, par, simpar_OL, ones(1,n_u)); pars = s${sys}_numpar; x_0_ppp = s${sys}_state(pars); [y_ppp,y_par,x_ppp, t_ppp] = s${sys}_ssim(x_0_ppp, pars, simpars, ones(1,n_u)); simpar_PPP = simpars; simpar_PPP.first = simpar.first; [y_PPP,y_par,x_PPP, t_PPP] = s${sys}_ssim(x_0_ppp, pars, simpar_PPP, ones(1,n_u)); figure(2); grid; title("Outputs of ${sys}_sim and s${sys}_ssim"); plot(t_ol,y_ol, '*', t_ppp, y_ppp, '+', t_OL, y_OL, t_PPP, y_PPP); ## Basis functions Us = ppp_ustar(A_u,1,t_OL',0,0)'; figure(3); grid; title("Basis functions"); plot(t_OL, Us); endif ## Do it [y,u,t,p,U,t_open,t_ppp,t_est,its_ppp,its_est] \ = ppp_nlin_run ("${sys}",i_ppp,i_par,A_u,w_s,N,Q,extras); ## Compute values at ends of ol intervals T_open = cumsum(t_open); T_open = T_open(1:length(T_open)-1); # Last point not in t j=[]; for i = 1:length(T_open) j = [j; find(T_open(i)*ones(size(t))==t)]; |
︙ | ︙ | |||
133 134 135 136 137 138 139 | echo "Making sensitivity simulation for system ${sys} (lang ${lang})" if [ "${lang}" = "oct" ]; then oct='-oct' fi ## System | | | | | | | | | | | | | | | | | | > | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | echo "Making sensitivity simulation for system ${sys} (lang ${lang})" if [ "${lang}" = "oct" ]; then oct='-oct' fi ## System mtt -q ${mtt_parameters} -stdin ${sys} sympar m mtt -q ${mtt_parameters} -stdin ${sys} simpar m mtt -q ${mtt_parameters} -stdin ${oct} ${sys} state ${lang} mtt -q ${mtt_parameters} -stdin ${oct} ${sys} numpar ${lang} mtt -q ${mtt_parameters} -stdin ${oct} ${sys} input ${lang} mtt -q ${mtt_parameters} -stdin ${oct} ${sys} ode2odes ${lang} mtt -q ${mtt_parameters} -stdin ${sys} sim m ## Sensitivity system mtt -q ${mtt_parameters} -stdin -s s${sys} sympar m mtt -q ${mtt_parameters} -stdin -s s${sys} simpar m mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} state ${lang} mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} numpar ${lang} mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} input ${lang} mtt -q ${mtt_parameters} -stdin ${oct} -s s${sys} ode2odes ${lang} mtt -q ${mtt_parameters} -stdin -s s${sys} ssim m ## Additional system reps for PPP mtt -q ${mtt_parameters} -stdin ${sys} sm m mtt -q ${mtt_parameters} -stdin ${sys} def m mtt -q ${mtt_parameters} -stdin -s s${sys} def m } ## Make the code # #make_model; make_nppp; |