Azzera filtri
Azzera filtri

Reusing ConstraintDerivative from AD in fmincon

2 visualizzazioni (ultimi 30 giorni)
Rory Gover
Rory Gover il 4 Lug 2023
Risposto: Ayush Aniket il 25 Ago 2023
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)?

Risposte (1)

Ayush Aniket
Ayush Aniket il 25 Ago 2023
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.

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by