|
|
@ -1,27 +1,12 @@ |
|
|
|
#include "Attractor.hpp" |
|
|
|
|
|
|
|
#include "Logger.hpp" |
|
|
|
#include <fstream> |
|
|
|
#include <iostream> |
|
|
|
#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")), kernel->getDimension()); |
|
|
|
} |
|
|
|
|
|
|
|
Attractor::Attractor() : |
|
|
|
kernel(0), projector(0) { |
|
|
|
stfu::node kernel_node; |
|
|
@ -49,81 +34,11 @@ Attractor::Attractor() : |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
std::cout << kernel_node << std::endl; |
|
|
|
|
|
|
|
kernel = AttractorKernel::createAttractorKernel(kernel_node); |
|
|
|
kernel->generate_random_parameters(); |
|
|
|
|
|
|
|
stfu::node projector_node; |
|
|
|
projector_node.value("dimensions") = "2"; |
|
|
|
|
|
|
|
std::cout << projector_node << std::endl; |
|
|
|
|
|
|
|
projector = Projector::createProjector(projector_node, kernel->getDimension()); |
|
|
|
} |
|
|
|
|
|
|
|
Attractor::~Attractor() { |
|
|
|
delete kernel; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// this should probably done in the projector section
|
|
|
|
void Attractor::init_range() { |
|
|
|
// stabilize attractor
|
|
|
|
for(unsigned int i = 0; i < 1000000; i++) { |
|
|
|
iterate(); |
|
|
|
if(kernel->convergent() || kernel->divergent()){ |
|
|
|
kernel->generate_random_parameters(); |
|
|
|
LogDebug("Generating new parameters.\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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"); |
|
|
|
} |
|
|
|