-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_one.m
72 lines (50 loc) · 2.04 KB
/
main_one.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [out, params] = main_one(Dataset,out,input_params)
% This is the main script for a single simulation or optimisation step.
% The inputs and outputs are optional.
close all;
reset_path;
% To create a Dataset use: Dataset = importParquet('XXX.csv');
% Dataset = parquetread('Code/Common/Import/ExampleDataset.parquet');
if ~exist('Dataset','var'), Dataset = []; end
% To append the output from a previous estimation, use the input out.
if ~exist('out','var'), out = []; end
% To pass the parameters from a previous estimation, use the input params.
% To generate a parameters structure, use: params = load_output(out);
if ~exist('input_params','var'), input_params = []; end
%% Setup
% The following settings must be defined.
% ModelName: choose from the available Models (OCV, RORC, EHMT, etc.)
% Target: choose from Simulate, Plot, Compare or Parameter
% Estimator: choose from the available Methods (Fmincon, PEM)
% Settings
ModelName = 'EHMT';
Target = 'Simulate';
Estimator = 'PEM';
j = 0;
%% Start
fprintf('\nComputation started at %s\n', datetime("now"));
% Add relevant paths
reset_path;
addpath(genpath(strcat('./Code/Models/',ModelName)));
addpath(genpath(strcat('./Code/Methods/',Estimator)));
% Define dimensionless model
input_params.fit_derivative = false; % true or false
[Model, params] = step0(ModelName,j,input_params);
Model.Noise = false; % true or false
% Load or generate data
[true_sol, params] = step1(Target,Model,params,j,Dataset);
% Perform estimation and update parameter values
[est_sol, params] = step2(Target,Model,params,j);
% Run simulation using updated parameters
[pred_sol, params] = step3(Target,Model,params,j,est_sol);
% Compare prediction and data
params = step4(Target,params,true_sol,pred_sol);
%% Save
% Only need to save the updated parameters structure as plots
% can be re-generated using Simulate or Compare.
% Convert and save the parameters in a table
out = tabulate_output(params,out);
% Save output and current figure
save_output(out,['Data/out_' ModelName]);
% save_plot(gcf,['Data/plot_' ModelName]);
end