|
|
|
#ifndef ATTRACTOR_HPP
|
|
|
|
#define ATTRACTOR_HPP
|
|
|
|
|
|
|
|
#include "Logger.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "AttractorKernel.hpp"
|
|
|
|
#include "Projector.hpp"
|
|
|
|
|
|
|
|
class Attractor {
|
|
|
|
public:
|
|
|
|
// should be private really
|
|
|
|
Projector* projector;
|
|
|
|
|
|
|
|
Attractor(const std::string& filename)
|
|
|
|
: projector(0)
|
|
|
|
, kernel(0)
|
|
|
|
{
|
|
|
|
LogInfo("Reading file '%s'...\n", filename.c_str());
|
|
|
|
|
|
|
|
stfu::node system;
|
|
|
|
if(!system.read(filename.c_str())){
|
|
|
|
std::cerr << "Couldn't open file (" << filename << ") for reading\n";
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
kernel = AttractorKernel::createAttractorKernel(system.getChild("AttractorKernel"));
|
|
|
|
projector = Projector::createProjector(system.getChild(system.getValue("Projector")), kernel->getDimension());
|
|
|
|
}
|
|
|
|
|
|
|
|
Attractor();
|
|
|
|
|
|
|
|
~Attractor() {
|
|
|
|
delete kernel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_range() {
|
|
|
|
for(unsigned int i = 0; i < 1000000; i++) {
|
|
|
|
iterate();
|
|
|
|
if(kernel->convergent() || kernel->divergent()){
|
|
|
|
kernel->generate_random_parameters();
|
|
|
|
LogDebug("Generating new parameters.\n");
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void iterate() {
|
|
|
|
(*kernel)();
|
|
|
|
}
|
|
|
|
|
|
|
|
void plot() {
|
|
|
|
projector->plot(kernel->vector());
|
|
|
|
}
|
|
|
|
|
|
|
|
void 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");
|
|
|
|
}
|
|
|
|
|
|
|
|
stfu::node stf_output(){
|
|
|
|
stfu::node kernel_node = kernel-> stf_output();
|
|
|
|
stfu::node projector_node;/* = projector->stf_output();*/
|
|
|
|
stfu::node system;
|
|
|
|
system.addChild("AttractorKernel", kernel_node);
|
|
|
|
system.addChild("Projector", projector_node);
|
|
|
|
return system;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, Attractor const& x);
|
|
|
|
|
|
|
|
private:
|
|
|
|
AttractorKernel* kernel;
|
|
|
|
|
|
|
|
Attractor(Attractor const &);
|
|
|
|
Attractor& operator=(Attractor const &);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ATTRACTOR_HPP
|
|
|
|
|