00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __MULTILAYERPERCEPTRON_H__
00017 #define __MULTILAYERPERCEPTRON_H__
00018
00019 #include <string>
00020
00021 #include "../Perceptron/Perceptron.h"
00022
00023 #include "../Utilities/Vector.h"
00024 #include "../Utilities/Matrix.h"
00025
00026 namespace Flood
00027 {
00028
00030
00031 class MultilayerPerceptron
00032 {
00033
00034 public:
00035
00036
00037
00038 explicit MultilayerPerceptron(void);
00039
00040
00041
00042 explicit MultilayerPerceptron(int, const Vector<int>&, int);
00043
00044
00045
00046 explicit MultilayerPerceptron(int, int, int);
00047
00048
00049
00050 explicit MultilayerPerceptron(int);
00051
00052
00053
00054 explicit MultilayerPerceptron(const char*);
00055
00056
00057
00058 MultilayerPerceptron(const MultilayerPerceptron&);
00059
00060
00061
00062 virtual ~MultilayerPerceptron(void);
00063
00064
00065
00066 MultilayerPerceptron& operator = (const MultilayerPerceptron&);
00067
00068
00069
00071
00072 enum LayerActivationFunction{Logistic, HyperbolicTangent, Threshold, SymmetricThreshold, Linear};
00073
00075
00076 enum ScalingMethod{None, MeanStandardDeviation, MinimumMaximum};
00077
00079
00080 enum NumericalEpsilonMethod{Absolute, Relative};
00081
00083
00084 enum NumericalDifferentiationMethod{ForwardDifferences, CentralDifferences};
00085
00086
00087
00088
00089
00091
00092 inline int get_inputs_number(void)
00093 {
00094 return(inputs_number);
00095 }
00096
00098
00099 inline int get_hidden_layers_number(void)
00100 {
00101 return(hidden_layers_size.get_size());
00102 }
00103
00105
00106 inline Vector<int>& get_hidden_layers_size(void)
00107 {
00108 return(hidden_layers_size);
00109 }
00110
00113
00114 inline int get_hidden_layer_size(int i)
00115 {
00116 return(hidden_layers_size[i]);
00117 }
00118
00120
00121 inline int get_outputs_number(void)
00122 {
00123 return(outputs_number);
00124 }
00125
00126 int get_hidden_layer_inputs_number(int);
00127 int get_output_layer_inputs_number(void);
00128
00129 Vector< Vector<Perceptron> >& get_hidden_layers(void);
00130 Vector<Perceptron>& get_hidden_layer(int);
00131
00132 Vector<Perceptron>& get_output_layer(void);
00133
00134
00135
00136 int get_neural_parameters_number(void);
00137
00138 int get_hidden_layers_parameters_number(void);
00139 int get_hidden_layer_parameters_number(int);
00140
00141 int get_output_layer_parameters_number(void);
00142
00143 Vector<double> get_neural_parameters(void);
00144
00145 Vector< Vector<double> > get_hidden_layers_biases(void);
00146 Vector<double> get_hidden_layer_biases(int);
00147
00148 Vector< Matrix<double> > get_hidden_layers_synaptic_weights(void);
00149 Matrix<double> get_hidden_layer_synaptic_weights(int);
00150
00151 Vector< Matrix<double> > get_hidden_layers_parameters(void);
00152 Matrix<double> get_hidden_layer_parameters(int);
00153
00154 Vector<double> get_output_layer_biases(void);
00155 Matrix<double> get_output_layer_synaptic_weights(void);
00156 Matrix<double> get_output_layer_parameters(void);
00157
00158 int get_hidden_layer_bias_index(int, int);
00159 int get_hidden_layer_synaptic_weight_index(int, int, int);
00160
00161 int get_output_layer_bias_index(int);
00162 int get_output_layer_synaptic_weight_index(int, int);
00163
00164
00165
00166 Vector<LayerActivationFunction>& get_hidden_layers_activation_function(void);
00167 Vector<std::string> get_hidden_layers_activation_function_name(void);
00168
00169 LayerActivationFunction& get_hidden_layer_activation_function(int);
00170 std::string get_hidden_layer_activation_function_name(int);
00171
00172 LayerActivationFunction& get_output_layer_activation_function(void);
00173 std::string get_output_layer_activation_function_name(void);
00174
00175
00176
00177 ScalingMethod& get_inputs_scaling_method(void);
00178 std::string get_inputs_scaling_method_name(void);
00179
00180 ScalingMethod& get_outputs_unscaling_method(void);
00181 std::string get_outputs_unscaling_method_name(void);
00182
00183
00184
00185 Vector<std::string>& get_input_variables_name(void);
00186 std::string& get_input_variable_name(int);
00187
00188 Vector<std::string>& get_input_variables_units(void);
00189 std::string& get_input_variable_units(int);
00190
00191 Vector<std::string>& get_input_variables_description(void);
00192 std::string& get_input_variable_description(int);
00193
00194
00195
00196 Vector<std::string>& get_output_variables_name(void);
00197 std::string& get_output_variable_name(int);
00198
00199 Vector<std::string>& get_output_variables_units(void);
00200 std::string& get_output_variable_units(int);
00201
00202 Vector<std::string>& get_output_variables_description(void);
00203 std::string& get_output_variable_description(int);
00204
00205
00206
00207 Vector< Vector<std::string>* > get_variables_information(void);
00208
00209
00210
00211 Vector<double>& get_input_variables_mean(void);
00212 double get_input_variable_mean(int);
00213
00214 Vector<double>& get_input_variables_standard_deviation(void);
00215 double get_input_variable_standard_deviation(int);
00216
00217 Vector<double>& get_input_variables_minimum(void);
00218 double get_input_variable_minimum(int);
00219
00220 Vector<double>& get_input_variables_maximum(void);
00221 double get_input_variable_maximum(int);
00222
00223 Vector< Vector<double>* > get_input_variables_mean_standard_deviation(void);
00224 Vector< Vector<double>* > get_input_variables_minimum_maximum(void);
00225
00226
00227
00228 Vector<double>& get_output_variables_mean(void);
00229 double get_output_variable_mean(int);
00230
00231 Vector<double>& get_output_variables_standard_deviation(void);
00232 double get_output_variable_standard_deviation(int);
00233
00234 Vector<double>& get_output_variables_minimum(void);
00235 double get_output_variable_minimum(int);
00236
00237 Vector<double>& get_output_variables_maximum(void);
00238 double get_output_variable_maximum(int);
00239
00240 Vector< Vector<double>* > get_output_variables_mean_standard_deviation(void);
00241 Vector< Vector<double>* > get_output_variables_minimum_maximum(void);
00242
00243 Vector< Vector<double>* > get_variables_statistics(void);
00244
00245
00246
00247 Vector<double>& get_output_variables_lower_bound(void);
00248 double get_output_variables_lower_bound(int);
00249
00250 Vector<double>& get_output_variables_upper_bound(void);
00251 double get_output_variable_upper_bound(int);
00252
00253 Vector< Vector<double>* > get_output_variables_bounds(void);
00254
00255
00256
00259
00260 inline int get_independent_parameters_number(void)
00261 {
00262 return(independent_parameters.get_size());
00263 }
00264
00265 Vector<double>& get_independent_parameters(void);
00266 double get_independent_parameter(int);
00267
00268
00269
00270 ScalingMethod& get_independent_parameters_scaling_method(void);
00271 std::string get_independent_parameters_scaling_method_name(void);
00272
00273
00274
00275 Vector<std::string>& get_independent_parameters_name(void);
00276 std::string& get_independent_parameter_name(int);
00277
00278 Vector<std::string>& get_independent_parameters_units(void);
00279 std::string& get_independent_parameter_units(int);
00280
00281 Vector<std::string>& get_independent_parameters_description(void);
00282 std::string& get_independent_parameter_description(int);
00283
00284 Vector< Vector<std::string>* > get_independent_parameters_information(void);
00285
00286
00287
00288 Vector<double>& get_independent_parameters_mean(void);
00289 double get_independent_parameter_mean(int);
00290
00291 Vector<double>& get_independent_parameters_standard_deviation(void);
00292 double get_independent_parameter_standard_deviation(int);
00293
00294 Vector<double>& get_independent_parameters_minimum(void);
00295 double get_independent_parameter_minimum(int);
00296
00297 Vector<double>& get_independent_parameters_maximum(void);
00298 double get_independent_parameter_maximum(int);
00299
00300 Vector< Vector<double>* > get_independent_parameters_mean_standard_deviation(void);
00301 Vector< Vector<double>* > get_independent_parameters_minimum_maximum(void);
00302
00303 Vector< Vector<double>* > get_independent_parameters_statistics(void);
00304
00305
00306
00307 Vector<double>& get_independent_parameters_lower_bound(void);
00308 double get_independent_parameter_lower_bound(int);
00309
00310 Vector<double>& get_independent_parameters_upper_bound(void);
00311 double get_independent_parameter_upper_bound(int);
00312
00313 Vector< Vector<double>* > get_independent_parameters_bounds(void);
00314
00315
00316
00317 int get_parameters_number(void);
00318
00319 Vector<double> get_parameters(void);
00320
00321
00322
00323 NumericalDifferentiationMethod& get_numerical_differentiation_method(void);
00324 std::string get_numerical_differentiation_method_name(void);
00325
00326 NumericalEpsilonMethod& get_numerical_epsilon_method(void);
00327 std::string get_numerical_epsilon_method_name(void);
00328
00329 double get_numerical_epsilon(void);
00330
00331
00332
00333 bool get_display_range_out_warning(void);
00334 bool get_display(void);
00335
00336
00337
00338 void set(void);
00339 void set(int, const Vector<int>&, int);
00340 void set(int, int, int);
00341 void set(int);
00342 void set(const char*);
00343 void set(const MultilayerPerceptron&);
00344
00345 void set_default(void);
00346
00347
00348
00349 void set_network_architecture(int, const Vector<int>&, int);
00350 void set_network_architecture(int, int, int);
00351
00352 void set_hidden_layers_size(const Vector<int>&);
00353 void set_hidden_layer_size(int);
00354
00355
00356
00357 void set_neural_parameters(const Vector<double>&);
00358
00359 void set_hidden_layers_biases(const Vector< Vector<double> >&);
00360 void set_hidden_layer_biases(int, const Vector<double>&);
00361
00362 void set_hidden_layers_synaptic_weights(const Vector< Matrix<double> >&);
00363 void set_hidden_layer_synaptic_weights(int, const Matrix<double>&);
00364
00365 void set_hidden_layers_parameters(const Vector< Matrix<double> >&);
00366 void set_hidden_layer_parameters(int, const Matrix<double>&);
00367
00368 void set_output_layer_biases(const Vector<double>&);
00369 void set_output_layer_synaptic_weights(const Matrix<double>&);
00370 void set_output_layer_parameters(const Matrix<double>&);
00371
00372
00373
00374 void set_hidden_layers_activation_function(const Vector<LayerActivationFunction>&);
00375 void set_hidden_layer_activation_function(int, const LayerActivationFunction&);
00376
00377 void set_output_layer_activation_function(const LayerActivationFunction&);
00378
00379 void set_hidden_layers_activation_function(const Vector<std::string>&);
00380 void set_hidden_layer_activation_function(int, const std::string&);
00381
00382 void set_output_layer_activation_function(const std::string&);
00383
00384
00385
00386 void set_inputs_scaling_method(const ScalingMethod&);
00387 void set_outputs_unscaling_method(const ScalingMethod&);
00388
00389 void set_variables_scaling_method(const ScalingMethod&);
00390
00391 void set_inputs_scaling_method(const std::string&);
00392 void set_outputs_unscaling_method(const std::string&);
00393
00394
00395
00396 void set_input_variables_name(const Vector<std::string>&);
00397 void set_input_variable_name(int, const std::string&);
00398
00399 void set_input_variables_units(const Vector<std::string>&);
00400 void set_input_variable_units(int, const std::string&);
00401
00402 void set_input_variables_description(const Vector<std::string>&);
00403 void set_input_variable_description(int, const std::string&);
00404
00405
00406
00407 void set_output_variables_name(const Vector<std::string>&);
00408 void set_output_variable_name(int, const std::string&);
00409
00410 void set_output_variables_units(const Vector<std::string>&);
00411 void set_output_variable_units(int, const std::string&);
00412
00413 void set_output_variables_description(const Vector<std::string>&);
00414 void set_output_variable_description(int, const std::string&);
00415
00416
00417
00418 void set_variables_information(const Vector< Vector<std::string> >&);
00419
00420
00421
00422 void set_input_variables_mean(const Vector<double>&);
00423 void set_input_variable_mean(int, double);
00424
00425 void set_input_variables_standard_deviation(const Vector<double>&);
00426 void set_input_variable_standard_deviation(int, double);
00427
00428 void set_input_variables_minimum(const Vector<double>&);
00429 void set_input_variable_minimum(int, double);
00430
00431 void set_input_variables_maximum(const Vector<double>&);
00432 void set_input_variable_maximum(int, double);
00433
00434 void set_input_variables_mean_standard_deviation(const Vector< Vector<double> >&);
00435 void set_input_variables_minimum_maximum(const Vector< Vector<double> >&);
00436
00437 void set_output_variables_mean(const Vector<double>&);
00438 void set_output_variable_mean(int, double);
00439
00440
00441
00442 void set_output_variables_standard_deviation(const Vector<double>&);
00443 void set_output_variable_standard_deviation(int, double);
00444
00445 void set_output_variables_minimum(const Vector<double>&);
00446 void set_output_variable_minimum(int, double);
00447
00448 void set_output_variables_maximum(const Vector<double>&);
00449 void set_output_variable_maximum(int, double);
00450
00451 void set_output_variables_mean_standard_deviation(const Vector< Vector<double> >&);
00452 void set_output_variables_minimum_maximum(const Vector< Vector<double> >&);
00453
00454
00455
00456 void set_variables_statistics(const Vector< Vector<double> >&);
00457
00458
00459
00460 void set_output_variables_lower_bound(const Vector<double>&);
00461 void set_output_variable_lower_bound(int, double);
00462
00463 void set_output_variables_upper_bound(const Vector<double>&);
00464 void set_output_variable_upper_bound(int, double);
00465
00466 void set_output_variables_bounds(const Vector< Vector<double> >&);
00467
00468
00469
00470 void set_independent_parameters_number(int);
00471
00472 void set_independent_parameters(const Vector<double>&);
00473 void set_independent_parameter(int, double);
00474
00475
00476
00477 void set_independent_parameters_scaling_method(const ScalingMethod&);
00478 void set_independent_parameters_scaling_method(const std::string&);
00479
00480
00481
00482 void set_independent_parameters_name(const Vector<std::string>&);
00483 void set_independent_parameter_name(int, const std::string&);
00484
00485 void set_independent_parameters_units(const Vector<std::string>&);
00486 void set_independent_parameter_units(int, const std::string&);
00487
00488 void set_independent_parameters_description(const Vector<std::string>&);
00489 void set_independent_parameter_description(int, const std::string&);
00490
00491
00492
00493 void set_independent_parameters_mean(const Vector<double>&);
00494 void set_independent_parameter_mean(int, double);
00495
00496 void set_independent_parameters_standard_deviation(const Vector<double>&);
00497 void set_independent_parameter_standard_deviation(int, double);
00498
00499 void set_independent_parameters_minimum(const Vector<double>&);
00500 void set_independent_parameter_minimum(int, double);
00501
00502 void set_independent_parameters_maximum(const Vector<double>&);
00503 void set_independent_parameter_maximum(int, double);
00504
00505 void set_independent_parameters_mean_standard_deviation(const Vector< Vector<double> >&);
00506 void set_independent_parameters_minimum_maximum(const Vector< Vector<double> >&);
00507
00508 void set_independent_parameters_statistics(const Vector< Vector<double> >&);
00509
00510
00511
00512 void set_independent_parameters_lower_bound(const Vector<double>&);
00513 void set_independent_parameter_lower_bound(int, double);
00514
00515 void set_independent_parameters_upper_bound(const Vector<double>&);
00516 void set_independent_parameter_upper_bound(int, double);
00517
00518 void set_independent_parameters_bounds(const Vector< Vector<double> >&);
00519
00520
00521
00522 void set_parameters(const Vector<double>&);
00523
00524
00525
00526 void set_scaling_method(const ScalingMethod&);
00527
00528
00529
00530 void set_numerical_differentiation_method(const NumericalDifferentiationMethod&);
00531 void set_numerical_differentiation_method(const std::string&);
00532
00533 void set_numerical_epsilon_method(const NumericalEpsilonMethod&);
00534 void set_numerical_epsilon_method(const std::string&);
00535
00536 void set_numerical_epsilon(double);
00537
00538
00539
00540 void set_display_range_out_warning(bool);
00541 void set_display(bool);
00542
00543
00544
00545 void initialize_neural_parameters(double);
00546 void initialize_biases(double);
00547 void initialize_synaptic_weights(double);
00548
00549 void initialize_neural_parameters_uniform(void);
00550 void initialize_neural_parameters_uniform(double, double);
00551 void initialize_neural_parameters_uniform(const Vector<double>&, const Vector<double>&);
00552 void initialize_neural_parameters_uniform(const Vector< Vector<double> >&);
00553
00554 void initialize_neural_parameters_normal(void);
00555 void initialize_neural_parameters_normal(double, double);
00556 void initialize_neural_parameters_normal(const Vector<double>&, const Vector<double>&);
00557 void initialize_neural_parameters_normal(const Vector< Vector<double> >&);
00558
00559
00560
00561 void initialize_independent_parameters(double);
00562
00563 void initialize_independent_parameters_uniform(void);
00564 void initialize_independent_parameters_uniform(double, double);
00565 void initialize_independent_parameters_uniform(const Vector<double>&, const Vector<double>&);
00566 void initialize_independent_parameters_uniform(const Vector< Vector<double> >&);
00567
00568 void initialize_independent_parameters_normal(void);
00569 void initialize_independent_parameters_normal(double, double);
00570 void initialize_independent_parameters_normal(const Vector<double>&, const Vector<double>&);
00571 void initialize_independent_parameters_normal(const Vector< Vector<double> >&);
00572
00573
00574
00575 void initialize_parameters(double);
00576
00577 void initialize_parameters_uniform(void);
00578 void initialize_parameters_uniform(double, double);
00579 void initialize_parameters_uniform(const Vector<double>&, const Vector<double>&);
00580 void initialize_parameters_uniform(const Vector< Vector<double> >&);
00581
00582 void initialize_parameters_normal(void);
00583 void initialize_parameters_normal(double, double);
00584 void initialize_parameters_normal(const Vector<double>&, const Vector<double>&);
00585 void initialize_parameters_normal(const Vector< Vector<double> >&);
00586
00587
00588
00589 double calculate_neural_parameters_norm(void);
00590 double calculate_independent_parameters_norm(void);
00591 double calculate_parameters_norm(void);
00592
00593
00594
00595 Vector<double> calculate_output(const Vector<double>&);
00596 Matrix<double> calculate_output_matrix(const Matrix<double>&);
00597
00598 Vector< Vector<double> > calculate_forward_propagation(const Vector<double>&);
00599 Vector< Vector<double> > calculate_forward_propagation_derivative(const Vector<double>&);
00600 Vector< Vector<double> > calculate_forward_propagation_second_derivative(const Vector<double>&);
00601
00602 void check_input_range(const Vector<double>&);
00603
00604 Vector<double> calculate_scaled_input(const Vector<double>&);
00605
00606 Vector<double> calculate_hidden_layer_combination(int, const Vector<double>&);
00607 Vector<double> calculate_hidden_layer_activation(int, const Vector<double>&);
00608 Vector<double> calculate_hidden_layer_activation_derivative(int, const Vector<double>&);
00609 Vector<double> calculate_hidden_layer_activation_second_derivative(int, const Vector<double>&);
00610
00611 Vector<double> calculate_hidden_layer_output(int, const Vector<double>&);
00612
00613 Vector<double> calculate_output_layer_combination(const Vector<double>&);
00614 Vector<double> calculate_output_layer_activation(const Vector<double>&);
00615 Vector<double> calculate_output_layer_activation_derivative(const Vector<double>&);
00616 Vector<double> calculate_output_layer_activation_second_derivative(const Vector<double>&);
00617
00618 Vector<double> calculate_output_layer_output(const Vector<double>&);
00619
00620 Vector<double> calculate_unscaled_output(const Vector<double>&);
00621 Vector<double> calculate_bounded_output(const Vector<double>&);
00622
00623
00624
00625 Matrix<double> calculate_Jacobian(const Vector<double>&);
00626 Vector< Matrix<double> > calculate_Jacobian_vector(const Matrix<double>&);
00627
00628 Matrix<double> calculate_hidden_layer_Jacobian(int, const Vector<double>&);
00629 Matrix<double> calculate_output_layer_Jacobian(const Vector<double>&);
00630
00631 Matrix<double> calculate_Jacobian_numerical_differentiation(const Vector<double>&);
00632
00633 Matrix<double> calculate_Jacobian_forward_differences(const Vector<double>&);
00634 Matrix<double> calculate_Jacobian_central_differences(const Vector<double>&);
00635
00636
00637
00638 Matrix<double> calculate_sensitivity(const Vector<double>&);
00639 Vector< Matrix<double> > calculate_sensitivity_vector(const Matrix<double>&);
00640
00641 Matrix<double> calculate_sensitivity_numerical_differentiation(const Vector<double>&);
00642
00643 Matrix<double> calculate_sensitivity_forward_differences(const Vector<double>&);
00644 Matrix<double> calculate_sensitivity_central_differences(const Vector<double>&);
00645
00646
00647
00648 Vector<double> scale_independent_parameters(void);
00649 void unscale_independent_parameters(const Vector<double>&);
00650
00651 void bound_independent_parameters(void);
00652 void bound_independent_parameter(int);
00653
00654
00655
00656 double calculate_actual_epsilon(double);
00657
00658
00659
00660 std::string get_expression(void);
00661
00662 Vector<std::string> get_inputs_name_expression(void);
00663 Vector<std::string> get_scaled_inputs_name_expression(void);
00664
00665 Vector<std::string> get_hidden_layer_inputs_name_expression(int);
00666 Vector<std::string> get_hidden_layer_outputs_name_expression(int);
00667
00668 Vector<std::string> get_output_layer_inputs_name_expression(void);
00669
00670 Vector<std::string> get_scaled_outputs_name_expression(void);
00671 Vector<std::string> get_outputs_name_expression(void);
00672
00673 std::string get_hidden_layer_activation_function_expression(int);
00674 std::string get_output_layer_activation_function_expression(void);
00675
00676 std::string get_hidden_layer_expression(int);
00677 std::string get_output_layer_expression(void);
00678
00679 std::string get_forward_propagation_expression(void);
00680
00681 std::string get_inputs_scaling_expression(void);
00682 std::string get_outputs_unscaling_expression(void);
00683
00684 void save_expression(const char*);
00685
00686
00687
00688 std::string get_Hinton_diagram(void);
00689 void save_Hinton_diagram(const char*);
00690
00691
00692
00693 std::string to_XML(bool);
00694
00695 void print(void);
00696 void save(const char*);
00697 void load(const char*);
00698
00699
00700
00701
00717
00718 template<class BoundaryConditionsType>
00719 Vector<double> calculate_output(const Vector<double>& input, BoundaryConditionsType& boundary_conditions)
00720 {
00721
00722
00723 #ifdef _DEBUG
00724
00725 int size = input.get_size();
00726
00727 if(size != inputs_number)
00728 {
00729 std::cerr << "Flood Error: MultilayerPerceptron class." << std::endl
00730 << "Vector<double> calculate_output(const Vector<double>&, const BoundaryConditionsType&) method."
00731 << std::endl
00732 << "Size must be equal to number of inputs." << std::endl;
00733
00734 exit(1);
00735 }
00736
00737 #endif
00738
00739 int hidden_layers_number = get_hidden_layers_number();
00740
00741 check_input_range(input);
00742
00743
00744
00745 Vector<double> scaled_input = calculate_scaled_input(input);
00746
00747 Vector< Vector<double> > forward_propagation = calculate_forward_propagation(scaled_input);
00748
00749 Vector<double> unscaled_output = calculate_unscaled_output(forward_propagation[hidden_layers_number]);
00750
00751
00752
00753 Vector<double> particular_solution = boundary_conditions.calculate_particular_solution(input);
00754 Vector<double> homogeneous_solution = boundary_conditions.calculate_homogeneous_solution(input);
00755
00756 Vector<double> boundary_conditions_output = particular_solution + homogeneous_solution*unscaled_output;
00757
00758
00759
00760 Vector<double> bounded_output = calculate_bounded_output(boundary_conditions_output);
00761
00762 return(bounded_output);
00763 }
00764
00765
00766
00767
00779
00780 template<class BoundaryConditionsType>
00781 Matrix<double> calculate_Jacobian(const Vector<double>& input, BoundaryConditionsType& boundary_conditions)
00782 {
00783 Vector<double> output = calculate_output(input);
00784 Matrix<double> Jacobian = calculate_Jacobian(input);
00785
00786
00787
00788 Vector<double> particular_solution = boundary_conditions.calculate_particular_solution(input);
00789 Vector<double> homogeneous_solution = boundary_conditions.calculate_homogeneous_solution(input);
00790 Vector<double> particular_solution_derivative = boundary_conditions.calculate_particular_solution_derivative(input);
00791 Vector<double> homogeneous_solution_derivative = boundary_conditions.calculate_homogeneous_solution_derivative(input);
00792
00793 for(int i = 0; i < outputs_number; i++)
00794 {
00795 for(int j = 0; j < inputs_number; j++)
00796 {
00797 Jacobian[i][j]
00798 = particular_solution_derivative[i]
00799 + homogeneous_solution_derivative[i]*output[i]
00800 + homogeneous_solution[i]*Jacobian[i][j];
00801 }
00802 }
00803
00804 return(Jacobian);
00805 }
00806
00807
00808 protected:
00809
00810
00811
00813
00814 int inputs_number;
00815
00819
00820 Vector<int> hidden_layers_size;
00821
00823
00824 int outputs_number;
00825
00829
00830 Vector< Vector<Perceptron> > hidden_layers;
00831
00834
00835 Vector<Perceptron> output_layer;
00836
00838
00839 Vector<LayerActivationFunction> hidden_layers_activation_function;
00840
00842
00843 LayerActivationFunction output_layer_activation_function;
00844
00846
00847 ScalingMethod inputs_scaling_method;
00848
00850
00851 ScalingMethod outputs_unscaling_method;
00852
00854
00855 Vector<std::string> input_variables_name;
00856
00858
00859 Vector<std::string> input_variables_units;
00860
00862
00863 Vector<std::string> input_variables_description;
00864
00866
00867 Vector<std::string> output_variables_name;
00868
00870
00871 Vector<std::string> output_variables_units;
00872
00874
00875 Vector<std::string> output_variables_description;
00876
00877
00879
00880 Vector<double> input_variables_mean;
00881
00883
00884 Vector<double> input_variables_standard_deviation;
00885
00887
00888 Vector<double> input_variables_minimum;
00889
00891
00892 Vector<double> input_variables_maximum;
00893
00894
00896
00897 Vector<double> output_variables_mean;
00898
00900
00901 Vector<double> output_variables_standard_deviation;
00902
00904
00905 Vector<double> output_variables_minimum;
00906
00908
00909 Vector<double> output_variables_maximum;
00910
00911
00913
00914 Vector<double> output_variables_lower_bound;
00915
00917
00918 Vector<double> output_variables_upper_bound;
00919
00920
00922
00923 Vector<double> independent_parameters;
00924
00926
00927 ScalingMethod independent_parameters_scaling_method;
00928
00929
00931
00932 Vector<std::string> independent_parameters_name;
00933
00935
00936 Vector<std::string> independent_parameters_units;
00937
00939
00940 Vector<std::string> independent_parameters_description;
00941
00942
00944
00945 Vector<double> independent_parameters_mean;
00946
00948
00949 Vector<double> independent_parameters_standard_deviation;
00950
00952
00953 Vector<double> independent_parameters_minimum;
00954
00956
00957 Vector<double> independent_parameters_maximum;
00958
00959
00961
00962 Vector<double> independent_parameters_lower_bound;
00963
00965
00966 Vector<double> independent_parameters_upper_bound;
00967
00968
00972
00973 NumericalDifferentiationMethod numerical_differentiation_method;
00974
00976
00977 NumericalEpsilonMethod numerical_epsilon_method;
00978
00980
00981 double numerical_epsilon;
00982
00984
00985 bool display_range_out_warning;
00986
00988
00989 bool display;
00990 };
00991
00992 }
00993
00994 #endif
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012