|
|
|
#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)
|
|
|
|
{
|
|
|
|
if (filename == "") {
|
|
|
|
LogInfo("Making random attractor\n");
|
|
|
|
generate_random();
|
|
|
|
} else {
|
|
|
|
LogInfo("Reading file '%s'\n", filename.c_str());
|
|
|
|
|
|
|
|
stfu::node system;
|
|
|
|
if(!system.read(filename.c_str())) throw std::runtime_error(filename + " could not be opened");
|
|
|
|
|
|
|
|
kernel = AttractorKernel::createAttractorKernel(system.getChild("AttractorKernel"));
|
|
|
|
projector = Projector::createProjector(system.getChild(system.getValue("Projector")), kernel->getDimension());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~Attractor() {
|
|
|
|
delete kernel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_range() {
|
|
|
|
ProgressIndicator p(std::cout, LOG_VERBOSE, "searching for parameters");
|
|
|
|
for(unsigned int i = 0; i < 1000000; i++) {
|
|
|
|
iterate();
|
|
|
|
if(kernel->convergent() || kernel->divergent()){
|
|
|
|
kernel->generate_random_parameters();
|
|
|
|
p.show();
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void iterate() {
|
|
|
|
(*kernel)();
|
|
|
|
}
|
|
|
|
|
|
|
|
void project() {
|
|
|
|
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);
|
|
|
|
system.addValue("Projector") = "Projector";
|
|
|
|
return system;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, Attractor const& x);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void generate_random();
|
|
|
|
|
|
|
|
AttractorKernel* kernel;
|
|
|
|
|
|
|
|
Attractor(Attractor const &);
|
|
|
|
Attractor& operator=(Attractor const &);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ATTRACTOR_HPP
|
|
|
|
|