Help with Surrogate Modeling Multivariable Objective Function

5 views (last 30 days)
Hi,
I am trying to figure out how to create an objective function with multiple variable inputs. The objective function needs to be the energy input (Ein) into a system as a function of L,A,and T. Right now I have the equation for the energy input (Ein) in terms of each of these variables. For instance:
Ein = L^2+L
Ein = A^2 +A
Ein = T^2 +T
My actual equation is more complex but just to give a general idea. I now want to create an objective function (Ein) as a function of L,A, and T by combining the 3 known equations. This is part of a general optimization problem where I want to find the optimal paramaters that maximize Ein. I was looking at surrogate modeling to create this new objective function but am not sure if it is able to handle my problem. Please let me know if you have any suggestions.
Thanks!

Accepted Answer

Walter Roberson
Walter Roberson on 5 Mar 2021
Yes, you should be able to do that. Construct lb and ub vectors (mandatory!! and must be finite!) that are length() equal to the number of variables being optimized over. The objective function should then expect a vector of that length.
Internally the function can index the vector whenever needs, or it can assign the elements to meaningful variable names and use the names, whichever is easier. Indexing is typically easier for functions automatically generated from symbolic expressions; assigning to local variables is typically more readable.
  7 Comments
Nicolas Herard
Nicolas Herard on 5 Mar 2021
Edited: Nicolas Herard on 5 Mar 2021
Thank you! I changed the function to
function [Ein] = objconstr(LAT)
Ein = (LAT(1)^2 + LAT(1))*(LAT(2)^2 + LAT(2))*(LAT(3)^2 + LAT(3));
end
to return one scalar (Ein). and the rest of the code to
lb = [0;45;0.5]
ub = [5;80;1]
x=surrogateopt(@objconstr,lb,ub)
and it is running.
Is the new objective function equivalent to what I was looking for?
Walter Roberson
Walter Roberson on 5 Mar 2021
I now want to create an objective function (Ein) as a function of L,A, and T by combining the 3 known equations.
It seems to me that if you have three input sources, that the total energy in the system would be the sum of the sources rather than the product of the sources ?
Question: Is it all the same to you if you increase the L by (say) 100 and decrease the A by 102, with you saying "That's a net decrease of 2, that's fine!" ? As compared to (for example) increasing the L component by 1 and decreasing the A by 2 for a net decrease of 1, but with the values kept more balanced?
It is common in such situations to use an objective that is a weighted sum of squares (with using equal weights to be common), so like
Ein = w1*(LAT(1)^2 + LAT(1)).^2 + w2*(LAT(2)^2 + LAT(2)).^2 + w3 * (LAT(3)^2 + LAT(3)).^2;
This allows you to adjust the relative importance of the factors, but keeps them more balanced.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!