You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
non linear optimization with fmincon
1 view (last 30 days)
Show older comments
Hi, I am solving a nonlinear optimization problem: Xop=fmincon(@ident1,[0.1;0.1],[],[],[],[],[1 1],[50 5]); problem.options =optimset('Display','iter-detailed'); I found Xop= 2.6147 1.0000 I don't understand why the second value of Xop don't change although i change the upper value. If upper value is 0.5 Xop(2)=0.5 Can you help me? thanks
11 Comments
Alexandra Harkai
on 2 Nov 2016
What is your objective function?
Anoire BEN JDIDIA
on 2 Nov 2016
Edited: Walter Roberson
on 2 Nov 2016
function [eps] =ident1(x)
global Hilb
global tsim
x
eps=sum(abs(Hilb-(x(1)*13270.8617*(55.89*exp(-((tsim- 2.915)/7.182).^2) + 65.16*exp(-((tsim- 378.4)/224.1).^2) + 4.952 *exp(-((tsim-41.41)/9.817).^2) + 8.203*exp(-((tsim-228.6)/ 48.32).^2) + 6.925*exp(-((tsim- 166.4)/54.56).^2) + 2.585*exp(-((tsim-274.2 )/ 28.11).^2) +53.45*exp(-((tsim-50.93)/ 146.7).^2) + 1.155*exp(-((tsim-302)/16.94).^2)-0.29*(30.65*exp(-((tsim-1.463)/1.283).^2) -3.707*exp(-((tsim-12.16)/9.039).^2) + 158.4*exp(-((tsim-9.824e+004)/ 5.722e+004).^2) + 0.09067*exp(-((tsim- 156.9 )/ 0.2263 ).^2)+ 0.1171*exp(-((tsim- 220.8)/23.39).^2) -0.6953*exp(-((tsim- 182.4 )/396.7).^2) + 0.2898*exp(-((tsim- 158.8)/33.83).^2) -0.1958*exp(-((tsim- 183.8)/ 0.3628).^2)))+ x(2)*0.688*(55.89*exp(-((tsim- 2.915)/7.182).^2) + 65.16*exp(-((tsim- 378.4)/224.1).^2) + 4.952 *exp(-((tsim-41.41)/9.817).^2) + 8.203*exp(-((tsim-228.6)/ 48.32).^2) + 6.925*exp(-((tsim- 166.4)/54.56).^2) + 2.585*exp(-((tsim-274.2 )/ 28.11).^2) +53.45*exp(-((tsim-50.93)/ 146.7).^2) + 1.155*exp(-((tsim-302)/16.94).^2)-0.29*(30.65*exp(-((tsim-1.463)/1.283).^2) -3.707*exp(-((tsim-12.16)/9.039).^2) + 158.4*exp(-((tsim-9.824e+004)/ 5.722e+004).^2) + 0.09067*exp(-((tsim- 156.9 )/ 0.2263 ).^2)+ 0.1171*exp(-((tsim- 220.8)/23.39).^2) -0.6953*exp(-((tsim- 182.4 )/396.7).^2) + 0.2898*exp(-((tsim- 158.8)/33.83).^2) -0.1958*exp(-((tsim- 183.8)/ 0.3628).^2))).^2+ 0.87*( 30.65*exp(-((tsim-1.463)/1.283).^2) -3.707*exp(-((tsim-12.16)/9.039).^2) + 158.4*exp(-((tsim-9.824e+004)/ 5.722e+004).^2) + 0.09067*exp(-((tsim- 156.9 )/ 0.2263 ).^2)+ 0.1171*exp(-((tsim- 220.8)/23.39).^2) -0.6953*exp(-((tsim- 182.4 )/396.7).^2) + 0.2898*exp(-((tsim- 158.8)/33.83).^2) -0.1958*exp(-((tsim- 183.8)/ 0.3628).^2)).^2 + x(2)*6156180.1101 +1732750.255 + 567.84 - x(1)*13270.8617*( 39.78*exp(-((tsim- 62.36)/ 51.23 ).^2) + 39.99*exp(-((tsim+13.07)/ 49.11).^2) + 6.574*exp(-((tsim-95.15)/ 7.534).^2) + 7.534*exp(-((tsim-131)/ 20.23).^2) + 3.91e+013*exp(-((tsim- 1.36e+005)/ 2.603e+004).^2) + 15.31*exp(-((tsim-162.5)/49.37).^2) + 11.18*exp(-((tsim- 11.18)/ 41.93).^2) + 5.944*exp(-((tsim- 275.8)/ 15.14 ).^2)-0.29*( 4.629e+004*cos(0.01037*tsim) -8.526e+004*sin(0.01037*tsim ) -6.644e+004*cos(2*0.01037*tsim) + 3426 *sin(2*0.01037*tsim) + 3290*cos(3*0.01037*tsim) + 4.341e+004*sin(3*0.01037*tsim) + 2.338e+004 *cos(4*0.01037*tsim) -2284*sin(4*0.01037*tsim) -1166*cos(5*0.01037*tsim) -1.008e+004*sin(5*0.01037*tsim) -3297 *cos(6*0.01037*tsim) + 421.1*sin(6*0.01037*tsim) + 96.45 *cos(7*0.01037*tsim) + 738.4*sin(7*0.01037*tsim) +6.41*cos(8*0.01037*tsim) -10.68*sin(8*0.01037*tsim)))+ x(2)*0.688*(( 39.78*exp(-((tsim- 62.36)/ 51.23 ).^2) + 39.99*exp(-((tsim+13.07)/ 49.11).^2) + 6.574*exp(-((tsim-95.15)/ 7.534).^2) + 7.534*exp(-((tsim-131)/ 20.23).^2) + 3.91e+013*exp(-((tsim- 1.36e+005)/ 2.603e+004).^2) + 15.31*exp(-((tsim-162.5)/49.37).^2) + 11.18*exp(-((tsim- 11.18)/ 41.93).^2) + 5.944*exp(-((tsim- 275.8)/ 15.14 ).^2)-0.29*( 4.629e+004*cos(0.01037*tsim) -8.526e+004*sin(0.01037*tsim ) -6.644e+004*cos(2*0.01037*tsim) + 3426 *sin(2*0.01037*tsim) + 3290*cos(3*0.01037*tsim) + 4.341e+004*sin(3*0.01037*tsim) + 2.338e+004 *cos(4*0.01037*tsim) -2284*sin(4*0.01037*tsim) -1166*cos(5*0.01037*tsim) -1.008e+004*sin(5*0.01037*tsim) -3297 *cos(6*0.01037*tsim) + 421.1*sin(6*0.01037*tsim) + 96.45 *cos(7*0.01037*tsim) + 738.4*sin(7*0.01037*tsim) +6.41*cos(8*0.01037*tsim) -10.68*sin(8*0.01037*tsim)))).^2+ 0.87*( 4.629e+004*cos(0.01037*tsim) -8.526e+004*sin(0.01037*tsim ) -6.644e+004*cos(2*0.01037*tsim) + 3426 *sin(2*0.01037*tsim) + 3290*cos(3*0.01037*tsim) + 4.341e+004*sin(3*0.01037*tsim) + 2.338e+004 *cos(4*0.01037*tsim) -2284*sin(4*0.01037*tsim) -1166*cos(5*0.01037*tsim) -1.008e+004*sin(5*0.01037*tsim) -3297 *cos(6*0.01037*tsim) + 421.1*sin(6*0.01037*tsim) + 96.45 *cos(7*0.01037*tsim) + 738.4*sin(7*0.01037*tsim) +6.41*cos(8*0.01037*tsim) -10.68*sin(8*0.01037*tsim)).^2)));
end
Alexandra Harkai
on 2 Nov 2016
Why should the optimum be at a different Xop(2) value? (Didn't decode the long function but it seems to be the an absolute value of a polynomial, so there could be bits where even though the range is wider, it will not move away from the local optimum.)
Can you plot the ident1 function for a range of [x y] values where x is fixed?
When the upper bound is 0.5, then the lower bound can't be 1, are you changing the problem config?
Alexandra Harkai
on 2 Nov 2016
Edited: Alexandra Harkai
on 2 Nov 2016
In addition to plotting parts of the [x y] surface, the 'iter-detailed' display carries lots of info why the second coordinate doesn't change. Using these optimalisation options it shows where the function argument moves during the iterations. With the 'PlotFcn' defined this would also be displayed:
opts = optimoptions(@fmincon, 'Display','iter-detailed', 'PlotFcn', @optimplotx); % this has to be defined first
Xop = fmincon(@ident1,[0.1;0.1],[],[],[],[],[1 1],[50 5], opts); % then calling the optimisation using those options
Anoire BEN JDIDIA
on 2 Nov 2016
not work. error msg: ??? Undefined function or method 'optimoptions' for input arguments of type 'function_handle'.
Error in ==> simultest2 at 18 opts = optimoptions('Display','iter-detailed', 'PlotFcn', @optimplotx); % this has to be defined first
Alexandra Harkai
on 2 Nov 2016
My bad, wrong syntax. Corrected the code now.
Anoire BEN JDIDIA
on 2 Nov 2016
problem.options = optimset('Display','iter','Algorithm','sqp','PlotFcn',@optimplotx); xop=fmincon(@ident1,[0.1;0.1],[],[],[],[],[1 1],[100 100],[],problem.options); its work but i have bad result. xop =
2.6147
1.0000
if lwer value of X(2)=2 we will have xop(2)=2
Alexandra Harkai
on 2 Nov 2016
Edited: Alexandra Harkai
on 2 Nov 2016
What does the iterative display tell you? What reason does it give for finishing the optimisation? You can try to find the exit flag:
[xop, ~, exitflag] = fmincon(...)
How do these compare to when you use a different lower/upper boundary?
These give information for you about why the algorithm stopped and help to think about how you might want to change your optimisation according to What Can Be Wrong If The Solver Succeeds?
Anoire BEN JDIDIA
on 2 Nov 2016
if i try : problem.options = optimset('Display','iter-detailed','Algorithm','SQP','PlotFcn',@optimplotx);
[xop, ~, exitflag] = fmincon(@ident1,[3;3],[],[],[],[],[1 2.5],[100 100],[],problem.options); i found xop =
3.1273
2.5000
Alexandra Harkai
on 2 Nov 2016
I don't know all the parameters you are using for your optimisation, but regardless, the best advice I can give is to look at all the previous questions above and try to find out how your optimisation behaves. Check the iteration process, not just the final result. Check the linked MATLAB Documentation here too.
Answers (0)
See Also
Categories
Find more on Optimization in Help Center and File Exchange
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
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)