SystemAnalysisDpt-CMC-MSU / ellipsoids

Ellipsoidal Toolbox for MATLAB is a standalone set of easy-to-use configurable MATLAB routines and classes to perform operations with ellipsoids and hyperplanes of arbitrary dimensions
http://systemanalysisdpt-cmc-msu.github.io/ellipsoids
Other
20 stars 7 forks source link

Regularization error in ReachContinuous #45

Open yzh89 opened 8 years ago

yzh89 commented 8 years ago

I have been trying reachablility set computation for some aircraft dynamics. I kept on getting strange errors in the regularization process. The code is attached test.txt

The errors when runing "rsObj_A = elltool.reach.ReachContinuous(lsys, x0EllObj, dirsMat, timeVec, 'isRegEnabled', true, 'isJustCheck', false, 'regTol', 1e-7);" are the following.

" Error using modgen.common.checkvar (line 69) matrix must be symmetric.

Error in gras.la.regposdefmat (line 20) modgen.common.checkvar(inpMat, 'gras.la.ismatsymm(x)',...

Error in gras.mat.MatrixPosReg>@(x)gras.la.regposdefmat(x,self.regTol) (line 28) @(x) gras.la.regposdefmat(x, self.regTol), resArray,...

Error in gras.gen.MatVector.evalMFunc (line 68) resArray(:,:,iElem)=fHandle(dataArray(:,:,iElem));

Error in gras.mat.MatrixPosReg/evaluate (line 27) resArray = gras.gen.SquareMatVector.evalMFunc(...

Error in gras.ellapx.lreachplain.ExtEllApxBuilder/calcEllApxMatrixDeriv (line 12) BPBTransMat=BPBTransDynamics.evaluate(t);

Error in gras.ellapx.lreachplain.ExtEllApxBuilder/getEllApxMatrixDerivFunc/@(t,y)calcEllApxMatrixDeriv(self,self.getProblemDef().getAtDynamics,self.getProblemDef.getBPBTransDynamics,self.getGoodDirSet.getRGoodDirOneCurveSpline(iGoodDir),t,y)

Error in gras.ode.MatrixODESolver>@(t,y)(reshape(fDerivFunc(t,reshape(y,reshapeSizeVec)),[],1)) (line 30) fMatrixDerivFunc=@(t, y)(reshape(fDerivFunc(t, ...

Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in gras.ode.MatrixODESolver/solve (line 32) [timeVec, xResMat] = ...

Error in gras.ellapx.lreachplain.ATightEllApxBuilder/build (line 54) [~,data_Q_star]=solverObj.solve(fHandle,...

Error in gras.ellapx.lreachplain.ATightEllApxBuilder/getEllTubes (line 110) self.build();

Error in gras.ellapx.gen.EllApxCollectionBuilder/getEllTubes (line 43) ellTubeTempRel=self.builderList{iBuilder}.getEllTubes();

Error in elltool.reach.ReachContinuous/auxMakeEllTubeRel (line 136) extEllTubeRel = extellTubeBuilder.getEllTubes();

Error in elltool.reach.ReachContinuous/internalMakeEllTubeRel (line 168) [ellTubeRel,goodDirSetObj] = self.auxMakeEllTubeRel(...

Error in elltool.reach.AReach/makeEllTubeRel (line 657) [ellTubeRel, goodDirSetObj] = self.internalMakeEllTubeRel(...

Error in elltool.reach.AReach (line 767) [self.ellTubeRel,goodDirSetObj,probDynObj] =...

Error in elltool.reach.ReachContinuous (line 298) self=self@elltool.reach.AReach(varargin{:});

Software Version: ET Version 2.1 CVX and MPT is the ones included in the toolbox MATLAB Version: 8.5.0.197613 (R2015a) Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1) Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode MATLAB Version 8.5 (R2015a) Simulink Version 8.5 (R2015a) Bioinformatics Toolbox Version 4.5.1 (R2015a) Communications System Toolbox Version 6.0 (R2015a) Computer Vision System Toolbox Version 6.2 (R2015a) Control System Toolbox Version 9.9 (R2015a) Curve Fitting Toolbox Version 3.5.1 (R2015a) DSP System Toolbox Version 9.0 (R2015a) Data Acquisition Toolbox Version 3.7 (R2015a) Database Toolbox Version 5.2.1 (R2015a) Datafeed Toolbox Version 5.1 (R2015a) Fixed-Point Designer Version 5.0 (R2015a) Fuzzy Logic Toolbox Version 2.2.21 (R2015a) Global Optimization Toolbox Version 3.3.1 (R2015a) Image Acquisition Toolbox Version 4.9 (R2015a) Image Processing Toolbox Version 9.2 (R2015a) Instrument Control Toolbox Version 3.7 (R2015a) MATLAB Coder Version 2.8 (R2015a) MATLAB Compiler Version 6.0 (R2015a) MATLAB Compiler SDK Version 6.0 (R2015a) MATLAB Report Generator Version 4.1 (R2015a) Mapping Toolbox Version 4.1 (R2015a) Model Predictive Control Toolbox Version 5.0.1 (R2015a) Multi-Parametric Toolbox Version 3.1 (R2011a) Neural Network Toolbox Version 8.3 (R2015a) OPC Toolbox Version 3.3.3 (R2015a) Optimization Toolbox Version 7.2 (R2015a) Parallel Computing Toolbox Version 6.6 (R2015a) Partial Differential Equation Toolbox Version 2.0 (R2015a) Robust Control Toolbox Version 5.3 (R2015a) Signal Processing Toolbox Version 7.0 (R2015a) SimEvents Version 4.4 (R2015a) SimMechanics Version 4.6 (R2015a) Simscape Version 3.13 (R2015a) Simulink 3D Animation Version 7.3 (R2015a) Simulink Coder Version 8.8 (R2015a) Simulink Control Design Version 4.2 (R2015a) Simulink Design Optimization Version 2.7 (R2015a) Spreadsheet Link EX Version 3.2.3 (R2015a) Stateflow Version 8.5 (R2015a) Statistics and Machine Learning Toolbox Version 10.0 (R2015a) Symbolic Math Toolbox Version 6.2 (R2015a) System Identification Toolbox Version 9.2 (R2015a) Wavelet Toolbox Version 4.14.1 (R2015a)

yzh89 commented 8 years ago

Looks like commit 55b4c1e is already good to test my setup. Thanks for fixing it so fast.

Happy Holidays, Yuchen

yzh89 commented 8 years ago

Looks like still having issue on the precision. I used the latest commit on master to test. The problem itself is modified according to a154e3b

Error is following.

check [any touch line is always within any external approx] has failed for xTouchCurveMat, expected precision=2.000000e-05, actual precision=3.013283e-05

pgagarinov commented 8 years ago

This might be caused by using a different CPU. This happened before when some tests pass on older CPUs and fail on newer CPUs because of different CPU instructions being used. On my is Core i7 5820k the attached example (test zip) works. test.zip

However even on my CPU the same example integrated into the test coverage fails in the branch i.e.

gras.ellapx.uncertcalc.test.regr.run_comptests('filter',{'yuchenZhouProb1','.','._'})

produced the same error as you reported. I plan to figure out why this happens and fix this within a few next weeks when I have time.

Meanwhile I suggest you use a simple workaround by replacing throwerror with throwwarn on line 445 (it might be different in your case but this is the one that throws the reported exception). And do not forget to replace import modgen.common.throwerror; with import modgen.common.throwwarn; It is probably a good idea to run the solver in a relaxed self-checking mode when only warnings are thrown and a user becomes responsible for the quality of calculation results. Anyway, just keep an eye on what throwwarn prints out to make sure that the precision is within an acceptable range every time you run the solver because those checks are there for a reason. Based on what I see 3.013283e-05 is good enough but the solver is very conservative which is a good idea for a production use I believe.

And of course you can participate in improving the solver or finding the bugs by figuring our why gras.ellapx.uncertcalc.test.regr.run_comptests('filter',{'yuchenZhouProb1','.','._'}) fails on your own if you do not want to wait for my fix and replacing exceptions with warnings doesn't work for you for some reason.

pgagarinov commented 8 years ago

Were you able to calculate the dynamics by replacing throwerror with throwwarn?

Also, can you please, if possible, provide more details about the problem that leads to this specific linear control system? Maybe you have some paper? Right now I can use any interesting example of real problem that can be solved with help of the toolbox, especially for enhancing a list of demo examples. Thanks.

yzh89 commented 8 years ago

Yes I am able to calculate the dynamics. There are still some precision issue so I am using another more stable dynamics instead. The linearization comes from http://uavbook.byu.edu/doku.php?id=lecture lecture 5. It includes a linearized model of the lateral motion of a fix-wing aircraft. The main issue is that the external approximation sometimes becomes way too far from the theoretically support function boundary derived from Prof. AB Kurzhanskiy's book.

For a good example of using the toolbox, you can refer to the paper I published in CDC 2015 using this toolbox. It is in the archive http://arxiv.org/abs/1512.01195. I was using a linearized quadrotor dynamics.

pgagarinov commented 8 years ago

So do you do your research at Cornell University? If - can you please tell me a name of the department just for the record. I hope I could compile a list of places where the toolbox is used to increase its popularity. Thanks a lot.