How to Put Objective and Constraints functions in the same function ?

7 ビュー (過去 30 日間)
youssef refaat
youssef refaat 2020 年 3 月 15 日
編集済み: Matt J 2020 年 3 月 16 日
Greetings All,
I am working on an optimization problem with non linear inequality constraints and i wish to put the objective and constraints functions in the same function;
the problem is that my objective function is not an algebriac expression it is rather an implicit value from Look up tables
i define my objective function as follows
function OBJ = Obj(X)
OBJ = X(11); % where x11 is a value from a generated LUT
end
and here is the non linear constraints function
function [C, CEQ] = NonLinCon(X, LUT1, LUT2, IP)
% vectorized design variables
DOF.M(1).N = X(:,1);
DOF.M(2).N = X(:,2);
DOF.M(3).N = X(:,3);
DOF.M(4).N = X(:,4);
DOF.M(5).N = X(:,5);
DOF.M(1).S = X(:,6);
DOF.M(2).S = X(:,7);
DOF.M(3).S = X(:,8);
DOF.M(4).S = X(:,9);
DOF.M(5).S = X(:,10);
DOF.R = IP.R;
DOF.VDS_MARGIN = IP.VDS_MARGIN;
DOF.IB = X(:,11).*1e-3;
DOF.VDD = IP.VDD;
DOF.CL = IP.CL;
DOF.VICM = IP.VICM;
DOF.VOCM = IP.VOCM;
DOF.M(6).N = DOF.M(5).N;
DOF.M(6).S = DOF.M(5).S;
[~, OP] = mainfnc(LUT1,LUT2,DOF);
% Nonlinear Inequality Constraints
C(:,1) = IP.UGF ./ double(OP.UGF) - 1;
C(:,2) = IP.PM ./ double(OP.PM) - 1;
C(:,3) = log10(IP.AVDC) ./ log10(double(OP.AVDC)) - 1;
C(:,4) = IP.FO ./ double(OP.FO) - 1;
C(:,5) = IP.FP1 ./ double(OP.FP1) - 1;
c(:,6) = IP.VO_SWING ./ double(OP.VO_SWING) - 1;
CEQ = [];
end
i cant seem to follow the example provided in the documentation (solver based approach)
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 3 月 15 日
Please post your objective function and constraints here. Only then can we have some idea what the issue is here.
youssef refaat
youssef refaat 2020 年 3 月 15 日
done; i've edited the thread.

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2020 年 3 月 15 日
編集済み: Matt J 2020 年 3 月 15 日
I am working on an optimization problem with non linear inequality constraints and i wish to put the objective and constraints functions in the same function;
See this link,
the problem is that my objective function is not an algebriac expression it is rather an implicit value from Look up tables
It is very important that you do not use nearest-neighbor or linear interpolation to perform the table lookup. You must use a twice differentiable interpolatior, like 'cubic' or 'pchip'. Otherwise, your function and gradient evaluations will be rife with discontinuities, which fmincon cannot handle
  2 件のコメント
youssef refaat
youssef refaat 2020 年 3 月 16 日
編集済み: youssef refaat 2020 年 3 月 16 日
i've read the documentation example ; but i dont understand how to apply it in my case; how will i write the computeall function ? do i just give it my function handle @Obj
and then creating the nested function by giving it the same function handle ?
what will the value of y (in nested function objectiveconstr( then be in this case ?
Matt J
Matt J 2020 年 3 月 16 日
編集済み: Matt J 2020 年 3 月 16 日
how will i write the computeall function
The computeall function should be written to calculate any variables you want shared between your objective and constraints. Those variables should also be initialized in the workspace of runobjconstr similar to what is done in these lines
xLast = []; % Last place computeall was called
myf = []; % Use for objective at xLast
myc = []; % Use for nonlinear inequality constraint
myceq = []; % Use for nonlinear equality constraint
what will the value of y (in nested function objectiveconstr( then be in this case ?
y is the result of evaluating the objective function. The lines that compute it can use the shared variables generated by computeall(). In the example, these are [myf,myc,myceq], but they can be any shared quantities that you wish.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by