Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modular model building and model updating #125

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading