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)?

回答(1 个)

Ayush Aniket
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.

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by