35 views (last 30 days)
Show older comments
Alexander on 12 Dec 2012
-
-
Link
Direct link to this question
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function
I'm using a comprehensive MATLAB code to create a stiffened pressure vessel (that fulfills a known set of structural design criteria). The code to design the pressure vessel is written as a function, with four input variables that define the scantlings of the stiffeners for the design. The objective function (using FMINCON) calls up this design code function, and, in theory, the FMINCON algorithm is expected to modify the four design variables until an ideal solution is found (i.e. the pressure vessel design that represents a minimal weight solution, but satisfies all structural design criteria).
Unfortunately, as written, the current code appears to iterate through a single design variable, rather than all four design variables. As a result, no feasible solution is found. How do I modify the FMINCON function to ensure that the full multivariable design space is considered? Why does the default FMINCON function focus on a single design variable at a time, rather than iterating through all four design variables concurrently?
Any insights would be tremendously appreciated.
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Answers (2)
Kye Taylor on 12 Dec 2012
Edited: Kye Taylor on 12 Dec 2012
Open in MATLAB Online
The key is to modify your objective function to be one that can be utilized by the fmincon interface.
For example, if your objective function has a signature that looks like
function f = myfun(x1,x2,x3,x4)
% assuming x1,...,x4 are scalars
% computations with x1,...,x4 like
f = x1*x2*x3*x4
rewrite it like
function f = myfun(x)
% input to objectives passed to fmincon can
% be a vector. So treat its scalar components
% as your design variables
x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);
% computations with x1,...,x4 like
f = x1*x2*x3*x4
2 Comments Show NoneHide None
Show NoneHide None
Matt J on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116796
Edited: Matt J on 12 Dec 2012
Open in MATLAB Online
Or, you could change the way you call FMINCON
fmincon(@(x)myfun(x(1),x(2),x(3),x(4)), xInitial,....)
Alexander on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116798
Thanks for the quick response, Kye!
My objective function is already structured in the manner that you suggested ...
function f = PV_objfun(x)
x7 = x(1); x8 = x(2); x9 = x(3); x10 = x(4);
f = PV_design_code(x7,x8,x9,x10);
The variable "f" represents the value of the objective function (i.e. the weight of the pressure vessel). To calculate the value of f, FMINCON is expected to call up the robust design alogrithm ("PV_design_code"), with the four variables determined by the FMINCON algorithm.
Unfortunately, FMINCON seems to focus on a single variable, such as x(1), without altering any of the other variables.
Sign in to comment.
Matt J on 12 Dec 2012
Edited: Matt J on 12 Dec 2012
Have you checked that small changes in the remaining variables x8, x9, x10 affect the output value of the objective function? If they do not, what you're seeing makes perfect sense.
A common mistake is to have non-differentiable quantizer operations in the objective function like ROUND, FLOOR, CEIL, etc... These make the function locally flat in some or all variables.
6 Comments Show 4 older commentsHide 4 older comments
Show 4 older commentsHide 4 older comments
Alexander on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116801
Thanks for the suggestion, Matt! I haven't conducted a sensitivity analysis on the four parameters, but my engineering judgment suggests that they should all influence the objective function. The parameters represent the dimensions of a standard T-stiffener: web thickness, web height, flange thickness, and flange width. The objective function sums all of the material weight for the total pressure vessel, so changing all of the dimensions should affect the amount of material similarly. I'll check to make sure that everything is coded correctly, but in order to attain a feasible solution (i.e. one that "passes" the structural design rules for maximum stress, stiffener tripping, etc.), all four parameters must be varied.
Matt J on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116803
Edited: Matt J on 12 Dec 2012
Make sure there are no quantization operations in your nonlinear constraint functions (if you have any) as well. All functions fed to FMINCON must be differentiable and smoothly varying.
Alexander on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116805
That could definitely be an issue. I have an equality constraint that is essentially a binary value. If the pressure vessel design "passes" all of the programmed design rules, the binary value is 1. Otherwise, if even one of the rules is "failed," the binary value is 0. I'm not sure if FMINCON is robust enough to handle the situation where I don't already start with a "passing" (but non-ideal) solution, as I suspect that there is a discontinuity in that binary jump from 0 to 1. The constraint condition is that the the specific value (defined as "check_final_binary") has to equal 1.
Matt J on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116806
Edited: Matt J on 12 Dec 2012
As I said, FMINCON can only work with twice differentiable (and hence continuous) functions. So, no discontinuities are allowed, be they in the constraints or in the objective.
Sean on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116807
You could use the 'DiffMinChange' option in optimset() to force fmincon to look further for its finite differences. This can help it step away from locally flat or discontinuous points.
Matt J on 12 Dec 2012
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/56424-multivariable-optimization-with-the-fmincon-function#comment_116824
Edited: Matt J on 12 Dec 2012
It's still questionable whether DiffMinChange would make a difference for FMINCON algorithms where line searches are involved. The finite difference calculations normally control the direction of the search for the next point, but not the step size. If the step size isn't large enough to skip over the locally flat region, then you'll still get stuck.
On the other hand, it would make some sense if the FMINCON code did choose the initial step size of the line search at least as large as DiffMinChange, but I've seen no documentation of that being the case.
Sign in to comment.
Sign in to answer this question.
See Also
Categories
Mathematics and OptimizationOptimization ToolboxSystems of Nonlinear Equations
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Tags
- fmincon
- multivariable optimization
Products
- MATLAB
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office