Skip to content

Commit

Permalink
Упрощена основная программа, вызывающая тестирование тех или иных алг…
Browse files Browse the repository at this point in the history
…оритмов.

Колебания, на которых тестируются алгоритмы, - теперь приближены к реальным данным.
  • Loading branch information
e-maxx committed Dec 27, 2011
1 parent edf20af commit fbd1b2f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
7 changes: 7 additions & 0 deletions constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
#define CONSTANTS_H


#include <boost/math/constants/constants.hpp>


//! Константа, с которой сравниваются дробные числа.
#define EPS 1E-9


//! Число "пи"
#define PI boost::math::constants::pi<long double>()


#endif // CONSTANTS_H
73 changes: 35 additions & 38 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,65 @@
#include "math_modelling/math_modelling.hpp"
#include "math_modelling/artifical_input/plane_angles/artifical_input_plane_angles_harmonious.hpp"
#include "algorithms/old_algorithms/average_speed_algorithm.hpp"
#include "algorithms/old_algorithms/average_speed_riccati_algorithm.hpp"
#include "algorithms/auto_generated/2_step.hpp"
//#include "algorithms/biquaternion/average_speed_biquaternion_algorithm.hpp"
#include "algorithms/old_algorithms/panov_algorithm.hpp"
#include "algorithms/old_algorithms/panov_riccati_algorithm.hpp"
#include "algorithms/old_algorithms/method_2step_4degree.hpp"
#include "types/plane_angles.hpp"
#include "types/biquaternion.hpp"


void test_average_speed_algorithm (double h) {
boost::shared_ptr < algorithm<quaternion,vector3> > alg (
new average_speed_algorithm<quaternion,vector3> ()
);
alg->set_step (0.0001);
alg->set_last_time (10);

void test_algorithm (boost::shared_ptr < algorithm<quaternion,vector3> > alg, long double h) {
alg->set_step (h);
alg->set_last_time (3600);


boost::shared_ptr < artifical_input<quaternion,vector3> > input (
new artifical_input_plane_angles_harmonious (
plane_angles (0.1, 0.2, 0.3),
plane_angles (1, 2, 3)
plane_angles (20 * PI/180, 15 * PI/180, 20 * PI/180),
plane_angles (PI/2, PI, PI)
)
);


math_modelling<quaternion,vector3> m;
m.set_data (input);
auto result = m.run_algorithm (alg);
BOOST_AUTO( result, m.run_algorithm (alg) );

auto res = *result;
std::cerr << res.max_difference << std::endl;
BOOST_AUTO( res, *result );
std::cerr << std::fixed << res.max_difference << ' ';
std::cout << std::fixed << res.max_difference << '\t';
}


void test_auto_generated_2_step_algorithm (double h) {
template <class alg>
void test_algorithm (long double h) {
boost::shared_ptr < algorithm<quaternion,vector3> > alg (
new auto_generated_2_step_algorithm<quaternion,vector3> ()
new alg ()
);
alg->set_step (h);
alg->set_last_time (10);
test_algorithm (alg, h);
}


boost::shared_ptr < artifical_input<quaternion,vector3> > input (
new artifical_input_plane_angles_harmonious (
plane_angles (0.1, 0.2, 0.3),
plane_angles (1, 2, 3)
)
);

int main() {
freopen ("output.txt", "wt", stdout);

math_modelling<quaternion,vector3> m;
m.set_data (input);
auto result = m.run_algorithm (alg);
std::cerr.precision (20);
std::cout.precision (20);

auto res = *result;
std::cerr << res.max_difference << std::endl;
}
for (long double h=0.8; ; h/=2) {
default_integrator (boost::shared_ptr< integrator<vector3> > (new simpson_integrator<vector3> (h / 10)));
std::cout << std::fixed << h << '\t';

test_algorithm < average_speed_algorithm<quaternion,vector3> > (h);
test_algorithm < average_speed_riccati_algorithm<quaternion,vector3> > (h);
test_algorithm < panov_algorithm > (h);
test_algorithm < panov_riccati_algorithm > (h);
test_algorithm < method_2step_4degree > (h);

int main() {

test_auto_generated_2_step_algorithm (0.1);
test_auto_generated_2_step_algorithm (0.01);
test_auto_generated_2_step_algorithm (0.001);
test_auto_generated_2_step_algorithm (0.0001);
test_auto_generated_2_step_algorithm (0.00001);
std::cerr << std::endl;
std::cout << std::endl;
}

}
}

0 comments on commit fbd1b2f

Please sign in to comment.