[討論] 關於fmincon限制式的問題(有附檔案連結)

看板MATLAB作者 (小叮噹)時間12年前 (2013/04/11 18:54), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
各位前輩大家好 我想請問一下關於fmincon的限制式寫法我有一些疑惑 我先說目前的問題是:我最佳化疊代的結果沒有依照我給的範圍去解 答案會超出限制式範圍 先附上檔案以方便前輩們幫忙 https://dl.dropbox.com/u/43545062/sample.rar 我的題目是這樣的 限制式: 0 < x < 2.875 0 < D < 0.05 D= 0.38 / ( -15.58+19.27 * X ) 目標: 求 min T T= sqrt(D^2) 程式的寫法 主程式 =================================== close all; clear; format long; options = optimset('Display','iter','Algorithm','active-set'); [xStr, f_xStr] = fmincon(@objfun,[0],[],[],[],[],[],[],@confun,options) =================================== 限制式副程式 =================================== function [c, ceq] = confun(x) Xmax= x -2.875; Xmin= -x -0; Dmax = 0.3764/(-15.5755+19.2672*x) -0.05 ; Dmin = -(0.3764/(-15.5755+19.2672*x)) -0 ; c = [ Xmax; Xmin; Dmax; Dmin;]; ceq = [ ]; =================================== 目標副程式 =================================== function f = objfun(x) D = 0.3764/(-15.5755+19.2672*x); T=sqrt(D^2); f=T; =================================== 希望可以請各位高手幫忙解決這個問題 謝謝大家 -- ▃▃▃▃▃▃▃▃▃▃▃▃▃▃ ▃▅▆▅▃ ▃▃▃▃▃▃▃▃▃▃▃▃▃ ▂▁ ▁ ◢█◥◤ ▄▂ ▄▂ ●● ▆▅▄▅◣ ◢█▋ ▌ ◥ ▌ ◥_▂▁▂◢ █◤ ●/\● ▌ ▕◢▅◢▆▅▄▅ˍ ╲ˍ'˙ ˍ╱ ˍ _ _ ◣ ▁▂ ˍ  ̄ ◥◤  ̄ ˍ ◥◣ _◣ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.135.13.60
文章代碼(AID): #1HPfPTM8 (MATLAB)
文章代碼(AID): #1HPfPTM8 (MATLAB)