matlab标准化出现负值,为什么我求出来的约束条件是负值
本帖最后由 renwoxinfen 于 2016-11-8 09:01 編輯
程序如下:
a.m
% 設(shè)計(jì)變量(螺桿平均直徑D和長度L)的初始值
x0=[30;5000];
% 設(shè)計(jì)變量(螺桿平均直徑D長度L)的下界與上界
Lb=[30;5000];
Ub=[200;6000];
% 調(diào)用多維約束優(yōu)化函數(shù)
% 線性不等式約束放入約束函數(shù)文件,參數(shù)A,b定義為空矩陣
% 沒有線性等式約束,參數(shù)Aeq,beq定義為空矩陣
options=optimset('largescale','off','display','iter');
% 'largescale','off'關(guān)閉了大規(guī)模方式;
% 'display'用來控制計(jì)算過程的顯示;
% 'iter'表示顯示優(yōu)化過程的每次計(jì)算結(jié)果。
[x,fn,exitflag,output]=fmincon(@lgyh_f,x0,[],[],[],[],Lb,Ub,@lgyh_g,options);
% 返回值exitflag:>0表示計(jì)算收斂,=0表示超過了最大的迭代次數(shù),<0表示計(jì)算不收斂;
% 返回值output有3個(gè)分量,其中:
% iterations是優(yōu)化過程中迭代次數(shù),funcCount是代入函數(shù)值的次數(shù),algorithm是優(yōu)化所采用的算法
disp '? ?? ?? ?********??螺桿的優(yōu)化設(shè)計(jì)最優(yōu)解??********'
fprintf('? ?? ?? ?? ???螺桿的平均直徑? ?? ?? ? D = %3.4f mm \n',x(1))
fprintf('? ?? ?? ?? ?? ?? ?螺桿的長度? ?? ?? ? H = %3.4f mm \n',x(2))
fprintf('? ?? ?? ?? ?? ?? ?螺桿的體積? ?? ?? ? V = %3.4f mm^3 \n',fn)
% 調(diào)用多維約束優(yōu)化非線性約束函數(shù)(jsqyh_g)計(jì)算最優(yōu)點(diǎn)x*的性能約束函數(shù)值
g=lgyh_g(x);
disp '? ?? ?? ???========? ? 最優(yōu)點(diǎn)的性能約束函數(shù)值? ? ========'
fprintf('? ?? ?? ?? ?? ? 螺桿的壓縮強(qiáng)度? ?? ???g1 = %3.4f MPa \n',g(1))
fprintf('? ?? ?? ?? ?? ? 螺桿的穩(wěn)定性? ?? ?? ? g2 = %3.4f N \n',g(2))
% 2-目標(biāo)函數(shù)(lgyh_f)
function f=lgyh_f(x)
% 螺桿的厚度T;
T=17;
f=pi*(x(1)+T)*T*x(2);
% 3-約束函數(shù)(lgyh_g)
function [g,ceq]=lgyh_g(x)
% 螺桿的作用力Q;螺桿厚度T;載荷P;彈性模量E;許用壓應(yīng)力Cy;
Q=50000;T=17;E=2.06e5;sigma_y=690;
% 螺桿壓縮強(qiáng)度條件
sigma=Q/(pi*x(1)*T);? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ? % 鋼管壓應(yīng)力
g(1)=sigma-sigma_y;
% 螺桿穩(wěn)定性條件
sigma_c=pi^2*E*(x(1)^2+T^2)/(8*5*0.49*x(2)^2);? ?% 穩(wěn)定臨界應(yīng)力
g(2)=sigma-sigma_c;
% 螺桿平均直徑邊界條件
g(3)=30-x(1);
g(4)=x(1)-200;
% 螺桿長度邊界條件
g(5)=5000-x(2);
g(6)=x(2)-6000;
% 沒有非線性等式約束
ceq=[];
運(yùn)算結(jié)果:
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.
First-order? ?? ?Norm of
Iter F-count? ?? ?? ?? ?f(x)??Feasibility? ?optimality? ?? ?? ?step
0? ?? ? 3? ? 1.281757e+07? ? 2.503e+01? ? 1.727e+03
1? ?? ? 6? ? 1.628459e+07? ? 1.206e+01? ? 8.307e+04? ? 1.303e+01
2? ?? ? 9? ? 1.760328e+07? ? 8.008e+00? ? 1.443e+04? ? 4.938e+00
3? ?? ?12? ? 1.984732e+07? ? 1.498e+00? ? 6.160e+03? ? 8.404e+00
4? ?? ?15? ? 2.037307e+07? ? 2.541e-03? ? 2.281e+03? ? 1.969e+00
5? ?? ?18? ? 2.037397e+07? ? 2.046e-10? ? 5.602e+00? ? 3.351e-03
6? ?? ?21? ? 2.037397e+07? ? 0.000e+00? ? 1.408e-03? ? 6.474e-08
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
********??螺桿的優(yōu)化設(shè)計(jì)最優(yōu)解??********
螺桿的平均直徑? ?? ?? ? D = 59.2969 mm
螺桿的長度? ?? ?? ? H = 5000.0000 mm
螺桿的體積? ?? ?? ? V = 20373967.6274 mm^3
========? ? 最優(yōu)點(diǎn)的性能約束函數(shù)值? ? ========
螺桿的壓縮強(qiáng)度? ?? ???g1 = -674.2116 MPa
螺桿的穩(wěn)定性? ?? ?? ? g2 = -0.0000 N
為什么螺桿的壓縮強(qiáng)度寄穩(wěn)定性為負(fù)值?
總結(jié)
以上是生活随笔為你收集整理的matlab标准化出现负值,为什么我求出来的约束条件是负值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 渐开线曲线方程c语言,proe常用曲线方
- 下一篇: matlab_取整函数