comparison scripts/optimization/sqp.m @ 6382:f74e71ef6612

[project @ 2007-03-05 21:29:40 by jwe]
author jwe
date Mon, 05 Mar 2007 21:29:40 +0000
parents 34f96dd5441b
children 2a04f026ef54
comparison
equal deleted inserted replaced
6381:8a844b3d10b1 6382:f74e71ef6612
177 ## Choose an initial NxN symmetric positive definite Hessan 177 ## Choose an initial NxN symmetric positive definite Hessan
178 ## approximation B. 178 ## approximation B.
179 179
180 n = length (x); 180 n = length (x);
181 181
182 B = eye (n, n);
183
184 ## Evaluate objective function, constraints, and gradients at initial 182 ## Evaluate objective function, constraints, and gradients at initial
185 ## value of x. 183 ## value of x.
186 ## 184 ##
187 ## obj_fun 185 ## obj_fun
188 ## obj_grad 186 ## obj_grad
198 if (length (objf) > 1) 196 if (length (objf) > 1)
199 obj_grd = objf{2}; 197 obj_grd = objf{2};
200 if (length (objf) > 2) 198 if (length (objf) > 2)
201 obj_hess = objf{3}; 199 obj_hess = objf{3};
202 have_hess = 1; 200 have_hess = 1;
203 B = feval (obj_hess, x);
204 endif 201 endif
205 endif 202 endif
206 else 203 else
207 error ("sqp: invalid objective function"); 204 error ("sqp: invalid objective function");
208 endif 205 endif
255 obj = feval (obj_fun, x); 252 obj = feval (obj_fun, x);
256 nfun = 1; 253 nfun = 1;
257 254
258 c = feval (obj_grd, x); 255 c = feval (obj_grd, x);
259 256
257 if (have_hess)
258 B = feval (obj_hess, x);
259 else
260 B = eye (n, n);
261 endif
262
260 ce = feval (ce_fun, x); 263 ce = feval (ce_fun, x);
261 F = feval (ce_grd, x); 264 F = feval (ce_grd, x);
262 265
263 ci = feval (ci_fun, x); 266 ci = feval (ci_fun, x);
264 C = feval (ci_grd, x); 267 C = feval (ci_grd, x);