Clear Filters
Clear Filters

Giving target function outputs to optimization algorithm

3 views (last 30 days)
I have a multivariable function that I am trying to optimize the output of. The function is time-consuming so I am using surrogate optimization (through the global optimization toolbox). However, during the run of the function at a specific point, I am also obtaining knowledge of the function values at various additional points. (This is because I am using a continuation method when running the function, but that doesn'tmatter too much). This means that after a few times the optimization algorithm calls the function, I already have dozens of known function output values. My question is- Is there a way to inform the algorithm about these values? Either through the optimization options or through the code of the optimization code itself?
So far what I did is tabluate the obtained values, so that If the optimization algorithm calls the function with a value very near one of them, I can return the obtained value instead of running the function. However this is kind of a workaround and not an actual solution.
Would be thankfull for any assistance

Answers (1)

Alan Weiss
Alan Weiss on 25 Jan 2024
While I haven't tried this before, it sounds to me as if you could change your objective function to use a data set of known points and objective function values, and the set of known points and values can grow over time. I'm not sure how you would best make use of this extra information, but that is something else.
For example, suppose M is the auxiliary matrix of known points, where each known point is one row in M. Suppose N is the vector of associated objective function values, so N(i) is the objective function value of row i of M. Maybe the easiest way to do things is to have M and N be persistent variables. Write the objective function like this:
function fval = myfun(x)
persistent M N
% Perform your computation here. You might want to check whether M and N
% are empty or not before using them.
%
% When you find a new point, say p with objective function value f, include
% them in the matrices:
M = [M;p(:)']; % ensure that p is in row form when appending
N = [N;f];
end
Alan Weiss
MATLAB mathematical toolbox documentation
  5 Comments
Alan Weiss
Alan Weiss on 29 Jan 2024
Oh, sorry for misunderstanding your request. Now I understand that you want to change the surrogateopt algorithm to accept extra data points and values in the middle of a run. That is indeed what you said in your original post, but I didn't understand it until now.
I don't know of any way of doing what you ask. I suppose that you could record the points and associated values, have a relatively short MaxFunctionEvaluations limit, and repeatedly restart surrogateopt with those points and values given in the InitialPoints option. But I doubt that this would really improve your optimization. So the short answer is no, I don't know of a way that would help.
Alan Weiss
MATLAB mathematical toolbox documentation
nathan blanc
nathan blanc on 30 Jan 2024
OK, thanks Alan. Maybe someone else might have a different answer.
Nathan

Sign in to comment.

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!