# Why Am I getting this warning about SNOPT derivative structure

7 visualizaciones (últimos 30 días)
Mudrik Ahmed el 4 de Sept. de 2021
Respondida: Anurag Ojha el 19 de Jun. de 2024
Warning: User is not providing SNOPT derivatives structures
> In snopt (line 334)
In lambert4_64bit (line 245)
Warning: Derivatives provided but not structures: estimating structure via snJac.
> In snopt (line 347)
In lambert4_64bit (line 245)
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Anurag Ojha el 19 de Jun. de 2024
Hi Mudrik
The warning message indicates that the SNOPT solver expects specific derivative structures for the objective function and constraints but did not receive them. Instead, SNOPT is estimating these structures via the snJac function.
In optimization, providing derivative (Jacobian and Hessian) information is crucial for solvers to efficiently and accurately find solutions. When using SNOPT in MATLAB, it is beneficial to provide these derivatives explicitly. The structure of these derivatives should match what SNOPT expects. If not provided, SNOPT will try to estimate them, which can lead to inefficiencies or inaccuracies.
To resolve this warning, you should provide the derivatives explicitly if possible. If your objective function and constraints are smooth and differentiable, you can manually calculate and provide these derivatives. If not, MATLAB will attempt to estimate them.
% Define the objective function and its gradient
% Example objective function: Rosenbrock's function
f = 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;
% Gradient of the objective function
200*(x(2)-x(1)^2)];
end
% Define the constraints and their gradients
% Example constraints: Inequality and Equality constraints
c = [x(1)^2 + x(2)^2 - 1]; % Inequality constraint (circle of radius 1)
ceq = [x(1) + x(2) - 1]; % Equality constraint (line x1 + x2 = 1)
% Gradient of the inequality constraint
% Gradient of the equality constraint
end
% Main script to solve the optimization problem
function main()
% Define the initial guess
x0 = [0.5; 0.5];
% Set optimization options
options = optimoptions('fmincon', ...
'Algorithm', 'sqp'); % 'sqp' uses SNOPT under the hood
% Solve the optimization problem
[x, fval, exitflag, output] = fmincon(@myObjective, x0, [], [], [], [], [], [], @myConstraints, options);
% Display the optimization results
disp(['Optimization exit flag: ' num2str(exitflag)]);
disp(['Optimized solution: ' num2str(x')]);
disp(['Objective function value: ' num2str(fval)]);
end
% Call the main function to execute the optimization
main();
Feasible point with lower objective function value found, but optimality criteria not satisfied. See output.bestfeasible.. Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. Optimization exit flag: 2 Optimized solution: 0.6188 0.3812 Objective function value: 0.14561
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Mathematics en Help Center y File Exchange.

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by