24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
######################################
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2 2001/04/04 08:36:25 gawthrop
## Restuctured to be more logical.
## Data is now in columns to be compatible with MTT.
##
## Revision 1.1 2000/12/28 11:58:07 peterg
## Put under CVS
##
|
>
>
>
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
######################################
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3 2001/04/05 11:50:12 gawthrop
## Tidied up documentation + verbose mode
##
## Revision 1.2 2001/04/04 08:36:25 gawthrop
## Restuctured to be more logical.
## Data is now in columns to be compatible with MTT.
##
## Revision 1.1 2000/12/28 11:58:07 peterg
## Put under CVS
##
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
extras.max_iterations = 10;
extras.v = 1e-5;
extras.verbose = 0;
endif
[n_data,n_y] = size(y_0);
n_th = length(i_s);
error_old = inf;
error_old_old = inf;
error = 1e50;
reduction = inf;
predicted_reduction = 0;
|
>
>
>
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
extras.max_iterations = 10;
extras.v = 1e-5;
extras.verbose = 0;
endif
[n_data,n_y] = size(y_0);
if n_data<n_y
error("ppp_optimise: y_0 should be in columns, not rows")
endif
n_th = length(i_s);
error_old = inf;
error_old_old = inf;
error = 1e50;
reduction = inf;
predicted_reduction = 0;
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
while (abs(reduction)>extras.criterion)&&\
(abs(error)>extras.criterion)&&\
(iterations<extras.max_iterations)
iterations = iterations + 1; # Increment iteration counter
[y,y_par] = eval(sim_command); # Simulate
##Evaluate error, cost derivative J and cost second derivative JJ
error = 0;
J = zeros(n_th,1);
JJ = zeros(n_th,n_th);
for i = 1:n_y
|
>
>
>
>
>
>
>
>
>
>
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
while (abs(reduction)>extras.criterion)&&\
(abs(error)>extras.criterion)&&\
(iterations<extras.max_iterations)
iterations = iterations + 1; # Increment iteration counter
[y,y_par] = eval(sim_command); # Simulate
[N_data,N_y] = size(y);
if (N_y!=n_y)
mess = sprintf("n_y (%i) in data not same as n_y (%i) in model", n_y,N_y);
error(mess);
endif
## Use the last part of the simulation to compare with data
y = y(1+N_data-n_data:N_data,:);
y_par = y_par(1+N_data-n_data:N_data,:);
##Evaluate error, cost derivative J and cost second derivative JJ
error = 0;
J = zeros(n_th,1);
JJ = zeros(n_th,n_th);
for i = 1:n_y
|