TUMcps / CORA

Toolbox for Reachability Analysis
GNU General Public License v3.0
100 stars 32 forks source link

Nonlinear system adaptive-linreach tuning error #43

Closed akaph2p closed 10 months ago

akaph2p commented 10 months ago

I received an error stating 'Tuning error...report to devs' when i ran my code.

% Parameters --------------------------------------------------------------

params.tFinal = 400;
params.R0 = zonotope([[0; 0.0124; 650], diag([0.001,0.001,1])]);
params.U = zonotope([0.66]);

% Reachability Settings ---------------------------------------------------

options.timeStep = 1;
options.taylorTerms = 4;
options.zonotopeOrder = 50;
options.alg = 'lin-adaptive';
options.tensorOrder = 2;

options.lagrangeRem.simplify = 'simplify';

% System Dynamics ---------------------------------------------------------

reactor = nonlinearSys(@pke);

% Reachability Analysis ---------------------------------------------------

tic
R = reach(reactor, params, options);
tComp = toc;
disp(['computation time of reachable set: ',num2str(tComp)]);

% Simulation --------------------------------------------------------------
tic
simOpt.points = 10;
simRes = simulateRandom(reactor, params, simOpt);
tComp = toc;
disp(['computation time of simulation: ',num2str(tComp)]);

%% Visualization -----------------------------------------------------------
tic

figure(1)
hold on; box on;
% plot reachable sets
useCORAcolors("CORA:contDynamics")
plotOverTime(R,1,'DisplayName','Reachable set');
% plot initial set
plotOverTime(R.R0,1, 'DisplayName','Initial set');
% plot simulation results      
plotOverTime(simRes,1,'DisplayName','Simulations');
sgtitle('n vs time')

toc

Error message:

Error using nonlinearSys/linReach_adaptive (line 76)
Tuning error.. report to devs

Error in nonlinearSys/reach_adaptive (line 85)
        [Rnext.ti,Rnext.tp,options] = linReach_adaptive(obj,options,options.R);

Error in contDynamics/reach (line 68)
        [timeInt,timePoint,res,~,options] = reach_adaptive(obj,params,options);

Error in reactor_nl (line 31)
R = reach(reactor, params, options);
wetzlingerm commented 10 months ago

Thank you for reporting this issue. You encountered a bug in the automated tuning that rarely occurs. Since we currently don't have any system where this happens, please post your dynamics file pke.m here or send it to us via email (see here) so that we can investigate and fix what's going on.

akaph2p commented 10 months ago

Hi, here's the pke.m file.

function dx = pke(x,u)
% Inputs:
%    x - [n, C1, Trx]
%    u - [rhoc, 0, 0]
%
% Outputs:
%    dx - [n',  C1', Trx']

% Parameters
alpha = 0.001;  
T0 = 0;    
BETA = 0.01;   
l = 1;      
lambda1 = 1;
beta1 = 0.0248; 
Tc = 650;   
P0 = 250;

mdotp = 5;  
m = 1;       
Cp = 1;    
q0 = 0;

% Control
rhoc = u(1);
n = x(1);
C1 = x(2);
Trx = x(3);

% differential equations
dx(1,1) = n*(rhoc - alpha*Trx - alpha*T0 - BETA)/l + lambda1*C1 + q0;
dx(2,1) = beta1*n/l - lambda1*C1;
dx(3,1) = -2*mdotp*Trx/m + 2*mdotp*Tc/m + P0*n/(m*Cp);
wetzlingerm commented 10 months ago

Thank you for your patience! We have meanwhile found a solution to this issue. Give us a couple more days to work out the details, the fix will be integrated into the next update (either tomorrow or next Monday).

wetzlingerm commented 10 months ago

Fixed in CORA v2024.0.2.