From e6ab4a8ed100d5d5b7611c74cf3ccd556f1f1d71 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:04:34 +0100 Subject: Initial commit --- include/HyperNeat/Utils/Atomic.hpp | 12 +++++++++ include/HyperNeat/Utils/Function.hpp | 12 +++++++++ include/HyperNeat/Utils/LoadFile.hpp | 40 ++++++++++++++++++++++++++++++ include/HyperNeat/Utils/Map.hpp | 12 +++++++++ include/HyperNeat/Utils/NodeTypes.hpp | 22 +++++++++++++++++ include/HyperNeat/Utils/Pi.hpp | 9 +++++++ include/HyperNeat/Utils/Point.hpp | 21 ++++++++++++++++ include/HyperNeat/Utils/Pointer.hpp | 12 +++++++++ include/HyperNeat/Utils/Random.hpp | 14 +++++++++++ include/HyperNeat/Utils/SaveFile.hpp | 45 ++++++++++++++++++++++++++++++++++ include/HyperNeat/Utils/Set.hpp | 12 +++++++++ include/HyperNeat/Utils/Size.hpp | 12 +++++++++ include/HyperNeat/Utils/String.hpp | 11 +++++++++ include/HyperNeat/Utils/Thread.hpp | 11 +++++++++ include/HyperNeat/Utils/ValueMap.hpp | 12 +++++++++ include/HyperNeat/Utils/ValuePoint.hpp | 19 ++++++++++++++ include/HyperNeat/Utils/Vector.hpp | 12 +++++++++ include/HyperNeat/Utils/Vector2D.hpp | 12 +++++++++ 18 files changed, 300 insertions(+) create mode 100644 include/HyperNeat/Utils/Atomic.hpp create mode 100644 include/HyperNeat/Utils/Function.hpp create mode 100644 include/HyperNeat/Utils/LoadFile.hpp create mode 100644 include/HyperNeat/Utils/Map.hpp create mode 100644 include/HyperNeat/Utils/NodeTypes.hpp create mode 100644 include/HyperNeat/Utils/Pi.hpp create mode 100644 include/HyperNeat/Utils/Point.hpp create mode 100644 include/HyperNeat/Utils/Pointer.hpp create mode 100644 include/HyperNeat/Utils/Random.hpp create mode 100644 include/HyperNeat/Utils/SaveFile.hpp create mode 100644 include/HyperNeat/Utils/Set.hpp create mode 100644 include/HyperNeat/Utils/Size.hpp create mode 100644 include/HyperNeat/Utils/String.hpp create mode 100644 include/HyperNeat/Utils/Thread.hpp create mode 100644 include/HyperNeat/Utils/ValueMap.hpp create mode 100644 include/HyperNeat/Utils/ValuePoint.hpp create mode 100644 include/HyperNeat/Utils/Vector.hpp create mode 100644 include/HyperNeat/Utils/Vector2D.hpp (limited to 'include/HyperNeat/Utils') diff --git a/include/HyperNeat/Utils/Atomic.hpp b/include/HyperNeat/Utils/Atomic.hpp new file mode 100644 index 0000000..850a06e --- /dev/null +++ b/include/HyperNeat/Utils/Atomic.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_ATOM_HPP__ +#define __HYPERNEAT_ATOM_HPP__ + +#include + +namespace hyperneat +{ + template + using Atomic = std::atomic; +} + +#endif diff --git a/include/HyperNeat/Utils/Function.hpp b/include/HyperNeat/Utils/Function.hpp new file mode 100644 index 0000000..ebcb27b --- /dev/null +++ b/include/HyperNeat/Utils/Function.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_FUNCTION_HPP__ +#define __HYPERNEAT_FUNCTION_HPP__ + +#include + +namespace hyperneat +{ + template + using Function = std::function; +} + +#endif diff --git a/include/HyperNeat/Utils/LoadFile.hpp b/include/HyperNeat/Utils/LoadFile.hpp new file mode 100644 index 0000000..1960e90 --- /dev/null +++ b/include/HyperNeat/Utils/LoadFile.hpp @@ -0,0 +1,40 @@ +#ifndef __HYPERNEAT_LOADFILE_HPP__ +#define __HYPERNEAT_LOADFILE_HPP__ + +#include +#include +#include + +namespace hyperneat +{ + using Istream = std::istream; + + class Genome; + class Organism; + class Population; + class NoveltyMetric; + class PopulationPrms; + class NoveltyMetricPrms; + + class LoadFile + { + public: + LoadFile(Istream& stream); + + void loadPopulation(Population& population); + void loadPopulationPrms(PopulationPrms& prms); + void loadNeuralNetPrms(NeuralNetPrms& prms); + void loadNoveltyMetric(NoveltyMetric& noveltyMetric); + void loadNoveltyMetricPrms(NoveltyMetricPrms& prms); + void loadOrganism(Organism& organism); + void loadGenome(Genome& genome); + + private: + Istream& nextPrm(bool arrayVal = false); + Istream& nextArrayValue(); + + Istream& _stream; + }; +} + +#endif diff --git a/include/HyperNeat/Utils/Map.hpp b/include/HyperNeat/Utils/Map.hpp new file mode 100644 index 0000000..c735ab3 --- /dev/null +++ b/include/HyperNeat/Utils/Map.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_MAP_HPP__ +#define __HYPERNEAT_MAP_HPP__ + +#include + +namespace hyperneat +{ + template + using Map = std::map; +} + +#endif diff --git a/include/HyperNeat/Utils/NodeTypes.hpp b/include/HyperNeat/Utils/NodeTypes.hpp new file mode 100644 index 0000000..815214e --- /dev/null +++ b/include/HyperNeat/Utils/NodeTypes.hpp @@ -0,0 +1,22 @@ +#ifndef __HYPERNEAT_NODETYPES_HPP__ +#define __HYPERNEAT_NODETYPES_HPP__ + +#include + +namespace hyperneat +{ + enum class NodeType { + NULL_TYPE = -1, + SIGMOID = 0, + GAUSSIAN = 1, + SINE = 2, + ABSOLUTE = 3, + }; + + String nodeToString(NodeType type); + NodeType stringToNode(const String& str); + + const size_t NODE_TYPES_COUNT = 4; +} + +#endif diff --git a/include/HyperNeat/Utils/Pi.hpp b/include/HyperNeat/Utils/Pi.hpp new file mode 100644 index 0000000..00a3df2 --- /dev/null +++ b/include/HyperNeat/Utils/Pi.hpp @@ -0,0 +1,9 @@ +#ifndef __HYPERNEAT_PI_HPP__ +#define __HYPERNEAT_PI_HPP__ + +namespace hyperneat +{ + const double PI = 3.14159265359; +} + +#endif diff --git a/include/HyperNeat/Utils/Point.hpp b/include/HyperNeat/Utils/Point.hpp new file mode 100644 index 0000000..ba51bac --- /dev/null +++ b/include/HyperNeat/Utils/Point.hpp @@ -0,0 +1,21 @@ +#ifndef __HYPERNEAT_POINT_HPP__ +#define __HYPERNEAT_POINT_HPP__ + +namespace hyperneat +{ + class Point + { + public: + Point() = default; + Point(double x, double y); + + double distance(const Point& other) const; + bool operator== (const Point& other) const; + bool operator< (const Point& other) const; + + double _x = 0.0; + double _y = 0.0; + }; +} + +#endif diff --git a/include/HyperNeat/Utils/Pointer.hpp b/include/HyperNeat/Utils/Pointer.hpp new file mode 100644 index 0000000..f02e853 --- /dev/null +++ b/include/HyperNeat/Utils/Pointer.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_POINTER_HPP__ +#define __HYPERNEAT_POINTER_HPP__ + +#include + +namespace hyperneat +{ + template + using Pointer = std::unique_ptr; +} + +#endif diff --git a/include/HyperNeat/Utils/Random.hpp b/include/HyperNeat/Utils/Random.hpp new file mode 100644 index 0000000..4a4d979 --- /dev/null +++ b/include/HyperNeat/Utils/Random.hpp @@ -0,0 +1,14 @@ +#ifndef __HYPERNEAT_RANDOM_HPP__ +#define __HYPERNEAT_RANDOM_HPP__ + +#include + +namespace hyperneat +{ + using RandGen = std::mt19937_64; + using IntDist = std::uniform_int_distribution; + using RealDist = std::uniform_real_distribution; + using BellDist = std::normal_distribution; +} + +#endif diff --git a/include/HyperNeat/Utils/SaveFile.hpp b/include/HyperNeat/Utils/SaveFile.hpp new file mode 100644 index 0000000..18cad38 --- /dev/null +++ b/include/HyperNeat/Utils/SaveFile.hpp @@ -0,0 +1,45 @@ +#ifndef __HYPERNEAT_SAVEFILE_HPP__ +#define __HYPERNEAT_SAVEFILE_HPP__ + +#include +#include +#include + +namespace hyperneat +{ + using Ostream = std::ostream; + + class Genome; + class Organism; + class Population; + class NoveltyMetric; + class NeuralNetPrms; + class PopulationPrms; + class NoveltyMetricPrms; + + class SaveFile + { + public: + SaveFile(Ostream& stream); + + void savePopulation(Population& population, bool shuttedDown = false, size_t tabs = 0, + const String& prefix = ""); + void savePopulationPrms(const PopulationPrms& prms, size_t tabs = 0, const String& prefix = ""); + void saveNeuralNetPrms(const NeuralNetPrms& prms, size_t tabs = 0, const String& prefix = ""); + void saveOrganism(const Organism& organism, bool shuttedDown = false, size_t tabs = 0, + const String& prefix = ""); + void saveGenome(const Genome& genome, size_t tabs = 0, const String& prefix = ""); + void saveNoveltyMetric(const NoveltyMetric& noveltyMetric, bool shuttedDown = false, size_t tabs = 0, + const String& prefix = ""); + void saveNoveltyMetricPrms(const NoveltyMetricPrms& noveltyMetricPrms, size_t tabs = 0, + const String& prefix = ""); + + private: + Ostream& print(size_t tabs = 0); + String newl(size_t lines = 1); + + Ostream& _stream; + }; +} + +#endif diff --git a/include/HyperNeat/Utils/Set.hpp b/include/HyperNeat/Utils/Set.hpp new file mode 100644 index 0000000..d403e6b --- /dev/null +++ b/include/HyperNeat/Utils/Set.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_SET_HPP__ +#define __HYPERNEAT_SET_HPP__ + +#include + +namespace hyperneat +{ + template + using Set = std::set; +} + +#endif diff --git a/include/HyperNeat/Utils/Size.hpp b/include/HyperNeat/Utils/Size.hpp new file mode 100644 index 0000000..0ef5616 --- /dev/null +++ b/include/HyperNeat/Utils/Size.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_SIZE_HPP__ +#define __HYPERNEAT_SIZE_HPP__ + +#include +#include + +namespace hyperneat +{ + using std::size_t; +} + +#endif diff --git a/include/HyperNeat/Utils/String.hpp b/include/HyperNeat/Utils/String.hpp new file mode 100644 index 0000000..ab74d45 --- /dev/null +++ b/include/HyperNeat/Utils/String.hpp @@ -0,0 +1,11 @@ +#ifndef HYPERNEAT_STRING_HPP +#define HYPERNEAT_STRING_HPP + +#include + +namespace hyperneat +{ + using String = std::string; +} + +#endif diff --git a/include/HyperNeat/Utils/Thread.hpp b/include/HyperNeat/Utils/Thread.hpp new file mode 100644 index 0000000..4b861e3 --- /dev/null +++ b/include/HyperNeat/Utils/Thread.hpp @@ -0,0 +1,11 @@ +#ifndef __HYPERNEAT_THREAD_HPP__ +#define __HYPERNEAT_THREAD_HPP__ + +#include + +namespace hyperneat +{ + using Thread = std::thread; +} + +#endif diff --git a/include/HyperNeat/Utils/ValueMap.hpp b/include/HyperNeat/Utils/ValueMap.hpp new file mode 100644 index 0000000..c2910b5 --- /dev/null +++ b/include/HyperNeat/Utils/ValueMap.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_VALUEMAP_HPP__ +#define __HYPERNEAT_VALUEMAP_HPP__ + +#include +#include + +namespace hyperneat +{ + using ValueMap = Vector; +} + +#endif diff --git a/include/HyperNeat/Utils/ValuePoint.hpp b/include/HyperNeat/Utils/ValuePoint.hpp new file mode 100644 index 0000000..b9e15ab --- /dev/null +++ b/include/HyperNeat/Utils/ValuePoint.hpp @@ -0,0 +1,19 @@ +#ifndef __HYPERNEAT_VALUEPOINT_HPP__ +#define __HYPERNEAT_VALUEPOINT_HPP__ + +#include + +namespace hyperneat +{ + class ValuePoint : public Point + { + public: + ValuePoint() = default; + ValuePoint(double x, double y, double value, double segment); + + double _value = 0.0; + double _segment = 0.0; + }; +} + +#endif diff --git a/include/HyperNeat/Utils/Vector.hpp b/include/HyperNeat/Utils/Vector.hpp new file mode 100644 index 0000000..f7352e4 --- /dev/null +++ b/include/HyperNeat/Utils/Vector.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_VECTOR_HPP__ +#define __HYPERNEAT_VECTOR_HPP__ + +#include + +namespace hyperneat +{ + template + using Vector = std::vector; +} + +#endif diff --git a/include/HyperNeat/Utils/Vector2D.hpp b/include/HyperNeat/Utils/Vector2D.hpp new file mode 100644 index 0000000..257dbe6 --- /dev/null +++ b/include/HyperNeat/Utils/Vector2D.hpp @@ -0,0 +1,12 @@ +#ifndef __HYPERNEAT_VECTOR2D_HPP__ +#define __HYPERNEAT_VECTOR2D_HPP__ + +#include + +namespace hyperneat +{ + template + using Vector2D = Vector>; +} + +#endif -- cgit v1.2.1