How to Put Objective and Constraints functions in the same function ?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
2020년 3월 15일
Please post your objective function and constraints here. Only then can we have some idea what the issue is here.
답변 (1개)
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
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 Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!