Fixing a value inside the objective function while using FMINCON
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am using 'fmincon' inside a script 'Script.m' optimizing the output of the function 'cost_simplified' based on the independent variable 'q' ( i have provided the code script). But while varying the values of 'q' I need to keep the value of a double which is dependent on 'q' i.e., 'X.pa' same as 'contact_points' which is a constant taken as input ( i.e. i need to satisfy 'X.pa==contact_points', and then proceed further inside the function 'cost_simplified').
How can i meet this constrain ('X.pa==contact_points') inside the objective function 'cost_simplified' ?
I have tried for 'if ~isequal(X.pa,contact_points) return end' . But using 'return' brings out the error "Output Argument "..." not assigned during call to "Script.m>cost_simplified". If i assign output argument to 'zero' , optimization algorithm 'fmincon' stops as the ouput 'zero' remains constant after every iteration.
nonlincon=@(q) graspcon(q,G,contact_points,Kc_new,X); %%% concept of extra parameters
[q{i},cost_val_new(i)]= fmincon (@(q) cost_simplified(w,yopt,q,G,contact_points,object.normals,mu,fmin,fmax,k,X,object),q0,A,b,Aeq,beq,lb,ub,nonlincon);
3 件のコメント
採用された回答
Matt J
2019 年 6 月 30 日
編集済み: Matt J
2019 年 6 月 30 日
You should not try to abort your objective function just because you know that the q fmincon is in the process of evaluating doesn't satisfy intended constraints. Preventing fmincon from completing its evaluation of q is denying it the very information it needs to search for a solution.
7 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Nonlinear Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!