Skip to content

Commit

Permalink
Merge 4efa73f into 504fc7f
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlarson1 committed May 22, 2024
2 parents 504fc7f + 4efa73f commit c206c9f
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 112 deletions.
2 changes: 1 addition & 1 deletion pounders/m/formquad.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
% H [dbl] [n-by-n-by-m] Array of model Hessians centered at X(xk_in, :)
% Mind [int] [np_max-by-1] Integer vector of model interpolation indices
%
function [Mdir, np, valid, G, H, Mind] = formquad(X, F, delta, xk_in, np_max, Pars, vf)
function [Mdir, np, valid, G, H, Mind] = formquad(X, F, delta, xk_in, np_max, Pars, vf, ignored_arg)

% --DEPENDS ON-------------------------------------------------------------
% phi2eval : Evaluates the quadratic basis for vector inputs
Expand Down
30 changes: 30 additions & 0 deletions pounders/m/formquad_model_improvement.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function Xsp = formquad_model_improvement(x_k, Cres, Gres, Hres, Mdir, np, Low, Upp, delta, Model, combinemodels)

n = length(x_k);

% Update for modelimp; Cres unchanged b/c xk_in unchanged
[G, H] = combinemodels(Cres, Gres, Hres);

% Evaluate model-improving points to pick best one
% ! May eventually want to normalize Mdir first for infty norm
% Plus directions
[Mdir1, np1] = bmpts(x_k, Mdir(1:n - np, :), Low, Upp, delta, Model.Par(3));
for i = 1:n - np1
D = Mdir1(i, :);
Res(i, 1) = D * (G + .5 * H * D');
end
[a1, b] = min(Res(1:n - np1, 1));
Xsp = Mdir1(b, :);
% Minus directions
[Mdir1, np2] = bmpts(x_k, -Mdir(1:n - np, :), Low, Upp, delta, Model.Par(3));
for i = 1:n - np2
D = Mdir1(i, :);
Res(i, 1) = D * (G + .5 * H * D');
end
[a2, b] = min(Res(1:n - np2, 1));
if a2 < a1
Xsp = Mdir1(b, :);
end

end

14 changes: 14 additions & 0 deletions pounders/m/gaussnewton.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function [Mdir, np, valid, Gres, Hres, Mind] = gaussnewton(X, F, delta, xk_in, np_max, Pars, vf, aux)

Gres = aux{xk_in}';
[n, m] = size(Gres);
Hres = zeros(n, n, m);

% silly things to make everything compatible in pounders
valid = true;
np = n;

Mdir = []; % because valid is always true, pounders should never try to read this.
Mind = []; % ditto above

end

0 comments on commit c206c9f

Please sign in to comment.