forked from tsdev/spinw
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vary arg to simplex and lm4 (and tests)
- Loading branch information
1 parent
8cb0a1a
commit 5b72585
Showing
4 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ | |
% Here `x` is a vector of $N$ independent variables, `p` are the | ||
% $M$ parameters to be optimized and `y` is the simulated model. | ||
% If `resid_handle` argument is false (default) then the function returns | ||
% a scalar (the cost funciton to minimsie e.g. chi-squared). If | ||
% a scalar (the cost funciton to minimise e.g. chi-squared). If | ||
% `resid_handle` is true then the function returns a vector of residuals | ||
% (not the residuals squared). | ||
% | ||
|
@@ -138,10 +138,15 @@ | |
% returns array of residuals, if false (default) then function handle | ||
% returns a scalar cost function. | ||
% | ||
% `'vary'` | ||
% : Boolean vector with $M$ elements (one per parameter), if an element is | ||
% false, the corresponding parameter will be fixed (not optimised). | ||
% Default is true for all parameters. | ||
% | ||
% ### See Also | ||
% | ||
% [ndbase.lm] \| [ndbase.pso] | ||
|
||
% | ||
% Original author: John D'Errico | ||
% E-mail: [email protected] | ||
% Release: 4 | ||
|
@@ -161,13 +166,16 @@ | |
inpForm.size = {[1 -1] [1 1] [1 1] [1 1] [-5 -2] [-3 -4] }; | ||
inpForm.soft = {false false false false true true }; | ||
|
||
inpForm.fname = [inpForm.fname {'resid_handle'}]; | ||
inpForm.defval = [inpForm.defval {false}]; | ||
inpForm.size = [inpForm.size {[1 1]}]; | ||
inpForm.fname = [inpForm.fname {'resid_handle', 'vary'}]; | ||
inpForm.defval = [inpForm.defval {false, true(1, Np)}]; | ||
inpForm.size = [inpForm.size {[1 1], [1, Np]}]; | ||
|
||
param = sw_readparam(inpForm, varargin{:}); | ||
|
||
cost_func_wrap = ndbase.cost_function_wrapper(func, p0, "data", dat, 'lb', param.lb, 'ub', param.ub, 'resid_handle', param.resid_handle); | ||
cost_func_wrap = ndbase.cost_function_wrapper(func, p0, "data", dat, ... | ||
'lb', param.lb, 'ub', param.ub, ... | ||
'resid_handle', param.resid_handle, ... | ||
'ifix', find(~param.vary)); | ||
|
||
% transform starting values into their unconstrained surrogates. | ||
p0_free = cost_func_wrap.get_free_parameters(p0); | ||
|