├── Figures ├── desktop.ini ├── paper │ ├── cost 20pt.eps │ ├── cost.eps │ ├── cost_more_noise.eps │ ├── upred_uref.eps │ ├── upred_uref_more_noise.eps │ ├── y1y2.eps │ ├── y1y2_more_noise.eps │ ├── y1y2_overN.eps │ ├── y1y2y3.eps │ ├── y1y2y3_more_noise.eps │ ├── y2_not_robust.eps │ ├── y2_robust.eps │ ├── y2_robust_more_noise.eps │ ├── y3y4.eps │ ├── y3y4_more_noise.eps │ ├── y3y4_overN.eps │ ├── y3y4y5.eps │ ├── y3y4y5_more_noise.eps │ ├── y4y5.eps │ ├── y4y5_more_noise.eps │ ├── y4y5_overN.eps │ ├── ys_ypreds.eps │ ├── ys_ypreds_more_noise.eps │ ├── yt2red 20pt.eps │ ├── yt2red.eps │ └── yt2red_more_noise.eps └── reachmpc.png ├── NZPC.m ├── README.md ├── Robust_MPC_polytopes.m ├── ZPC.m ├── contDynamics ├── @contDynamics │ ├── checkOptionsSimulate.m │ ├── contDynamics.m │ ├── copyOptions.m │ ├── derivatives.m │ ├── dimension.m │ ├── display.m │ ├── linReach.m │ ├── private │ │ ├── abstrerr_lin.m │ │ ├── abstrerr_poly.m │ │ ├── create3rdOrderTensorFile.m │ │ ├── createHessianTensorFile.m │ │ ├── createHigherOrderTensorFiles.m │ │ ├── createJacobianFile.m │ │ ├── createJacobianFile_freeParam.m │ │ ├── createParametricDynamicFile.m │ │ ├── linError.m │ │ ├── linError_higherOrder.m │ │ ├── linError_mixed_noInt.m │ │ ├── linError_thirdOrder.m │ │ ├── precompStatError.m │ │ ├── reportReachError.m │ │ └── select.m │ ├── pruneDynamics.m │ ├── reach.m │ ├── simulateRRT.m │ ├── simulateRandom.m │ └── symVariables.m ├── @linParamSys │ ├── LinParamWrapper_initReach.m │ ├── checkOptionsReach.m │ ├── coreReach.m │ ├── display.m │ ├── errorSolution.m │ ├── getfcn.m │ ├── initReach.m │ ├── initReach_inputDependence.m │ ├── linParamSys.m │ ├── post.m │ ├── postReach.m │ ├── preReach.m │ ├── private │ │ ├── apprSquare.m │ │ ├── dependentHomSol.m │ │ ├── dependentInputSol.m │ │ ├── expMap.m │ │ ├── highOrderMappingMatrix.m │ │ ├── inputSolution.m │ │ ├── inputTie.m │ │ ├── mappingMatrix.m │ │ ├── nonlinMap.m │ │ └── tie.m │ └── simulate.m ├── @linProbSys │ ├── checkOptionsReach.m │ ├── display.m │ ├── getfcn.m │ ├── initReach.m │ ├── linProbSys.m │ ├── plot.m │ ├── post.m │ ├── private │ │ ├── exactTerms.m │ │ ├── infNorm.m │ │ ├── inputSolution.m │ │ ├── pexpm.m │ │ ├── sample.m │ │ └── tie.m │ ├── reachAlternative.m │ └── simulate.m ├── @linearSys │ ├── checkOptionsReach.m │ ├── coreReach.m │ ├── deltaReach.m │ ├── display.m │ ├── errorSolution.m │ ├── exponentialMatrices.m │ ├── getfcn.m │ ├── initReach.m │ ├── initReach_Euclidean.m │ ├── linError.m │ ├── linearSys.m │ ├── post.m │ ├── postReach.m │ ├── post_Euclidean.m │ ├── preReach.m │ ├── private │ │ ├── constInputSolution.m │ │ ├── exponential.m │ │ ├── exponential_Krylov.m │ │ ├── exponential_Krylov_precomputed.m │ │ ├── exponential_Krylov_projected.m │ │ ├── initOutputEquation.m │ │ ├── initReach_Decomp.m │ │ ├── initReach_Krylov.m │ │ ├── initReach_Krylov_nonProjected.m │ │ ├── inputInducedUpdates.m │ │ ├── inputSolution.m │ │ ├── inputSolution_Krylov.m │ │ ├── inputTie.m │ │ ├── outputSet.m │ │ ├── post_Krylov.m │ │ ├── post_Krylov_nonProjected.m │ │ ├── rA_initReach.m │ │ ├── rA_initTimeStepTaylorTerms.m │ │ ├── rA_inputTie.m │ │ ├── rA_post.m │ │ ├── rA_postTSTT_bloatings.m │ │ ├── rA_postTSTT_checkTimeStep.m │ │ ├── rA_postTSTT_savedSets.m │ │ ├── rA_postTimeStepTaylorTerms.m │ │ ├── rA_propInhom.m │ │ ├── reach_adaptive.m │ │ ├── reach_decomp.m │ │ ├── reach_fromStart.m │ │ ├── reach_krylov.m │ │ ├── reach_standard.m │ │ ├── reach_wrappingfree.m │ │ ├── subspace_Krylov.m │ │ ├── subspace_Krylov_individual.m │ │ ├── subspace_Krylov_individual_Wang.m │ │ └── tie.m │ ├── reach.m │ ├── reach_fromStart_tVec.m │ ├── simulate.m │ └── trajectoryError.m ├── @linearSysDT │ ├── checkOptionsObserve.m │ ├── checkOptionsReach.m │ ├── display.m │ ├── initOutputEquation.m │ ├── linearSysDT.m │ ├── observe.m │ ├── post.m │ ├── private │ │ ├── arnoldi.m │ │ ├── constInputSolution.m │ │ ├── determineKrylovOrder.m │ │ ├── exponential.m │ │ ├── exponential_Krylov.m │ │ ├── exponential_Krylov_precomputed.m │ │ ├── exponential_Krylov_projected.m │ │ ├── inputSolution.m │ │ ├── inputSolution_Krylov.m │ │ ├── inputTie.m │ │ ├── observe │ │ │ ├── SMA_SISO_Zonotope.m │ │ │ └── observe_setMembership.m │ │ ├── outputSet.m │ │ ├── subspace_Krylov.m │ │ ├── subspace_Krylov_individual.m │ │ ├── subspace_Krylov_individual_Wang.m │ │ └── tie.m │ ├── reach.m │ └── simulate.m ├── @nonlinDASys │ ├── checkOptionsReach.m │ ├── consistentInitialState.m │ ├── display.m │ ├── getfcn.m │ ├── initReach.m │ ├── linReach.m │ ├── nonlinDASys.m │ ├── post.m │ ├── private │ │ ├── createHessianTensorFile_powSys.m │ │ ├── linError.m │ │ ├── linError_mixed_noInt.m │ │ ├── linError_thirdOrder.m │ │ └── linearize.m │ ├── simulate.m │ ├── simulateRRT.m │ └── simulateRRT_det.m ├── @nonlinParamSys │ ├── checkOptionsReach.m │ ├── display.m │ ├── getfcn.m │ ├── initReach.m │ ├── linearize.m │ ├── nonlinParamSys.m │ ├── post.m │ ├── private │ │ └── symbolicDerivation.m │ └── simulate.m ├── @nonlinearSys │ ├── checkOptionsReach.m │ ├── createRemainderFile_certainInput.m │ ├── display.m │ ├── getfcn.m │ ├── initReach.m │ ├── linearize.m │ ├── nonlinearSys.m │ ├── post.m │ ├── private │ │ ├── allowedError.m │ │ ├── createTaylorFile.m │ │ └── errorEval.m │ ├── reachInner.m │ ├── simulate.m │ └── taylor.m └── @nonlinearSysDT │ ├── checkOptionsReach.m │ ├── display.m │ ├── linReach.m │ ├── nonlinearSysDT.m │ ├── private │ ├── linError_mixed_noInt.m │ ├── linError_thirdOrder.m │ └── linearize.m │ ├── reach.m │ └── simulate.m ├── contSet ├── @conZonotope │ ├── and.m │ ├── boundDir.m │ ├── cartesianProduct.m │ ├── center.m │ ├── conZonotope.m │ ├── display.m │ ├── enclose.m │ ├── interval.m │ ├── intervalMultiplication.m │ ├── isempty.m │ ├── mixedMultiplication.m │ ├── mptPolytope.m │ ├── mtimes.m │ ├── plot.m │ ├── plotFilled.m │ ├── plotFilledSplit.m │ ├── plotFilledTemplate.m │ ├── plotTemplate.m │ ├── plotZono.m │ ├── plus.m │ ├── private │ │ ├── ksi_iterative.m │ │ ├── ksi_optimizer.m │ │ ├── potVertices.m │ │ └── removeZeroConstraints.m │ ├── project.m │ ├── quadraticMultiplication.m │ ├── reduce.m │ ├── rescale.m │ ├── split.m │ ├── vertices.m │ └── zonotope.m ├── @contSet │ ├── contSet.m │ └── display.m ├── @generalSet │ ├── display.m │ ├── generalSet.m │ └── parallelotope.m ├── @halfspace │ ├── commonPoint.m │ ├── display.m │ ├── eventFcn.m │ ├── get.m │ ├── halfspace.m │ ├── in.m │ ├── intersectionTime_oneDirection.m │ ├── isIntersecting.m │ ├── isIntersectingApprox.m │ ├── maps.m │ ├── mapsCubic.m │ ├── mapsQuad.m │ ├── mapsQuad_06Sep2013.m │ ├── mapsQuad_old.m │ ├── mapsQuad_test06Sep2013.m │ ├── mapsQuad_unc.m │ ├── mtimes.m │ ├── partialGuardProjection.m │ ├── plot.m │ ├── plus.m │ ├── polytope.m │ ├── private │ │ └── rotationMatrix.m │ ├── project.m │ ├── projectHighDim.m │ ├── rotate.m │ ├── zonoIn.m │ ├── zonoIntersect.m │ └── zonoPartiallyIn.m ├── @interval │ ├── abs.m │ ├── acos.m │ ├── acosh.m │ ├── and.m │ ├── asin.m │ ├── asinh.m │ ├── atan.m │ ├── atanh.m │ ├── cos.m │ ├── cosh.m │ ├── ctranspose.m │ ├── diag.m │ ├── display.m │ ├── enclosingRadius.m │ ├── enlarge.m │ ├── eq.m │ ├── eventFcn.m │ ├── exp.m │ ├── get.m │ ├── gridPoints.m │ ├── horzcat.m │ ├── hull.m │ ├── in.m │ ├── infimum.m │ ├── interval.m │ ├── isIntersecting.m │ ├── isIntersectingApprox.m │ ├── isempty.m │ ├── isscalar.m │ ├── le.m │ ├── length.m │ ├── log.m │ ├── lt.m │ ├── mid.m │ ├── minus.m │ ├── mpower.m │ ├── mrdivide.m │ ├── mtimes.m │ ├── ne.m │ ├── plot.m │ ├── plotFilled.m │ ├── plus.m │ ├── polytope.m │ ├── power.m │ ├── prod.m │ ├── projectHighDim.m │ ├── rad.m │ ├── rdivide.m │ ├── reshape.m │ ├── sin.m │ ├── sinh.m │ ├── size.m │ ├── sqrt.m │ ├── subsasgn.m │ ├── subsref.m │ ├── sum.m │ ├── supremum.m │ ├── tan.m │ ├── tanh.m │ ├── times.m │ ├── transpose.m │ ├── uminus.m │ ├── uplus.m │ ├── vertcat.m │ ├── vertices.m │ ├── volume.m │ └── zonotope.m ├── @vertices │ ├── collect.m │ ├── dirPolytope.m │ ├── dirPolytope2.m │ ├── dirPolytopeBoth.m │ ├── dirPolytopeNew.m │ ├── display.m │ ├── enclosingZonotope3.m │ ├── enclosingZonotope4.m │ ├── get.m │ ├── interval.m │ ├── isempty.m │ ├── mtimes.m │ ├── parallelotope.m │ ├── plot.m │ ├── plot3d.m │ ├── plotFilled.m │ ├── plus.m │ ├── polygon.m │ ├── rotate.m │ ├── subsref.m │ ├── vertices.m │ └── zonotope.m ├── @zonotope │ ├── abs.m │ ├── and.m │ ├── appVolume.m │ ├── box.m │ ├── cartesianProduct.m │ ├── center.m │ ├── conZonotope.m │ ├── constrSat.m │ ├── containsPoint.m │ ├── cubicMultiplication.m │ ├── cubicMultiplication_interval.m │ ├── cubicMultiplication_old.m │ ├── cubicMultiplication_simple.m │ ├── deleteAligned.m │ ├── deleteZeros.m │ ├── dim.m │ ├── dirPolytopeNew.m │ ├── display.m │ ├── dominantDirections.m │ ├── enclose.m │ ├── encloseMany.m │ ├── enclosingPolytope.m │ ├── enclosingZonotope.m │ ├── enlarge.m │ ├── eventFcn.m │ ├── exactPlus.m │ ├── filterOut.m │ ├── generatorLength.m │ ├── generators.m │ ├── get.m │ ├── guardProjection.m │ ├── guardProjection_09Sep2013.m │ ├── guardProjection_constFlow.m │ ├── halfspace.m │ ├── in.m │ ├── inORH.m │ ├── inParallelotope.m │ ├── inViaProj.m │ ├── intersection.m │ ├── interval.m │ ├── intervalMultiplication.m │ ├── isIntersecting.m │ ├── isIntersectingApprox.m │ ├── isempty.m │ ├── minus.m │ ├── mixedCubicMultiplication.m │ ├── mixedMultiplication.m │ ├── mptPolytope.m │ ├── mtimes.m │ ├── multiPolytope.m │ ├── norm.m │ ├── or.m │ ├── orthVectors.m │ ├── partialGuardProjection.m │ ├── partialGuardProjection_forward.m │ ├── plot.m │ ├── plotAsText.m │ ├── plotFilled.m │ ├── plus.m │ ├── polygon.m │ ├── polytope.m │ ├── private │ │ ├── andAveraging.m │ │ ├── evaluateRotations.m │ │ ├── generatorVolumeFilter.m │ │ ├── kmeansFilter.m │ │ ├── lengthFilter.m │ │ ├── ndimCross.m │ │ ├── nonzeroFilter.m │ │ ├── pickedGenerators.m │ │ ├── reduceCluster.m │ │ ├── reduceCombastel.m │ │ ├── reduceConstOpt.m │ │ ├── reduceGirard.m │ │ ├── reduceMethA.m │ │ ├── reduceMethB.m │ │ ├── reduceMethC.m │ │ ├── reduceMethE.m │ │ ├── reduceMethF.m │ │ ├── reducePCA.m │ │ ├── reduceRedistribute.m │ │ ├── reduceScott.m │ │ ├── reorderingFilter.m │ │ └── volumeFilter.m │ ├── project.m │ ├── quadZonotope.m │ ├── quadraticMultiplication.m │ ├── quadraticMultiplication_interval.m │ ├── quadraticMultiplication_parallel.m │ ├── quadraticMultiplication_zono.m │ ├── quadraticProgramming_interval.m │ ├── radius.m │ ├── randPoint.m │ ├── randPointExtreme.m │ ├── reduce.m │ ├── reduceUnderApprox.m │ ├── rotate.m │ ├── set.m │ ├── split.m │ ├── splitFirstGen.m │ ├── tensorMultiplication.m │ ├── tensorMultiplication_zono.m │ ├── underapproximate.m │ ├── unify.m │ ├── vertices.m │ ├── volume.m │ ├── volumeRatio.m │ └── zonotope.m ├── gramSchmidt.m ├── plotPolytope3D.m ├── randProbZonotope.m └── readPlotOptions.m ├── matrixSet ├── @intervalMatrix │ ├── abs.m │ ├── changeLog_intervalMatrix.txt │ ├── dependentTerms.m │ ├── display.m │ ├── dominantVertices.m │ ├── exactSquare.m │ ├── expm.m │ ├── expmAbsoluteBound.m │ ├── expmInd.m │ ├── expmIndMixed.m │ ├── expmMixed.m │ ├── expmNormInf.m │ ├── expmVertex.m │ ├── exponentialRemainder.m │ ├── interval.m │ ├── intervalMatrix.m │ ├── matPolytope.m │ ├── matZonotope.m │ ├── mpower.m │ ├── mtimes.m │ ├── norm.m │ ├── plot.m │ ├── plus.m │ ├── powers.m │ ├── randomIntervalMatrix.m │ ├── randomSampling.m │ ├── subsref.m │ ├── vertices.m │ └── volume.m ├── @matZonotope │ ├── changeLog_matZonotope.txt │ ├── concatenate.m │ ├── dependentTerms.m │ ├── display.m │ ├── dominantVertices.m │ ├── expmInd.m │ ├── expmIndMixed.m │ ├── expmMixed.m │ ├── expmOneParam.m │ ├── expmVertex.m │ ├── get.m │ ├── intervalMatrix.m │ ├── matPolytope.m │ ├── matZonotope.m │ ├── mpower.m │ ├── mtimes.m │ ├── norm.m │ ├── plot.m │ ├── plus.m │ ├── powers.m │ ├── randomSampling.m │ ├── reduce.m │ ├── set.m │ ├── subsref.m │ ├── vertices.m │ ├── volume.m │ └── zonotope.m ├── changeLog_matrixSet.txt ├── mat2vec.m ├── randomDelta.m └── vec2mat.m ├── models └── auxiliary │ └── stirredTankReactor │ ├── hessianTensor_stirredTankReactor.m │ ├── jacobian_stirredTankReactor.m │ └── stirredTankReactor_lastVersion.mat ├── plotPolyZono.m ├── utilities ├── compLipConst.m ├── cstrDiscr.m ├── invIntMatrixAuto.m ├── linError_mixed_noInt_DTT.m ├── linearize_DTT.m └── nonlinearDT.m └── workspaces ├── ZPC.mat ├── ZPC_in100st5W0.1V0.02N2.mat ├── ZPC_in4st100W0.01V0.002.mat ├── ZPC_wo_costline.mat ├── poly.mat ├── poly_W0.01V0.002.mat └── poly_W0.1V0.02N2.mat /Figures/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | InfoTip=This folder is shared online. 3 | IconFile=C:\Program Files\Google\Drive\googledrivesync.exe 4 | IconIndex=16 5 | -------------------------------------------------------------------------------- /Figures/reachmpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/Figures/reachmpc.png -------------------------------------------------------------------------------- /contDynamics/@contDynamics/dimension.m: -------------------------------------------------------------------------------- 1 | function [dim]=dimension(obj) 2 | % display - Returns the dimension of the system 3 | % 4 | % Syntax: 5 | % [dim]=dimension(obj) 6 | % 7 | % Inputs: 8 | % obj - contDynamics object 9 | % 10 | % Outputs: 11 | % dim - system dimension 12 | % 13 | % Example: 14 | % 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 08-May-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | dim = obj.dim; 30 | 31 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@contDynamics/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a continuous dynamics object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - contDynamics object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % cd=contDynamics('test function',[1 2],1,3); 15 | % display(cd); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 02-May-2007 25 | % Last update: 17-October-2007 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %display name and id 31 | disp(['Continuous dynamics "',obj.name,'"']); 32 | 33 | % display number of states 34 | disp(['number of states: ', num2str(obj.dim)]); 35 | 36 | % display number of inputs 37 | disp(['number of inputs: ' num2str(obj.nrOfInputs)]); 38 | 39 | % display number of outputs 40 | disp(['number of outputs: ' num2str(obj.nrOfOutputs)]); 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@contDynamics/private/createJacobianFile_freeParam.m: -------------------------------------------------------------------------------- 1 | function createJacobianFile_freeParam(Jdyn,path,name) 2 | % createJacobianFile_freeParam - generates an mFile that allows to compute the 3 | % jacobian for a certain state, input, and parameter value 4 | % 5 | % Syntax: 6 | % createJacobianFile_freeParam(obj) 7 | % 8 | % Inputs: 9 | % Jdyn - jacobians 10 | % path - path where the function should be created 11 | % name - name of the nonlinear function to which the jacobian should 12 | % belong 13 | % 14 | % Outputs: 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 07-June-2017 26 | % Last update: --- 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | 33 | fid = fopen([path '/jacobian_freeParam_',name,'.m'],'w'); 34 | fprintf(fid, '%s\n\n', ['function [A,B]=jacobian_freeParam_',name,'(x,u,p)']); 35 | 36 | % SYSTEM MATRIX 37 | % write "A=[" 38 | fprintf(fid, '%s', 'A=['); 39 | % write rest of matrix 40 | writeMatrix(Jdyn.x,fid); 41 | 42 | % INPUT MATRIX 43 | % write "B=[" 44 | fprintf(fid, '%s', 'B=['); 45 | % write rest of matrix 46 | writeMatrix(Jdyn.u,fid); 47 | 48 | %close file 49 | fclose(fid); 50 | 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@contDynamics/private/reportReachError.m: -------------------------------------------------------------------------------- 1 | function reportReachError(ME,time,ind) 2 | % reportReachError - reports information to the user in case 3 | % the reachable set explodes; in other cases, the same information 4 | % as without this function is displayed 5 | % 6 | % Syntax: 7 | % reportReachError(ME,time,ind) 8 | % 9 | % Inputs: 10 | % ME - MException object 11 | % time - current time 12 | % ind - cuurnend step 13 | % 14 | % Outputs: 15 | % --- 16 | 17 | % Author: Mark Wetzlinger 18 | % Written: 19-May-2020 19 | % Last update: --- 20 | % Last revision:--- 21 | 22 | %------------- BEGIN CODE -------------- 23 | 24 | % called due to set explosion 25 | if strcmp(ME.identifier,'reach:setexplosion') 26 | 27 | % display information to user 28 | fprintf("\n"); 29 | disp(ME.message); 30 | disp(" Step " + ind + " at time t=" + time); 31 | disp("The reachable sets until the current step are returned."); 32 | fprintf("\n"); 33 | else 34 | % any other run-time error: report information 35 | rethrow(ME); 36 | end 37 | end 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linParamSys/LinParamWrapper_initReach.m: -------------------------------------------------------------------------------- 1 | function varargout = LinParamWrapper_initReach(varargin) 2 | %wrapper for initReach function from LinParamSys 3 | 4 | %------------- BEGIN CODE -------------- 5 | [varargout{1:nargout}] = initReach(varargin{:}); 6 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linParamSys/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a linVarSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - linVarSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 05-Aug-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Linear parametric system'); 35 | 36 | % display paraemter type 37 | if obj.constParam 38 | disp('parameter: constant'); 39 | else 40 | disp('parameter: time-varying'); 41 | end 42 | 43 | %display A-Matrix 44 | disp('System matrix: '); 45 | display(obj.A); 46 | 47 | %display B-Matrix 48 | disp('Input matrix: '); 49 | display(obj.B); 50 | 51 | disp('-----------------------------------'); 52 | 53 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linParamSys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the linear system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj) 7 | % 8 | % Inputs: 9 | % obj - linIntSys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 07-May-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | function dxdt = f(t,x) 30 | dxdt = obj.sampleMatrix.A*x+double(obj.B*options.u); 31 | end 32 | 33 | handle = @f; 34 | end 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linParamSys/postReach.m: -------------------------------------------------------------------------------- 1 | function [Rnext,IH] = postReach(obj,Rinit,R_tp,c) 2 | % postReach - computes the reachable continuous set for the first time 3 | % interval as a postprocessing step 4 | % 5 | % Syntax: 6 | % [Rnext] = postReach(obj,Rinit,R_tp) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % Rinit - initial reachable set 11 | % R_tp - reachable set at the next point in time 12 | % 13 | % Outputs: 14 | % Rnext - next reachable set 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 03-May-2011 26 | % Last update: 25-July-2016 (intervalhull replaced by interval)--- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | %load data from object structure 33 | F=obj.F; 34 | inputCorr=0; %add input correction later 35 | RV=obj.RV; 36 | 37 | 38 | %time interval solution 39 | R_err = F*(Rinit+(-c))+inputCorr; 40 | R_ti=enclose(Rinit,R_tp)+R_err; 41 | 42 | %write results to reachable set struct Rfirst 43 | Rnext.tp=R_tp+RV; 44 | Rnext.ti=R_ti+RV; 45 | 46 | %compute enclosing hull 47 | IH_init = interval(Rinit); 48 | IH_tp = interval(R_tp); 49 | IH_err = interval(R_err+RV); 50 | 51 | IH = enclose(IH_init,IH_tp) + IH_err; 52 | 53 | %IH_alt = interval(R_ti); 54 | 55 | 56 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linParamSys/preReach.m: -------------------------------------------------------------------------------- 1 | function [obj] = preReach(obj,options) 2 | % preReach - prepares reachable set computation for linear systems 3 | % 4 | % Syntax: 5 | % [obj] = preReach(obj,options) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % options - options for the computation of the reachable set 10 | % 11 | % Outputs: 12 | % obj - linearSys object 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 26-August-2011 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | % compute mapping matrix 30 | [obj] = mappingMatrix(obj,options); 31 | % compute time interval error (tie) 32 | obj = tie(obj); 33 | %compute reachable set due to uncertain input 34 | U = deleteZeros(options.U); 35 | obj.RV = errorSolution(obj,options,U); 36 | 37 | 38 | 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a linProbSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - linProbSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 06-October-2007 23 | % Last update: --- 24 | % Last revision: --- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Linear time continuous probabilistic system'); 35 | 36 | %display A-Matrix 37 | disp('System matrix: '); 38 | A=obj.A 39 | 40 | %display B-Matrix 41 | disp('Input matrix: '); 42 | B=obj.B 43 | 44 | disp('-----------------------------------'); 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the linear probabilistic system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 06-October-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | function dxdt = f(t,x) 30 | dxdt = obj.A*x+double(obj.B*options.u); 31 | end 32 | 33 | handle = @f; 34 | end 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/linProbSys.m: -------------------------------------------------------------------------------- 1 | classdef linProbSys < contDynamics 2 | % linProbSys class (linProbSys: linear probabilistic system) 3 | % 4 | % Syntax: 5 | % object constructor: Obj = linearSys(varargin) 6 | % copy constructor: Obj = otherObj 7 | % 8 | % Inputs: 9 | % name - name of system 10 | % A - state matrix 11 | % B - input matrix 12 | % C - noise matrix 13 | % 14 | % Outputs: 15 | % Obj - Generated Object 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 06-October-2007 25 | % Last update: 26-February-2008 26 | % 05-August-2016 (changed to new OO format) 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | properties (SetAccess = private, GetAccess = public) 32 | A = []; 33 | B = []; 34 | C = []; 35 | taylor = []; 36 | end 37 | 38 | methods 39 | %class constructor 40 | function obj = linProbSys(varargin) 41 | obj@contDynamics(varargin{1},length(varargin{2}),1,1); %instantiate parent class 42 | %4 inputs 43 | if nargin==4 44 | obj.A = varargin{2}; 45 | obj.B = varargin{3}; 46 | obj.C = varargin{4}; 47 | end 48 | end 49 | end 50 | end 51 | 52 | 53 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/private/infNorm.m: -------------------------------------------------------------------------------- 1 | function [n]=infNorm(A) 2 | % infNorm - returns the maximum of the infinity norm of an interval matrix 3 | % 4 | % Syntax: 5 | % [n]=infNorm(A) 6 | % 7 | % Inputs: 8 | % A - interval matrix 9 | % 10 | % Outputs: 11 | % n - infinity norm of the interval matrix 12 | % 13 | % Example: 14 | % A=interval(rand(3),rand(3)+1); 15 | % n=infNorm(A); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: OTHER_FUNCTION_NAME1, OTHER_FUNCTION_NAME2 22 | 23 | % Author: Matthias Althoff 24 | % Written: 12-February-2007 25 | % Last update: --- 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | n=norm(abs(A),inf); 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/private/sample.m: -------------------------------------------------------------------------------- 1 | function [obj] = sample(obj) 2 | % sample - computes a sample of the system matrix 3 | % 4 | % Syntax: 5 | % [obj] = sample(obj) 6 | % 7 | % Inputs: 8 | % obj - linIntSys object 9 | % 10 | % Outputs: 11 | % obj - linIntSys object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 16-May-2007 23 | % Last update: 15-June-2016 24 | % 25-July-2016 (intervalhull replaced by interval) 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %get left and right system matrix 30 | [Aleft,Aright]=interval(obj.A); 31 | 32 | %convert to interval matrix 33 | intervals=[reshape(Aleft,[],1),reshape(Aright,[],1)]; 34 | 35 | %build interval 36 | I=interval(intervals(:,1), intervals(:,2)); 37 | 38 | %get vertices of interval 39 | V = vertices(I); 40 | W = unique(V', 'rows')'; 41 | 42 | %reshape to different As 43 | [rows,cols]=size(Aleft); 44 | for i=1:length(W(1,:)) 45 | obj.sample.A{i}=reshape(W(:,i),rows,cols); 46 | end 47 | 48 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/private/tie.m: -------------------------------------------------------------------------------- 1 | function [obj] = tie(obj,options) 2 | % tie - tie: time interval error; computes the error done by 3 | % building the convex hull of time point solutions 4 | % 5 | % Syntax: 6 | % [obj]=tie(obj,options) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % 11 | % Outputs: 12 | % obj - linearSys object 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: expm, inputSol 21 | 22 | % Author: Matthias Althoff 23 | % Written: 08-May-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %load data from object/options structure 30 | Apower=obj.taylor.powers; 31 | taylorTerms=options.taylorTerms; 32 | r=options.timeStep; 33 | dim=dimension(obj); 34 | 35 | %initialize Asum 36 | Asum=zeros(dim); 37 | 38 | for i=2:taylorTerms 39 | %compute factor 40 | exp1=-i/(i-1); exp2=-1/(i-1); 41 | int=interval((i^exp1-i^exp2)*r^i,0); 42 | %compute powers 43 | Aadd=int*Apower{i}; 44 | %compute sum 45 | Asum=Asum+Aadd/factorial(i); 46 | end 47 | 48 | %write to object structure 49 | obj.taylor.F=Asum+obj.taylor.error; 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linProbSys/reachAlternative.m: -------------------------------------------------------------------------------- 1 | function [Rnext,options] = reachAlternative(obj,R,options) 2 | % reachAlternative - computes the reachable continuous probabilistic set for one time 3 | % step of a linear interval system 4 | % 5 | % Syntax: 6 | % [Rnext,options] = reachAlternative(obj,R,options) 7 | % 8 | % Inputs: 9 | % obj - linProbSys object 10 | % R - reachable set of the previous time step 11 | % options - options for the computation of the reachable set 12 | % 13 | % Outputs: 14 | % Rnext - reachable set of the next time step 15 | % options - options for the computation of the reachable set 16 | % 17 | % Example: 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 27-September-2007 27 | % Last update: 09-September-2009 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %next set (no input) 33 | R.ti=obj.taylor.eAt*R.ti; 34 | 35 | %bloating due to input 36 | R.ti=R.ti+obj.taylor.Rinput+obj.taylor.pRinput; 37 | 38 | %reduce 39 | Rnext.ti=reduce(R.ti,'girard',options.zonotopeOrder); 40 | Rnext.tp=[]; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/coreReach.m: -------------------------------------------------------------------------------- 1 | function [Rfirst] = coreReach(obj,Rinit) 2 | % coreReach - computes the reachable continuous set for the next time step 3 | % without considering uncertain inputs 4 | % 5 | % Syntax: 6 | % [Rfirst] = coreReach(obj,Rinit,options) 7 | % 8 | % Inputs: 9 | % Rinit - initial reachable set 10 | % 11 | % Outputs: 12 | % obj - linearSys object 13 | % Rfirst - first reachable set 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 03-May-2011 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %load data from object structure 31 | eAt=obj.taylor.eAt; 32 | Rtrans=obj.taylor.Rtrans; 33 | 34 | %first time step homogeneous solution 35 | Rhom_tp=eAt*Rinit + Rtrans; 36 | 37 | %write results to reachable set struct Rfirst 38 | Rfirst=Rhom_tp; 39 | 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a linearSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 16-May-2007 23 | % Last update: --- 24 | % Last revision: --- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Linear time continuous system'); 35 | 36 | %display A-Matrix 37 | disp('System matrix: '); 38 | A=obj.A 39 | 40 | %display B-Matrix 41 | disp('Input matrix: '); 42 | B=obj.B 43 | 44 | disp('-----------------------------------'); 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/exponentialMatrices.m: -------------------------------------------------------------------------------- 1 | function [eAt, eAtInt] = exponentialMatrices(obj,options) 2 | % exponentialMatrices - computes the exponential matrix for the initial 3 | % state and constant input solution 4 | % 5 | % Syntax: 6 | % [eAt, eAtInt] = exponentialMatrices(obj,options) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % options - options for the computation of the reachable set 11 | % 12 | % Outputs: 13 | % eAt - exponential matrix for the initial state solution 14 | % eAtInt - exponential matrix for the constant input solution 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 27-August-2013 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | % compute exponential matrix 33 | obj = exponential(obj,options); 34 | % compute reachable set due to input 35 | obj = inputSolution(obj,options); 36 | 37 | %extract data 38 | eAt = obj.taylor.eAt; 39 | eAtInt = obj.taylor.eAtInt; 40 | 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the linear system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 07-May-2007 24 | % Last update: 20-March-2008 25 | % 05-December-2017 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | if ~isempty(obj.c) 31 | c = obj.c; 32 | else 33 | c = 0; 34 | end 35 | 36 | function dxdt = f(~,x) 37 | dxdt = obj.A*x + obj.B*options.u + c; 38 | end 39 | 40 | handle = @f; 41 | end 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/initReach.m: -------------------------------------------------------------------------------- 1 | function [Rfirst,options] = initReach(obj,Rinit,options) 2 | % initReach - computes the reachable continuous set for the 3 | % first time step in the 4 | % 5 | % Syntax: 6 | % [obj,Rfirst,options] = initReach(obj,Rinit,options) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % Rinit - initial reachable set 11 | % options - options for the computation of the reachable set 12 | % 13 | % Outputs: 14 | % obj - linearSys object 15 | % Rfirst - first reachable set 16 | % options - options for the computation of the reachable set 17 | % 18 | % Example: 19 | % 20 | % Other m-files required: none 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: none 25 | 26 | % Author: Matthias Althoff 27 | % Written: 07-November-2018 28 | % Last update: --- 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | % check whether error specification for Krylov space exists 34 | if isfield(options,'krylovError') 35 | %compute in Krylov space 36 | [Rfirst,options] = initReach_Krylov(obj,Rinit,options); 37 | else 38 | % compute in untransformed space 39 | [Rfirst,options] = initReach_Euclidean(obj,Rinit,options); 40 | end 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/post.m: -------------------------------------------------------------------------------- 1 | function [Rnext,options] = post(obj,~,options) 2 | % post - calls the post functions in the stnadrad or Krylov space 3 | % 4 | % Syntax: 5 | % [Rnext,options] = post(obj,R,options) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % R - reachable set of the previous time step 10 | % options - options for the computation of the reachable set 11 | % 12 | % Outputs: 13 | % Rnext - reachable set of the next time step 14 | % options - options for the computation of the reachable set 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 07-November-2018 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | % check whether error specification for Krylov space exists 32 | if isfield(options,'krylovError') 33 | %compute in Krylov space 34 | [Rnext,options] = post_Krylov(obj,options); 35 | else 36 | % compute in untransformed space 37 | [Rnext,options] = post_Euclidean(obj,options); 38 | end 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/postReach.m: -------------------------------------------------------------------------------- 1 | function [Rnext,IH] = postReach(obj,Rinit,R_tp,c) 2 | % postReach - computes the reachable continuous set for the first time 3 | % interval as a postprocessing step 4 | % 5 | % Syntax: 6 | % [Rnext] = postReach(obj,Rinit,R_tp) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % Rinit - initial reachable set 11 | % R_tp - reachable set at the next point in time 12 | % 13 | % Outputs: 14 | % Rnext - next reachable set 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 03-May-2011 26 | % Last update: 25-July-2016 (intervalhull replaced by interval) 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | %load data from object structure 33 | F=obj.taylor.F; 34 | inputCorr=obj.taylor.inputCorr; 35 | RV=obj.taylor.RV; 36 | 37 | 38 | %time interval solution 39 | R_err = F*(Rinit+(-c))+inputCorr; 40 | R_ti=enclose(Rinit,R_tp)+R_err; 41 | 42 | %write results to reachable set struct Rfirst 43 | Rnext.tp=R_tp+RV; 44 | Rnext.ti=R_ti+RV; 45 | 46 | %compute enclosing hull 47 | IH_init = interval(Rinit); 48 | IH_tp = interval(R_tp); 49 | IH_err = interval(R_err+RV); 50 | 51 | IH = or(IH_init,IH_tp) + IH_err; 52 | 53 | %IH_alt = interval(R_ti); 54 | 55 | 56 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSys/post_Euclidean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/contDynamics/@linearSys/post_Euclidean.m -------------------------------------------------------------------------------- /contDynamics/@linearSys/preReach.m: -------------------------------------------------------------------------------- 1 | function [obj] = preReach(obj,options) 2 | % preReach - prepares reachable set computation for linear systems 3 | % 4 | % Syntax: 5 | % [obj] = preReach(obj,options) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % options - options for the computation of the reachable set 10 | % 11 | % Outputs: 12 | % obj - linearSys object 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 03-May-2011 24 | % Last update: 29-October-2017 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | 30 | % compute exponential matrix 31 | obj = exponential(obj,options); 32 | % compute time interval error (tie) 33 | obj = tie(obj,options); 34 | % compute reachable set due to input 35 | obj = inputSolution(obj,options); 36 | %change the time step 37 | obj.taylor.timeStep=options.timeStep; 38 | % compute exponential matrix 39 | obj.taylor.eAt=expm(obj.A*options.timeStep); 40 | 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSysDT/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a linearSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 16-May-2007 23 | % Last update: --- 24 | % Last revision: --- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Linear time-discrete system'); 35 | 36 | %display A-Matrix 37 | disp('System matrix: '); 38 | A=obj.A 39 | 40 | %display B-Matrix 41 | disp('Input matrix: '); 42 | B=obj.B 43 | 44 | disp('-----------------------------------'); 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@linearSysDT/post.m: -------------------------------------------------------------------------------- 1 | function [Rnext,options] = post(obj,~,options) 2 | % post - calls the post functions in the stnadrad or Krylov space 3 | % 4 | % Syntax: 5 | % [Rnext,options] = post(obj,R,options) 6 | % 7 | % Inputs: 8 | % obj - linearSys object 9 | % R - reachable set of the previous time step 10 | % options - options for the computation of the reachable set 11 | % 12 | % Outputs: 13 | % Rnext - reachable set of the next time step 14 | % options - options for the computation of the reachable set 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 07-November-2018 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | % check whether error specification for Krylov space exists 32 | if isfield(options,'krylovError') 33 | %compute in Krylov space 34 | [Rnext,options] = post_Krylov(obj,options); 35 | else 36 | % compute in untransformed space 37 | [Rnext,options] = post_Euclidean(obj,options); 38 | end 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinDASys/consistentInitialState.m: -------------------------------------------------------------------------------- 1 | function y0 = consistentInitialState(obj, x0, y0, u0) 2 | % consistentInitialState - returns a consisten initial state, i.e. one for 3 | % which the algebraic equations are fulfilled 4 | % 5 | % Syntax: 6 | % example_nonlinearDA_reach_01_powerSystem_3bus() 7 | % 8 | % Inputs: 9 | % x0 - initial dynamic state 10 | % y0 - guessed initial algeraic state (changed by this function) 11 | % u0 - initial input 12 | % 13 | % Outputs: 14 | % y0 - updated initial algebraic state 15 | % 16 | % Example: 17 | % 18 | % 19 | % Author: Matthias Althoff 20 | % Written: 18-August-2016 21 | % Last update: --- 22 | % Last revision:--- 23 | 24 | 25 | %------------- BEGIN CODE -------------- 26 | 27 | %init 28 | converged = 0; 29 | 30 | while ~converged 31 | l = obj.conFile(x0, y0, u0); 32 | [~,~,~,~,~,F] = obj.jacobian(x0, y0, u0); 33 | 34 | %evaluate jacobian 35 | delta_y = F\(-l); 36 | 37 | %check convergence 38 | if norm(delta_y)<1e-10 39 | converged = 1; 40 | end 41 | 42 | y0 = y0 + delta_y; 43 | end 44 | 45 | %------------- END OF CODE -------------- 46 | -------------------------------------------------------------------------------- /contDynamics/@nonlinDASys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the DAE system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj,options) 7 | % 8 | % Inputs: 9 | % obj - nonlinDASys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 17-November-2011 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | function dxdt = f(t, z) 30 | %obtain x and y 31 | x = z(1:obj.dim); 32 | y = z((obj.dim+1):(obj.dim+obj.nrOfConstraints)); 33 | 34 | %return derivatives 35 | dxdt(1:obj.dim,1) = obj.dynFile(x, y, options.u); 36 | dxdt((obj.dim+1):(obj.dim+obj.nrOfConstraints),1) = obj.conFile(x, y, options.u); 37 | end 38 | 39 | handle = @f; 40 | end 41 | 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinParamSys/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a linVarSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - linVarSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 27-May-2011 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | % display number of parameter 34 | disp(['number of parameters: ',num2str(obj.nrOfParam)]); 35 | 36 | %display type 37 | disp('type: Nonlinear parameter system'); 38 | 39 | %display state space equations 40 | %create symbolic variables 41 | vars = symVariables(obj); 42 | 43 | %insert symbolic variables into the system equations 44 | f=obj.mFile(vars.x,vars.u,vars.p); 45 | disp('state space equations:') 46 | for i=1:length(f) 47 | disp(['f(',num2str(i),') = ',char(f(i))]); 48 | end 49 | 50 | disp('-----------------------------------'); 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinParamSys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the linear system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 17-October-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | function dxdt = f(t,x) 30 | dxdt = obj.mFile(x,options.u,options.p); 31 | end 32 | 33 | handle = @f; 34 | end 35 | 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinParamSys/simulate.m: -------------------------------------------------------------------------------- 1 | function [t,x,ind] = simulate(obj,params,options) 2 | % simulate - simulates the system within a location 3 | % 4 | % Syntax: 5 | % [t,x,ind] = simulate(obj,params,options) 6 | % 7 | % Inputs: 8 | % obj - nonlinParamSys object 9 | % params - struct containing the parameters for the simulation 10 | % .tStart: initial time 11 | % .tFinal: final time 12 | % .x0: initial point 13 | % options - ODE45 options (for hybrid systems) 14 | % 15 | % Outputs: 16 | % t - time vector 17 | % x - state vector 18 | % ind - returns the event which has been detected 19 | % 20 | % Example: 21 | % 22 | % Other m-files required: none 23 | % Subfunctions: none 24 | % MAT-files required: none 25 | % 26 | % See also: none 27 | 28 | % Author: Matthias Althoff 29 | % Written: 26-May-2011 30 | % Last update: 08-May-2020 (MW, update interface) 31 | % Last revision:--- 32 | 33 | %------------- BEGIN CODE -------------- 34 | 35 | if isempty(options.Events) 36 | [t,x] = ode45(getfcn(obj,params),... 37 | [params.tStart,params.tFinal],params.x0,options); 38 | ind = []; 39 | else 40 | [t,x,te,xe,ind] = ode45(getfcn(obj,params),... 41 | [params.tStart,params.tFinal],params.x0,options); 42 | end 43 | 44 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSys/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a nonlinearSys object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - nonlinearSys object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 17-October-2007 23 | % Last update: --- 24 | % Last revision: --- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Nonlinear time continuous system'); 35 | 36 | %display state space equations 37 | %generate symbolic states 38 | for i=1:obj.dim 39 | command=['syms x',num2str(i)]; 40 | eval(command); 41 | command=['x(',num2str(i),')=x',num2str(i),';']; 42 | eval(command); 43 | end 44 | %generate symbolic inputs 45 | for i=1:obj.nrOfInputs 46 | command=['syms u',num2str(i)]; 47 | eval(command); 48 | command=['u(',num2str(i),')=u',num2str(i),';']; 49 | eval(command); 50 | end 51 | 52 | dx=obj.mFile(x,u) 53 | 54 | disp('-----------------------------------'); 55 | 56 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSys/getfcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = getfcn(obj,options) 2 | % getfcn - returns the function handle of the continuous function specified 3 | % by the linear system object 4 | % 5 | % Syntax: 6 | % [handle] = getfcn(obj) 7 | % 8 | % Inputs: 9 | % obj - linearSys object 10 | % 11 | % Outputs: 12 | % handle - function handle 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 17-October-2007 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | function dxdt = f(t,x) 30 | dxdt = obj.mFile(x,options.u); 31 | end 32 | 33 | handle = @f; 34 | end 35 | 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSys/private/allowedError.m: -------------------------------------------------------------------------------- 1 | function [allErr] = allowedError(obj,linSys,options) 2 | % allowedError - computes the allowed linearization error 3 | % 4 | % Syntax: 5 | % [allErr] = allowedError(obj,linSys,options) 6 | % 7 | % Inputs: 8 | % obj - nonlinear system object 9 | % linSys - linear system object 10 | % options - options struct 11 | % 12 | % Outputs: 13 | % obj - nonlinear system object 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: 22 | 23 | % Author: Matthias Althoff 24 | % Written: 29-October-2007 25 | % Last update: 22-January-2008 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %retrieve data 31 | f0=obj.linError.f0; 32 | deltaT=options.timeStep; 33 | expFactor=obj.expFactor; 34 | 35 | A=linSys.A; 36 | eAt=expm(A*deltaT); 37 | dim=length(f0); 38 | I=eye(dim); 39 | 40 | %compute allowed lin error 41 | %allErr=inv(eAt-I)*A*f0*deltaT*expFactor; 42 | 43 | %compute inverse and check if possible 44 | if det(eAt-I)==0 45 | inverse=inv(eAt-I+1e-4); 46 | disp('inversion approximation'); 47 | else 48 | inverse=inv(eAt-I); 49 | end 50 | %allErr=inverse*A*ones(dim,1)*deltaT*expFactor; 51 | allErr=inverse*A*deltaT*expFactor; 52 | allErr=abs(allErr); 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSys/private/createTaylorFile.m: -------------------------------------------------------------------------------- 1 | function createTaylorFile(fTaylor,path,name) 2 | % createTaylorFile - generates an mFile of the Taylor expansion of the 3 | % nonlinear systems object 4 | % 5 | % Syntax: 6 | % createTaylorFile(obj,fTaylor,path,name) 7 | % 8 | % Inputs: 9 | % obj - nonlinear sytsem object 10 | % fTaylor - Taylor expressions 11 | % path - path for file location 12 | % name - name of the corresponding nonlinear system 13 | % 14 | % Outputs: 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 06-December-2016 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | fid = fopen([path '/taylorModel_',name,'.m'],'w'); 33 | fprintf(fid, '%s\n\n', ['function f=taylorModel_',name,'(x,u)']); 34 | for k=1:length(fTaylor) 35 | str=['f(',num2str(k),',1)=',char(fTaylor(k,1)),';']; 36 | %generate left and right brackets 37 | str=strrep(str,'L','('); 38 | str=strrep(str,'R',')'); 39 | 40 | %write in file 41 | fprintf(fid, '%s\n', str); 42 | end 43 | 44 | %close file 45 | fclose(fid); 46 | 47 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSys/private/errorEval.m: -------------------------------------------------------------------------------- 1 | function [perfInd] = errorEval(IHerrorActual,IHerrorAssume) 2 | % errorEval - computes performance index of the linearization error 3 | % 4 | % Syntax: 5 | % [perfInd] = errorEval(IHerrorActual,IHerrorAssume) 6 | % 7 | % Inputs: 8 | % IHerrorActual - cell array of actual linearizatuion errors 9 | % IHerrorAssume - assumed linearization error 10 | % 11 | % Outputs: 12 | % perfInd - performance index 13 | % 14 | % Example: 15 | % Text for example... 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: 22 | 23 | % Author: Matthias Althoff 24 | % Written: 15-January-2008 25 | % Last update: --- 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | 31 | %compute performance index 32 | perfInd=max(edgeLength(IHerrorActual)./edgeLength(IHerrorAssume)); 33 | 34 | 35 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSysDT/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays a nonlinearSysDT object 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - nonlinearSysDT object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff, Niklas Kochdumper 22 | % Written: 27-October-2011 23 | % Last update: 29-January-2018 (NK) 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | disp('-----------------------------------'); 29 | 30 | %display parent object 31 | display@contDynamics(obj); 32 | 33 | %display type 34 | disp('type: Nonlinear time discrete system'); 35 | 36 | %display state space equations 37 | %generate symbolic states 38 | for i=1:obj.dim 39 | command=['syms x',num2str(i)]; 40 | eval(command); 41 | command=['x(',num2str(i),')=x',num2str(i),';']; 42 | eval(command); 43 | end 44 | %generate symbolic inputs 45 | for i=1:obj.nrOfInputs 46 | command=['syms u',num2str(i)]; 47 | eval(command); 48 | command=['u(',num2str(i),')=u',num2str(i),';']; 49 | eval(command); 50 | end 51 | 52 | dx=obj.mFile(x,u) 53 | 54 | disp('-----------------------------------'); 55 | 56 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contDynamics/@nonlinearSysDT/linReach.m: -------------------------------------------------------------------------------- 1 | function Rtp = linReach(obj,Rinit,options) 2 | % linReach - computes the reachable set after linearization 3 | % 4 | % Syntax: 5 | % [Rtp] = linReach(obj,Rinit,options) 6 | % 7 | % Inputs: 8 | % obj - nonlinearSysDT system object 9 | % Rinit - initial reachable set 10 | % options - options struct 11 | % 12 | % Outputs: 13 | % Rtp - resulting reachable set 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: 22 | 23 | % Author: Matthias Althoff, Niklas Kochdumper 24 | % Written: 21-August-2012 25 | % Last update: 29-January-2018 (NK) 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % linearize nonlinear system 31 | [obj,A_lin,U] = linearize(obj,Rinit,options); 32 | 33 | %translate Rinit by linearization point 34 | Rdelta = Rinit + (-obj.linError.p.x); 35 | 36 | % compute reachable set of linearized system 37 | Rtp = A_lin*Rdelta + U; 38 | 39 | % obtain linearization error 40 | if options.tensorOrder > 2 41 | Verror = linError_thirdOrder(obj, options, Rdelta); 42 | else 43 | Verror = linError_mixed_noInt(obj, options, Rdelta); 44 | end 45 | 46 | 47 | %add interval of actual error 48 | Rtp=Rtp+Verror; 49 | 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/display.m: -------------------------------------------------------------------------------- 1 | function display( obj ) 2 | % display - Displays the center, generators and constrains of a c-zonotope 3 | % 4 | % Syntax: 5 | % display( obj ) 6 | % 7 | % Inputs: 8 | % obj - c-zonotope object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % Z=contZonotope(rand(2,6)); 15 | % display(Z); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Dmitry Grebenyuk 24 | % Written: 20-December-2017 25 | % Last update: --- 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | name = [inputname(1), ' = ']; 31 | disp(name) 32 | 33 | display@zonotope(obj) 34 | 35 | %display constraints 36 | disp('A: '); 37 | disp(obj.A); 38 | 39 | disp('b: '); 40 | disp(obj.b); 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/mptPolytope.m: -------------------------------------------------------------------------------- 1 | function res = mptPolytope(obj) 2 | % mptPolytope - convert a constrained zonotope object to a mptPolytope 3 | % 4 | % Syntax: 5 | % res = mptPolytope(obj) 6 | % 7 | % Inputs: 8 | % obj - c-zonotope object 9 | % 10 | % Outputs: 11 | % res - mptPolytope object 12 | % 13 | % Example: 14 | % Z = [0 1 0 1;0 1 2 -1]; 15 | % A = [-2 1 -1]; 16 | % b = 2; 17 | % cZono = conZonotope(Z,A,b); 18 | % poly = mptPolytope(cZono); 19 | % 20 | % hold on 21 | % plotFilled(cZono,[1,2],'r','EdgeColor','none') 22 | % plot(poly,[1,2],'g'); 23 | % 24 | % Other m-files required: none 25 | % Subfunctions: none 26 | % MAT-files required: none 27 | % 28 | % See also: none 29 | 30 | % Author: Niklas Kochdumper 31 | % Written: 13-May-2018 32 | % Last update: --- 33 | % Last revision:--- 34 | 35 | %------------- BEGIN CODE -------------- 36 | 37 | % extract vertices of the constrained zonotope 38 | v = vertices(obj); 39 | V = get(v,'V'); 40 | 41 | % construct MPTpolytope 42 | res = mptPolytope(V'); 43 | 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/mtimes.m: -------------------------------------------------------------------------------- 1 | function [cZ] = mtimes(factor1,factor2) 2 | % mtimes - Overloaded '.*' operator for the multiplication of a matrix or an 3 | % interval matrix with a constrained zonotope 4 | % 5 | % Syntax: 6 | % [cZ] = times(matrix,cZ) 7 | % 8 | % Inputs: 9 | % matrix - numerical or interval matrix 10 | % cZ - conZonotope object 11 | % 12 | % Outputs: 13 | % cZ - constrained zonotpe after multiplication with a matrix 14 | % 15 | % Example: 16 | % Z = [0 1 0 1;0 1 2 -1]; 17 | % A = [-2 1 -1]; 18 | % b = 2; 19 | % cZono = conZonotope(Z,A,b); 20 | % cMul = [3 1;2 4] * cZono; 21 | % 22 | % hold on 23 | % plot(cZono,[1,2],'r'); 24 | % plot(cMul,[1,2],'b'); 25 | % 26 | % Other m-files required: none 27 | % Subfunctions: none 28 | % MAT-files required: none 29 | % 30 | % See also: plus 31 | 32 | % Author: Niklas Kochdumper 33 | % Written: 15-May-2018 34 | % Last update: --- 35 | % Last revision:--- 36 | 37 | %------------- BEGIN CODE -------------- 38 | 39 | % Call superclass method 40 | if ~isnumeric(factor1) 41 | error('conZontope/mtimes: operation not implemented yet!') 42 | else 43 | cZ = mtimes@zonotope(factor1,factor2); 44 | end 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/private/removeZeroConstraints.m: -------------------------------------------------------------------------------- 1 | function obj = removeZeroConstraints(obj) 2 | % removeZeroConstraints - remove the trivial constraint [0 0 .. 0]*ksi = 0 3 | % 4 | % Syntax: 5 | % obj = removeZeroConstraints(obj) 6 | % 7 | % Inputs: 8 | % obj - c-zonotope object 9 | % 10 | % Outputs: 11 | % obj - c-zonotope object without trivial constraints 12 | % 13 | % Other m-files required: none 14 | % Subfunctions: none 15 | % MAT-files required: none 16 | % 17 | % See also: none 18 | 19 | % Author: Niklas Kochdumper 20 | % Written: 29-May-2018 21 | % Last update: --- 22 | % Last revision:--- 23 | 24 | %------------- BEGIN CODE -------------- 25 | 26 | 27 | % Remove the trivial constraint [0 0 .. 0]*ksi = 0 28 | 29 | % select all trivial constraints 30 | temp = all(obj.A==0,2); 31 | ind = find(temp == 1); 32 | obj.A(ind,:) = []; 33 | 34 | % check if all eliminated constraints are satisfiable 35 | if any(obj.b(ind)) 36 | error('Unsatisfiable constraint [0 0 ...0]*x = c !'); 37 | end 38 | 39 | obj.b(ind) = []; 40 | 41 | end 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/project.m: -------------------------------------------------------------------------------- 1 | function obj = project(obj,dim) 2 | % project - project a constrained zonotope object to a subspace 3 | % 4 | % Syntax: 5 | % obj = project(obj,dim) 6 | % 7 | % Inputs: 8 | % obj - constrained zonotope object 9 | % dim - dimensions of the projection 10 | % 11 | % Outputs: 12 | % 13 | % Example: 14 | % Z = [0 1 0 1 0;0 1 2 -1 0;0 0 0 0 1]; 15 | % A = [-2 1 -1 0]; 16 | % b = 2; 17 | % cZono = conZonotope(Z,A,b); 18 | % projZono = project(cZono,[1,2]); 19 | % 20 | % 21 | % Other m-files required: none 22 | % Subfunctions: none 23 | % MAT-files required: none 24 | % 25 | % See also: --- 26 | 27 | % Author: Niklas Kochdumper 28 | % Written: 11-May-2018 29 | % Last update: --- 30 | % Last revision:--- 31 | 32 | %------------- BEGIN CODE -------------- 33 | 34 | obj.Z = obj.Z(dim,:); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@conZonotope/zonotope.m: -------------------------------------------------------------------------------- 1 | function res = zonotope(obj) 2 | % zonotope - over-approximates a constrained zonotope with a zonotope 3 | % 4 | % Syntax: 5 | % res = zonotope(obj) 6 | % 7 | % Inputs: 8 | % obj - c-zonotope object 9 | % 10 | % Outputs: 11 | % res - zonotope object 12 | % 13 | % Example: 14 | % Z = [0 1 0 1;0 1 2 -1]; 15 | % A = [-2 1 -1]; 16 | % b = 2; 17 | % cZono = conZonotope(Z,A,b); 18 | % zono = zonotope(cZono); 19 | % 20 | % hold on 21 | % plotFilled(cZono,[1,2],'r','EdgeColor','none') 22 | % plot(zono,[1,2],'b'); 23 | % 24 | % Other m-files required: none 25 | % Subfunctions: none 26 | % MAT-files required: none 27 | % 28 | % See also: none 29 | 30 | % Author: Niklas Kochdumper 31 | % Written: 13-May-2018 32 | % Last update: --- 33 | % Last revision:--- 34 | 35 | %------------- BEGIN CODE -------------- 36 | 37 | % remove all constraints of the constrained zonotope 38 | ng = floor((size(obj.Z,2)-1)/size(obj.Z,1)) + 1; 39 | 40 | obj = reduce(obj,'girard',ng,0); 41 | 42 | % construct the resulting zonotope object 43 | res = zonotope(obj.Z); 44 | 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@contSet/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays the id and dimension of a continuous set 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - contSet object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % S=contSet(2); 15 | % display(S); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 02-May-2007 25 | % Last update: --- 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %display id 31 | disp(['id: ', num2str(obj.id)]); 32 | 33 | %display dimension 34 | disp(['dimension: ', num2str(obj.dimension)]); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@generalSet/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays the C matrix and d vector of a pplPolytope 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - pplPolytope object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 19-October-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %display dimension 30 | disp('dimension: '); 31 | disp(obj.dim); 32 | 33 | %display center 34 | disp('C: '); 35 | disp(obj.C); 36 | 37 | %display generators 38 | disp('d: '); 39 | disp(obj.d); 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@generalSet/generalSet.m: -------------------------------------------------------------------------------- 1 | classdef generalSet 2 | % generalSet class 3 | % 4 | % Syntax: 5 | % object constructor: obj = generalSet(varargin) 6 | % copy constructor: obj = otherObj 7 | % 8 | % Inputs: 9 | % input1 - function handle 10 | % input2 - variable set 11 | % 12 | % Outputs: 13 | % obj - generated object 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: interval, polytope 20 | 21 | % Author: Matthias Althoff 22 | % Written: 04-November-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | properties (SetAccess = private, GetAccess = public) 29 | fct_handle = []; 30 | variable_set = []; 31 | segmentation = []; 32 | samples = []; 33 | end 34 | 35 | methods 36 | %class constructor 37 | function obj = generalSet(handle,contSet,seg) 38 | obj.fct_handle = handle; 39 | obj.variable_set = contSet; 40 | obj.segmentation = seg; 41 | end 42 | 43 | %methods in seperate files 44 | Z = parallelotope(obj) 45 | 46 | %display functions 47 | plot(varargin) 48 | display(obj) 49 | end 50 | end 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@generalSet/parallelotope.m: -------------------------------------------------------------------------------- 1 | function [Z] = parallelotope(varargin) 2 | % parallelotope - Takes sampled values to estimate an enclosure and uses 3 | % optimization techniques to guarantee the enclosure 4 | % 5 | % Syntax: 6 | % [Z] = parallelotope(obj) 7 | % 8 | % Inputs: 9 | % P - generalSet object 10 | % 11 | % Outputs: 12 | % Z - collection of parallelotopes enclosing the general set 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: --- 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 04-November-2010 24 | % Last update: 25-July-2016 (intervalhull replaced by interval) 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | 30 | %overapproximate variable region by an interval hull 31 | if ~isa(obj.variable_set, 'interval') 32 | obj.variable_set = interval(obj.variable_set); 33 | end 34 | 35 | %divide variable set according to the segmentation vector; specify 36 | %partition 37 | cells = partition(get(obj.variable_set,'intervals'),obj.segmentation); 38 | 39 | %get cells of partition 40 | for i=1:prod(obj.segmentation) 41 | intervalTmp = cellIntervals(cells,cellNr); 42 | IH{i} = interval(intervalTmp(:,1), intervalTmp(:,2)); 43 | end 44 | 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/commonPoint.m: -------------------------------------------------------------------------------- 1 | function res = commonPoint(obj, h_other) 2 | % commonPoint - find arbitrary common point of two halfspaces 3 | % 4 | % Syntax: 5 | % res = commonPoint(obj, h_other) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % h_other - other halfspace object 10 | % 11 | % Outputs: 12 | % res - common point 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 27-August-2013 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %dimension 30 | dim = length(obj.c); 31 | 32 | %unit vector as initial point 33 | x_0 = [1; zeros(dim-1,1)]; 34 | 35 | %first direction multiplier alpha_1 36 | alpha_1 = obj.d - obj.c.'*x_0/(obj.c.'*obj.c); 37 | 38 | %first projection 39 | x_1 = x_0 + alpha_1*obj.c; 40 | 41 | %new direction 42 | n_2 = h_other.c - h_other.c.'*obj.c/norm(obj.c)^2*obj.c; 43 | 44 | %second direction multiplier alpha_2 45 | alpha_2 = h_other.d - h_other.c.'*x_1/(h_other.c.'*n_2); 46 | 47 | %second projection 48 | res = x_1 + alpha_2*n_2; 49 | 50 | 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays the normal vector and distance to the origin of a 3 | % halfspace 4 | % 5 | % Syntax: 6 | % display(h) 7 | % 8 | % Inputs: 9 | % h - halfspace object 10 | % 11 | % Outputs: 12 | % --- 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 06-June-2011 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %display dimension, generators 30 | disp('dimension: '); 31 | disp(length(obj.c)); 32 | 33 | %display normal vector 34 | disp('normal vector: '); 35 | disp(obj.c); 36 | 37 | %display distance to origin 38 | disp('distance to origin: '); 39 | disp(obj.d); 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/eventFcn.m: -------------------------------------------------------------------------------- 1 | function [value,isterminal,direction] = eventFcn(obj,x,direction) 2 | % eventFcn - Returns the results of an event function that detects if a 3 | % trajectory enters or leaves a halfspace; 4 | % this event function is needed, e.g. for matlab ode-solvers 5 | % 6 | % Syntax: 7 | % [value,isterminal,direction] = eventFcn(obj,x,direction) 8 | % 9 | % Inputs: 10 | % obj - halfspace object 11 | % x - system state 12 | % direction - event if the state enters or leaves the interval hull? 13 | % 14 | % Outputs: 15 | % value - value of the event function 16 | % isterminal - specifies if the simulation stops if an event turns zero 17 | % direction - specifies if the value of the event function has to 18 | % turn from negative to positive or the other way round 19 | % 20 | % Example: 21 | % --- 22 | % 23 | % Other m-files required: none 24 | % Subfunctions: none 25 | % MAT-files required: none 26 | % 27 | % See also: --- 28 | 29 | % Author: Matthias Althoff 30 | % Written: 06-June-2011 31 | % Last update: --- 32 | % Last revision:--- 33 | 34 | %------------- BEGIN CODE -------------- 35 | 36 | %compute value to determine zero crossing 37 | value = obj.c'*x-obj.d; 38 | % Always stop the integration when event detected 39 | isterminal = 1; 40 | % direction is fed through and not changed 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/get.m: -------------------------------------------------------------------------------- 1 | function val = get(obj, propName) 2 | % get - Retrieve object data from obj 3 | % 4 | % Syntax: 5 | % val = get(obj, propName) 6 | % 7 | % Properties: 8 | % equations - number of halfspace equations 9 | 10 | % Author: Matthias Althoff 11 | % Written: 06-June-2011 12 | % Last update: --- 13 | % Last revision:--- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | switch propName 18 | case 'c' 19 | val = obj.c; 20 | case 'd' 21 | val = obj.d; 22 | case 'equations' 23 | val = 1; %return number of halfspace equations 24 | otherwise 25 | error([propName,' is not a valid asset property']) 26 | end 27 | 28 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/in.m: -------------------------------------------------------------------------------- 1 | function [result] = in(obj1,obj2) 2 | % in - determines if elements of a zonotope obj2 are in a halfspace 3 | % obj1 in an overapproximate way 4 | % 5 | % Syntax: 6 | % [result] = in(obj1,obj2) 7 | % 8 | % Inputs: 9 | % obj1 - halfspace object 10 | % obj2 - zonotope object 11 | % 12 | % Outputs: 13 | % result - 1/0 if zonotope is in, or not 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 14-June-2016 26 | % Last update: 27-July-2016 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %the zonotope penetrates the halfspace if part of the projection is 32 | %negative 33 | 34 | if isa(obj2,'conZonotope') 35 | 36 | b = boundDir(obj2,obj1.c,'upper'); 37 | result = (b < obj1.d); 38 | 39 | elseif isa(obj2,'zonotope') 40 | % projection 41 | projZ = obj1.c'*obj2 - obj1.d; 42 | projIH = interval(projZ); 43 | 44 | % minimum negative 45 | result = (infimum(projIH) <= 0); 46 | 47 | else 48 | error('Operation not implemented yet!'); 49 | end 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/mtimes.m: -------------------------------------------------------------------------------- 1 | function [h] = mtimes(factor,h) 2 | % mtimes - Overloaded '*' operator for the multiplication of a matrix with 3 | % a halfspace 4 | % 5 | % Syntax: 6 | % [h] = mtimes(factor,h) 7 | % 8 | % Inputs: 9 | % factor - numerical matrix 10 | % h - halfspace object 11 | % 12 | % Outputs: 13 | % h - halfspace object 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: plus 23 | 24 | % Author: Matthias Althoff 25 | % Written: 26-August-2013 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %assume that factor is an invertible matrix 32 | invMat = inv(factor); 33 | h.c = invMat.'*h.c; 34 | 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/plot.m: -------------------------------------------------------------------------------- 1 | function plot(varargin) 2 | % plot - Plots 2-dimensional projection of a halfspace 3 | % 4 | % Syntax: 5 | % plot(obj,dimensions,type) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % dimensions - dimensions that should be projected (optional); assume 10 | % that other entries of the normal vector are zeros 11 | % type - plot type 12 | % 13 | % 14 | % Outputs: 15 | % none 16 | % 17 | % Example: 18 | % --- 19 | % 20 | % Other m-files required: none 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: none 25 | 26 | % Author: Matthias Althoff 27 | % Written: 23-August-2013 28 | % Last update: --- 29 | % Last revision:--- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %If only one argument is passed 34 | if nargin==1 35 | obj=varargin{1}; 36 | dimensions=[1,2]; 37 | type='frame'; 38 | 39 | %If two arguments are passed 40 | elseif nargin==2 41 | obj=varargin{1}; 42 | dimensions=varargin{2}; 43 | type='frame'; 44 | 45 | %If too many arguments are passed 46 | elseif nargin==3 47 | obj=varargin{1}; 48 | dimensions=varargin{2}; 49 | type=varargin{3}; 50 | end 51 | 52 | % compute slope 53 | m = -obj.c(dimensions(1))/obj.c(dimensions(2)); 54 | b = obj.d/obj.c(dimensions(2)); 55 | 56 | %plot reference line 57 | refline(m,b); 58 | 59 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/plus.m: -------------------------------------------------------------------------------- 1 | function [h] = plus(summand1,summand2) 2 | % plus - Overloaded '+' operator for the addition of a vector with a 3 | % halfspace 4 | % 5 | % Syntax: 6 | % [h] = plus(summand1,summand2) 7 | % 8 | % Inputs: 9 | % summand1 - halfspace object or numerical vector 10 | % summand2 - halfspace object or numerical vector 11 | % 12 | % Outputs: 13 | % h - halfspace object 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: mtimes 23 | 24 | % Author: Matthias Althoff 25 | % Written: 28-August-2013 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %Find a halfspace object 32 | %Is summand1 a halfspace? 33 | if strcmp('halfspace',class(summand1)) 34 | %initialize resulting zonotope 35 | h=summand1; 36 | %initialize other summand 37 | summand=summand2; 38 | %Is summand2 a zonotope? 39 | elseif strcmp('halfspace',class(summand2)) 40 | %initialize resulting zonotope 41 | h=summand2; 42 | %initialize other summand 43 | summand=summand1; 44 | end 45 | 46 | %Is summand a zonotope? 47 | if isnumeric(summand) 48 | %Calculate minkowski sum 49 | h.d = h.d + h.c.'*summand; 50 | else 51 | h = []; 52 | end 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/polytope.m: -------------------------------------------------------------------------------- 1 | function [P]=polytope(obj) 2 | % polytope - Converts an halfspace object to a polytope object 3 | % 4 | % Syntax: 5 | % [P]=polytope(obj) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % 10 | % Outputs: 11 | % P - polytope object 12 | % 13 | % Example: 14 | % hs=halfspace(C,d); 15 | % P=polytope(hs); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Victor Charlent 24 | % Written: 28/06/2016 25 | % Last update: 17-March-2017, Matthias Althoff 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | A = get(obj, 'c')'; 31 | b = get(obj, 'd'); 32 | 33 | P = mptPolytope(A,b); 34 | 35 | end 36 | 37 | 38 | %------------- END OF CODE -------------- 39 | 40 | -------------------------------------------------------------------------------- /contSet/@halfspace/project.m: -------------------------------------------------------------------------------- 1 | function S = project(h, S) 2 | % project - projects a set onto the halfspace 3 | % 4 | % Syntax: 5 | % S = project(h, S) 6 | % 7 | % Inputs: 8 | % h - halfspace object 9 | % S - set to be projected 10 | % 11 | % Outputs: 12 | % S - projected set 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: plus 22 | 23 | % Author: Matthias Althoff 24 | % Written: 04-September-2013 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %obtain dimension 31 | dim = length(h.c); 32 | 33 | %obtain linear map 34 | M = eye(dim) - h.c*h.c.'/(h.c.'*h.c); 35 | n = (h.d*h.c)/(h.c.'*h.c); 36 | 37 | %compute affine map 38 | S = M*S + n; 39 | 40 | 41 | % %create unit vector 42 | % uVec = [1;zeros(dim-1,1)]; 43 | % 44 | % %obtain rotation matrix 45 | % rotMat = rotationMatrix(h, uVec); 46 | % 47 | % %rotate set and halfspace 48 | % S = rotMat*S; 49 | % h = rotMat*h; 50 | % 51 | % %project onto first coordinate 52 | % M = diag([0;ones(dim-1,1)]); 53 | % dist = h.d/norm(h.c); 54 | % S = M*S + [dist;zeros(dim-1,1)]; 55 | % 56 | % %rotate back 57 | % S = rotMat.'*S; 58 | 59 | 60 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/projectHighDim.m: -------------------------------------------------------------------------------- 1 | function res = projectHighDim(obj,N,dim) 2 | % projectHighDim - project a halfspace object to a higher dimensional 3 | % space 4 | % 5 | % Syntax: 6 | % res = projectHighDim(obj,N,dim) 7 | % 8 | % Inputs: 9 | % obj - halfspace object 10 | % N - dimension of the higher dimensional space 11 | % dim - states of the high dimensional space that correspond to the 12 | % states of the low dimensional mptPolytope object 13 | % 14 | % Outputs: 15 | % res - halfspace object in the high dimensional space 16 | % 17 | % Example: 18 | % C = [2.1, 3.4, 5.2]; 19 | % d = 1.7; 20 | % hs = halfspace(C,d); 21 | % 22 | % hsHigh = projectHighDim(hs,10,[1,7,9]) 23 | % 24 | % Other m-files required: none 25 | % Subfunctions: none 26 | % MAT-files required: none 27 | % 28 | % See also: mptPolytope/projectHighDim, interval/projectHighDim 29 | 30 | % Author: Niklas Kochdumper 31 | % Written: 16-July-2018 32 | % Last update: --- 33 | % Last revision:--- 34 | 35 | %------------- BEGIN CODE -------------- 36 | 37 | % initialize variables 38 | C = zeros(N,1); 39 | d = obj.d; 40 | 41 | % insert parameters from the original halfspace object 42 | C(dim) = obj.c; 43 | 44 | % construct the resulting high dimensional halfspace object 45 | res = halfspace(C,d); 46 | 47 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/rotate.m: -------------------------------------------------------------------------------- 1 | function h = rotate(h, newDir, rotPoint) 2 | % rotate - rotates a halfspace around a rotation point rotPoint such that 3 | % the new normal vector is aligned with newDir 4 | % 5 | % Syntax: 6 | % h = rotate(h, newDir, rotPoint) 7 | % 8 | % Inputs: 9 | % h - halfspace object 10 | % newDir - vector pointing in the new direction 11 | % rotPoint - rotation point 12 | % 13 | % Outputs: 14 | % h - halfspace object 15 | % 16 | % Example: 17 | % --- 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: plus 24 | 25 | % Author: Matthias Althoff 26 | % Written: 28-August-2013 27 | % Last update: --- 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %obtain rotation matrix 33 | rotMat = rotationMatrix(h, newDir); 34 | 35 | %translate and rotate halfspace 36 | h = rotMat*(h + (-rotPoint)) + rotPoint; 37 | 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/zonoIn.m: -------------------------------------------------------------------------------- 1 | function res = zonoIn(obj, Z) 2 | % zonoIn - Checks if a zonotope is within a halfspace 3 | % 4 | % Syntax: 5 | % res = zonoIn(obj, Z) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % Z - zonotope object 10 | % 11 | % Outputs: 12 | % res - boolean variable, 1 if in halfspace, 0 otherwise 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 02-September-2013 24 | % Last update: 22-August-2016 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %compute map on normal vector of the halfspace 30 | IH = interval(obj.c' * Z) + (-obj.d); 31 | 32 | %check if interval contains 0 33 | if supremum(IH)<=0 34 | res = 1; 35 | else 36 | res = 0; 37 | end 38 | 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/zonoIntersect.m: -------------------------------------------------------------------------------- 1 | function res = zonoIntersect(obj, Z) 2 | % zonoIntersect - Checks if a zonotope intersects with the halfspace 3 | % 4 | % Syntax: 5 | % zonoIntersect(obj) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 08-August-2011 23 | % Last update: 19-August-2016 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %compute map on normal vector of the halfspace 29 | IH = interval(obj.c' * Z) + (-obj.d); 30 | 31 | %check if interval contains 0 32 | if infimum(IH)<0 && supremum(IH)>=0 33 | res = 1; 34 | else 35 | res = 0; 36 | end 37 | 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@halfspace/zonoPartiallyIn.m: -------------------------------------------------------------------------------- 1 | function res = zonoPartiallyIn(obj, Z) 2 | % zonoIn - Checks if a zonotope is partially within a halfspace 3 | % 4 | % Syntax: 5 | % res = zonoPartiallyIn(obj, Z) 6 | % 7 | % Inputs: 8 | % obj - halfspace object 9 | % Z - zonotope object 10 | % 11 | % Outputs: 12 | % res - boolean variable, 1 if in halfspace, 0 otherwise 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 02-September-2013 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %compute map on normal vector of the halfspace 30 | IH = interval(obj.c' * Z) + (-obj.d); 31 | 32 | %check if interval contains 0 33 | if IH(1,1)<=0 34 | res = 1; 35 | else 36 | res = 0; 37 | end 38 | 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/and.m: -------------------------------------------------------------------------------- 1 | function obj = and(obj,otherObj) 2 | % and - computes intersection of intervals. Overloaded '&' operator for 3 | % intervals 4 | % 5 | % Syntax: 6 | % obj = and(obj,otherObj) 7 | % 8 | % Inputs: 9 | % obj - interval object 10 | % otherObj - interval object 11 | % 12 | % Outputs: 13 | % obj - interval object 14 | % 15 | % Example: 16 | % a = interval([1;-1], [2; 1]); 17 | % b = interval([1.5; -2], [2.5; 0]); 18 | % c = a&b 19 | % 20 | % Other m-files required: none 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: --- 25 | 26 | % Author: Matthias Althoff 27 | % Written: 26-June-2015 28 | % Last update: --- 29 | % Last revision:--- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | 34 | inf = max(obj.inf, otherObj.inf); 35 | sup = min(obj.sup, otherObj.sup); 36 | 37 | if all(all(inf <= sup)) %twice all because of interval matrices 38 | obj.inf = inf; 39 | obj.sup = sup; 40 | else 41 | obj.inf = []; 42 | obj.sup = []; 43 | end 44 | 45 | 46 | 47 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/asinh.m: -------------------------------------------------------------------------------- 1 | function res = asinh(intVal) 2 | % asinh - Overloaded 'asinh()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = asinh(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 12-February-2016 23 | % Last update: 21-February-2016 the matrix case is rewritten (Dmitry Grebenyuk) 24 | % Last revision:--- 25 | 26 | % x_ is x infimum, x-- is x supremum 27 | 28 | % [asinh(x_), asinh(x--)]. 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | 33 | res = interval(); 34 | 35 | res.inf = asinh(intVal.inf); 36 | res.sup = asinh(intVal.sup); 37 | 38 | 39 | 40 | % matrix case 41 | % rand(100, 100) 42 | %time_CORA = 43 | % 0.001107971243036 44 | %time_INTLAB = 45 | % 0.010044490163099 46 | 47 | 48 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/atan.m: -------------------------------------------------------------------------------- 1 | function res = atan(intVal) 2 | % atan - Overloaded 'atan()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = atan(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 05-February-2016 23 | % Last update: 21-February-2016 the matrix case is rewritten (Dmitry Grebenyuk) 24 | % Last revision:--- 25 | 26 | % x_ is x infimum, x-- is x supremum 27 | 28 | % [atan(x_), atan(x--)]. 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | res = interval(); 33 | 34 | res.inf = atan(intVal.inf); 35 | res.sup = atan(intVal.sup); 36 | 37 | % matrix case 38 | % rand(100, 100) 39 | %time_CORA = 40 | % 3.998627914054368e-004 41 | %time_INTLAB = 42 | % 0.004031745868841 43 | 44 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/ctranspose.m: -------------------------------------------------------------------------------- 1 | function intVal = ctranspose(intVal) 2 | % ctranspose - Overloaded ''' operator for single operand 3 | % 4 | % Syntax: 5 | % intVal = ctranspose(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % intVal - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Dmitry Grebenyuk 22 | % Written: 14-August-2016 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %infimum 29 | intVal.inf = intVal.inf.'; 30 | 31 | %supremum 32 | intVal.sup = intVal.sup.'; 33 | 34 | %------------- END OF CODE -------------- 35 | end 36 | -------------------------------------------------------------------------------- /contSet/@interval/diag.m: -------------------------------------------------------------------------------- 1 | function res = diag(obj) 2 | % diag - Create diagonal matrix or get diagonal elements of matrix 3 | % 4 | % Syntax: 5 | % res = diag(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % res - diagonal matrix or diagonal elements of matrix 12 | % 13 | % Example: 14 | % I = interval([1 2; -1 1], [2 3; 0 10]); 15 | % d = diag(I); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: 22 | 23 | % Author: Matthias Althoff 24 | % Written: 02-November-2017 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % obtain result 31 | res = interval(diag(obj.inf), diag(obj.sup)); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/display.m: -------------------------------------------------------------------------------- 1 | function display(obj) 2 | % display - Displays the left and right limit of the interval 3 | % 4 | % Syntax: 5 | % display(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % a = interval(2,3); 15 | % display(a); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 19-June-2015 25 | % Last update: 22-February-2016 now it displays the name (Dmitry Grebenyuk) 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %determine size of interval 31 | [rows, columns] = size(obj.inf); 32 | 33 | name = [inputname(1), ' = ']; 34 | disp(name) 35 | for i = 1:rows 36 | str = []; 37 | % display one row 38 | for j = 1:columns 39 | newStr = sprintf('[%0.5f,%0.5f]',obj.inf(i,j),obj.sup(i,j)); 40 | str = [str,' ',newStr]; 41 | end 42 | disp(str); 43 | end 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/enclosingRadius.m: -------------------------------------------------------------------------------- 1 | function r = enclosingRadius(obj) 2 | % enclosingRadius - Computes radius of enclosing hyperball of an interval 3 | % 4 | % Syntax: 5 | % r = enclosingRadius(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % r - radius of enclosing hyperball 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 22-July-2016 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %compte interval radius 30 | intervalRadius = rad(obj); 31 | 32 | %compute radius 33 | r = sqrt(sum(intervalRadius.^2)); 34 | 35 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/enlarge.m: -------------------------------------------------------------------------------- 1 | function obj = enlarge(obj,factor) 2 | % enlarge - Enlarges an interval object around its center 3 | % 4 | % Syntax: 5 | % obj = enlarge(obj,factor) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % factor - enlarging factor (scalar or column vector) 10 | % 11 | % Outputs: 12 | % obj - enlarged interval object 13 | % 14 | % Example: 15 | % I = interval([1 2; -1 1]); 16 | % I = enlatge(I,2); 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: 23 | 24 | % Author: Matthias Althoff 25 | % Written: 22-July-2016 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %get center and radius 32 | c = 0.5*(obj.inf + obj.sup); 33 | r = 0.5*(obj.sup - obj.inf); 34 | 35 | %enlarged intervals 36 | obj.inf = c-r.*factor; 37 | obj.sup = c+r.*factor; 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/eq.m: -------------------------------------------------------------------------------- 1 | function res = eq(obj1,obj2) 2 | % eq - Overloads the == operator; here: Are both intervals equal? 3 | % 4 | % Syntax: 5 | % res = eq(obj1,obj2) 6 | % 7 | % Inputs: 8 | % obj1 - interval object 9 | % obj2 - another interval object 10 | % 11 | % Outputs: 12 | % res - Boolean variable: 1 if obj1 is subset or equal to obj2 13 | % 14 | % Example: 15 | % I1 = interval([1; -1], [2; 1]); 16 | % I2 = interval([1; -2], [2; 2]); 17 | % I1 == I2 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: --- 24 | 25 | % Author: Matthias Althoff 26 | % Written: 05-August-2016 27 | % Last update: --- 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %all left borders of obj1 bigger than obj2? 33 | leftResult = all(all(infimum(obj1) == infimum(obj2))); 34 | 35 | %all right borders of obj1 smaller than obj2? 36 | rightResult = all(all(supremum(obj1) == supremum(obj2))); 37 | 38 | %left and right interval test must be true 39 | res = leftResult & rightResult; 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/exp.m: -------------------------------------------------------------------------------- 1 | function res = exp(intVal) 2 | % exp - Overloaded 'exp()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = exp(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: interval 20 | 21 | % Author: Matthias Althoff 22 | % Written: 25-June-2015 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | % x_ is x infimum, x-- is x supremum 27 | 28 | % [exp(x_), exp(x--)]. 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %exponential function is monotonic 33 | res = interval(exp(intVal.inf), exp(intVal.sup)); 34 | 35 | % matrix case 36 | % rand(100, 100) 37 | %time_CORA = 38 | % 6.127413732464556e-004 39 | %time_INTLAB = 40 | % 0.004009680390026 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/get.m: -------------------------------------------------------------------------------- 1 | function val = get(obj, propName) 2 | % get - Retrieve object data from obj 3 | % 4 | % Syntax: 5 | % val = get(obj, propName) 6 | % 7 | % Properties: 8 | % equations - number of halfspace equations 9 | 10 | % Author: Niklas Kochdumper 11 | % Written: 16-May-2018 12 | % Last update: --- 13 | % Last revision:--- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | switch propName 18 | case 'equations' 19 | % return number of inequatlity constraints describing the interval 20 | val = 2*length(obj); 21 | otherwise 22 | error([propName,' is not a valid asset property']) 23 | end 24 | 25 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/horzcat.m: -------------------------------------------------------------------------------- 1 | function obj = horzcat(varargin) 2 | % horzcat - Overloads the operator for horizontal concatenation, e.g. 3 | % a = [b,c,d]; 4 | % 5 | % Syntax: 6 | % obj = horzcat(varargin) 7 | % 8 | % Inputs: 9 | % varargin - list of interval objects 10 | % 11 | % Outputs: 12 | % obj - interval object 13 | % 14 | % Example: 15 | % a=interval(-1, 1); 16 | % b=interval(1, 2); 17 | % c = [a,b]; 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 26-June-2015 27 | % Last update: 08-August-2016 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | obj = varargin{1}; 33 | 34 | %if object is not an interval 35 | if ~isa(obj,'interval') 36 | tmp = obj; 37 | obj = interval(); 38 | obj.inf = tmp; 39 | obj.sup = tmp; 40 | end 41 | 42 | for i = 2:nargin 43 | %check if concatented variable is an interval 44 | if isa(varargin{i},'interval') 45 | obj.inf = [obj.inf, varargin{i}.inf]; 46 | obj.sup = [obj.sup, varargin{i}.sup]; 47 | else 48 | obj.inf = [obj.inf, varargin{i}]; 49 | obj.sup = [obj.sup, varargin{i}]; 50 | end 51 | end 52 | 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/hull.m: -------------------------------------------------------------------------------- 1 | function obj = hull(intVal1, intVal2) 2 | % hull - The union of two intervals 3 | % a = hull(b, c); 4 | % 5 | % Syntax: 6 | % obj = hull(intVal1, intVal2) 7 | % 8 | % Inputs: 9 | % intVal1, intVal2 - intervals 10 | % 11 | % Outputs: 12 | % obj - an interval object 13 | % 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Dmitry Grebenyuk 22 | % Written: 20-April-2016 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | obj = intVal1; 29 | 30 | obj.inf = min(intVal1.inf, intVal2.inf); 31 | obj.sup = max(intVal1.sup, intVal2.sup); 32 | 33 | 34 | %------------- END OF CODE -------------- 35 | -------------------------------------------------------------------------------- /contSet/@interval/in.m: -------------------------------------------------------------------------------- 1 | function [result] = in(obj1,obj2) 2 | % in - determines if elements of a zonotope obj2 are in an interval 3 | % 4 | % Syntax: 5 | % [result] = in(obj1,obj2) 6 | % 7 | % Inputs: 8 | % obj1 - interval object 9 | % obj2 - zonotope object 10 | % 11 | % Outputs: 12 | % result - 1/0 if zonotope is in, or not 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Niklas Kochdumper 24 | % Written: 16-May-2018 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % obtain constraints C*x= infimum(obj2)); 35 | 36 | %all right borders of obj1 smaller than obj2? 37 | rightResult = all(supremum(obj1) <= supremum(obj2)); 38 | 39 | %left and right interval test must be true 40 | res = leftResult & rightResult; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/length.m: -------------------------------------------------------------------------------- 1 | function L = length(obj) 2 | % length - Overloads the opertor that returns the length of the longest 3 | % array dimension 4 | % 5 | % Syntax: 6 | % L = length(obj) 7 | % 8 | % Inputs: 9 | % obj - interval object 10 | % 11 | % Outputs: 12 | % L - length of the largest array dimension in X. 13 | % 14 | % Example: 15 | % a=interval([-1 1], [1 2]); 16 | % length(a) 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 18-November-2015 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %returns length of infimum 32 | L = length(obj.inf); 33 | 34 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/lt.m: -------------------------------------------------------------------------------- 1 | function res = lt(obj1,obj2) 2 | % lt - Overloads the < operator; here: Is one interval the subset of 3 | % another interval? 4 | % 5 | % Syntax: 6 | % res = lt(obj1,obj2) 7 | % 8 | % Inputs: 9 | % obj1 - interval object 10 | % obj2 - another interval object 11 | % 12 | % Outputs: 13 | % res - Boolean variable: 1 if obj1 is subset of obj2 14 | % 15 | % Example: 16 | % I1 = interval([1; -1], [2; 1]); 17 | % I2 = interval([1; -2], [2; 2]); 18 | % I1 < I2 19 | % 20 | % Other m-files required: none 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: --- 25 | 26 | % Author: Matthias Althoff 27 | % Written: 22-July-2016 28 | % Last update: --- 29 | % Last revision:--- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %all left borders of obj1 bigger than obj2? 34 | leftResult = all(infimum(obj1) > infimum(obj2)); 35 | 36 | %all right borders of obj1 smaller than obj2? 37 | rightResult = all(supremum(obj1) < supremum(obj2)); 38 | 39 | %left and right interval test must be true 40 | res = leftResult & rightResult; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/mid.m: -------------------------------------------------------------------------------- 1 | function res = mid(obj) 2 | % mid - returns the center of an interval 3 | % 4 | % Syntax: 5 | % res = mid(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % res - numerical value 12 | % 13 | % Example: 14 | % a = interval([-1 1], [1 2]); 15 | % b = mid(a) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 26-June-2015 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | res = 0.5*(obj.inf + obj.sup); 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/minus.m: -------------------------------------------------------------------------------- 1 | function res = minus(minuend,subtrahend) 2 | % plus - Overloaded '-' operator for intervals 3 | % 4 | % Syntax: 5 | % res = plus(summand1,summand2) 6 | % 7 | % Inputs: 8 | % minuend - interval or numerical value 9 | % subtrahend - interval or numerical value 10 | % 11 | % Outputs: 12 | % res - interval 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: mtimes 21 | 22 | % Author: Matthias Althoff 23 | % Written: 25-June-2015 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %init 30 | res = interval(); 31 | 32 | %Find an interval object 33 | %Is minuend an interval? 34 | if isa(minuend,'interval') 35 | %Is subtrahend an interval? 36 | if isa(subtrahend,'interval') 37 | %Calculate infimum and supremum 38 | res.inf = minuend.inf - subtrahend.sup; 39 | res.sup = minuend.sup - subtrahend.inf; 40 | else 41 | %Calculate infimum and supremum 42 | res.inf = minuend.inf - subtrahend; 43 | res.sup = minuend.sup - subtrahend; 44 | end 45 | else 46 | %minuend must be a particular value 47 | %Calculate infimum and supremum 48 | res.inf = minuend - subtrahend.sup; 49 | res.sup = minuend - subtrahend.inf; 50 | end 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/mrdivide.m: -------------------------------------------------------------------------------- 1 | function res = mrdivide(numerator,denominator) 2 | % mrdivide - Overloaded matrix division '/' operator for intervals 3 | % 4 | % Syntax: 5 | % res = mrdivide(numerator, denominator) 6 | % 7 | % Inputs: 8 | % numerator, denominator - interval objects 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 25-June-2015 23 | % Last update: 01-July-2015 24 | % 10-September-2015 25 | % 13-March-2016 Speed improvement 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % to initiate res 31 | res = interval(); 32 | 33 | if isscalar(denominator) 34 | res = numerator ./ denominator; 35 | else 36 | error('The function of mrdivide works only for an interval / a number case.') 37 | end 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/ne.m: -------------------------------------------------------------------------------- 1 | function res = ne( int1, int2 ) 2 | % ne( int1, int2 ) - ' ~= ' overloading 3 | % 4 | % Syntax: 5 | % res = ne( int1, int2 ) 6 | % 7 | % Inputs: 8 | % int1, int2 - intervals 9 | % 10 | % Outputs: 11 | % res - boolean 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: interval 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % 20 | % Author: Dmitry Grebenyuk 21 | % Written: 06-August-2017 22 | % Last update: --- 23 | % Last revision:--- 24 | 25 | %------------- BEGIN CODE -------------- 26 | 27 | res = any(infimum(int1) ~= infimum(int2)) ||... 28 | any(supremum(int1) ~= supremum(int2)); 29 | 30 | end 31 | 32 | %----------------- END ----------------- -------------------------------------------------------------------------------- /contSet/@interval/plot.m: -------------------------------------------------------------------------------- 1 | function h=plot(varargin) 2 | % plot - Plots 2-dimensional projection of an interval 3 | % 4 | % Syntax: 5 | % plot(obj,dimensions) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % dimensions - dimensions that should be projected (optional) 10 | % type - plot type 11 | % 12 | % Outputs: 13 | % none 14 | % 15 | % Example: 16 | % I = interval([1; -1], [2; 1]); 17 | % plot(I) 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 31-July-2016 27 | % Last update: --- 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %convert to zonotope 33 | Z = zonotope(varargin{1}); 34 | 35 | %plot zonotope 36 | if nargin == 1 37 | h= plot(Z); 38 | else 39 | h= plot(Z,varargin{2:end}); 40 | end 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/plotFilled.m: -------------------------------------------------------------------------------- 1 | function plotFilled(varargin) 2 | % plotFilled - Plots 2-dimensional projection of an interval which is 3 | % colored inside 4 | % 5 | % Syntax: 6 | % plotFilled(I) plots the interval I for the first two dimensions 7 | % plotFilled(I,dims) plots the interval I for the two dimensions i,j: "dims=[i,j]" and returns handle to line-plot object 8 | % plotFilled(I,dims,'Color','red',...) adds the standard plotting preferences 9 | % 10 | % Inputs: 11 | % I - interval object 12 | % dimensions - dimensions that should be projected (optional) 13 | % type - plot type 14 | % 15 | % Outputs: 16 | % none 17 | % 18 | % Example: 19 | % I = interval([1; -1], [2; 1]); 20 | % plot(I) 21 | % 22 | % Other m-files required: none 23 | % Subfunctions: none 24 | % MAT-files required: none 25 | % 26 | % See also: none 27 | 28 | % Author: Matthias Althoff 29 | % Written: 05-August-2016 30 | % Last update: --- 31 | % Last revision:--- 32 | 33 | %------------- BEGIN CODE -------------- 34 | 35 | %convert to zonotope 36 | Z = zonotope(varargin{1}); 37 | 38 | %plot zonotope 39 | if nargin == 1 40 | plotFilled(Z); 41 | else 42 | plotFilled(Z,varargin{2:end}); 43 | end 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/prod.m: -------------------------------------------------------------------------------- 1 | function res = prod( obj, dim ) 2 | % prod - product of array elements 3 | % 4 | % Syntax: 5 | % res = prod( obj, dim ) 6 | % 7 | % Inputs: 8 | % obj - input array (interval) 9 | % dim - 1 - product of column's elements; 2 - of row's elements 10 | % 11 | % Outputs: 12 | % res - interval 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | 21 | % Author: Dmitry Grebenyuk 22 | % Written: 24-October-2017 23 | % Last update: 24 | % Last revision:--- 25 | 26 | if dim == 1 % reduce to a row 27 | S.type='()'; % to avoid Matlab's bug 28 | S.subs={1,':'}; 29 | res = subsref(obj,S); 30 | for i = 2:size(obj, dim) 31 | S.subs={i,':'}; 32 | res = res .* subsref(obj,S); 33 | end 34 | elseif dim == 2 % reduce to a column 35 | S.type='()'; 36 | S.subs={':', 1}; 37 | res = subsref(obj,S); 38 | for i = 2:size(obj, dim) 39 | S.subs={':', i}; 40 | res = res .* subsref(obj,S); 41 | end 42 | else 43 | error ('Wrong input') 44 | end 45 | end 46 | 47 | -------------------------------------------------------------------------------- /contSet/@interval/projectHighDim.m: -------------------------------------------------------------------------------- 1 | function res = projectHighDim(obj,N,dim) 2 | % projectHighDim - project an interval object to a higher dimensional 3 | % space 4 | % 5 | % Syntax: 6 | % res = projectHighDim(obj,N,dim) 7 | % 8 | % Inputs: 9 | % obj - interval object 10 | % N - dimension of the higher dimensional space 11 | % dim - states of the high dimensional space that correspond to the 12 | % states of the low dimensional interval object 13 | % 14 | % Outputs: 15 | % res - interval object in the high dimensional space 16 | % 17 | % Example: 18 | % inter = interval([1;-3],[4;1]); 19 | % interHigh = projectHighDim(inter,10,[3;5]); 20 | % 21 | % Other m-files required: none 22 | % Subfunctions: none 23 | % MAT-files required: none 24 | % 25 | % See also: none 26 | 27 | % Author: Niklas Kochdumper 28 | % Written: 06-July-2018 29 | % Last update: --- 30 | % Last revision:--- 31 | 32 | %------------- BEGIN CODE -------------- 33 | 34 | % initialize variables 35 | sup = ones(N,1) * inf; 36 | infi = ones(N,1) * (-inf); 37 | 38 | % insert parameters from the low dimensional interval object 39 | sup(dim) = supremum(obj); 40 | infi(dim) = infimum(obj); 41 | 42 | % construct the resulting high dimensional interval object 43 | res = interval(infi,sup); 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/rad.m: -------------------------------------------------------------------------------- 1 | function res = rad(obj) 2 | % rad - returns the radius of an interval 3 | % 4 | % Syntax: 5 | % res = rad(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % res - numerical value 12 | % 13 | % Example: 14 | % a = interval([-1 1], [1 2]); 15 | % b = rad(a) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 26-June-2015 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | res = 0.5*(obj.sup - obj.inf); 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/reshape.m: -------------------------------------------------------------------------------- 1 | function obj = reshape(varargin) 2 | % reshape - Overloads the operator 'reshape' for reshaping matrices 3 | % 4 | % Syntax: 5 | % obj = reshape(varargin) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % sz1,...,szN - integers defining the reshaping 10 | % 11 | % Outputs: 12 | % obj - interval object 13 | % 14 | % Example: 15 | % a=interval([-1 -2; -3 -4], [1 2; 3 4]); 16 | % b=reshape(a, 4, 1); 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 05-August-2015 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | obj = varargin{1}; 32 | 33 | %apply reshaping for infimum and supremum 34 | obj.inf = reshape(obj.inf, varargin{2:end}); 35 | obj.sup = reshape(obj.sup, varargin{2:end}); 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/sinh.m: -------------------------------------------------------------------------------- 1 | function res = sinh(intVal) 2 | % sinh - Overloaded 'sinh()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = sinh(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 05-February-2016 23 | % Last update: 21-February-2016 the matrix case is rewritten (Dmitry Grebenyuk) 24 | % Last revision:--- 25 | 26 | % x_ is x infimum, x-- is x supremum 27 | 28 | % [sinh(x_), sinh(x--)]. 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | res = interval(); 33 | 34 | res.inf = sinh(intVal.inf); 35 | res.sup = sinh(intVal.sup); 36 | 37 | % matrix case 38 | % rand(100, 100) 39 | %time_CORA = 40 | % 5.578342515440901e-004 41 | %time_INTLAB = 42 | % 0.008773613318865 43 | 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/size.m: -------------------------------------------------------------------------------- 1 | function [varargout] = size(obj, varargin) 2 | % size - Overloads the opertor that returns the size of the object 3 | % 4 | % Syntax: 5 | % varargout = size(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % varargout - varying outputs, see 'doc size' 12 | % 13 | % Example: 14 | % a=interval([-1 1], [1 2]); 15 | % size(a) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 26-January-2016 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %return size of infimum 31 | if nargin > 1 32 | [varargout{1:nargout}] = size(obj.inf,varargin{1}); 33 | else 34 | [varargout{1:nargout}] = size(obj.inf); 35 | end 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/sum.m: -------------------------------------------------------------------------------- 1 | function res = sum(intVal) 2 | % sum - Overloaded 'sum()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = sum(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 05-August-2016 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | % init 29 | res = interval(); 30 | 31 | %infimum 32 | res.inf = sum(intVal.inf); 33 | 34 | %supremum 35 | res.sup = sum(intVal.sup); 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/supremum.m: -------------------------------------------------------------------------------- 1 | function res = supremum(obj) 2 | % supremum - returns the supremum of an interval 3 | % 4 | % Syntax: 5 | % res = sup(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % res - numerical value 12 | % 13 | % Example: 14 | % a = interval([-1 1], [1 2]); 15 | % b = sup(a) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 25-June-2015 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | res = obj.sup; 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/tanh.m: -------------------------------------------------------------------------------- 1 | function res = tanh(intVal) 2 | % tanh - Overloaded 'tanh()' operator for intervals 3 | % 4 | % Syntax: 5 | % res = tanh(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % res - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 05-February-2016 23 | % Last update: 22-February-2016 the matrix case is rewritten (Dmitry Grebenyuk) 24 | % Last revision:--- 25 | 26 | % x_ is x infimum, x-- is x supremum 27 | 28 | % [tanh(x_), tanh(x--)]. 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | res = interval(); 33 | 34 | res.inf = tanh(intVal.inf); 35 | res.sup = tanh(intVal.sup); 36 | 37 | % matrix case 38 | % rand(100, 100) 39 | %time_CORA = 40 | % 3.929944670515823e-004 41 | %time_INTLAB = 42 | % 0.005584974001024 43 | 44 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/transpose.m: -------------------------------------------------------------------------------- 1 | function intVal = transpose(intVal) 2 | % transpose - Overloaded '.'' operator for single operand 3 | % 4 | % Syntax: 5 | % intVal = transpose(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % intVal - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Dmitry Grebenyuk 22 | % Written: 07-February-2016 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %infimum 29 | intVal.inf = intVal.inf.'; 30 | 31 | %supremum 32 | intVal.sup = intVal.sup.'; 33 | 34 | %------------- END OF CODE -------------- 35 | -------------------------------------------------------------------------------- /contSet/@interval/uminus.m: -------------------------------------------------------------------------------- 1 | function intVal = uminus(intVal) 2 | % uminus - Overloaded '-' operator for single operand 3 | % 4 | % Syntax: 5 | % intVal = uplus(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % intVal - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 25-June-2015 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %store values 29 | inf = intVal.inf; 30 | sup = intVal.sup; 31 | 32 | %infimum 33 | intVal.inf = -sup; 34 | 35 | %supremum 36 | intVal.sup = -inf; 37 | 38 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/uplus.m: -------------------------------------------------------------------------------- 1 | function intVal = uplus(intVal) 2 | % uplus - Overloaded '+' operator for single operand (dummy function) 3 | % 4 | % Syntax: 5 | % intVal = uplus(intVal) 6 | % 7 | % Inputs: 8 | % intVal - interval object 9 | % 10 | % Outputs: 11 | % intVal - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: mtimes 20 | 21 | % Author: Matthias Althoff 22 | % Written: 25-June-2015 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | 29 | %dummy function; input = output 30 | 31 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/vertcat.m: -------------------------------------------------------------------------------- 1 | function obj = vertcat(varargin) 2 | % vertcat - Overloads the opertor for vertical concatenation, e.g. 3 | % a = [b;c;d]; 4 | % 5 | % Syntax: 6 | % obj = horzcat(varargin) 7 | % 8 | % Inputs: 9 | % varargin - list of interval objects 10 | % 11 | % Outputs: 12 | % obj - interval object 13 | % 14 | % Example: 15 | % a=interval(-1, 1); 16 | % b=interval(1, 2); 17 | % c = [a,b]; 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 26-June-2015 27 | % Last update: 08-August-2016 28 | % Last revision:--- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | obj = varargin{1}; 33 | 34 | %if object is not an interval 35 | if ~isa(obj,'interval') 36 | tmp = obj; 37 | obj = interval(); 38 | obj.inf = tmp; 39 | obj.sup = tmp; 40 | end 41 | 42 | for i = 2:nargin 43 | %check if concatented variable is an interval 44 | if isa(varargin{i},'interval') 45 | obj.inf = [obj.inf; varargin{i}.inf]; 46 | obj.sup = [obj.sup; varargin{i}.sup]; 47 | else 48 | obj.inf = [obj.inf; varargin{i}]; 49 | obj.sup = [obj.sup; varargin{i}]; 50 | end 51 | end 52 | 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/vertices.m: -------------------------------------------------------------------------------- 1 | function V = vertices(obj) 2 | % vertices - Computes vertices of an interval object 3 | % 4 | % Syntax: 5 | % V = vertices(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % V - vertices object 12 | % 13 | % Example: 14 | % I = interval([1; -1], [2; 1]); 15 | % V = vertices(I); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 24-Juli-2006 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %convert to zonotope 31 | Z = zonotope(obj); 32 | 33 | %obtain vertices 34 | V = vertices(Z); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/volume.m: -------------------------------------------------------------------------------- 1 | function V = volume(obj) 2 | % volume - Computes volume of an interval 3 | % 4 | % Syntax: 5 | % V = volume(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % V - volume 12 | % 13 | % Example: 14 | % I = interval([1; -1], [2; 1]); 15 | % V = volume(I); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 24-July-2016 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | if ~isempty(obj) 31 | V = prod(2*rad(obj)); 32 | else 33 | V = 0; 34 | end 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@interval/zonotope.m: -------------------------------------------------------------------------------- 1 | function Z = zonotope(obj) 2 | % zonotope - Converts an interval object into a zonotope object 3 | % 4 | % Syntax: 5 | % Z = zonotope(obj) 6 | % 7 | % Inputs: 8 | % obj - interval object 9 | % 10 | % Outputs: 11 | % Z - zonotope object 12 | % 13 | % Example: 14 | % I = interval([1;-1], [2; 1]); 15 | % Z = zonotope(I); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: interval, polytope 22 | 23 | % Author: Matthias Althoff 24 | % Written: 22-July-2016 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %obtain center 31 | c = mid(obj); 32 | 33 | %construct generator matrrix G 34 | G = diag(rad(obj)); 35 | 36 | %instantiate zonotope 37 | Z = zonotope([c,G]); 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/collect.m: -------------------------------------------------------------------------------- 1 | function [V] = collect(Vdummy,Vcells) 2 | % collect - collects cell arrays of vertices 3 | % 4 | % Syntax: 5 | % [V] = collect(V,Vcells) 6 | % 7 | % Inputs: 8 | % V - vertices object 9 | % Vcells - cell array of vertices objects 10 | % 11 | % Outputs: 12 | % V - vertices object 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 07-October-2008 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %delete empty vertices cells 30 | i=1; 31 | while i<=length(Vcells) 32 | if isempty(Vcells{i}.V) 33 | Vcells(i)=[]; 34 | else 35 | i=i+1; 36 | end 37 | end 38 | 39 | %collect vertices 40 | V=Vcells{1}; 41 | for i=2:length(Vcells) 42 | newPoints=length(Vcells{i}.V); 43 | V.V(:,(end+1):(end+newPoints))=Vcells{i}.V; 44 | end 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/dirPolytope2.m: -------------------------------------------------------------------------------- 1 | function [Zenclose] = dirPolytope2(Vdummy,V,options) 2 | % polytope - Converts a zonotope to a polytope representation 3 | % 4 | % Syntax: 5 | % [P] = polytope(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % P - polytope object 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % P=polytope(Z); 16 | % plot(P); 17 | % hold on 18 | % plot(Z); 19 | % 20 | % Other m-files required: vertices, polytope 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: intervalhull, vertices 25 | 26 | % Author: Matthias Althoff 27 | % Written: 24-September-2007 28 | % Last update: 31-March-2008 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %delete empty vertices cells 34 | i=1; 35 | while i<=length(V) 36 | if isempty(V{i}) 37 | V(i)=[]; 38 | else 39 | i=i+1; 40 | end 41 | end 42 | 43 | if ~isempty(V) 44 | 45 | Vsum=[]; 46 | for i=1:length(V) 47 | Vsum=[Vsum,V{i}]; 48 | end 49 | 50 | %compute unoriented hull 51 | Vtrans=Vsum; 52 | Min=min(Vtrans,[],2); 53 | Max=max(Vtrans,[],2); 54 | IHtrans=intervalhull([Min,Max]); 55 | Ztrans=zonotope(IHtrans); 56 | Zenclose=Ztrans; 57 | 58 | else 59 | Zenclose=[]; 60 | end 61 | 62 | 63 | 64 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/display.m: -------------------------------------------------------------------------------- 1 | function display(V) 2 | % display - Displays the matrix of vertices as column vectors 3 | % 4 | % Syntax: 5 | % display(V) 6 | % 7 | % Inputs: 8 | % V - vertices object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % V=vertices(rand(2,6)); 15 | % display(V); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 14-September-2006 25 | % Last update: 22-March-2007 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | disp('V: '); 31 | disp(V.V); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/enclosingZonotope4.m: -------------------------------------------------------------------------------- 1 | function [Zenclose] = enclosingZonotope(V,Glast) 2 | % polytope - Converts a zonotope to a polytope representation 3 | % 4 | % Syntax: 5 | % [P] = polytope(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % P - polytope object 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % P=polytope(Z); 16 | % plot(P); 17 | % hold on 18 | % plot(Z); 19 | % 20 | % Other m-files required: vertices, polytope 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: intervalhull, vertices 25 | 26 | % Author: Matthias Althoff 27 | % Written: 02-October-2008 28 | % Last update: --- 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %compute parallelotope 34 | V=get(V,'V'); 35 | Vtrans=inv(Glast)*V; 36 | Min=min(Vtrans,[],2); 37 | Max=max(Vtrans,[],2); 38 | IHtrans=intervalhull([Min,Max]); 39 | Ztrans=zonotope(IHtrans); 40 | Zenclose=Glast*Ztrans; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/get.m: -------------------------------------------------------------------------------- 1 | function val = get(obj, propName) 2 | % get - Retrieve object data from obj 3 | % 4 | % Syntax: 5 | % val = get(obj, propName) 6 | % 7 | % Properties: 8 | % property1 - vertices 9 | 10 | % Author: Matthias Althoff 11 | % Written: 30-September-2006 12 | % Last update: 23-March-2007 13 | % Last revision: --- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | switch propName 18 | case 'V' 19 | val = obj.V; 20 | otherwise 21 | error([propName,' is not a valid asset property']) 22 | end 23 | 24 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/interval.m: -------------------------------------------------------------------------------- 1 | function I = interval(V) 2 | % interval - Encloses a point set by an interval hull 3 | % 4 | % Syntax: 5 | % I = interval(V) 6 | % 7 | % Inputs: 8 | % V - vertices object 9 | % 10 | % Outputs: 11 | % I - interval object 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: intervalhull(constructor) 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: vertices, polytope 20 | 21 | % Author: Matthias Althoff 22 | % Written: 27-July-2016 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %if vertices object is nonempty 29 | if ~isempty(V.V) 30 | %minimum values 31 | leftLimit=min(V.V,[],2); 32 | 33 | %maximum values 34 | rightLimit=max(V.V,[],2); 35 | 36 | %instantiate interval hull 37 | I = interval(leftLimit,rightLimit); 38 | else 39 | I = []; 40 | end 41 | 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/isempty.m: -------------------------------------------------------------------------------- 1 | function res = isempty(obj) 2 | % is_empty - returns 1 if there is no vertex and 0 otherwise 3 | % 4 | % Syntax: 5 | % res = is_empty(obj) 6 | % 7 | % Inputs: 8 | % obj - vertices object 9 | % 10 | % Outputs: 11 | % res - result in {0,1} 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 20-April-2018 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | res = isempty(obj.V); 30 | 31 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/mtimes.m: -------------------------------------------------------------------------------- 1 | function [V] = mtimes(factor1,factor2) 2 | % mtimes - Overloaded '*' operator for the multiplication of a matrix or an 3 | % interval matrix with vertices 4 | % 5 | % Syntax: 6 | % [V] = mtimes(factor1,factor2) 7 | % 8 | % Inputs: 9 | % factor1 - matrix or vertices object 10 | % factor2 - matrix or vertices object 11 | % 12 | % Outputs: 13 | % V - Vertices after multiplication with a matrix 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: plus 22 | 23 | % Author: Matthias Althoff 24 | % Written: 07-October-2008 25 | % Last update: --- 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %Find a vertices object 31 | %Is factor1 a vertices object? 32 | if strcmp('vertices',class(factor1)) 33 | %initialize resulting zonotope 34 | V=factor1; 35 | %initialize other summand 36 | matrix=factor2; 37 | %compute result 38 | V.V=V.V*matrix; 39 | %Is factor2 a vertices object? 40 | elseif strcmp('vertices',class(factor2)) 41 | %initialize resulting zonotope 42 | V=factor2; 43 | %initialize other summand 44 | matrix=factor1; 45 | %compute result 46 | V.V=matrix*V.V; 47 | end 48 | 49 | 50 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/parallelotope.m: -------------------------------------------------------------------------------- 1 | function [Z]=parallelotope(obj,Lambda) 2 | % parallelotope - Computes a parallelotope in G-representation based on a 3 | % coordinate transformation in which the transformed vertices are enclosed 4 | % by an intervalhull 5 | % 6 | % Syntax: 7 | % [Z]=parallelotope(obj,Lambda) 8 | % 9 | % Inputs: 10 | % obj - vertices object 11 | % Lambda - Lambda matrix determining the coordinate transformation 12 | % 13 | % Outputs: 14 | % Z - zonotope object 15 | % 16 | % Example: 17 | % --- 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: --- 24 | 25 | % Author: Matthias Althoff 26 | % Written: 07-June-2009 27 | % Last update: --- 28 | % Last revision: --- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %compute inverse of Lambda 33 | invLambda=inv(Lambda); 34 | 35 | %compute enclosing intervalhull in transformed coordinate system 36 | IH=interval(invLambda*obj); 37 | Z=Lambda*zonotope(IH); 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/plot3d.m: -------------------------------------------------------------------------------- 1 | function plot3d(V) 2 | % plot3d - Plots the convex hull of vertices in 3D 3 | % 4 | % Syntax: 5 | % plot(V) 6 | % 7 | % Inputs: 8 | % V - vertices object 9 | % 10 | % Outputs: 11 | % none 12 | % 13 | % Example: 14 | % V=vertices(rand(3,6)); 15 | % plot3d(V) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 06-October-2007 25 | % Last update: 31-July-2018 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %transpose matrix of vertices 31 | vTrans = V.V'; 32 | 33 | %Plot if there are more than three points 34 | if length(vTrans(:,1))>3 35 | %determine vertex indices for convex hull vertices from potential 36 | %vertices 37 | vertexIndices=convhulln(vTrans); 38 | else 39 | vertexIndices=[1 2 3]; 40 | end 41 | 42 | %plot patches 43 | patch('Faces',vertexIndices,'Vertices',vTrans,'FaceColor','red','FaceAlpha', 0.75); 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/plotFilled.m: -------------------------------------------------------------------------------- 1 | function plotFilled(varargin) 2 | % plotFilled - Plots convex hull of vertices that are projected onto the first 3 | % and second coordinate; plots are filled with color 4 | % 5 | % Syntax: 6 | % plotFilled(V) 7 | % 8 | % Inputs: 9 | % V - vertices object 10 | % 11 | % Outputs: 12 | % none 13 | % 14 | % Example: 15 | % V=vertices(rand(2,6)); 16 | % plotFilled(V) 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 18-August-2016 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %If only one argument is passed 32 | if nargin==1 33 | V=varargin{1}; 34 | type='b'; 35 | 36 | %If two arguments are passed 37 | elseif nargin>=2 38 | V=varargin{1}; 39 | type(1:length(varargin)-1)=varargin(2:end); 40 | end 41 | 42 | % convert vertices to polygon 43 | p = polygon(V); 44 | 45 | % plot 46 | if ~isempty(p) 47 | fill(p(1,:),p(2,:),type{:}); 48 | end 49 | 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@vertices/rotate.m: -------------------------------------------------------------------------------- 1 | function [V] = rotate(V,dims,angle) 2 | % rotates - rotates a set of points projected on two coordinates with the 3 | % specified angle 4 | % 5 | % Syntax: 6 | % [V] = rotate(V,dims,angle) 7 | % 8 | % Inputs: 9 | % V - vertices object 10 | % dims - projected dimensions 11 | % angle - rotation angle 12 | % 13 | % Outputs: 14 | % V - vertices object 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 06-October-2008 26 | % Last update: --- 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %rotation matrix 32 | R=[cos(angle) -sin(angle); sin(angle) cos(angle)]; 33 | 34 | %rotate points 35 | V.V(dims,:)=R*V.V(dims,:); 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/abs.m: -------------------------------------------------------------------------------- 1 | function [Z] = abs(Z) 2 | % abs - Returns a zonotope with absolute values of the center and the 3 | % generators 4 | % 5 | % Syntax: 6 | % [Z] = abs(Z) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % 11 | % Outputs: 12 | % Z - zonotope, whereas Z=(|c|,|g_1|,...,|g_n|) 13 | % 14 | % Example: 15 | % Z=zonotope([1 -1 0; 0 0 -1]); 16 | % Z=abs(Z)-->Z=[1 1 0; 0 0 1] 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 30-September-2006 26 | % Last update: 22-March-2007 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | Z.Z=abs(Z.Z); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/appVolume.m: -------------------------------------------------------------------------------- 1 | function [vol] = appVolume(Z,r) 2 | % volume - Computes the volume of a zonotope 3 | % 4 | % Syntax: 5 | % [vol] = volume(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % vol - volume 12 | % 13 | % Example: 14 | % Z=zonotope([1 -1 0; 0 0 -1]); 15 | % vol=volume(Z) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 24-August-2007 25 | % Last update: 13-September-2016 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %get matrix of generators 31 | G=Z.Z(:,2:end); 32 | 33 | %dimension and nrOfGenerators 34 | [dim,nrOfGen]=size(G); 35 | 36 | %prefilter generators 37 | for i=1:length(G(1,:)) 38 | h(i)=norm(G(:,i)'*G,1); 39 | end 40 | [value,indexFiltered]=sort(h); 41 | Gfiltered=G(:,indexFiltered((end-dim-r+1):end)); 42 | 43 | %dimension and new nrOfGenerators 44 | [dim,nrOfGen]=size(Gfiltered); 45 | 46 | %possible combinations of n=dim generators from all generators 47 | comb = combinator(nrOfGen,dim,'c'); 48 | nrOfComb=length(comb(:,1)); 49 | 50 | for i=1:nrOfComb 51 | parallelogramVol(i)=abs(det(Gfiltered(:,comb(i,:)))); 52 | end 53 | 54 | vol=2^dim*sum(parallelogramVol); 55 | 56 | 57 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/box.m: -------------------------------------------------------------------------------- 1 | function [Z] = box(Z) 2 | % box - Computes an enclosing axis-aligned box 3 | % 4 | % Syntax: 5 | % [Z] = box(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % Z - zonotope object 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % B=box(Z); 16 | % plot(Z); 17 | % hold on 18 | % plot(B); 19 | % 20 | % Other m-files required: intervalhull(constructor) 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: vertices, polytope 25 | 26 | % Author: Matthias Althoff 27 | % Written: 09-March-2009 28 | % Last update: --- 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %extract generators 34 | G=Z.Z(:,2:end); 35 | 36 | %determine new generator matrix 37 | G=diag(sum(abs(G),2)); 38 | 39 | %instantiate interval hull 40 | Z.Z=[Z.Z(:,1),G]; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/cartesianProduct.m: -------------------------------------------------------------------------------- 1 | function Z = cartesianProduct(Z1,Z2) 2 | % cartesianProduct - Returns the cartesian product of two zonotopes 3 | % 4 | % Syntax: 5 | % Z = cartesianProduct(Z1,Z2) 6 | % 7 | % Inputs: 8 | % Z1 - zonotope object 9 | % Z2 - zonotope object 10 | % 11 | % Outputs: 12 | % Z - zonotope object 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 18-May-2011 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | c = [Z1.Z(:,1); Z2.Z(:,1)]; 31 | 32 | %determine sizes of generator matrices 33 | [rows_1, cols_1] = size(Z1.Z(:,2:end)); 34 | [rows_2, cols_2] = size(Z2.Z(:,2:end)); 35 | 36 | %copy generators 37 | G(1:rows_1, 1:cols_1) = Z1.Z(:,2:end); 38 | G((rows_1+1):(rows_1+rows_2), (cols_1+1):(cols_1+cols_2)) = Z2.Z(:,2:end); 39 | 40 | %generate new zonotope 41 | Z = zonotope([c,G]); 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/center.m: -------------------------------------------------------------------------------- 1 | function [c] = center(Z) 2 | % center - Returns the center of a zonotope 3 | % 4 | % Syntax: 5 | % [c] = center(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % c - center of the zonotope Z 12 | % 13 | % Example: 14 | % Z=zonotope([1 1 0; 0 0 1]); 15 | % c=center(Z)-->c=[1;0] 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 30-September-2006 25 | % Last update: 22-March-2007 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | c=Z.Z(:,1); 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/conZonotope.m: -------------------------------------------------------------------------------- 1 | function res = conZonotope(obj) 2 | % conZonotope - convert a zonotope object into a constrained zonotope 3 | % object 4 | % 5 | % Syntax: 6 | % res = conZonotope(obj) 7 | % 8 | % Inputs: 9 | % obj - zonotope object 10 | % 11 | % Outputs: 12 | % res - c-zonotope object 13 | % 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Niklas Kochdumper 22 | % Written: 23-May-2018 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | res = conZonotope(obj.Z,[],[]); 29 | 30 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/constrSat.m: -------------------------------------------------------------------------------- 1 | function res = constrSat(obj,C,d) 2 | % constrSat - checks if all values x of a zonotope satisfy the constraint 3 | % Cx<=d 4 | % 5 | % Syntax: 6 | % res = constrSat(obj,C,d) 7 | % 8 | % Inputs: 9 | % obj - zonotope object 10 | % C - normal vectors of constraints 11 | % d - distance to origin of constraints 12 | % 13 | % Outputs: 14 | % res - 1/0 if constraint is satisfied 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 10-August-2011 26 | % Last update: 14-May-2017 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %check if constraints are violated 32 | IH = interval(C*obj) + (-d); 33 | 34 | %check if interval contains 0 35 | res = all(supremum(IH)<0); 36 | 37 | 38 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/containsPoint.m: -------------------------------------------------------------------------------- 1 | function result = containsPoint(Z1,p) 2 | % containsPoint - determines if the point p is inside the zonotope Z1 3 | % 4 | % Syntax: 5 | % result = containsPoint(Z1,p) 6 | % 7 | % Inputs: 8 | % Z1 - zonotope object 9 | % p - point specified as a vector 10 | % 11 | % Outputs: 12 | % result - 1/0 if point is inside the zonotope or not 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Niklas Kochdumper 24 | % Written: 30-January-2018 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % generate halfspace representation if empty 31 | if isempty(Z1.halfspace) 32 | Z1 = halfspace(Z1); 33 | end 34 | 35 | %simple test: Is point inside the zonotope? 36 | inequality = (Z1.halfspace.H*p<=Z1.halfspace.K); 37 | 38 | result = (all(inequality)); 39 | 40 | %------------- END OF CODE -------------- 41 | -------------------------------------------------------------------------------- /contSet/@zonotope/deleteZeros.m: -------------------------------------------------------------------------------- 1 | function [Zred]=deleteZeros(Z) 2 | % deleteZeros - removes zero generators 3 | % 4 | % Syntax: 5 | % [Zred]=deleteZeros(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % Zred - reduced zonotope object 12 | % 13 | % Other m-files required: none 14 | % Subfunctions: none 15 | % MAT-files required: none 16 | % 17 | % See also: 18 | 19 | % Author: Matthias Althoff 20 | % Written: 15-January-2009 21 | % Last update: --- 22 | % Last revision: --- 23 | 24 | %------------- BEGIN CODE -------------- 25 | 26 | %get Z-matrix from zonotope Z 27 | Zmatrix=get(Z,'Z'); 28 | 29 | %extract generator matrix 30 | c=Zmatrix(:,1); 31 | G=Zmatrix(:,2:end); 32 | 33 | %Delete zero-generators 34 | G=nonzeroFilter(G); 35 | 36 | Zred=zonotope([c,G]); 37 | 38 | %------------- END OF CODE -------------- 39 | -------------------------------------------------------------------------------- /contSet/@zonotope/dim.m: -------------------------------------------------------------------------------- 1 | function [n] = dim(Z) 2 | % dim - Returns the dimension of a zonotope in the sense that the rank of 3 | % the generator matrix is computed 4 | % 5 | % Syntax: 6 | % [n] = dim(Z) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % 11 | % Outputs: 12 | % n - dimension of the zonotope Z 13 | % 14 | % Example: 15 | % Z=zonotope([1 1 0; 0 0 1]); 16 | % n=dim(Z)-->n=2 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 06-May-2009 26 | % Last update: --- 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | n=rank(Z.Z(:,2:end)); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/dirPolytopeNew.m: -------------------------------------------------------------------------------- 1 | function [Zenclose] = dirPolytopeNew(Z,direction) 2 | % polytope - Converts a zonotope to a polytope representation 3 | % 4 | % Syntax: 5 | % [P] = polytope(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % P - polytope object 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % P=polytope(Z); 16 | % plot(P); 17 | % hold on 18 | % plot(Z); 19 | % 20 | % Other m-files required: vertices, polytope 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: intervalhull, vertices 25 | 26 | % Author: Matthias Althoff 27 | % Written: 14-October-2008 28 | % Last update: --- 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | dim=length(direction); 34 | orient=eye(dim); 35 | 36 | newGen=direction/norm(direction); 37 | 38 | %retrieve most aligned generator from orient 39 | for iGen=1:length(orient(1,:)) 40 | h(iGen)=abs(newGen'*orient(:,iGen)/norm(orient(:,iGen))); 41 | end 42 | 43 | [val,ind]=sort(h); 44 | pickedIndices=ind(1:(end-1)); 45 | 46 | newP=[newGen,orient(:,pickedIndices)]; 47 | 48 | %compute oriented rectangular hull 49 | Ztrans=inv(newP)*Z; 50 | IHtrans=intervalhull(Ztrans); 51 | Ztrans=zonotope(IHtrans); 52 | Zenclose=newP*Ztrans; 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/display.m: -------------------------------------------------------------------------------- 1 | function display(Z) 2 | % display - Displays the center and generators of a zonotope 3 | % 4 | % Syntax: 5 | % display(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,6)); 15 | % display(Z); 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 14-September-2006 25 | % Last update: 22-March-2007 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %display id, dimension 31 | display(Z.contSet); 32 | 33 | %display center 34 | disp('c: '); 35 | disp(Z.Z(:,1)); 36 | 37 | %display generators 38 | disp('g_i: '); 39 | disp(Z.Z(:,2:end)); 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/enlarge.m: -------------------------------------------------------------------------------- 1 | function Z = enlarge(Z,factorVec) 2 | % enlarge - enlarges the generators of a zonotope by a vector of factors 3 | % 4 | % Syntax: 5 | % Z = enlarge(Z,factorVec) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % factorVec - vector of factors for the enlargement of each dimension 10 | % 11 | % Outputs: 12 | % Z - zonotope object 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 20-November-2010 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | Z.Z(:,2:end)=diag(factorVec)*Z.Z(:,2:end); 31 | 32 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/eventFcn.m: -------------------------------------------------------------------------------- 1 | function [handle] = eventFcn(obj,x,direction) 2 | % eventFcn - Returns the results of an event function that detects if a 3 | % trajectory enters or leaves a zonotope; 4 | % this event function is needed, e.g. for matlab ode-solvers 5 | % 6 | % Syntax: 7 | % [value,isterminal,direction] = eventFcn(obj,x,direction) 8 | % 9 | % Inputs: 10 | % obj - zonotope object 11 | % x - system state 12 | % direction - event if the state enters or leaves the interval hull? 13 | % 14 | % Outputs: 15 | % value - value of the event function 16 | % isterminal - specifies if the simulation stops if an event turns zero 17 | % direction - specifies if the value of the event function has to 18 | % turn from negative to positive or the other way round 19 | % 20 | % Example: 21 | % --- 22 | % 23 | % Other m-files required: none 24 | % Subfunctions: none 25 | % MAT-files required: none 26 | % 27 | % See also: --- 28 | 29 | % Author: Matthias Althoff 30 | % Written: 07-May-2007 31 | % Last update: --- 32 | % Last revision: --- 33 | 34 | %------------- BEGIN CODE -------------- 35 | 36 | value=obj.halfspace.H*x-obj.halfspace.K; 37 | % Always stop the integration when event detected 38 | isterminal = ones(length(obj.halfspace.K),1)*all(value<=0); 39 | % Vectorize direction 40 | direction = ones(length(obj.halfspace.K),1)*direction; 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/generatorLength.m: -------------------------------------------------------------------------------- 1 | function [genLen] = generatorLength(Z) 2 | % generatorLength - Returns the lengths of the generators 3 | % 4 | % Syntax: 5 | % [genLen] = generatorLength(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % genLen - vector of generator length 12 | % 13 | % Example: --- 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 19-July-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | genLen=vnorm(Z.Z(:,2:end),1); 29 | 30 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/generators.m: -------------------------------------------------------------------------------- 1 | function G = generators(Z) 2 | % generators - Returns the generators of a zonotope as a matrix whose 3 | % column vectors are the generators 4 | % 5 | % Syntax: 6 | % G = generators(Z) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % 11 | % Outputs: 12 | % G - matrix of generators stored as column vectors 13 | % 14 | % Example: 15 | % Z=zonotope([1 1 0; 0 0 1]); 16 | % G=generators(Z) 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 28-November-2016 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | G = Z.Z(:,2:end); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/get.m: -------------------------------------------------------------------------------- 1 | function val = get(obj, propName) 2 | % get - Retrieve object data from obj 3 | % 4 | % Syntax: 5 | % val = get(obj, propName) 6 | % 7 | % Properties: 8 | % Z - zonotope matrix 9 | 10 | % Author: Matthias Althoff 11 | % Written: 30-September-2006 12 | % Last update: 23-March-2007 13 | % Last revision: --- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | switch propName 18 | case 'Z' 19 | val = obj.Z; 20 | case 'equations' 21 | val= obj.halfspace.equations; 22 | otherwise 23 | error([propName,' is not a valid asset property']) 24 | end 25 | 26 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/halfspace.m: -------------------------------------------------------------------------------- 1 | function [obj] = halfspace(obj) 2 | % halfspace - Generates halfspace representation of the zonotope 3 | % 4 | % Syntax: 5 | % [obj] = halfspace(obj) 6 | % 7 | % Inputs: 8 | % obj - zonotope object 9 | % 10 | % Outputs: 11 | % obj - zonotope object 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 07-May-2007 24 | % Last update: 06-April-2017 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %convert zonotope to polytope and retrieve halfspace representation 30 | P = polytope(obj); 31 | H = get(P,'H'); 32 | K = get(P,'K'); 33 | 34 | %write to object structure 35 | obj.halfspace.H=H; 36 | obj.halfspace.K=K; 37 | obj.halfspace.equations=length(K); 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/in.m: -------------------------------------------------------------------------------- 1 | function result = in(Z1,Z2) 2 | % in - determines if zonotope Z1 is enclosed by zonotope Z2 3 | % 4 | % Syntax: 5 | % result = in(Z1,Z2) 6 | % 7 | % Inputs: 8 | % Z1 - 1st zonotope object 9 | % Z2 - 2nd zonotope object 10 | % 11 | % Outputs: 12 | % result - 1/0 if zonotope is in, or not 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Matthias Althoff 24 | % Written: 07-May-2007 25 | % Last update: 06-April-2017 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % generate halfspace representation if empty 31 | if isempty(Z2.halfspace) 32 | Z2 = halfspace(Z2); 33 | end 34 | 35 | %simple test: Is the center of Z1 in Z2? 36 | c = center(Z1); 37 | inequality = (Z2.halfspace.H*c<=Z2.halfspace.K); 38 | 39 | if ~all(inequality) 40 | result = 0; 41 | else 42 | % perform halfspace projection 43 | halfspaceProj = Z2.halfspace.H*Z1 + (-Z2.halfspace.K); 44 | 45 | % obtain intervals of halfspace projection 46 | intHalfProj = interval(halfspaceProj); 47 | 48 | % supremum has to be less or equal to 0 49 | result = all(supremum(intHalfProj) <= 0); 50 | 51 | end 52 | 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/inORH.m: -------------------------------------------------------------------------------- 1 | function [res] = inORH(Z1,Z2,rotMatrixInv) 2 | % inORH - checks if a zonotope Z1 is in an oriented rectangular hull (Z2) 3 | % which has a certain rotation matrix 4 | % 5 | % Syntax: 6 | % [res] = inORH(Z1,Z2,rotMatrix) 7 | % 8 | % Inputs: 9 | % Z1 - zonotope object 10 | % Z2 - ORH in zonotope representation 11 | % rotMatrixInv - inverse rotation matrix of the ORH 12 | % 13 | % Outputs: 14 | % res - 1/0 depending if Z1 is enclosed in Z2 or not 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: in 23 | 24 | % Author: Matthias Althoff 25 | % Written: 15-January-2008 26 | % Last update: --- 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %rotate Z1 and Z2 32 | Z1rot=rotMatrixInv*Z1; 33 | Z2rot=rotMatrixInv*Z2; 34 | 35 | %convert rotated zonotopes to interval hulls 36 | IH1=interval(Z1rot); 37 | IH2=interval(Z2rot); 38 | 39 | %check if IH1 in IH2 40 | res=(IH1<=IH2); 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/inViaProj.m: -------------------------------------------------------------------------------- 1 | function result = inViaProj(Z1,Z2) 2 | % inViaProj - determines if zonotope Z1 is enclosed by zonotope Z2 for all 3 | % possible 2D projections 4 | % 5 | % Syntax: 6 | % result = inViaProj(Z1,Z2) 7 | % 8 | % Inputs: 9 | % Z1 - 1st zonotope object 10 | % Z2 - 2nd zonotope object 11 | % 12 | % Outputs: 13 | % result - 1/0 if zonotope is in, or not 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 06-April-2017 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | % dimension 32 | dim = length(center(Z1)); 33 | 34 | % combinations of projections 35 | comb = combinator(dim,2,'c'); 36 | 37 | % init result 38 | result = 1; 39 | 40 | % loop through projections 41 | for i = 1:length(comb(:,1)) 42 | % perform projections 43 | Z1proj = project(Z1,comb(i,:)); 44 | Z2proj = project(Z2,comb(i,:)); 45 | 46 | % check enclosure 47 | if ~in(Z1proj, Z2proj) 48 | result = 0; 49 | break 50 | end 51 | end 52 | 53 | 54 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/interval.m: -------------------------------------------------------------------------------- 1 | function I = interval(Z) 2 | % interval - Overapproximates a zonotope by an interval hull 3 | % 4 | % Syntax: 5 | % I = interval(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % I - interval object 12 | % 13 | % Example: 14 | % Z = zonotope(rand(2,5)); 15 | % I = interval(Z); 16 | % plot(Z); 17 | % hold on 18 | % plot(I); 19 | % 20 | % Other m-files required: intervalhull(constructor) 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: vertices, polytope 25 | 26 | % Author: Matthias Althoff 27 | % Written: 14-September-2006 28 | % Last update: 22-March-2007 29 | % 11-November-2010 30 | % 04-May-2011 31 | % 22-July-2016 32 | % Last revision: --- 33 | 34 | %------------- BEGIN CODE -------------- 35 | 36 | %extract center 37 | c = Z.Z(:,1); 38 | 39 | %determine left and right limit 40 | %specially designed for high performance 41 | delta = sum(abs(Z.Z),2) - abs(c); 42 | leftLimit = c - delta; 43 | rightLimit = c + delta; 44 | 45 | %instantiate interval hull 46 | I = interval(leftLimit,rightLimit); 47 | 48 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/intervalMultiplication.m: -------------------------------------------------------------------------------- 1 | function Z = intervalMultiplication(Z,I) 2 | % intervalMultiplication - computes the multiplication of an interval with 3 | % a zonotope; requires a seperate function since the zonotope class is no 4 | % longer superior to the interval class 5 | % 6 | % Syntax: 7 | % Z = intervalMultiplication(Z,I) 8 | % 9 | % Inputs: 10 | % Z - zonotope object 11 | % I - interval object 12 | % 13 | % Outputs: 14 | % Z - Zonotpe after multiplication of an interval with a zonotope 15 | % 16 | % Example: 17 | % Z=zonotope([1 1 0; 0 0 1]); 18 | % I=interval([0 1; 1 0], [1 2; 2 1]); 19 | % plot(Z); 20 | % hold on 21 | % Z=intervalMultiplication(Z,I); 22 | % plot(Z); 23 | % 24 | % Other m-files required: none 25 | % Subfunctions: none 26 | % MAT-files required: none 27 | % 28 | % See also: plus 29 | 30 | % Author: Matthias Althoff 31 | % Written: 26-July-2016 32 | % Last update: --- 33 | % Last revision:--- 34 | 35 | %------------- BEGIN CODE -------------- 36 | 37 | 38 | %get center of interval matrix 39 | T=mid(I); 40 | %get radius of interval matrix 41 | S=rad(I); 42 | %auxiliary value 43 | Zabssum=sum(abs(Z.Z),2); 44 | %compute new zonotope 45 | Z.Z=[T*Z.Z,diag(S*Zabssum)]; 46 | 47 | 48 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/isIntersecting.m: -------------------------------------------------------------------------------- 1 | function res = isIntersecting(obj1,obj2) 2 | % isIntersecting - determines if a set obj2 intersects a zonotope obj1 3 | % 4 | % Syntax: 5 | % res = isIntersecting(obj1,obj2) 6 | % 7 | % Inputs: 8 | % obj1 - zonotope object 9 | % obj2 - zonotope or interval object 10 | % 11 | % Outputs: 12 | % result - 1/0 if set is intersecting, or not 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: --- 22 | 23 | % Author: Niklas Kochdumper 24 | % Written: 24-May-2018 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % convert intervals to zonotopes 31 | if isa(obj2,'interval') 32 | obj2 = zonotope(obj2); 33 | end 34 | 35 | % different set representations 36 | if isa(obj2,'zonotope') 37 | 38 | % convert to constraint zonotopes and check if the intersection is 39 | % empty 40 | res = ~isempty(conZonotope(obj1) & conZonotope(obj2)); 41 | 42 | else 43 | error('Operation not implemented yet!'); 44 | end 45 | 46 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/isempty.m: -------------------------------------------------------------------------------- 1 | function res = isempty(obj) 2 | % is_empty - returns 1 if a zonotope is empty and 0 otherwise 3 | % 4 | % Syntax: 5 | % res = is_empty(obj) 6 | % 7 | % Inputs: 8 | % obj - zonotope object 9 | % 10 | % Outputs: 11 | % res - result in {0,1} 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 21-August-2015 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | res = isempty(obj.Z); 30 | 31 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/mixedMultiplication.m: -------------------------------------------------------------------------------- 1 | function [Zquad] = mixedMultiplication(Z1,Z2,Q) 2 | % mixedMultiplication - computes \{Q_{ijk}*x_j*y_k|x \in Z1, y \in Z2\} 3 | % 4 | % Syntax: 5 | % [Zquad] = mixedMultiplication(Z1,Z2,Q) 6 | % 7 | % Inputs: 8 | % Z1 - zonotope object 9 | % Z2 - zonotope object 10 | % Q - quadratic coefficients as a cell of matrices 11 | % 12 | % Outputs: 13 | % Zquad - zonotope object 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 18-September-2012 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | 32 | %get matrix of zonotope 33 | Zmat1 = get(Z1,'Z'); 34 | Zmat2 = get(Z2,'Z'); 35 | dim = length(Q); 36 | 37 | %for each dimension, compute generator elements 38 | for i = 1:dim 39 | 40 | %pure quadratic evaluation 41 | quadMat = Zmat1'*Q{i}*Zmat2; 42 | 43 | %vectorize 44 | quadVec = reshape(quadMat,1,[]); 45 | 46 | %center 47 | c(i,1) = quadVec(1); 48 | 49 | %generators 50 | G(i, :) = quadVec(2:end); 51 | end 52 | 53 | %generate new zonotope 54 | Zquad = zonotope([c, G]); 55 | 56 | 57 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/mptPolytope.m: -------------------------------------------------------------------------------- 1 | function res = mptPolytope(Z) 2 | % mptPolytope - Converts a zonotope object to a mptPolytope object 3 | % 4 | % Syntax: 5 | % res = mptPolytope(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % res - mptPolytope object 12 | % 13 | % Example: 14 | % zono = zonotope(rand(2,5)); 15 | % poly = mptPolytope(zono); 16 | % 17 | % plot(poly,[1,2],'r'); 18 | % figure 19 | % plot(zono,[1,2],'b'); 20 | % 21 | % Other m-files required: vertices, polytope 22 | % Subfunctions: none 23 | % MAT-files required: none 24 | % 25 | % See also: interval, vertices 26 | 27 | % Author: Niklas Kochdumper 28 | % Written: 06-August-2018 29 | % Last update: --- 30 | % Last revision:--- 31 | 32 | %------------- BEGIN CODE -------------- 33 | 34 | res = polytope(Z,'mpt'); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/multiPolytope.m: -------------------------------------------------------------------------------- 1 | function [P] = multiPolytope(firstZ,Z) 2 | % multiPolytope - Converts a set of zonotope from a G- to a 3 | % H-representation and intersects them 4 | % 5 | % Syntax: 6 | % [P] = multiPolytope(firstZ,Z) 7 | % 8 | % Inputs: 9 | % firstZ - first zonotope objects 10 | % Z - cell array of zonotope objects 11 | % 12 | % Outputs: 13 | % P - polytope object 14 | % 15 | % Example: 16 | % Z=zonotope(rand(2,5)); 17 | % P=polytope(Z); 18 | % plot(P); 19 | % hold on 20 | % plot(Z); 21 | % 22 | % Other m-files required: vertices, polytope 23 | % Subfunctions: none 24 | % MAT-files required: none 25 | % 26 | % See also: intervalhull, vertices 27 | 28 | % Author: Matthias Althoff 29 | % Written: 30-September-2008 30 | % Last update: 26-February-2009 31 | % 30-July-2016 32 | % Last revision:--- 33 | 34 | %------------- BEGIN CODE -------------- 35 | 36 | %compute first polytope 37 | [P] = polytope(firstZ); 38 | 39 | %intersect with other polytopes 40 | for i=2:length(Z) 41 | Pnew = polytope(Z{i}); 42 | P=P&Pnew; %intersection 43 | end 44 | 45 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/private/kmeansFilter.m: -------------------------------------------------------------------------------- 1 | function [Gred]=kmeansFilter(G,rem) 2 | % kmeansFilter - filters out generators by the k-means clustering algorithm 3 | % 4 | % Syntax: 5 | % [Gred]=kmeansFilter(G,rem) 6 | % 7 | % Inputs: 8 | % G - matrix of generators 9 | % rem - number of remaining generators 10 | % 11 | % Outputs: 12 | % Gred - reduced matrix of generators 13 | % 14 | % Other m-files required: none 15 | % Subfunctions: none 16 | % MAT-files required: none 17 | % 18 | % See also: 19 | 20 | % Author: Matthias Althoff 21 | % Written: 12-September-2008 22 | % Last update: --- 23 | % Last revision: --- 24 | 25 | %------------- BEGIN CODE -------------- 26 | 27 | %filter generators with k-means 28 | [IDX,C] = kmeans(G',rem); 29 | Gred=C'; 30 | 31 | %------------- END OF CODE -------------- 32 | -------------------------------------------------------------------------------- /contSet/@zonotope/private/lengthFilter.m: -------------------------------------------------------------------------------- 1 | function [Gred]=lengthFilter(G,rem) 2 | % lengthFilter - filters out short generators 3 | % 4 | % Syntax: 5 | % [Gred]=lengthFilter(G,rem) 6 | % 7 | % Inputs: 8 | % G - matrix of generators 9 | % rem - number of remaining generators 10 | % 11 | % Outputs: 12 | % Gred - reduced matrix of generators 13 | % 14 | % Other m-files required: none 15 | % Subfunctions: none 16 | % MAT-files required: none 17 | % 18 | % See also: 19 | 20 | % Author: Matthias Althoff 21 | % Written: 12-September-2008 22 | % Last update: --- 23 | % Last revision: --- 24 | 25 | %------------- BEGIN CODE -------------- 26 | 27 | %prefilter generators 28 | for i=1:length(G(1,:)) 29 | h(i)=norm(G(:,i)); 30 | end 31 | [value,index]=sort(h); 32 | Gred=G(:,index((end-rem+1):end)); 33 | 34 | %------------- END OF CODE -------------- 35 | -------------------------------------------------------------------------------- /contSet/@zonotope/private/ndimCross.m: -------------------------------------------------------------------------------- 1 | function [v] = ndimCross(Q) 2 | % ndimCross - Computes the n-dimensional cross product 3 | % 4 | % Syntax: 5 | % [o] = orth(V) 6 | % 7 | % Inputs: 8 | % V - matrix of column vectors 9 | % 10 | % Outputs: 11 | % o - orthogonal vector 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % P=polytope(Z); 16 | % plot(P); 17 | % hold on 18 | % plot(Z); 19 | % 20 | % Other m-files required: vertices, polytope 21 | % Subfunctions: none 22 | % MAT-files required: none 23 | % 24 | % See also: intervalhull, vertices 25 | 26 | % Author: Matthias Althoff 27 | % Written: 14-September-2006 28 | % Last update: 22-March-2007 29 | % Last revision: --- 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | for i=1:length(Q(:,1)) 34 | D=Q; 35 | D(i,:)=[]; 36 | v(i,1)=(-1)^(i+1)*det(D); 37 | end 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/private/nonzeroFilter.m: -------------------------------------------------------------------------------- 1 | function [G]=nonzeroFilter(G) 2 | % nonZeroFilter - filters out generators of length 0 3 | % 4 | % Syntax: 5 | % [G]=nonzeroFilter(G) 6 | % 7 | % Inputs: 8 | % G - matrix of generators 9 | % 10 | % Outputs: 11 | % G - reduced matrix of generators 12 | % 13 | % Other m-files required: none 14 | % Subfunctions: none 15 | % MAT-files required: none 16 | % 17 | % See also: 18 | 19 | % Author: Matthias Althoff 20 | % Written: 12-September-2008 21 | % Last update: --- 22 | % Last revision: --- 23 | 24 | %------------- BEGIN CODE -------------- 25 | 26 | %Delete zero-generators 27 | i=1; 28 | while i<=length(G(1,:)) 29 | if G(:,i)==0*G(:,i) 30 | G(:,i)=[]; 31 | else 32 | i=i+1; 33 | end 34 | end 35 | 36 | %------------- END OF CODE -------------- 37 | -------------------------------------------------------------------------------- /contSet/@zonotope/private/reduceGirard.m: -------------------------------------------------------------------------------- 1 | function Zred = reduceGirard(Z,order) 2 | % reduceGirard - Reduce zonotope so that its order stays below a specified 3 | % limit 4 | % 5 | % Syntax: 6 | % [Zred]=reduceGirard(Z,order) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % order - desired order of the zonotope 11 | % 12 | % Outputs: 13 | % Zred - reduced zonotope 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: OTHER_FUNCTION_NAME1, OTHER_FUNCTION_NAME2 20 | 21 | % Author: Matthias Althoff 22 | % Written: 24-January-2007 23 | % Last update: 22-March-2007 24 | % 19-January-2009 (vnorm acceleration) 25 | % 11-October-2017 (use of auxiliary function pickedGenerators) 26 | % Last revision: --- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % initialize Z_red 31 | Zred=Z; 32 | 33 | % pick generators to reduce 34 | try 35 | [center, Gunred, Gred] = pickedGenerators(Z,order); 36 | catch 37 | disp('stop') 38 | end 39 | 40 | % box remaining generators 41 | d=sum(abs(Gred),2); 42 | %build box Gbox from interval hull vector d 43 | Gbox=diag(d); 44 | 45 | %build reduced zonotope 46 | Zred.Z=[center,Gunred,Gbox]; 47 | 48 | 49 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/private/reorderingFilter.m: -------------------------------------------------------------------------------- 1 | function [Gcells]=reorderingFilter(G) 2 | % reorderingFilter - saves combinations of generators to matrix cells 3 | % 4 | % Syntax: 5 | % [Gred]=volumeFilter(G) 6 | % 7 | % Inputs: 8 | % G - generator matrix 9 | % 10 | % Outputs: 11 | % Gcells - cells of generator matrices 12 | % 13 | % Other m-files required: none 14 | % Subfunctions: none 15 | % MAT-files required: none 16 | % 17 | % See also: 18 | 19 | % Author: Matthias Althoff 20 | % Written: 12-September-2008 21 | % Last update: 20-July-2010 22 | % 28-September-2010 23 | % Last revision:--- 24 | 25 | %------------- BEGIN CODE -------------- 26 | 27 | %obtain combinations 28 | [rows,cols]=size(G); 29 | comb = combinator(cols,rows,'c'); 30 | nrOfComb=length(comb(:,1)); 31 | 32 | Gcells=[]; 33 | for i=1:nrOfComb 34 | try 35 | Gcells{end+1}=G(:,comb(i,:)); 36 | catch 37 | disp('bad indices'); 38 | end 39 | end 40 | 41 | %------------- END OF CODE -------------- 42 | -------------------------------------------------------------------------------- /contSet/@zonotope/project.m: -------------------------------------------------------------------------------- 1 | function [Z] = project(Z,dim) 2 | % project - Returns a zonotope which is projected onto the specified 3 | % dimensions 4 | % 5 | % Syntax: 6 | % [Z] = project(Z,dim) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % dim - projected dimensions 11 | % 12 | % Outputs: 13 | % Z - zonotope, whereas Z=(|c|,|g_1|,...,|g_n|) 14 | % 15 | % Example: 16 | % Z=zonotope([1 -1 0; 0 0 -1]); 17 | % Z=abs(Z)-->Z=[1 1 0; 0 0 1] 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 15-September-2008 27 | % Last update: --- 28 | % Last revision: --- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | Z.Z=Z.Z(dim,:); 33 | 34 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/quadZonotope.m: -------------------------------------------------------------------------------- 1 | function [qZ] = quadZonotope(Z) 2 | % quadZonotope - converts a zonotope to a quadZonotope format 3 | % 4 | % Syntax: 5 | % [qZ] = quadZonotope(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % qZ - quadZonotope object 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: intervalhull(constructor) 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: vertices, polytope 21 | 22 | % Author: Matthias Althoff 23 | % Written: 05-September-2012 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %extract center and generators 30 | c=Z.Z(:,1); 31 | G=Z.Z(:,2:end); 32 | 33 | %instantiate quadZonotope 34 | qZ=quadZonotope(c,G,[],[],[]); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/radius.m: -------------------------------------------------------------------------------- 1 | function r = radius(Z) 2 | % radius - Computes the radius of a hypersphere enclosing a zonotope 3 | % 4 | % Syntax: 5 | % r = radius(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % r - radius 12 | % 13 | % Example: 14 | % Z=zonotope(rand(2,5)); 15 | % r=radius(Z); 16 | % 17 | % Other m-files required: --- 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: 22 | 23 | % Author: Matthias Althoff 24 | % Written: 19-April-2010 25 | % Last update: 27-July-2016 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %extract generators 31 | G=Z.Z(:,2:end); 32 | 33 | %method 1 34 | nrOfGenerators=length(G(1,:)); 35 | r=0; 36 | %add length of generators 37 | for i=1:nrOfGenerators 38 | rPart=norm(G(:,i)); 39 | r=r+rPart; 40 | end 41 | 42 | %method 2 43 | %compute enclosing interval hull 44 | IH=intervalhull(Z); 45 | %compute edge length 46 | l=rad(IH); 47 | %compute enclosing radius 48 | rAlt=sqrt(l'*l); 49 | 50 | %chose minimum 51 | r=min(r,rAlt); 52 | 53 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/randPoint.m: -------------------------------------------------------------------------------- 1 | function [p] = randPoint(obj) 2 | % randPoint - generates a random point within a zonotope 3 | % 4 | % Syntax: 5 | % [p] = randPoint(obj) 6 | % 7 | % Inputs: 8 | % obj - zonotope object 9 | % 10 | % Outputs: 11 | % p - random point in R^n 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 23-September-2008 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %obtain number of generators 30 | nrOfGenerators=length(obj.Z(1,:))-1; 31 | 32 | %initialize the random point 33 | p=obj.Z(:,1); 34 | 35 | %add generators randomly 36 | for i=1:nrOfGenerators 37 | p=p+(2*rand(1)-1)*obj.Z(:,i+1); 38 | end 39 | 40 | 41 | 42 | 43 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/randPointExtreme.m: -------------------------------------------------------------------------------- 1 | function [p] = randPointExtreme(obj) 2 | % randPointExtreme - generates a random extreme points of a zonotope 3 | % 4 | % Syntax: 5 | % [p] = randPointExtreme(obj) 6 | % 7 | % Inputs: 8 | % obj - zonotope object 9 | % 10 | % Outputs: 11 | % p - random point in R^n 12 | % 13 | % Example: 14 | % --- 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 14-May-2009 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %obtain number of generators 30 | nrOfGenerators=length(obj.Z(1,:))-1; 31 | 32 | %initialize the random point 33 | p=obj.Z(:,1); 34 | 35 | %add generators randomly 36 | for i=1:nrOfGenerators 37 | val=sign(2*rand(1)-1); 38 | p=p+val*obj.Z(:,i+1); 39 | end 40 | 41 | 42 | 43 | 44 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/rotate.m: -------------------------------------------------------------------------------- 1 | function [Z] = rotate(Z,dims,angle) 2 | % rotates - rotates a zonotope projected on two coordinates with the 3 | % specified angle 4 | % 5 | % Syntax: 6 | % [Z] = rotate(Z,dims,angle) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % dims - projected dimensions 11 | % angle - rotation angle 12 | % 13 | % Outputs: 14 | % Z - zonotope object 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Matthias Althoff 25 | % Written: 07-October-2008 26 | % Last update: --- 27 | % Last revision: --- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %rotation matrix 32 | R=[cos(angle) -sin(angle); sin(angle) cos(angle)]; 33 | 34 | %rotate points 35 | Z.Z(dims,:)=R*Z.Z(dims,:); 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/set.m: -------------------------------------------------------------------------------- 1 | function obj = set(obj, varargin) 2 | % set - Set data of obj 3 | % 4 | % Syntax: 5 | % obj = set(obj, varargin) 6 | % 7 | % Properties: 8 | % Z - zonotope matrix 9 | 10 | % Author: Matthias Althoff 11 | % Written: 30-September-2006 12 | % Last update: 23-March-2007 13 | % Last revision: --- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | propertyArgIn = varargin; 18 | while length(propertyArgIn) >= 2, 19 | property = propertyArgIn{1}; 20 | value = propertyArgIn{2}; 21 | propertyArgIn = propertyArgIn(3:end); 22 | switch property 23 | case 'Z' 24 | obj.Z = value; 25 | otherwise 26 | error('Property unknown') 27 | end 28 | end 29 | 30 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/splitFirstGen.m: -------------------------------------------------------------------------------- 1 | function [Znew] = splitFirstGen(Zdummy,Z) 2 | % splitFirstGen - splits first generator, which is in direction of the 3 | % vector field 4 | % 5 | % Syntax: 6 | % [Zrem] = firstSplitGen(Zdummy,Z) 7 | % 8 | % Inputs: 9 | % Z - cell array of zonotope objects 10 | % 11 | % Outputs: 12 | % Zrem - cell array of remaining zonotope objects 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 09-October-2008 24 | % Last update: --- 25 | % Last revision: --- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %initialize Znew 30 | Znew=[]; 31 | 32 | %split first generator 33 | for i=1:length(Z) 34 | %find longest generator 35 | G=Z{i}.Z(:,2:end); 36 | for j=1:length(G(1,:)) 37 | h(j)=norm(G(:,j)'*G,1); 38 | end 39 | [value,index]=sort(h); 40 | 41 | %split longest generator 42 | Ztemp = split(Z{i},index(end)); 43 | %Ztemp = split(Z{i},1); 44 | %write to Znew 45 | counter=length(Znew); 46 | Znew{counter+1}=Ztemp{1}; 47 | Znew{counter+2}=Ztemp{2}; 48 | end 49 | 50 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/tensorMultiplication_zono.m: -------------------------------------------------------------------------------- 1 | function Zres = tensorMultiplication_zono(Z,M,options) 2 | % tensorMultiplication_zono - computes \{M_{ijk...l}*x_j*x_k*...*x_l|x \in Z\} 3 | % when the center of Z is the origin and M is a matrix zonotope 4 | % 5 | % Syntax: 6 | % Zres = tensorMultiplication_zono(Z,M,options) 7 | % 8 | % Inputs: 9 | % Z - zonotope object 10 | % M - tensor 11 | % 12 | % Outputs: 13 | % Zres - zonotope object 14 | % 15 | % Example: 16 | % --- 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 10-October-2011 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %compute zonotope of center 32 | Zres = tensorMultiplication(Z,M.center,options); 33 | 34 | %add results from generators 35 | for i = 1:M.gens 36 | Zres = Zres + tensorMultiplication(Z,M.generator{i},options); 37 | end 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/@zonotope/volume.m: -------------------------------------------------------------------------------- 1 | function [vol] = volume(Z) 2 | % volume - Computes the volume of a zonotope 3 | % 4 | % Syntax: 5 | % [vol] = volume(Z) 6 | % 7 | % Inputs: 8 | % Z - zonotope object 9 | % 10 | % Outputs: 11 | % vol - volume 12 | % 13 | % Example: 14 | % Z=zonotope([1 -1 0; 0 0 -1]); 15 | % vol=volume(Z) 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 24-August-2007 25 | % Last update: 19-July-2010 26 | % Last revision:--- 27 | 28 | % Update: made function more memory efficient by using an accumulator 29 | % (Anna Kopetzki May-2016) 30 | 31 | %------------- BEGIN CODE -------------- 32 | 33 | %dimension and nrOfGenerators 34 | G=Z.Z(:,2:end); 35 | [dim,nrOfGen]=size(G); 36 | 37 | %possible combinations of n=dim generators from all generators 38 | comb = combinator(nrOfGen,dim,'c'); 39 | nrOfComb=length(comb(:,1)); 40 | 41 | accVol = 0; 42 | 43 | for i=1:nrOfComb 44 | try 45 | currVol=abs(det(G(:,comb(i,:)))); 46 | accVol = accVol + currVol; 47 | catch 48 | currVol=0; 49 | disp('parallelogram volume could not be computed'); 50 | end 51 | end 52 | 53 | vol=2^dim*accVol; 54 | 55 | 56 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/gramSchmidt.m: -------------------------------------------------------------------------------- 1 | function Q = gramSchmidt(B) 2 | % gramSchmidt - construct an orthonormal basis Q from the vectors in B 3 | % 4 | % Syntax: 5 | % Q = gramSchmidt(B) 6 | % 7 | % Inputs: 8 | % B - matrix with columns beeing the initial vectors for the basis 9 | % 10 | % Outputs: 11 | % Q - matrix whose columns span the orthonormal basis 12 | % 13 | % Example: 14 | % 15 | % B = [1 2;-1 1] 16 | % Q = gramSchmidt(B) 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: --- 23 | 24 | % Author: Niklas Kochdumper 25 | % Written: 23-January-2019 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE ------------- 30 | 31 | % construct suitable basis matrix if only a vector is provided 32 | if size(B,2) == 1 33 | B_ = eye(length(B)); 34 | [~,ind] = max(abs(B'*B_)); 35 | B_(:,ind) = []; 36 | B = [B,B_]; 37 | end 38 | 39 | % gram schmidt method 40 | Q = zeros(size(B)); 41 | R = zeros(size(B)); 42 | 43 | for j = 1:size(B,2) 44 | v = B(:,j); 45 | for i = 1:j-1 46 | R(i,j) = Q(:,i)'*B(:,j); 47 | v = v-R(i,j)*Q(:,i); 48 | end 49 | R(j,j) = norm(v); 50 | Q(:,j) = v/R(j,j); 51 | end 52 | 53 | end 54 | 55 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /contSet/randProbZonotope.m: -------------------------------------------------------------------------------- 1 | function [pZ] = randProbZonotope(dim,detGenerators,probGenerators) 2 | % randProbZonotope - Generates a random probabilistic zonotope. 3 | % 4 | % Syntax: 5 | % [Obj] = randProbZonotope(dim,detGenerators,probGenerators) 6 | % 7 | % Inputs: 8 | % dim - dimension of the vector space 9 | % detGenerators - number of deterministic generators 10 | % probGenerators - number of probabilistic generators 11 | % 12 | % Outputs: 13 | % Obj - random probabilistic zonotope object structure 14 | % 15 | % Example: 16 | % pZ = probZonotope(2,4,3); 17 | % plot(pZ); 18 | % 19 | % Other m-files required: none 20 | % Subfunctions: none 21 | % MAT-files required: none 22 | % 23 | % See also: none 24 | 25 | % Author: Matthias Althoff 26 | % Written: 23-August-2007 27 | % Last update: 04-March-2008 28 | % Last revision: --- 29 | 30 | %------------- BEGIN CODE -------------- 31 | 32 | %generators 33 | Z=rand(dim,detGenerators+1); 34 | g=-1+2*rand(dim,probGenerators); 35 | gamma=3; 36 | 37 | pZ=probZonotope(Z,g,gamma); 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/abs.m: -------------------------------------------------------------------------------- 1 | function M = abs(intMat) 2 | % abs - returns the absolute value bound of an interval matrix 3 | % 4 | % Syntax: 5 | % M = abs(intMat) 6 | % 7 | % Inputs: 8 | % intMat - interval matrix 9 | % 10 | % Outputs: 11 | % M - absolute value bound 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: OTHER_FUNCTION_NAME1, OTHER_FUNCTION_NAME2 20 | 21 | % Author: Matthias Althoff 22 | % Written: 21-July-2010 23 | % Last update: 26-August-2011 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | Minf=infimum(intMat.int); 29 | Msup=supremum(intMat.int); 30 | 31 | M=max(abs(Minf), abs(Msup)); 32 | 33 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/changeLog_intervalMatrix.txt: -------------------------------------------------------------------------------- 1 | 27 Feb 2015 (MA): 2 | 3 | - removed: abs.m, expmDist.m, expmNorm.m, expmNormErr.m, expmNormErrInf.m, 4 | 5 | 6 | -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/display.m: -------------------------------------------------------------------------------- 1 | function display(intMat) 2 | % display - Displays the interval matrix 3 | % 4 | % Syntax: 5 | % display(intMat) 6 | % 7 | % Inputs: 8 | % intMat - interval matrix 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 18-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %display dimension, generators 29 | disp('dimension: '); 30 | disp(intMat.dim); 31 | %display left and right limits 32 | disp('left limit: '); 33 | disp(infimum(intMat.int)); 34 | disp('right limit: '); 35 | disp(supremum(intMat.int)); 36 | 37 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/expmIndMixed.m: -------------------------------------------------------------------------------- 1 | function [eI,eI2,iPow,iPow2,E] = expmIndMixed(matI,intermediateOrder,maxOrder) 2 | % expmIndMixed - dummy function for interval matrices. 3 | % 4 | % Syntax: 5 | % eZ = expmInd(matZ,maxOrder) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % maxOrder - Taylor series order until computation with interval arith. 10 | % maxOrder - maximum Taylor series order until remainder is computed 11 | % 12 | % Outputs: 13 | % eZ - matrix zonotope exponential part 14 | % eI - interval matrix exponential part 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: plus 23 | 24 | % Author: Matthias Althoff 25 | % Written: 13-September-2010 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %compute powers 32 | iPow=powers(matI,intermediateOrder); 33 | 34 | %compute finite Taylor series 35 | %initialize matrix zonotope 36 | eI=matI^0; 37 | 38 | %compute finite Taylor sum 39 | for i=1:intermediateOrder 40 | eI = eI + iPow{i}*(1/factorial(i)); 41 | end 42 | 43 | %compute interval part 44 | [eI2,iPow2,E] = expmInd(matI, maxOrder, intermediateOrder+1, matI*iPow{intermediateOrder}); 45 | 46 | 47 | 48 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/expmVertex.m: -------------------------------------------------------------------------------- 1 | function eI = expmVertex(intMat) 2 | % expmVertex - computes the exponential matrix for the vertices of the 3 | % interval matrix 4 | % 5 | % Syntax: 6 | % eI = expmVertex(intMat) 7 | % 8 | % Inputs: 9 | % intMat - interval matrix 10 | % 11 | % Outputs: 12 | % eI - interval matrix exponential 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: ---end+i 21 | 22 | % Author: Matthias Althoff 23 | % Written: 02-July-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | 30 | %compute vertices 31 | V = dominantVertices(intMat, 100); 32 | 33 | %compute exponential matrices 34 | for i=1:length(V) 35 | eI{i} = expm(V{i}); 36 | end 37 | 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/interval.m: -------------------------------------------------------------------------------- 1 | function IH = interval(matI) 2 | % interval - Converts an interval matrix to an interval vector 3 | % 4 | % Syntax: 5 | % IH = interval(matI) 6 | % 7 | % Inputs: 8 | % matI - interval matrix 9 | % 10 | % Outputs: 11 | % IH - interval hull 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: vertices, polytope 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: --- 20 | 21 | % Author: Matthias Althoff 22 | % Written: 21-June-2010 23 | % Last update: 25-July-2016 (intervalhull replaced by interval) 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %convert matrix limits 29 | leftLimit = mat2vec(infimum(matI.int)); 30 | rightLimit = mat2vec(supremum(matI.int)); 31 | 32 | %instantiate interval hull (using MPT toolbox) 33 | IH=interval(leftLimit,rightLimit); 34 | 35 | 36 | 37 | 38 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/matPolytope.m: -------------------------------------------------------------------------------- 1 | function matP = matPolytope(matI) 2 | % matPolytopes - converts an interval matrix to a matrix polytope 3 | % 4 | % Syntax: 5 | % matP = matPolytope(matI) 6 | % 7 | % Inputs: 8 | % matI - interval matrix 9 | % 10 | % Outputs: 11 | % matP - polytope matrix 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: plus 20 | 21 | % Author: Matthias Althoff 22 | % Written: 21-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %obtain vertices 29 | V = dominantVertices(matI,inf); 30 | 31 | %instantiate matrix polytope 32 | matP=matPolytope(V); 33 | 34 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/matZonotope.m: -------------------------------------------------------------------------------- 1 | function matZ = matZonotope(matI) 2 | % matZonotopes - converts an interval matrix to a matrix zonotope 3 | % 4 | % Syntax: 5 | % matZ = matZonotope(matI) 6 | % 7 | % Inputs: 8 | % matI - interval matrix 9 | % 10 | % Outputs: 11 | % matZ - zonotope matrix 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: plus 20 | 21 | % Author: Matthias Althoff 22 | % Written: 21-June-2010 23 | % Last update: 25-July-2016 (intervalhull replaced by interval) 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %convert to interval 29 | IH=interval(matI); 30 | 31 | %convert to zonotope 32 | Z=zonotope(IH); 33 | Z=deleteZeros(Z); %delete zero generators 34 | 35 | %convert to matrix zonotope 36 | matZ=matZonotope(Z); 37 | 38 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/mpower.m: -------------------------------------------------------------------------------- 1 | function intMatPower = mpower(intMat,exponent) 2 | % mpower - Overloaded '^' operator for the power of an interval matrix 3 | % 4 | % Syntax: 5 | % intMatPower = mpower(intMat,exponent) 6 | % 7 | % Inputs: 8 | % intMat - interval matrix 9 | % exponent - exponent 10 | % 11 | % Outputs: 12 | % intMatPower - interval matrix 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 21-June-2010 24 | % Last update: 05-August-2010 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %factor1 is a numeric matrix 30 | if exponent>=0 31 | if exponent==0 32 | %return identity matrix 33 | intMatPower=intMat; 34 | intMatPower.int=intMat.int^0; 35 | elseif exponent==1 36 | %do nothing 37 | intMatPower=intMat; 38 | else 39 | intMatPower=intMat*intMat; 40 | for i=3:exponent 41 | %multiply matrix zonotope with itself 42 | intMatPower=intMatPower*intMat; 43 | end 44 | end 45 | 46 | else 47 | intMatPower=[]; 48 | disp('no negative powers supported') 49 | end 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/norm.m: -------------------------------------------------------------------------------- 1 | function res = norm(obj, varargin) 2 | % norm - computes exactly the maximum norm value of all possible matrices 3 | % 4 | % Syntax: 5 | % res = norm(obj, varargin) 6 | % 7 | % Inputs: 8 | % obj - interval matrix 9 | % varargin - list of optional inputs 10 | % 11 | % Outputs: 12 | % res - resulting maximum norm value 13 | % 14 | % Example: 15 | % --- 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: @zonotope/norm 22 | 23 | % Author: Matthias Althoff 24 | % Written: 02-November-2017 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | % convert interval matrix into zonotope matrix 31 | matZ = matZonotope(obj); 32 | 33 | % compute norm 34 | res = norm(matZ, varargin{:}); 35 | 36 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/plot.m: -------------------------------------------------------------------------------- 1 | function plot(varargin) 2 | % plot - Plots 2-dimensional projection of an interval matrix 3 | % 4 | % Syntax: 5 | % plot(obj,dimensions) 6 | % 7 | % Inputs: 8 | % obj - interval matrix 9 | % dimensions - dimensions that should be projected (optional) 10 | % 11 | % Outputs: 12 | % none 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: none 21 | 22 | % Author: Matthias Althoff 23 | % Written: 22-June-2010 24 | % Last update: 25-July-2016 (intervalhull replaced by interval) 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %convert to interval matrix to interval 30 | IH=interval(varargin{1}); 31 | 32 | %plot interval 33 | if nargin==1 34 | plot(IH); 35 | elseif nargin==2 36 | plot(IH,varargin{2}); 37 | else 38 | plot(IH,varargin{2},varargin{3}); 39 | end 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/powers.m: -------------------------------------------------------------------------------- 1 | function pow = powers(varargin) 2 | % powers - computes the powers of an interval matrix 3 | % 4 | % Syntax: 5 | % [intMat] = powers(varargin) 6 | % 7 | % Inputs: 8 | % intMat - interval matrix 9 | % maxOrder - maximum Taylor series order until remainder is computed 10 | % initialOrder - first Taylor series order 11 | % initialPower - initial power for mixed computations 12 | % 13 | % Outputs: 14 | % eI - interval matrix exponential 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: none 20 | % MAT-files required: none 21 | % 22 | % See also: plus 23 | 24 | % Author: Matthias Althoff 25 | % Written: 18-June-2010 26 | % Last update: 06-July-2010 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | if nargin==2 32 | intMat = varargin{1}; 33 | maxOrder = varargin{2}; 34 | initialOrder = 1; 35 | initialPower = intMat; 36 | elseif nargin==4 37 | intMat = varargin{1}; 38 | maxOrder = varargin{2}; 39 | initialOrder = varargin{3}; 40 | initialPower = varargin{4}; 41 | end 42 | 43 | %initialize power 44 | pow{initialOrder}=initialPower; 45 | 46 | %compute powers 47 | for i=(initialOrder+1):maxOrder 48 | pow{i} = pow{i-1}*intMat; 49 | end 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/vertices.m: -------------------------------------------------------------------------------- 1 | function matV = vertices(matI) 2 | % vertices - computes the vertices of an interval matrix 3 | % 4 | % Syntax: 5 | % matV = vertices(matI) 6 | % 7 | % Inputs: 8 | % matI - interval matrix 9 | % 10 | % Outputs: 11 | % matV - cell array of matrix vertices 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: plus 20 | 21 | % Author: Matthias Althoff 22 | % Written: 21-June-2010 23 | % Last update: 25-July-2016 (intervalhull replaced by interval) 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %conversion to an interval 29 | IH = interval(matI); 30 | 31 | %compute vertices 32 | V = get(vertices(IH),'V'); 33 | V = unique(V', 'rows')'; %eliminate vectors that occur multiple times 34 | 35 | %convert vertices to matrix vertices 36 | matV=cell(length(V(1,:)),1); 37 | for i=1:length(V(1,:)) 38 | matV{i}=vec2mat(V(:,i)); 39 | end 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@intervalMatrix/volume.m: -------------------------------------------------------------------------------- 1 | function vol = volume(matI) 2 | % volume - computes the volume of an interval matrix by computing the 3 | % volume of the corresponding interval hull 4 | % 5 | % Syntax: 6 | % vol = volume(matI) 7 | % 8 | % Inputs: 9 | % matI - interval matrix 10 | % 11 | % Outputs: 12 | % vol - volume 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 24-June-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %conversion to a zonotope 30 | IH = intervalhull(matI); 31 | 32 | %compute volume of the zonotope 33 | vol = volume(IH); 34 | 35 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/changeLog_matZonotope.txt: -------------------------------------------------------------------------------- 1 | 27 Feb 2015 (MA): 2 | 3 | - removed: abs.m, box.m, center.m, deleteZeros.m, dim.m, enclose.m, expmDist.m, halfspace.m, in.m, intervalhull.m, parallelotope.m, plot.m, polytope.m, randPoint.m, randPointExtreme.m, rotate.m, split.m, sup.m, twoDimHalfspace.m 4 | 5 | 6 | -------------------------------------------------------------------------------- /matrixSet/@matZonotope/concatenate.m: -------------------------------------------------------------------------------- 1 | function matZ1 = concatenate(matZ1,matZ2) 2 | % concatenate - concatenates the center and all generators of the second 3 | % matrix zonotope to the first one 4 | % 5 | % Syntax: 6 | % matZ = concatenate(matZ1,matZ2) 7 | % 8 | % Inputs: 9 | % matZ1 - zonotope matrix object 10 | % matZ2 - zonotope matrix object 11 | % 12 | % Outputs: 13 | % matZ - zonotope matrix object 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: mtimes 22 | 23 | % Author: Matthias Althoff 24 | % Written: 06-September-2013 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %add center 31 | matZ1.generator{end+1} = matZ2.center; 32 | 33 | %add generators 34 | for i = 1:length(matZ2.generator) 35 | matZ1.generator{end+1} = matZ2.generator{i}; 36 | end 37 | 38 | %update number of generators 39 | matZ1.gens = length(matZ1.generator); 40 | 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/display.m: -------------------------------------------------------------------------------- 1 | function display(matZ) 2 | % display - Displays the center and generators of a matrix zonotope 3 | % 4 | % Syntax: 5 | % display(matZ) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope object 9 | % 10 | % Outputs: 11 | % --- 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: none 20 | 21 | % Author: Matthias Althoff 22 | % Written: 18-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %display dimension, generators 29 | disp('dimension: '); 30 | disp(matZ.dim); 31 | disp('nr of generators: '); 32 | disp(matZ.gens); 33 | %display center 34 | disp('center: '); 35 | disp(matZ.center); 36 | 37 | %display generators 38 | disp('generators: '); 39 | for i=1:length(matZ.generator) 40 | disp(matZ.generator{i}); 41 | disp('---------------'); 42 | end 43 | 44 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/dominantVertices.m: -------------------------------------------------------------------------------- 1 | function matV = dominantVertices(matZ, maxNumber) 2 | % dominantVertices - computes the dominant vertices of a matrix zonotope 3 | % 4 | % Syntax: 5 | % matV = dominantVertices(matZ, maxNumber) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % maxNumber - maximum number of dominant vertices 10 | % 11 | % Outputs: 12 | % matV - cell array of matrix vertices 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 19-July-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %conversion to a zonotope 30 | Z = zonotope(matZ); 31 | 32 | %underapproximate zonotope 33 | V = underapproximate(Z); 34 | 35 | %convert vertices to matrix vertices 36 | for i=1:length(V(1,:)) 37 | matV{i}=vec2mat(V(:,i)); 38 | end 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/expmInd.m: -------------------------------------------------------------------------------- 1 | function eZ = expmInd(matZ,maxOrder) 2 | % expmInd - operator for the exponential matrix of a 3 | % matrix zonotope, evaluated independently 4 | % 5 | % Syntax: 6 | % eZ = expmInd(matZ,maxOrder) 7 | % 8 | % Inputs: 9 | % matZ - matrix zonotope 10 | % maxOrder - maximum Taylor series order until remainder is computed 11 | % 12 | % Outputs: 13 | % eZ - matrix zonotope exponential 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: plus 22 | 23 | % Author: Matthias Althoff 24 | % Written: 18-June-2010 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %compute finite Taylor series 31 | %initialize matrix zonotope 32 | eZ=matZ^0; 33 | %initialize power 34 | eZpow=matZ^0; 35 | 36 | %compute finite Taylor sum 37 | for i=1:maxOrder 38 | eZpow = eZpow*matZ; 39 | eZ = eZ + eZpow*(1/factorial(i)); 40 | end 41 | 42 | %compute remainder value 43 | %create over-approximating interval matrix 44 | intMat = intervalMatrix(matZ); 45 | %compute remainder value 46 | E = exponentialRemainder(intMat,maxOrder); 47 | 48 | %convert remainder and add it to the Taylor series 49 | eZ = eZ + matZonotope(E); 50 | 51 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/expmVertex.m: -------------------------------------------------------------------------------- 1 | function eZ = expmVertex(matZ) 2 | % expmVertex - computes the exponential matrix for the vertices of the 3 | % matrix zonotope 4 | % 5 | % Syntax: 6 | % eZ = expmVertex(matZ) 7 | % 8 | % Inputs: 9 | % matZ - matrix zonotope 10 | % 11 | % Outputs: 12 | % eZ - matrix zonotope exponential 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: ---end+i 21 | 22 | % Author: Matthias Althoff 23 | % Written: 19-July-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | 30 | %compute vertices 31 | V = dominantVertices(matZ, 100); 32 | 33 | %compute exponential matrices 34 | for i=1:length(V) 35 | eZ{i} = expm(V{i}); 36 | end 37 | 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/get.m: -------------------------------------------------------------------------------- 1 | function val = get(obj, propName) 2 | % get - Retrieve object data from obj 3 | % 4 | % Syntax: 5 | % val = get(obj, propName) 6 | % 7 | % Properties: 8 | % Z - zonotope matrix 9 | 10 | % Author: Matthias Althoff 11 | % Written: 30-September-2006 12 | % Last update: 23-March-2007 13 | % Last revision: --- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | switch propName 18 | case 'Z' 19 | val = obj.Z; 20 | case 'equations' 21 | val= obj.halfspace.equations; 22 | otherwise 23 | error([propName,' is not a valid asset property']) 24 | end 25 | 26 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/matPolytope.m: -------------------------------------------------------------------------------- 1 | function matP = matPolytope(matZ) 2 | % matPolytope - Converts a matrix zonotope into a matrix polytope 3 | % representation 4 | % 5 | % Syntax: 6 | % matP = matPolytope(matZ) 7 | % 8 | % Inputs: 9 | % matZ - matrix zonotope 10 | % 11 | % Outputs: 12 | % matP - matrix polytope 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: vertices, polytope 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: --- 21 | 22 | % Author: Matthias Althoff 23 | % Written: 22-June-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %convert matrix zonotope to a zonotope 30 | Z=zonotope(matZ); 31 | 32 | %obtain vertices 33 | V=get(vertices(Z),'V'); 34 | for i=1:length(V(1,:)) 35 | matrixVertex{i}=vec2mat(V(:,i)); 36 | end 37 | 38 | %convert polytope to matrix polytope 39 | matP=matPolytope(matrixVertex); 40 | 41 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/mpower.m: -------------------------------------------------------------------------------- 1 | function matZpower = mpower(matZ,exponent) 2 | % mpower - Overloaded '^' operator for the power of matrix zonotope 3 | % 4 | % Syntax: 5 | % matZ = mpower(matZ,exponent) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % exponent - exponent 10 | % 11 | % Outputs: 12 | % matZ - matrix zonotope 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 18-June-2010 24 | % Last update: 05-August-2010 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %factor1 is a numeric matrix 30 | if exponent>=0 31 | if exponent==0 32 | %return identity matrix 33 | matZpower=matZ; 34 | matZpower.center=eye(matZ.dim); 35 | matZpower.generator=[]; 36 | matZpower.gens=0; 37 | elseif exponent==1 38 | %do nothing 39 | matZpower=matZ; 40 | else 41 | matZpower=matZ*matZ; 42 | for i=3:exponent 43 | %multiply matrix zonotope with itself 44 | matZpower=matZpower*matZ; 45 | end 46 | end 47 | else 48 | matZpower=[]; 49 | disp('no negative powers supported') 50 | end 51 | 52 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/plot.m: -------------------------------------------------------------------------------- 1 | function plot(varargin) 2 | % plot - Plots 2-dimensional projection of a matrix zonotope 3 | % 4 | % Syntax: 5 | % plot(obj,dimensions) 6 | % 7 | % Inputs: 8 | % obj - matrix zonotope 9 | % dimensions - dimensions that should be projected (optional) 10 | % linespec - plot style (optional) 11 | % 12 | % Outputs: 13 | % none 14 | % 15 | % Example: 16 | % 17 | % Other m-files required: none 18 | % Subfunctions: none 19 | % MAT-files required: none 20 | % 21 | % See also: none 22 | 23 | % Author: Matthias Althoff 24 | % Written: 22-June-2010 25 | % Last update: --- 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE -------------- 29 | 30 | %convert from matrix zonotope to zonotope 31 | Z=zonotope(varargin{1}); 32 | 33 | %plot zonotope 34 | if nargin==1 35 | plot(Z); 36 | elseif nargin==2 37 | plot(Z,varargin{2}); 38 | else 39 | plot(Z,varargin{2},varargin{3}); 40 | end 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/powers.m: -------------------------------------------------------------------------------- 1 | function pow = powers(varargin) 2 | % powers - computes the powers of a matrix zonotope 3 | % 4 | % Syntax: 5 | % matZ = powers(matZ,maxOrder) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % maxOrder - maximum Taylor series order until remainder is computed 10 | % 11 | % Outputs: 12 | % matZ - matrix zonotope 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 05-August-2010 24 | % Last update: 24-September-2010 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | if nargin==2 30 | matZ = varargin{1}; 31 | maxOrder = varargin{2}; 32 | initialOrder = 1; 33 | initialPower = matZ; 34 | elseif nargin==4 35 | matZ = varargin{1}; 36 | maxOrder = varargin{2}; 37 | initialOrder = varargin{3}; 38 | initialPower = varargin{4}; 39 | end 40 | 41 | %initialize power 42 | pow{initialOrder}=initialPower; 43 | 44 | %compute powers 45 | for i=(initialOrder+1):maxOrder 46 | pow{i} = pow{i-1}*matZ; 47 | end 48 | 49 | 50 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/reduce.m: -------------------------------------------------------------------------------- 1 | function matZred = reduce(matZ,option,order, filterLength) 2 | % reduce - Reduces the order of a matrix zonotope 3 | % This is done by converting the matrix zonotope to a zonotope 4 | % 5 | % Syntax: 6 | % matZred = reduce(matZ,option,order) 7 | % 8 | % Inputs: 9 | % matZ - matrix zonotope 10 | % option - selects the reduction method 11 | % order - order of reduced zonotope 12 | % 13 | % Outputs: 14 | % matZred - reduced matrix zonotope 15 | % 16 | % Example: 17 | % 18 | % Other m-files required: none 19 | % Subfunctions: 20 | % MAT-files required: none 21 | % 22 | % See also: none 23 | 24 | % Author: Matthias Althoff 25 | % Written: 24-June-2010 26 | % Last update: --- 27 | % Last revision:--- 28 | 29 | %------------- BEGIN CODE -------------- 30 | 31 | %convert matrix zonotope to zonotope 32 | Z=zonotope(matZ); 33 | 34 | %reduce zonotope 35 | Zred = reduce(Z, option, order, filterLength); 36 | 37 | %convert back to matrix zonotope 38 | matZred = matZonotope(Zred); 39 | 40 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/set.m: -------------------------------------------------------------------------------- 1 | function obj = set(obj, varargin) 2 | % set - Set data of obj 3 | % 4 | % Syntax: 5 | % obj = set(obj, varargin) 6 | % 7 | % Properties: 8 | % matZ - matrix zonotope 9 | 10 | % Author: Matthias Althoff 11 | % Written: 05-August-2010 12 | % Last update: --- 13 | % Last revision:--- 14 | 15 | %------------- BEGIN CODE -------------- 16 | 17 | propertyArgIn = varargin; 18 | while length(propertyArgIn) >= 2, 19 | property = propertyArgIn{1}; 20 | value = propertyArgIn{2}; 21 | propertyArgIn = propertyArgIn(3:end); 22 | switch property 23 | case 'power' 24 | obj.power = value; 25 | otherwise 26 | error('Property unknown') 27 | end 28 | end 29 | 30 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/vertices.m: -------------------------------------------------------------------------------- 1 | function matV = vertices(matZ) 2 | % vertices - computes the vertices of a matrix zonotope 3 | % 4 | % Syntax: 5 | % matV = vertices(matZ) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % 10 | % Outputs: 11 | % matV - cell array of matrix vertices 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: plus 20 | 21 | % Author: Matthias Althoff 22 | % Written: 24-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %conversion to an intervalhull 29 | Z = zonotope(matZ); 30 | 31 | %compute vertices 32 | V = vertices(Z, 1:matZ.dim^2, 'alternative'); 33 | V = get(V,'V'); 34 | V = unique(V', 'rows')'; %eliminate vectors that occur multiple times 35 | 36 | %convert vertices to matrix vertices 37 | matV=cell(length(V(1,:)),1); 38 | for i=1:length(V(1,:)) 39 | matV{i}=vec2mat(V(:,i)); 40 | end 41 | 42 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/volume.m: -------------------------------------------------------------------------------- 1 | function vol = volume(matZ) 2 | % volume - computes the volume of a matrix zonotope by computing the volume 3 | % of the corresponding zonotope 4 | % 5 | % Syntax: 6 | % vol = volume(matZ) 7 | % 8 | % Inputs: 9 | % matZ - matrix zonotope 10 | % 11 | % Outputs: 12 | % vol - volume 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 24-June-2010 24 | % Last update: --- 25 | % Last revision:--- 26 | 27 | %------------- BEGIN CODE -------------- 28 | 29 | %conversion to a zonotope 30 | Z = zonotope(matZ); 31 | 32 | %compute volume of the zonotope 33 | vol = volume(Z); 34 | 35 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/@matZonotope/zonotope.m: -------------------------------------------------------------------------------- 1 | function Z = zonotope(matZ) 2 | % zonotope - Converts a matrix zonotope into a zonotope 3 | % 4 | % Syntax: 5 | % Z = zonotope(matZ) 6 | % 7 | % Inputs: 8 | % matZ - matrix zonotope 9 | % 10 | % Outputs: 11 | % Z - zonotope 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: plus 20 | 21 | % Author: Matthias Althoff 22 | % Written: 18-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %concert center 29 | center=mat2vec(matZ.center); 30 | 31 | %convert generators 32 | for i=1:matZ.gens 33 | generatorMatrix(:,i)=mat2vec(matZ.generator{i}); 34 | end 35 | 36 | %instantiate zonotope 37 | Z=zonotope([center,generatorMatrix]); 38 | 39 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /matrixSet/changeLog_matrixSet.txt: -------------------------------------------------------------------------------- 1 | 27 Feb 2015 (MA): 2 | 3 | - remove: Hausdorff.m, @intervalMatrix_old 4 | -------------------------------------------------------------------------------- /matrixSet/mat2vec.m: -------------------------------------------------------------------------------- 1 | function vec = mat2vec(mat) 2 | % mat2vec - Stores entries of a matrix into a vector 3 | % 4 | % Syntax: 5 | % vec = mat2vec(mat) 6 | % 7 | % Inputs: 8 | % mat - numerical matrix 9 | % 10 | % Outputs: 11 | % vec - numerical vector 12 | % 13 | % Example: 14 | % 15 | % Other m-files required: none 16 | % Subfunctions: none 17 | % MAT-files required: none 18 | % 19 | % See also: --- 20 | 21 | % Author: Matthias Althoff 22 | % Written: 18-June-2010 23 | % Last update: --- 24 | % Last revision:--- 25 | 26 | %------------- BEGIN CODE -------------- 27 | 28 | %get columns 29 | cols=length(mat(1,:)); 30 | 31 | %concartenate columns 32 | vec=[]; 33 | for i=1:cols 34 | vec(end+1:end+length(mat(:,i)),1)=mat(:,i); 35 | end 36 | 37 | %------------- END OF CODE -------------- 38 | -------------------------------------------------------------------------------- /matrixSet/vec2mat.m: -------------------------------------------------------------------------------- 1 | function [mat]=vec2mat(varargin) 2 | % vec2mat - Stores entries of a vector in a matrix 3 | % 4 | % Syntax: 5 | % [mat]=vec2mat(varargin) 6 | % 7 | % Inputs: 8 | % vec - vector 9 | % cols - number of columns for the matrix 10 | % 11 | % Outputs: 12 | % mat - matrix 13 | % 14 | % Example: 15 | % 16 | % Other m-files required: none 17 | % Subfunctions: none 18 | % MAT-files required: none 19 | % 20 | % See also: plus 21 | 22 | % Author: Matthias Althoff 23 | % Written: 18-June-2010 24 | % Last update: 22-June-2010 25 | % 05-October-2010 26 | % Last revision:--- 27 | 28 | %------------- BEGIN CODE ------------- 29 | 30 | 31 | if nargin==1 32 | vec = varargin{1}; 33 | %get columns 34 | cols = sqrt(length(vec)); 35 | elseif nargin==2 36 | vec = varargin{1}; 37 | %get columns 38 | cols = varargin{2}; 39 | end 40 | 41 | %seperate columns 42 | rows=length(vec)/cols; 43 | for i=1:cols 44 | mat(:,i)=vec(1:rows); 45 | vec(1:rows)=[]; 46 | end 47 | 48 | 49 | %------------- END OF CODE -------------- -------------------------------------------------------------------------------- /models/auxiliary/stirredTankReactor/hessianTensor_stirredTankReactor.m: -------------------------------------------------------------------------------- 1 | function Hf=hessianTensor_stirredTankReactor(x,u) 2 | 3 | 4 | 5 | Hf{1} = interval(sparse(4,4),sparse(4,4)); 6 | 7 | Hf{1}(2,1) = -(3780000000000000*exp(-8750/(x(2) + 350)))/(403*(x(2) + 350)^2); 8 | Hf{1}(1,2) = -(3780000000000000*exp(-8750/(x(2) + 350)))/(403*(x(2) + 350)^2); 9 | Hf{1}(2,2) = (7560000000000000*exp(-8750/(x(2) + 350))*(x(1) + 1/2))/(403*(x(2) + 350)^3) - (33075000000000000000*exp(-8750/(x(2) + 350))*(x(1) + 1/2))/(403*(x(2) + 350)^4); 10 | 11 | 12 | Hf{2} = interval(sparse(4,4),sparse(4,4)); 13 | 14 | Hf{2}(2,1) = (189000000000000000000*exp(-8750/(x(2) + 350)))/(97817*(x(2) + 350)^2); 15 | Hf{2}(1,2) = (189000000000000000000*exp(-8750/(x(2) + 350)))/(97817*(x(2) + 350)^2); 16 | Hf{2}(2,2) = (7319375000000*exp(-8750/(x(2) + 350))*((54000000000000*x(1))/239 + 27000000000000/239))/(97817*(x(2) + 350)^4) - (1673000000*exp(-8750/(x(2) + 350))*((54000000000000*x(1))/239 + 27000000000000/239))/(97817*(x(2) + 350)^3); 17 | -------------------------------------------------------------------------------- /models/auxiliary/stirredTankReactor/jacobian_stirredTankReactor.m: -------------------------------------------------------------------------------- 1 | function [A,B]=jacobian_stirredTankReactor(x,u) 2 | 3 | A=[397/403 - (432000000000*exp(-8750/(x(2) + 350)))/403,-(3780000000000000*exp(-8750/(x(2) + 350))*(x(1) + 1/2))/(403*(x(2) + 350)^2);... 4 | (21600000000000000*exp(-8750/(x(2) + 350)))/97817 - 9000/97817,(836500000*exp(-8750/(x(2) + 350))*((54000000000000*x(1))/239 + 27000000000000/239))/(97817*(x(2) + 350)^2) + 72683/97817]; 5 | 6 | B=[3/200,0;... 7 | 0,3/200]; 8 | 9 | -------------------------------------------------------------------------------- /models/auxiliary/stirredTankReactor/stirredTankReactor_lastVersion.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/models/auxiliary/stirredTankReactor/stirredTankReactor_lastVersion.mat -------------------------------------------------------------------------------- /utilities/invIntMatrixAuto.m: -------------------------------------------------------------------------------- 1 | function [intMatOut] = invIntMatrixAuto(intMatIn) 2 | %INVMATRIX Summary of this function goes here 3 | % Detailed explanation goes here 4 | intMatIn_int = intMatIn.int; 5 | Acenter = (intMatIn_int.sup + intMatIn_int.inf)/2; 6 | Adelta = (intMatIn_int.sup - intMatIn_int.inf)/2; 7 | 8 | 9 | M = pinv(eye(size(pinv(Acenter)*Adelta)) - abs(pinv(Acenter))*Adelta); 10 | mu = diag(M); 11 | Tmu = diag(mu); 12 | Tv = pinv(2*Tmu - eye(size(Tmu))); 13 | Blower = -M*abs(pinv(Acenter)) +Tmu*( pinv(Acenter) + abs(pinv(Acenter))) ; 14 | Bupper = M*abs(pinv(Acenter)) +Tmu* (pinv(Acenter) - abs(pinv(Acenter))) ; 15 | 16 | Blowerlower =min(Blower,Tv*Blower); 17 | Bupperupper =max(Bupper,Tv*Bupper); 18 | 19 | intMatOut = intervalMatrix((Bupperupper+Blowerlower)/2,(Bupperupper-Blowerlower)/2); 20 | 21 | % M = pinv(eye(size(Acenter)) - abs(pinv(Acenter))*Adelta); 22 | % mu = diag(M); 23 | % Tmu = diag(mu); 24 | % Tv = pinv(2*Tmu - eye(size(Acenter))); 25 | % Blower = -M*abs(pinv(Acenter)) +Tmu*( pinv(Acenter) + abs(pinv(Acenter))) ; 26 | % Bupper = M*abs(pinv(Acenter)) +Tmu* (pinv(Acenter) - abs(pinv(Acenter))) ; 27 | % 28 | % Blowerlower =min(Blower,Tv*Blower); 29 | % Bupperupper =max(Bupper,Tv*Bupper); 30 | end 31 | 32 | -------------------------------------------------------------------------------- /workspaces/ZPC.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/ZPC.mat -------------------------------------------------------------------------------- /workspaces/ZPC_in100st5W0.1V0.02N2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/ZPC_in100st5W0.1V0.02N2.mat -------------------------------------------------------------------------------- /workspaces/ZPC_in4st100W0.01V0.002.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/ZPC_in4st100W0.01V0.002.mat -------------------------------------------------------------------------------- /workspaces/ZPC_wo_costline.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/ZPC_wo_costline.mat -------------------------------------------------------------------------------- /workspaces/poly.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/poly.mat -------------------------------------------------------------------------------- /workspaces/poly_W0.01V0.002.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/poly_W0.01V0.002.mat -------------------------------------------------------------------------------- /workspaces/poly_W0.1V0.02N2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aalanwar/Data-Driven-Predictive-Control/b9b8fd58fe68f704a663eb26167c991edf794550/workspaces/poly_W0.1V0.02N2.mat --------------------------------------------------------------------------------