Skip to content

Commit

Permalink
use numerical sensitivities + fmincon #84
Browse files Browse the repository at this point in the history
  • Loading branch information
timueh committed Apr 6, 2020
1 parent 82c7dc9 commit 61b4357
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/core/createLocSolAndSens.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@
% [ sProb.nnlp, sProb.gBounds, sProb.rhoCas, sProb.lamCas, sProb.SSig ] = ...
% createLocalSolvers(sProb, opts);

% compute sensitivities (gradient, Jacobian, ...)
sProb.rhoCas = opts.sym('rho',1,1);
if ~isfield(sProb, 'sens')
fprintf('Using casadi to compute sensitivities...')
sProb.sens = createSens(sProb, opts);
fprintf('done\n\n');
else
fprintf('Using given sensitivities...\n');
end
pause(1)

[ sProb.nnlp, sProb.gBounds, sProb.rhoCas] = createLocalSolvers(sProb, opts);

% compute sensitivities (gradient, Jacobian, ...)
sProb.sens = createSens(sProb, opts);


% set up a merit function for line search
sProb.Mfun = createMfun(sProb, opts);
Expand Down
4 changes: 2 additions & 2 deletions src/core/createLocalSolvers.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
if use_fmincon
pars = [];
funs = sProb.locFuns;
jacs = sProb.locSens;
solve_nlp = @(x, z, rho, lambda, Sigma, pars)build_local_NLP(funs.ffi{i}, funs.ggi{i}, funs.hhi{i}, sProb.AA{i}, lambda, rho, z, Sigma, x, sProb.llbx{i}, sProb.uubx{i}, jacs.ggi{i});
sens = sProb.sens;
solve_nlp = @(x, z, rho, lambda, Sigma, pars)build_local_NLP(funs.ffi{i}, funs.ggi{i}, funs.hhi{i}, sProb.AA{i}, lambda, rho, z, Sigma, x, sProb.llbx{i}, sProb.uubx{i}, sens.JJac{i});
else
assert(isfield(sProb, 'locFunsCas'), 'locFunsCas field is missing')
nlp_reference = build_nlp_reference(sProb.xxCas{i},...
Expand Down

0 comments on commit 61b4357

Please sign in to comment.