Borrar filtros
Borrar filtros

simulation stopped because of step size tolerance and constraints

2 visualizaciones (últimos 30 días)
Azar Musayev
Azar Musayev el 11 de Mayo de 2022
Comentada: Rena Berman el 23 de Ag. de 2022
My simulation stopped because of step size tolerance and constraints.
I get this message: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.
<stopping criteria details>
gains: 20.000000 30.000000 50.000000 20.000000 30.000000 50.000000
settled: 141.900000 (sec)
IT IS MY SCRIPT
clear; matlabrc; clc; close all;
addpath(genpath('controllers'))
addpath(genpath('dynamics'))
addpath(genpath('tools'))
% Initial Control gains:
k_ria = 20; %(inter-agent position)
k_via = 30; %(inter-agent velocities)
k_rvl = 50; %(virtual-leader position)
k_vvl = 20; %(virtual-leader velocity)
k_obs = 30; %(obstacle position)
obs_dist = 50;
gains = [k_ria,k_via,k_rvl,k_vvl,k_obs,obs_dist]';
% simulate_dev(gains,1,1);
% Optimize:
options = optimoptions('fmincon','FiniteDifferenceStepSize',[1e-2 1e-1 1e-1 1e-1 1e-2 1e-2]);
% A = [4 0 0 0 30/31.5];
% b = 0;
A =[];
b = [];
Aeq = [];
beq = [];
lb = [0 0 0 0 0 20];
baseline = 1;
FOV = 50;
resH = 500;
ub = [100 100 100 100 100 (baseline/2)/tand(((FOV/2)/(resH/2))/2)];
ts_history = [];
min_dist = [];
save OUT ts_history min_dist
[optimized_gains,~,~,output] = fmincon(@simulate, gains, A,b,Aeq,beq,lb,ub,[], options);
%% Plot
load OUT
figure()
plot(min_dist,'*r')
plot(ts_history,'LineWidth',2)
grid on
xlabel('Iteration')
ylabel('Setting Time (sec)')
title('Convergence History')
% saveas(gcf,'../Report/figs/converge','png')
%% Plot:
% Generate plots of animation:
[ts1, total_error1] = simulate_dev(gains,1,0);
% saveas(gcf,'../Report/figs/trajectory_original','png')
close all
[ts2, total_error2] = simulate_dev(optimized_gains,1,0);
% saveas(gcf,'../Report/figs/trajectory_optimized','png')
close all
% Gains from the GA:
ga_gains = [91.9202,1.5019,82.4238,14.4036,34.2422,409.6430];
[ts3, total_error3] = simulate_dev(ga_gains,1,0);
%%
figure()
plot(linspace(0,ts1,numel(total_error1)),total_error1,'LineWidth',2); hold on
plot(linspace(0,ts2,numel(total_error2)),total_error2,'LineWidth',2)
plot(linspace(0,ts3,numel(total_error3)),total_error3,'LineWidth',2)
grid on
ylabel('Total Error Metric')
xlabel('Time (sec)')
title('Error History')
legend('Origina','Inter-Point','Genetic')
% saveas(gcf,'../Report/figs/error','png')
  4 comentarios
Rik
Rik el 9 de Jun. de 2022
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.

Iniciar sesión para comentar.

Respuestas (2)

John D'Errico
John D'Errico el 12 de Mayo de 2022
Editada: John D'Errico el 12 de Mayo de 2022
Let me see. You posed an optimization problem. The solver returned a result, one that SATISFIES the tolerances you posed. You were told that fact. Is there a problem?
"Stopped", "Terminated" and "Done" happen to be synonyms. As far as the solver is concerned, it is done. If the solver gave this message:
"Solver is done with the task assigned, now happy as a clam at high tide. All seems good in the world."
Would you have been happier? :)
  1 comentario
Rik
Rik el 9 de Jun. de 2022
Deleted comment:
Hello. Thanks for your explanation. As I understood the simulation is done succesfully. I would be happy If It print graphs about velocity, acceleration, distance.... for drones after simulation. How can you help me?

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 12 de Mayo de 2022
There are two distinct classes of optimizers.
  • there are optimizers such as quadrog() where the problem to be solved is represented as data, such as there being a multiplication of a constant matrix by the unknown. In such cases, the number of sub-regions to search may be finite and it may be possible to prove that the best solution has been found.
  • otherwise, the problem might have been represented as a function call to code that is not structured in any particular way, and may have internal conditions. In such cases, the optimizer can never be certain that it has found the best solution. The code might, for example, test if an input is exactly 59.17869777625.
fmincon (and all of the optimizers that expect function handles) cannot be sure they have found the global minimum... they didn't happen to test exactly 59.17869777625 for example.
Because there is a possibility that there might be better solutions, they never terminate with a message saying that the global minimum was found. Instead the best case is to find a location that looks quite good, such as gradient close to zero, and to fine tune... and then to stop and say "This might be it!" and report back the exact criteria for deciding that it has done as good a job as you configured for. Such as if it has already tuned the positions down to one part in 10^13 and you did not tell it that you needed even finer resolution.
The message you got was the best possible outcome for your search: it found a spot that looks great. But it can't be absolutely positive that there is no better solution, so it does not say "Global minimum found"
  1 comentario
Rik
Rik el 9 de Jun. de 2022
Deleted comment:
Hello. Thanks for your explanation. As I understood the simulation is done succesfully and as you said it looks good in the end of simulation. I would be happy If It print graphs about velocity, acceleration, distance.... for drones after simulation. How can you help me?

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by