Thread Subject: fminsearch matab problem

Subject: fminsearch matab problem

From: jimpx

Date: 18 Mar, 2008 20:05:37

Message: 1 of 3

Hello,

I want to pass a number of variables through fminsearch. Because of the structure of the program, some of those variables must be held constant while the others are minimized. Is there a way to do this with fminsearch, or is there another minimization program which allows this?

Thanks,

jimpx

Subject: fminsearch matab problem

From: Arthur G

Date: 19 Mar, 2008 15:27:10

Message: 2 of 3

On 2008-03-18 12:05:37 -0400, jimpx <falloncolm@gmail.com> said:

> Hello,
>
> I want to pass a number of variables through fminsearch. Because of the
> structure of the program, some of those variables must be held constant
> while the others are minimized. Is there a way to do this with
> fminsearch, or is there another minimization program which allows this?
>
> Thanks,
>
> jimpx

Write another (possibly anonymous) function that you use with
fminsearch. This anonymous function has for its inputs only those
variables you want to minimize with respect to, and others are help
constant. Here's an example using anonymous functions:

f = @(x,y) (x-y).^2; % A function of two variables
g = @(y) f(3, y); % Function "f", with x=3
yOpt = fminsearch(g, 0);

--Arthur

Subject: fminsearch matab problem

From: Thomas Clark

Date: 20 Mar, 2008 18:41:02

Message: 3 of 3

Even simpler, use a nested program structure!

Your m-file should read like this:


function [output] = my_optimisation(inputs)
% MY_OPTIMISATION does blah blah (header description)


% Make an initial guess
guess = make_first_guess(inputs);

% Calculate some other stuff
things_i_want_constant = some_computations();

% Perform the search, passing a handle to your nested
function as the evaluation function
x = fminsearch(@evaluation_fun,guess);


% Define the nested evaluation function
function [score] = evaluation_function(guess);

% Insert code to return a score as a function of guess.
% Note that this nested function also has access to the
% variables in the main function,
% e.g. the things_i_want_constant
score = ... your code....

% End the nested function
end
% End the main function
end



jimpx <falloncolm@gmail.com> wrote in message
<26104615.1205870768015.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hello,
>
> I want to pass a number of variables through fminsearch.
Because of the structure of the program, some of those
variables must be held constant while the others are
minimized. Is there a way to do this with fminsearch, or is
there another minimization program which allows this?
>
> Thanks,
>
> jimpx

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com