-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptimizationWindow.h
236 lines (172 loc) · 6.42 KB
/
OptimizationWindow.h
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#ifndef _MobiView2_OptimizationWindow_h_
#define _MobiView2_OptimizationWindow_h_
#include <CtrlLib/CtrlLib.h>
#include <AutoScroller/AutoScroller.h>
#include "PlotCtrl.h"
#define LAYOUTFILE <MobiView2/OptimizationWindow.lay>
#include <CtrlCore/lay.h>
#include "support/optimization.h"
#include "support/mcmc.h"
class OptimizationParameterSetup : public WithOptimizationLayout<Upp::ParentCtrl> {
public:
typedef OptimizationParameterSetup CLASSNAME;
OptimizationParameterSetup();
};
class OptimizationTargetSetup : public WithOptimizationTargetLayout<Upp::ParentCtrl> {
public:
typedef OptimizationTargetSetup CLASSNAME;
OptimizationTargetSetup();
};
class OptimizationRunSetup : public WithOptimizerSetupLayout<Upp::ParentCtrl> {
public:
typedef OptimizationRunSetup CLASSNAME;
OptimizationRunSetup();
};
class MCMCRunSetup : public WithMCMCSetupLayout<Upp::ParentCtrl> {
public:
typedef MCMCRunSetup CLASSNAME;
MCMCRunSetup();
};
class SensitivityRunSetup : public WithSensitivitySetupLayout<Upp::ParentCtrl> {
public:
typedef SensitivityRunSetup CLASSNAME;
SensitivityRunSetup();
};
class MobiView2;
class OptimizationWindow : public Upp::TopWindow {
public:
typedef OptimizationWindow CLASSNAME;
OptimizationWindow(MobiView2 *parent);
void add_parameter_clicked();
void add_group_clicked();
void remove_parameter_clicked();
void clear_parameters_clicked();
void add_virtual_clicked();
void add_target_clicked();
void remove_target_clicked();
void clear_targets_clicked();
void run_clicked(int run_mode);
void display_clicked();
void clean();
void set_error(const Upp::String &err_str);
void read_from_json_string(const Upp::String &json);
Upp::String write_to_json_string();
void symbol_edited(int row);
void expr_edited(int row);
void err_sym_edited(int row);
void weight_edited(int row);
void stat_edited(int row);
void start_edited(int row);
void end_edited(int row);
void sampler_method_selected();
bool err_sym_fixup();
private:
MobiView2 *parent;
bool add_single_parameter(Indexed_Parameter parameter, bool lookup_default = true);
void add_optimization_target(Optimization_Target &target);
void sub_bar(Upp::Bar &bar);
void write_to_json();
void read_from_json();
void tab_change();
bool run_mcmc_from_window(MCMC_Sampler method, double *sampler_params, int n_walkers, int n_pars, int n_steps, Optimization_Model *optim,
std::vector<double> &initial_values, std::vector<double> &min_bound, std::vector<double> &max_bound, int init_type, int callback_interval, int run_type);
bool run_variance_based_sensitivity(int n_samples, int sample_method, Optimization_Model *optim, double *min_bound, double *max_bound);
Upp::Array<Upp::EditDoubleNotNull> edit_min_ctrls;
Upp::Array<Upp::EditDoubleNotNull> edit_max_ctrls;
Upp::Array<Upp::EditField> edit_sym_ctrls;
Upp::Array<Upp::EditField> edit_expr_ctrls;
Upp::Array<Upp::DropList> target_stat_ctrls;
Upp::Array<Upp::EditDoubleNotNull> target_weight_ctrls;
Upp::Array<Upp::EditField> target_err_ctrls;
Upp::Array<Upp::EditTimeNotNull> target_start_ctrls;
Upp::Array<Upp::EditTimeNotNull> target_end_ctrls;
Upp::Array<Upp::EditDoubleNotNull> mcmc_sampler_param_ctrls;
Upp::ToolBar tool;
Upp::Splitter main_vertical;
OptimizationParameterSetup par_setup;
OptimizationTargetSetup target_setup;
public:
OptimizationRunSetup run_setup;
MCMCRunSetup mcmc_setup;
SensitivityRunSetup sensitivity_setup;
MC_Data mc_data;
// The only function of the 'parameters' vector is to hold data that is being edited by the parameter view.
// expr_pars is the final setup used in the optimizer runs, and will then hold a copy of data from
// 'parameters'
std::vector<Indexed_Parameter> parameters;
std::vector<Optimization_Target> targets;
Expr_Parameters expr_pars;
};
class MCMCProjectionCtrl : public WithMCMCProjectionLayout<Upp::ParentCtrl> {
public:
typedef MCMCProjectionCtrl CLASSNAME;
MCMCProjectionCtrl();
};
class MCMCResultWindow : public WithMCMCResultLayout<Upp::TopWindow> {
public:
typedef MCMCResultWindow CLASSNAME;
MCMCResultWindow(MobiView2 *parent);
MobiView2 *parent;
void begin_new_plots(MC_Data &data, std::vector<double> &min_bound, std::vector<double> &max_bound, int run_type);
void clean();
void resize_chain_plots();
void refresh_plots(s64 step = -1);
void burnin_slider_event();
void burnin_edit_event();
void sub_bar(Upp::Bar &bar);
void save_results();
bool load_results();
void map_to_main_pushed();
void median_to_main_pushed();
void generate_projections_pushed();
//bool halt_was_pushed;
private:
void refresh_result_summary(s64 step = -1);
Upp::ToolBar tool;
MC_Data *data = nullptr;
//TODO: Pack these into MC_Data? Would make more sense for serialization.
Upp::Vector<Upp::String> free_syms;
std::vector<double> min_bound;
std::vector<double> max_bound;
Upp::AutoScroller chain_plot_scroller;
Upp::AutoScroller triangle_plot_scroller;
Upp::ParentCtrl view_chain_plots;
Upp::ParentCtrl view_triangle_plots;
Upp::ParentCtrl view_result_summary;
MyRichView result_summary;
Upp::Button push_write_map;
Upp::Button push_write_median;
std::vector<double> acor_times;
std::vector<bool> acor_below_tolerance;
const int distr_resolution = 20;
double burnin[2];
std::vector<double> burnin_plot_y;
Upp::Array<Upp::ScatterCtrl> chain_plots;
Upp::Array<Data_Source_Owns_XY> histogram_ds;
Upp::Array<Upp::ScatterCtrl> histogram_plots;
Upp::Array<Table_Data_Owns_XYZ> triangle_plot_ds;
Upp::Array<Upp::ScatterCtrl> triangle_plots;
MCMCProjectionCtrl view_projections;
Upp::AutoScroller projection_plot_scroll;
Upp::ParentCtrl projection_plot_pane;
Upp::Array<MyPlot> projection_plots;
Upp::AutoScroller resid_plot_scroll;
Upp::ParentCtrl resid_plot_pane;
Upp::Array<MyPlot> resid_plots;
Upp::Array<MyPlot> resid_histograms;
Upp::AutoScroller autocorr_plot_scroll;
Upp::ParentCtrl autocorr_plot_pane;
Upp::Array<MyPlot> autocorr_plots;
public:
Expr_Parameters expr_pars;
std::vector<Optimization_Target> targets;
};
class VarianceSensitivityWindow : public WithVarSensitivityResultLayout<Upp::TopWindow> {
public:
typedef VarianceSensitivityWindow CLASSNAME;
VarianceSensitivityWindow();
void clean();
};
Plot_Setup
target_to_plot_setup(Optimization_Target &target, Model_Application *app);
#endif