|
|
|
#include "Attractor.hpp"
|
|
|
|
|
|
|
|
#include "Logger.hpp"
|
|
|
|
#include <fstream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
|
|
|
#include "stfu/stf.hpp"
|
|
|
|
|
|
|
|
#include "AttractorKernel.hpp"
|
|
|
|
#include "Projector.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
Attractor::Attractor(const std::string& filename) : kernel(0), projector(0) {
|
|
|
|
// opening file
|
|
|
|
LogInfo("Reading file '%s'...\n", filename.c_str());
|
|
|
|
|
|
|
|
stfu::node system;
|
|
|
|
system.read(filename.c_str());
|
|
|
|
|
|
|
|
kernel = AttractorKernel::createAttractorKernel(system.getChild("AttractorKernel"));
|
|
|
|
projector = Projector::createProjector(system.getChild(system.getValue("Projector")), system);
|
|
|
|
}
|
|
|
|
|
|
|
|
Attractor::~Attractor(){
|
|
|
|
delete kernel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this should probably done in the projector section
|
|
|
|
void Attractor::init_range() {
|
|
|
|
// stabilize attractor
|
|
|
|
for ( unsigned int i = 0; i < 100000; i++ ) {
|
|
|
|
iterate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Attractor::is_chaos() {
|
|
|
|
/*
|
|
|
|
check existence of attractor:
|
|
|
|
Escaping
|
|
|
|
Single point attractor
|
|
|
|
Lyapunov exponent
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
double sum = 0;
|
|
|
|
for ( unsigned int i = 0; i < dim; i++ ) {
|
|
|
|
const double dist = 0; //new_point[i] - point[i];
|
|
|
|
sum += dist*dist;
|
|
|
|
}
|
|
|
|
if ( sum >= 1.0e7 ) {
|
|
|
|
// big change => Escaping
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( sum <= 1.0e-7 ) {
|
|
|
|
// small change => singularity
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
*/
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attractor::iterate() {
|
|
|
|
(*kernel)();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Attractor::plot() {
|
|
|
|
const double * point = kernel->vector();
|
|
|
|
projector->plot(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
IO & control
|
|
|
|
*/
|
|
|
|
void Attractor::output() {
|
|
|
|
const unsigned int dimension = kernel->getDimension();
|
|
|
|
const double * point = kernel->vector();
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
|
|
|
LogMoreInfo("%f, ", point[i]);
|
|
|
|
}
|
|
|
|
LogMoreInfo("\n");
|
|
|
|
}
|