My old project for strange attractors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

91 lines
2.0 KiB

#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(LOG_VERBOSE, std::cout, "searching for parameters");
for(unsigned int i = 0; i < 1000000; i++) {
iterate();
if(kernel->convergent() || kernel->divergent()){
kernel->generate_random_parameters();
p.update();
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