├── .gitignore ├── LICENSE.pdf ├── MATLAB ├── +Observers │ ├── ExtendedKalmanFilter.m │ ├── KalmanFilter.m │ ├── Observer.m │ ├── ParticleFilter.m │ ├── UnscentedKalmanFilter.m │ ├── computeSigmaPoints.m │ ├── meanCovSampler.m │ ├── wcov.m │ └── wmean.m ├── +Prognosis │ ├── Predictor.m │ └── Prognoser.m ├── testKalmanFilter.m ├── testParticleFilter.m ├── testPredictor.m ├── testPrognoser.m └── testUnscentedKalmanFilter.m ├── README.md ├── docs └── PrognosticsAlgorithmLibrary-UserManual.pdf └── install └── PrognosticsAlgorithmLibrary.mltbx /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /LICENSE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/LICENSE.pdf -------------------------------------------------------------------------------- /MATLAB/+Observers/ExtendedKalmanFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/ExtendedKalmanFilter.m -------------------------------------------------------------------------------- /MATLAB/+Observers/KalmanFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/KalmanFilter.m -------------------------------------------------------------------------------- /MATLAB/+Observers/Observer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/Observer.m -------------------------------------------------------------------------------- /MATLAB/+Observers/ParticleFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/ParticleFilter.m -------------------------------------------------------------------------------- /MATLAB/+Observers/UnscentedKalmanFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/UnscentedKalmanFilter.m -------------------------------------------------------------------------------- /MATLAB/+Observers/computeSigmaPoints.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/computeSigmaPoints.m -------------------------------------------------------------------------------- /MATLAB/+Observers/meanCovSampler.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/meanCovSampler.m -------------------------------------------------------------------------------- /MATLAB/+Observers/wcov.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/wcov.m -------------------------------------------------------------------------------- /MATLAB/+Observers/wmean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Observers/wmean.m -------------------------------------------------------------------------------- /MATLAB/+Prognosis/Predictor.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Prognosis/Predictor.m -------------------------------------------------------------------------------- /MATLAB/+Prognosis/Prognoser.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/+Prognosis/Prognoser.m -------------------------------------------------------------------------------- /MATLAB/testKalmanFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/testKalmanFilter.m -------------------------------------------------------------------------------- /MATLAB/testParticleFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/testParticleFilter.m -------------------------------------------------------------------------------- /MATLAB/testPredictor.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/testPredictor.m -------------------------------------------------------------------------------- /MATLAB/testPrognoser.m: -------------------------------------------------------------------------------- 1 | function testPrognoser 2 | % testPrognoser Test Prognoser class for Battery model 3 | % 4 | % Copyright (c) 2016 United States Government as represented by the 5 | % Administrator of the National Aeronautics and Space Administration. 6 | % No copyright is claimed in the United States under Title 17, U.S. 7 | % Code. All Other Rights Reserved. 8 | 9 | % Create battery model 10 | %batt = BatteryCircuit.Create; 11 | batt = Battery.Create; 12 | 13 | % Set variable input profile 14 | % Dependent on model (circuit uses current, electrochemistry uses power) 15 | if strcmp(batt.name,'BatteryCircuit') 16 | loads = [2.63; 100*60]; 17 | elseif strcmp(batt.name,'Battery') 18 | loads = [8; 100*60]; 19 | else 20 | error('Model ' + batt.name + ' not supported'); 21 | end 22 | 23 | % Set up noise covariance matrices 24 | Q = diag(batt.V); 25 | R = diag(batt.N); 26 | 27 | % Create UKF 28 | UKF = Observers.UnscentedKalmanFilter(@batt.stateEqn,@batt.outputEqn,... 29 | Q,R,'symmetric',3-size(batt.states,2),1); 30 | 31 | % Create sample generator for input equation parameters 32 | % For each of the 5 load segments, sample from a uniform distribution with 33 | % the mean given in the loads vector and the range [-1,+1] W for load and 34 | % [-60,+60] s for the durations. 35 | gains = ones(length(loads),1); 36 | gains(2:2:end) = 60; 37 | inputParameterSampler = @(N) repmat(loads,1,N) + repmat(gains,1,N).*(rand(length(loads),N)-0.5); 38 | 39 | % Create Prognoser 40 | horizon = 5000; 41 | numSamples = 100; 42 | prognoser = Prognosis.Prognoser('model',batt,'observer',UKF,... 43 | 'horizon',horizon,'numSamples',numSamples,... 44 | 'stateSampler',@Observers.meanCovSampler,... 45 | 'inputParameterSampler',inputParameterSampler,... 46 | 'processNoiseSampler',@batt.generateProcessNoise); 47 | 48 | % Get initial state for battery simulation 49 | t0 = 0; 50 | [x0,u0,z0] = batt.getDefaultInitialization(t0,loads); 51 | 52 | % Update/initialize prognoser based on initial data 53 | prognoser.initialize(t0,x0,u0); 54 | prognoser.update(t0,u0,z0); 55 | 56 | % Set up output data matrices 57 | dt = 1; 58 | T = t0:dt:3100; 59 | X = zeros(length(x0),length(T)); 60 | Z = zeros(length(z0),length(T)); 61 | XEst = X; 62 | ZEst = Z; 63 | X(:,1) = x0; 64 | Z(:,1) = z0; 65 | XEst(:,1) = UKF.x; 66 | ZEst(:,1) = UKF.z; 67 | EODMean = []; 68 | EODMax = []; 69 | EODMin = []; 70 | predictionTimes = []; 71 | 72 | % Initialize simulation 73 | x = x0; 74 | u = u0; 75 | z = z0; 76 | 77 | % Simulate battery and run prognoser 78 | for i=2:length(T) 79 | % Update state from T(i-1) to T(i) 80 | x = batt.stateEqn(T(i-1),x,u,batt.generateProcessNoise(),dt); 81 | % Get inputs for time T(i) 82 | u = batt.inputEqn(T(i),loads); 83 | % Compute outputs for time T(i) 84 | z = batt.outputEqn(T(i),x,u,batt.generateSensorNoise()); 85 | 86 | % Update step for prognoser 87 | prognoser.update(T(i),u,z); 88 | 89 | % Predict once per minute 90 | if mod(i-1,60)==0 91 | prognoser.predict(); 92 | 93 | % Print some status 94 | fprintf('Time: %g s\n',T(i)); 95 | batt.printOutputs(z); 96 | fprintf(' EOD: %g s\n',mean(prognoser.predictor.predictions.thresholdTimes)); 97 | 98 | % Save some prediction data 99 | predictionTimes(end+1) = T(i); 100 | EODMean(end+1) = mean(prognoser.predictor.predictions.thresholdTimes); 101 | EODMin(end+1) = min(prognoser.predictor.predictions.thresholdTimes); 102 | EODMax(end+1) = max(prognoser.predictor.predictions.thresholdTimes); 103 | end 104 | 105 | % Save data 106 | X(:,i) = x; 107 | Z(:,i) = z; 108 | XEst(:,i) = UKF.x; 109 | ZEst(:,i) = UKF.z; 110 | end 111 | 112 | % Plot output estimates 113 | figure; 114 | subplot(2,1,1); 115 | plot(T,Z(1,:),'.',T,ZEst(1,:),'--'); 116 | title('Temperature Estimates'); 117 | xlabel('Time (s)') 118 | ylabel('Temperature (deg C)'); 119 | subplot(2,1,2); 120 | plot(T,Z(2,:),'.',T,ZEst(2,:),'--'); 121 | title('Voltage Estimates'); 122 | xlabel('Time (s)'); 123 | ylabel('Voltage (V)'); 124 | legend('Measured','Estimated'); 125 | 126 | % Compute actual end of discharge time, giving the exact loading parameters 127 | if strcmp(batt.name,'BatteryCircuit') 128 | batt.inputEqnHandle = @(P,t)BatteryCircuit.InputEqn(P,t,loads); 129 | elseif strcmp(batt.name,'Battery') 130 | batt.inputEqnHandle = @(P,t)Battery.InputEqn(P,t,loads); 131 | else 132 | error('Model ' + batt.name + ' not supported'); 133 | end 134 | T = batt.simulateToThreshold(); 135 | trueEOD = T(end); 136 | 137 | % Plot prediction results 138 | figure; 139 | plot(predictionTimes,EODMean,'o',predictionTimes,EODMin,'o',... 140 | predictionTimes,EODMax,'o',predictionTimes,... 141 | trueEOD*ones(size(predictionTimes)),'o'); 142 | legend('Predicted EOD Mean','Predicted EOD Min','Predicted EOD Max',... 143 | 'True EOD'); 144 | axis tight; 145 | xlabel('Time (s)') 146 | ylabel('EOD (s)') 147 | -------------------------------------------------------------------------------- /MATLAB/testUnscentedKalmanFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/MATLAB/testUnscentedKalmanFilter.m -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prognostics Algorithm Library 2 | 3 | The Prognostics Algorithm Library is a suite of algorithms implemented in the MATLAB programming language for model-based prognostics (remaining life computation). It includes algorithms for state estimation and prediction, including uncertainty propagation. The algorithms take as inputs component models developed in Matlab, and perform estimation and prediction functions. The library allows the rapid development of prognostics solutions for given models of components and systems. Different algorithms can be easily swapped to do comparative studies and evaluations of different algorithms to select the best for the application at hand. 4 | 5 | ## Citation 6 | 7 | Publications making use of software products obtained from this repository are requested to acknowledge the assistance received by using this repository. Please cite: "M. Daigle; Prognostics Algorithm Library [Computer software]. (2016). Retrieved from https://github.com/nasa/PrognosticsAlgorithmLibrary". 8 | 9 | ## Installation 10 | 11 | Installation can be done in one of two ways. Either (1) use the MATLAB toolbox installer provided in the install folder, which will install the toolbox in your local toolboxes folder and add the folder to your MATLAB path, or (2) copy the source from the MATLAB folder to any desired directory, and add that directory to your MATLAB path. Do not add the subdirectories (the package directories) to your MATLAB path. If the first option is used, then the MATLAB add-on manager can be used to uninstall the package; otherwise, the installation can be removed manually by removing the directory from your MATLAB path and deleting the source. 12 | 13 | ## User Manual 14 | 15 | Instructions for using the software can be found in the following sources: 16 | - [Wiki](https://github.com/nasa/PrognosticsAlgorithmLibrary/wiki) 17 | - [User Manual](https://github.com/nasa/PrognosticsAlgorithmLibrary/blob/master/docs/PrognosticsAlgorithmLibrary-UserManual.pdf) 18 | 19 | ## Dependencies 20 | 21 | Some modules included in this library are dependent on the [Prognostics Model Library](https://github.com/nasa/PrognosticsModelLibrary). 22 | 23 | ## Compatibility 24 | 25 | The PrognosticsModelLibrary has been tested with Matlab R2016a, but should work with older versions, down to at least R2012a. 26 | 27 | ## Contributions 28 | 29 | All contributions are welcome. Issues may be opened using GitHub. To contribute directly, open a pull request against the "develop" branch. Pull requests will be evaluated and integrated into the next official release. 30 | 31 | ## License 32 | 33 | This software is released under the [NASA Open Source Agreement Version 1.3](https://github.com/nasa/PrognosticsAlgorithmLibrary/blob/master/LICENSE.pdf). 34 | 35 | ## Notices 36 | 37 | Copyright © 2016 United States Government as represented by the Administrator of the National Aeronautics and Space Administration.  No copyright is claimed in the United States under Title 17, U.S. Code. All Other Rights Reserved. 38 | 39 | ### Disclaimers 40 | 41 | No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.  FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS." 42 | 43 | Waiver and Indemnity:  RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT.  IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW.  RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. 44 | 45 | -------------------------------------------------------------------------------- /docs/PrognosticsAlgorithmLibrary-UserManual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/docs/PrognosticsAlgorithmLibrary-UserManual.pdf -------------------------------------------------------------------------------- /install/PrognosticsAlgorithmLibrary.mltbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/PrognosticsAlgorithmLibrary/1a7b7171d1b38c87f17a47aa539fd179ca1bb1cf/install/PrognosticsAlgorithmLibrary.mltbx --------------------------------------------------------------------------------