Reusing ConstraintDerivative from AD in fmincon
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have a problem of the form:
opts = optimoptions('fmincon','Algorithm','sqp','Display','iter');
X = optimvar("X",size(lb),LowerBound=lb,UpperBound=ub);
prob = optimproblem('Objective',costFunction(X),'Constraints',constraints(X,constantPassthrough,variablePassthrough))
The costFunction() has a quadratic response to the control X, but the constraints() function is non-linear and non-convex and is fed constant passthrough arguments (which are constant within a given run) and variable passthrough arguments (which are iterated through within the run). The constraints function nominally consists of four OptimizationContraints and 1 OptimizationInequality.
The solutions for X are sought for N different conditions defined by variablePassthrough(i).
for i = 1:N
prob = optimproblem('Objective',costFunction(X),'Constraints',constraints(X,constantPassthrough,variablePassthrough(i)));
sol = solve(prob,x0,'Options',opts,'solver','fmincon','ObjectiveDerivative','auto','ConstraintDerivative','auto');
Xs(i,:) = sol.X;
end
Currently, the primary issue is that each time the solve() function is called, I believe that the AD is being used to redetermine the ConstraintDerivative. My understanding is that determining the ConstraintDerivative functions are the largest contributor to the computational cost each tme solve() is run.
Is there any way to have the ConstraintDerivative calculated the first time (i.e. i =1), and then reused for subsequent runs of (i = 2:N)?
댓글 수: 0
답변 (1개)
Ayush Aniket
2023년 8월 25일
No, there is no way to reuse the ConstraintDerivative as the ‘solve’ function computes it internally and there is no output for it.
A workaround that might help is to pass the gradient information separately for each optimization iteration. The following documentation page discusses that way:
Hope it helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!