-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_sim_specs_sim1_3KF_seed.m
79 lines (59 loc) · 2.09 KB
/
gen_sim_specs_sim1_3KF_seed.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
72
73
74
75
76
77
78
79
% Generate simulation specifications for tuning KF
% on SISO system
clear all
addpath("../yaml")
% Main folder where all simulation results will be saved
sims_dir = "simulations";
% Simulation group name
sim_name = "rod_obs_sim1_3KF_seed";
% Create main directory for these simulations
base_dir = fullfile(sims_dir, sim_name);
if ~isfolder(base_dir)
mkdir(base_dir);
end
% Subdirectory for spec files
sim_specs_dir = "sim_specs";
filepath = fullfile(base_dir, sim_specs_dir, "queue");
if ~isfolder(base_dir)
mkdir(base_dir);
end
% Seeds for each simulation
seed_values = 0:9;
fprintf("Generating simulation specification files...\n")
% Define struct to store info
% Basic info
data.info.label = "<placeholder>"; % this will be changed below
data.info.description = ...
"Simulations of single Kalman filters on linear SISO system with " + ...
"different random seeds.";
fprintf("%16s: %s\n", "Simulation", sim_name)
% System
data.system.setup_script = "sys_rodin_step.m";
data.system.label = "rodin_step";
% Input generation
data.inputs.setup_script = "rod_obs_sim_inputs.m";
% Observers
data.observers.setup_script = "obs_rodin_step.m";
% Simulation setup
data.setup.plot_dir = fullfile(sims_dir, sim_name, "plots");
data.setup.results_dir = fullfile(sims_dir, sim_name, "results");
data.setup.seed = "<placeholder>"; % this will be changed below;
data.setup.observers = ["KF1", "KF2", "KF3"];
data.setup.t_stop = 2500;
data.setup.verbose = false;
% Output handling
data.outputs.setup_script = "rod_obs_sim_outputs.m";
data.outputs.results_file = "<placeholder>"; % this will be changed below;
data.outputs.summary_file = "rod_obs_sim_outputs_summary.csv";
n_seeds = numel(seed_values);
for i = 1:n_seeds
% Label
data.info.label = sprintf("%s_%03d", sim_name, i);
data.outputs.results_file = sprintf("rod_obs_sim_outputs_%03d.csv", i);
% Change variable
data.setup.seed = seed_values(i);
% Save to Yaml file
filename = sprintf("sim_spec_%03d.yml", i);
yaml.dumpFile(fullfile(filepath, filename), data, "block")
fprintf("%16s: %s\n", "File created", filename)
end