├── JNF_NEAT ├── trainable.h ├── JNF_NEAT.layout ├── xor_solver.h ├── gene.cpp ├── gene.h ├── trained_neural_network.h ├── trained_neural_network.cpp ├── xor_solver.cpp ├── main.cpp ├── neuron.h ├── training_parameters.h ├── neuron.cpp ├── species.h ├── individual.h ├── individual.cpp ├── neural_network.h ├── neural_network_trainer.h ├── genome.h ├── JNF_NEAT.vcxproj.filters ├── species.cpp ├── genome.cpp ├── neural_network.cpp ├── neural_network_trainer.cpp └── JNF_NEAT.vcxproj ├── CMakeLists.txt ├── JNF_NEAT.sln ├── README.md ├── .gitignore └── LICENSE /JNF_NEAT/trainable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class ITrainable 5 | { 6 | public: 7 | virtual ~ITrainable() = default; 8 | 9 | virtual void Reset() = 0; 10 | virtual void Update(const std::vector& networkOutputs) = 0; 11 | virtual int GetOrCalculateFitness() = 0; 12 | 13 | virtual std::vector ProvideNetworkWithInputs() = 0; 14 | }; -------------------------------------------------------------------------------- /JNF_NEAT/JNF_NEAT.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /JNF_NEAT/xor_solver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "trainable.h" 3 | class XORSolver : public ITrainable { 4 | public: 5 | virtual void Reset() override; 6 | virtual void Update(const std::vector& networkOutputs) override; 7 | virtual int GetOrCalculateFitness() override; 8 | 9 | virtual std::vector ProvideNetworkWithInputs() override; 10 | private: 11 | int fitness = 0; 12 | std::vector lastInputs; 13 | }; -------------------------------------------------------------------------------- /JNF_NEAT/gene.cpp: -------------------------------------------------------------------------------- 1 | #include "gene.h" 2 | #include 3 | 4 | size_t Gene::numberOfExistingGenes = 0U; 5 | 6 | Gene::Gene() 7 | { 8 | SetRandomWeight(); 9 | numberOfExistingGenes++; 10 | std::cout << "New Gene created with historical marking: " << historicalMarking << "\t Number of total Genes: " << numberOfExistingGenes << std::endl; 11 | } 12 | 13 | void Gene::SetRandomWeight() 14 | { 15 | weight = (float)(rand() % 10'000) / 10'000.0f; 16 | } 17 | -------------------------------------------------------------------------------- /JNF_NEAT/gene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "neuron.h" 3 | 4 | struct Gene { 5 | public: 6 | Gene(); 7 | ~Gene() = default; 8 | Gene(const Gene& other) = default; 9 | Gene(Gene&& other) = default; 10 | Gene& operator=(const Gene& other) = default; 11 | 12 | std::size_t from = 0; 13 | std::size_t to = 0; 14 | float weight = 0.0f; 15 | std::size_t historicalMarking = numberOfExistingGenes; 16 | bool isEnabled = true; 17 | void SetRandomWeight(); 18 | private: 19 | static std::size_t numberOfExistingGenes; 20 | }; -------------------------------------------------------------------------------- /JNF_NEAT/trained_neural_network.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "neural_network.h" 3 | #include 4 | 5 | class TrainedNeuralNetwork { 6 | public: 7 | TrainedNeuralNetwork() = default; 8 | explicit TrainedNeuralNetwork(const NeuralNetwork& trainedNetwork); 9 | TrainedNeuralNetwork(const TrainedNeuralNetwork& other) = default; 10 | ~TrainedNeuralNetwork() = default; 11 | 12 | void LoadFromFile(const std::string& fileName); 13 | void SaveToFile(const std::string& fileName) const; 14 | 15 | std::vector GetOutputs(const std::vector& inputs); 16 | 17 | private: 18 | NeuralNetwork trainedNetwork; 19 | }; -------------------------------------------------------------------------------- /JNF_NEAT/trained_neural_network.cpp: -------------------------------------------------------------------------------- 1 | #include "trained_neural_network.h" 2 | 3 | TrainedNeuralNetwork::TrainedNeuralNetwork(const NeuralNetwork& trainedNetwork): 4 | trainedNetwork(trainedNetwork) 5 | { 6 | } 7 | 8 | std::vector TrainedNeuralNetwork::GetOutputs(const std::vector& inputs) 9 | { 10 | trainedNetwork.SetInputs(inputs); 11 | return trainedNetwork.GetOutputs(); 12 | } 13 | 14 | void TrainedNeuralNetwork::LoadFromFile(const std::string& fileName) 15 | { 16 | // TODO jnf 17 | // Implementation 18 | } 19 | 20 | void TrainedNeuralNetwork::SaveToFile(const std::string& fileName) const 21 | { 22 | // TODO jnf 23 | // Implementation 24 | } 25 | -------------------------------------------------------------------------------- /JNF_NEAT/xor_solver.cpp: -------------------------------------------------------------------------------- 1 | #include "xor_solver.h" 2 | #include 3 | 4 | void XORSolver::Reset() 5 | { 6 | fitness = 0; 7 | } 8 | 9 | void XORSolver::Update(const std::vector& networkOutputs) 10 | { 11 | int xorResult = (int)lastInputs[0] ^ (int)lastInputs[1]; 12 | int networksXorResult = int(networkOutputs[0] > 0.5f); 13 | 14 | if (xorResult == networksXorResult) { 15 | fitness += 10; 16 | } 17 | } 18 | 19 | int XORSolver::GetOrCalculateFitness() 20 | { 21 | return fitness; 22 | } 23 | 24 | std::vector XORSolver::ProvideNetworkWithInputs() 25 | { 26 | lastInputs.clear(); 27 | lastInputs.push_back(float(rand() % 2)); 28 | lastInputs.push_back(float(rand() % 2)); 29 | 30 | return lastInputs; 31 | } 32 | -------------------------------------------------------------------------------- /JNF_NEAT/main.cpp: -------------------------------------------------------------------------------- 1 | #include "neural_network_trainer.h" 2 | #include "xor_solver.h" 3 | #include 4 | #include 5 | 6 | int main() { 7 | srand((unsigned)time(0U)); 8 | std::cout << "Hello World" << std::endl; 9 | 10 | TrainingParameters params; 11 | params.numberOfInputs = 2; 12 | params.numberOfOutputs = 1; 13 | params.updatesPerGeneration = 10; 14 | 15 | std::vector population; 16 | for (int i = 0; i < 20; ++i) { 17 | population.push_back(new XORSolver()); 18 | } 19 | NeuralNetworkTrainer trainer(population, params); 20 | trainer.TrainUntilFitnessEquals(100); 21 | auto& champ = trainer.GetFittestSpecimen(); 22 | 23 | for (auto& individuum : population) { 24 | delete individuum; 25 | } 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(JNF_NEAT) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 5 | 6 | set(SOURCE_FILES 7 | JNF_NEAT/main.cpp 8 | JNF_NEAT/gene.h 9 | JNF_NEAT/gene.cpp 10 | JNF_NEAT/neural_network.h 11 | JNF_NEAT/neural_network.cpp 12 | JNF_NEAT/neural_network_trainer.h 13 | JNF_NEAT/neural_network_trainer.cpp 14 | JNF_NEAT/neuron.h 15 | JNF_NEAT/neuron.cpp 16 | JNF_NEAT/trainable.h 17 | JNF_NEAT/xor_solver.h 18 | JNF_NEAT/xor_solver.cpp 19 | JNF_NEAT/individual.h 20 | JNF_NEAT/individual.cpp 21 | JNF_NEAT/species.h 22 | JNF_NEAT/species.cpp 23 | JNF_NEAT/genome.h 24 | JNF_NEAT/genome.cpp) 25 | 26 | add_definitions(-std=c++14) 27 | add_executable(JNF_NEAT ${SOURCE_FILES}) -------------------------------------------------------------------------------- /JNF_NEAT/neuron.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Neuron { 5 | public: 6 | struct IncomingConnection { 7 | Neuron* incoming = nullptr; 8 | float weight = 1.0f; 9 | }; 10 | private: 11 | using Connections = std::vector; 12 | Connections connections; 13 | bool isSensor = false; 14 | float lastActionPotential = 0.0f; 15 | 16 | public: 17 | Neuron() = default; 18 | explicit Neuron(const Connections& connections); 19 | Neuron(const Neuron& other) = default; 20 | ~Neuron() = default; 21 | 22 | void SetInput(float input); 23 | void AddConnection(const IncomingConnection& connection); 24 | void AddConnection(IncomingConnection&& connection); 25 | float RequestDataAndGetActionPotential(); 26 | 27 | private: 28 | static float sigmoid(float d); 29 | }; -------------------------------------------------------------------------------- /JNF_NEAT/training_parameters.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | struct TrainingParameters { 4 | unsigned int numberOfInputs = 0U; 5 | unsigned int numberOfOutputs = 0U; 6 | unsigned int updatesPerGeneration = 1U; 7 | 8 | struct Advanced { 9 | struct Ranges { 10 | int minFitness = std::numeric_limits::min(); 11 | int maxFitness = 100; 12 | float minNeuralCharge = 0.0f; 13 | float maxNeuralCharge = 1.0f; 14 | } ranges; 15 | struct Mutation { 16 | float chanceForWeightMutation = 0.8f; 17 | float chanceForConnectionalMutation = 0.05f; 18 | float chanceForNeuralMutation = 0.03f; 19 | } mutation; 20 | struct Speciation { 21 | float importanceOfDisjointGenes = 1.0f; 22 | float importanceOfAverageWeightDifference = 0.3f; 23 | float compatibilityThreshold = 3.0f; 24 | } speciation; 25 | } advanced; 26 | }; -------------------------------------------------------------------------------- /JNF_NEAT/neuron.cpp: -------------------------------------------------------------------------------- 1 | #include "neuron.h" 2 | #include 3 | 4 | Neuron::Neuron(const Connections& connections) : 5 | connections(connections) { 6 | 7 | } 8 | 9 | void Neuron::AddConnection(const Neuron::IncomingConnection& connection) 10 | { 11 | connections.push_back(connection); 12 | } 13 | 14 | void Neuron::AddConnection(Neuron::IncomingConnection&& connection) 15 | { 16 | connections.push_back(connection); 17 | } 18 | 19 | float Neuron::RequestDataAndGetActionPotential() { 20 | if (isSensor){ 21 | return lastActionPotential; 22 | } 23 | 24 | float incomingPotentials = 0.0f; 25 | for (auto& in : connections){ 26 | incomingPotentials += in.incoming->RequestDataAndGetActionPotential() * in.weight; 27 | } 28 | lastActionPotential = sigmoid(incomingPotentials); 29 | return lastActionPotential; 30 | } 31 | 32 | float Neuron::sigmoid(float d) { 33 | return (float)tanh(d); 34 | } 35 | 36 | void Neuron::SetInput(float input) { 37 | isSensor = true; 38 | lastActionPotential = input; 39 | } -------------------------------------------------------------------------------- /JNF_NEAT/species.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "training_parameters.h" 3 | #include "neural_network.h" 4 | 5 | class Species { 6 | private: 7 | const TrainingParameters& parameters; 8 | std::vector population; 9 | NeuralNetwork representative; 10 | public: 11 | Species() = delete; 12 | explicit Species(const TrainingParameters& parameters); 13 | Species(const Species& other) = default; 14 | Species(Species&& other) = default; 15 | ~Species() = default; 16 | 17 | void AddIndividual(NeuralNetwork& individual); 18 | void SetPopulation(std::vector& population); 19 | 20 | bool IsCompatible(const NeuralNetwork& network) const; 21 | bool IsCompatible(const Genome& genome) const; 22 | 23 | float GetFitnessSharingModifier() const; 24 | 25 | private: 26 | double GetGeneticalDistance(const Genome& leftGenome, const Genome& rightGenome) const; 27 | void ElectRepresentative(); 28 | template 29 | constexpr bool IsAboveCompatibilityThreshold(T t) const; 30 | }; -------------------------------------------------------------------------------- /JNF_NEAT/individual.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "neural_network.h" 3 | #include "trainable.h" 4 | #include "training_parameters.h" 5 | #include "species.h" 6 | #include "genome.h" 7 | 8 | class Individual { 9 | private: 10 | ITrainable* trainable = nullptr; 11 | NeuralNetwork network; 12 | int fitness = 0; 13 | bool isFitnessUpToDate = false; 14 | const Species * species; 15 | 16 | public: 17 | Individual(ITrainable* trainable, const TrainingParameters& parameters); 18 | Individual(ITrainable* trainable, NeuralNetwork network); 19 | Individual(const Individual& other) = default; 20 | Individual(Individual&& other) = default; 21 | ~Individual() = default; 22 | 23 | Individual& operator=(const Individual& other) = default; 24 | 25 | 26 | void Reset() { trainable->Reset(); } 27 | void Update(); 28 | void ModifyFitness(float factor); 29 | int GetOrCalculateFitness(); 30 | void CoupleWithSpecies(Species& species); 31 | const Genome& GetGenome() const { return network.GetGenome(); } 32 | }; -------------------------------------------------------------------------------- /JNF_NEAT/individual.cpp: -------------------------------------------------------------------------------- 1 | #include "individual.h" 2 | 3 | Individual::Individual(ITrainable* trainable, const TrainingParameters& parameters) : 4 | trainable(trainable), 5 | network(parameters) 6 | { 7 | } 8 | 9 | Individual::Individual(ITrainable* trainable, NeuralNetwork network) : 10 | trainable(trainable), 11 | network(network) 12 | { 13 | } 14 | 15 | void Individual::Update() 16 | { 17 | network.SetInputs(trainable->ProvideNetworkWithInputs()); 18 | trainable->Update(network.GetOutputs()); 19 | isFitnessUpToDate = false; 20 | } 21 | 22 | void Individual::ModifyFitness(float factor) 23 | { 24 | fitness = (int)((float)fitness * factor); 25 | } 26 | 27 | int Individual::GetOrCalculateFitness() 28 | { 29 | if (!isFitnessUpToDate) { 30 | fitness = (int)((float)trainable->GetOrCalculateFitness() * species->GetFitnessSharingModifier()); 31 | isFitnessUpToDate = true; 32 | } 33 | return fitness; 34 | } 35 | 36 | void Individual::CoupleWithSpecies(Species& species) 37 | { 38 | species.AddIndividual(network); 39 | this->species = &species; 40 | } -------------------------------------------------------------------------------- /JNF_NEAT/neural_network.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "gene.h" 3 | #include "neuron.h" 4 | #include "genome.h" 5 | #include 6 | 7 | class NeuralNetwork { 8 | private: 9 | Genome genome; 10 | std::vector neurons; 11 | std::vector inputNeurons; 12 | std::vector outputNeurons; 13 | const TrainingParameters& parameters; 14 | 15 | public: 16 | explicit NeuralNetwork(const TrainingParameters & parameters); 17 | explicit NeuralNetwork(const TrainingParameters & parameters, const Genome& genome); 18 | explicit NeuralNetwork(const TrainingParameters & parameters, Genome&& genome); 19 | explicit NeuralNetwork(const TrainingParameters & parameters, const Genome&& genome) = delete; 20 | 21 | NeuralNetwork(const NeuralNetwork& other); 22 | NeuralNetwork(NeuralNetwork&& other); 23 | 24 | ~NeuralNetwork() = default; 25 | 26 | NeuralNetwork& operator= (const NeuralNetwork& other); 27 | 28 | const Genome& GetGenome() const { return genome; } 29 | 30 | void SetInputs(const std::vector& inputs); 31 | std::vector GetOutputs(); 32 | 33 | private: 34 | void ReadNumberOfInputsAndOutputsFromGenes(); 35 | void BuildNetworkFromGenes(); 36 | void InterpretInputsAndOutputs(); 37 | void DeleteAllNeurons(); 38 | }; -------------------------------------------------------------------------------- /JNF_NEAT/neural_network_trainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "neural_network.h" 3 | #include "trainable.h" 4 | #include "training_parameters.h" 5 | #include "genome.h" 6 | #include "individual.h" 7 | #include "species.h" 8 | #include 9 | 10 | class NeuralNetworkTrainer { 11 | private: 12 | std::vector population; 13 | std::vector species; 14 | TrainingParameters parameters; 15 | 16 | // Methods 17 | public: 18 | NeuralNetworkTrainer() = delete; 19 | explicit NeuralNetworkTrainer(std::vector& population, const TrainingParameters& parameters); 20 | explicit NeuralNetworkTrainer(std::vector& population, TrainingParameters&& parameters); 21 | 22 | NeuralNetworkTrainer(const NeuralNetworkTrainer& other) = default; 23 | 24 | ~NeuralNetworkTrainer() = default; 25 | 26 | 27 | void TrainUntilFitnessEquals(int fitnessToReach); 28 | void TrainUntilGenerationEquals(unsigned int generationsToTrain); 29 | 30 | Individual& GetFittestSpecimen(); 31 | 32 | private: 33 | void SetPopulation(std::vector& population); 34 | NeuralNetwork Breed(ITrainable* mother, ITrainable* father) const; 35 | 36 | void ResetPopulation(); 37 | void Repopulate(); 38 | void CategorizePopulationIntoSpecies(); 39 | void LetGenerationLive(); 40 | }; -------------------------------------------------------------------------------- /JNF_NEAT.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JNF_NEAT", "JNF_NEAT\JNF_NEAT.vcxproj", "{5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Debug|x64.ActiveCfg = Debug|x64 17 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Debug|x64.Build.0 = Debug|x64 18 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Debug|x86.Build.0 = Debug|Win32 20 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Release|x64.ActiveCfg = Release|x64 21 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Release|x64.Build.0 = Release|x64 22 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Release|x86.ActiveCfg = Release|Win32 23 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /JNF_NEAT/genome.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gene.h" 4 | #include "training_parameters.h" 5 | #include 6 | 7 | class Genome { 8 | // Members 9 | private: 10 | std::vector genes; 11 | const TrainingParameters& parameters; 12 | 13 | // Methods 14 | public: 15 | Genome() = delete; 16 | explicit Genome(const TrainingParameters& parameters); 17 | Genome(const Genome& other) = default; 18 | Genome(Genome&& other) = default; 19 | ~Genome() = default; 20 | 21 | Genome& operator=(const Genome& other); 22 | Gene& operator[](std::size_t index) { return genes[index]; } 23 | auto begin() { return genes.begin(); } 24 | auto end() { return genes.end(); } 25 | 26 | std::size_t ExtrapolateNeuronCount() const; 27 | std::size_t GetGeneCount() const; 28 | void MutateGenes(); 29 | 30 | private: 31 | static bool DidChanceOccure(float chance); 32 | bool ShouldAddNeuron() const { return DidChanceOccure(parameters.advanced.mutation.chanceForNeuralMutation); } 33 | bool ShouldAddConnection() const { return DidChanceOccure(parameters.advanced.mutation.chanceForConnectionalMutation); } 34 | bool ShouldMutateWeight() const { return DidChanceOccure(parameters.advanced.mutation.chanceForWeightMutation); } 35 | void AddRandomNeuron(); 36 | void AddRandomConnection(); 37 | void ShuffleWeights(); 38 | void MutateWeightOfGeneAt(std::size_t index); 39 | void PerturbWeightAt(std::size_t index); 40 | }; -------------------------------------------------------------------------------- /JNF_NEAT/JNF_NEAT.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | -------------------------------------------------------------------------------- /JNF_NEAT/species.cpp: -------------------------------------------------------------------------------- 1 | #include "species.h" 2 | #include 3 | 4 | Species::Species(const TrainingParameters& parameters) : 5 | parameters(parameters), 6 | representative(parameters) 7 | { 8 | } 9 | 10 | void Species::AddIndividual(NeuralNetwork& individual) 11 | { 12 | population.push_back(&individual); 13 | ElectRepresentative(); 14 | } 15 | 16 | void Species::SetPopulation(std::vector& population) 17 | { 18 | this->population.empty(); 19 | this->population.reserve(population.size()); 20 | for (auto& individual : population) { 21 | this->population.push_back(&individual); 22 | } 23 | ElectRepresentative(); 24 | } 25 | 26 | bool Species::IsCompatible(const NeuralNetwork& network) const { 27 | return IsCompatible(network.GetGenome()); 28 | } 29 | 30 | bool Species::IsCompatible(const Genome& genome) const { 31 | auto distanceToSpecies = GetGeneticalDistance(representative.GetGenome(), genome); 32 | return !IsAboveCompatibilityThreshold(distanceToSpecies); 33 | } 34 | 35 | float Species::GetFitnessSharingModifier() const{ 36 | unsigned int fitnessSharingDivisor = 0; 37 | 38 | for (auto& lhs : population) { 39 | for (auto& rhs : population) { 40 | auto distance = GetGeneticalDistance(lhs->GetGenome(), rhs->GetGenome()); 41 | if (IsAboveCompatibilityThreshold(distance)) { 42 | ++fitnessSharingDivisor; 43 | } 44 | } 45 | } 46 | 47 | float fitnessSharingFactor = 1.0f / (float) fitnessSharingDivisor; 48 | return fitnessSharingFactor; 49 | } 50 | 51 | double Species::GetGeneticalDistance(const Genome& leftGenome, const Genome& rightGenome) const 52 | { 53 | double totalWeightDifference = 0.0; 54 | size_t numberOfOverlapingGenes = 0; 55 | 56 | size_t sizeOfSmallerGenome = std::min(leftGenome.GetGeneCount(), rightGenome.GetGeneCount()); 57 | auto areSame = [&](size_t i) { 58 | return const_cast(leftGenome)[i].historicalMarking == const_cast(rightGenome)[i].historicalMarking; 59 | }; 60 | 61 | for (size_t i = 0; i < sizeOfSmallerGenome && areSame(i); ++i) { 62 | totalWeightDifference += 63 | (double)std::abs(const_cast(leftGenome)[i].weight - const_cast(rightGenome)[i].weight); 64 | 65 | ++numberOfOverlapingGenes; 66 | } 67 | 68 | auto numberOfDisjointGenes = leftGenome.GetGeneCount() + rightGenome.GetGeneCount() - (size_t)2 * numberOfOverlapingGenes; 69 | auto sizeOfBiggerGenome = std::max(leftGenome.GetGeneCount(), rightGenome.GetGeneCount()); 70 | auto disjointGenesInfluence = (double)numberOfDisjointGenes / (double)sizeOfBiggerGenome; 71 | 72 | auto averageWeightDifference = totalWeightDifference / (double)numberOfOverlapingGenes; 73 | 74 | disjointGenesInfluence *= (double)parameters.advanced.speciation.importanceOfDisjointGenes; 75 | averageWeightDifference *= (double)parameters.advanced.speciation.importanceOfAverageWeightDifference; 76 | 77 | return disjointGenesInfluence + averageWeightDifference; 78 | } 79 | 80 | void Species::ElectRepresentative() 81 | { 82 | auto randomMember = rand() % population.size(); 83 | representative = *population[randomMember]; 84 | } 85 | 86 | template 87 | constexpr bool Species::IsAboveCompatibilityThreshold(T t) const 88 | { 89 | return t > parameters.advanced.speciation.compatibilityThreshold; 90 | } 91 | -------------------------------------------------------------------------------- /JNF_NEAT/genome.cpp: -------------------------------------------------------------------------------- 1 | #include "genome.h" 2 | #include 3 | #include 4 | 5 | Genome::Genome(const TrainingParameters& parameters) : 6 | parameters(parameters) 7 | { 8 | genes.resize(parameters.numberOfInputs * parameters.numberOfOutputs); 9 | auto *currentGene = &genes.front(); 10 | for (auto in = 0U; in < parameters.numberOfInputs; ++in) { 11 | for (auto out = 0U; out < parameters.numberOfOutputs; ++out) { 12 | currentGene->from = in; 13 | currentGene->to = out + parameters.numberOfInputs; 14 | ++currentGene; 15 | } 16 | } 17 | } 18 | 19 | std::size_t Genome::ExtrapolateNeuronCount() const { 20 | auto CompareToNeuron = [](const Gene& lhs, const Gene& rhs) { 21 | return lhs.to < rhs.to; 22 | }; 23 | auto maxNeuronGene = std::max_element(genes.begin(), genes.end(), CompareToNeuron); 24 | // TODO jnf 25 | // Maybe add lookup table 26 | return maxNeuronGene->to + 1U; 27 | } 28 | 29 | std::size_t Genome::GetGeneCount() const { 30 | return genes.size(); 31 | } 32 | 33 | Genome& Genome::operator=(const Genome& other) 34 | { 35 | this->genes = other.genes; 36 | const_cast(this->parameters) = other.parameters; 37 | return *this; 38 | } 39 | 40 | void Genome::MutateGenes() { 41 | if (ShouldAddConnection()) { 42 | AddRandomConnection(); 43 | } 44 | else 45 | if (ShouldAddNeuron()) { 46 | AddRandomNeuron(); 47 | } 48 | else { 49 | ShuffleWeights(); 50 | } 51 | } 52 | 53 | bool Genome::DidChanceOccure(float chance) 54 | { 55 | auto num = rand() % 100; 56 | return num < int(100.0f * chance); 57 | } 58 | 59 | void Genome::AddRandomNeuron() 60 | { 61 | Gene* randGene = nullptr; 62 | do { 63 | int num = rand() % genes.size(); 64 | randGene = &genes[num]; 65 | } while (!randGene->isEnabled); 66 | 67 | auto numberOfNeurons = ExtrapolateNeuronCount(); 68 | 69 | Gene g1(*randGene); 70 | g1.to = numberOfNeurons; 71 | genes.push_back(std::move(g1)); 72 | 73 | Gene g2(*randGene); 74 | g2.from = numberOfNeurons; 75 | genes.push_back(std::move(g2)); 76 | 77 | randGene->isEnabled = false; 78 | } 79 | 80 | void Genome::AddRandomConnection() 81 | { 82 | auto GetRandomNumberBetween = [](size_t min, size_t max) { 83 | return rand() % (max - min) + min; 84 | }; 85 | 86 | Gene newConnection; 87 | auto numberOfNeurons = ExtrapolateNeuronCount() - 1U; 88 | 89 | newConnection.from = GetRandomNumberBetween(0U, numberOfNeurons - 1U); 90 | newConnection.to = GetRandomNumberBetween(newConnection.from + 1, numberOfNeurons); 91 | 92 | genes.push_back(newConnection); 93 | } 94 | 95 | void Genome::ShuffleWeights() 96 | { 97 | for (size_t i = 0; i < genes.size(); i++) { 98 | if (ShouldMutateWeight()) { 99 | MutateWeightOfGeneAt(i); 100 | } 101 | } 102 | } 103 | 104 | void Genome::MutateWeightOfGeneAt(size_t index) 105 | { 106 | constexpr float chanceOfTotalWeightReset = 0.1f; 107 | if (DidChanceOccure(chanceOfTotalWeightReset)) { 108 | genes[index].SetRandomWeight(); 109 | } 110 | else { 111 | PerturbWeightAt(index); 112 | } 113 | } 114 | 115 | void Genome::PerturbWeightAt(size_t index) 116 | { 117 | constexpr float perturbanceBoundaries = 0.2f; 118 | auto perturbance = (float)(rand() % 10'000) / 10'000.0f * perturbanceBoundaries; 119 | if (rand() % 2) { 120 | perturbance = -perturbance; 121 | } 122 | 123 | genes[index].weight *= perturbance; 124 | } 125 | 126 | -------------------------------------------------------------------------------- /JNF_NEAT/neural_network.cpp: -------------------------------------------------------------------------------- 1 | #include "neural_network.h" 2 | #include 3 | #include 4 | 5 | 6 | NeuralNetwork::NeuralNetwork(const TrainingParameters & parameters): 7 | parameters(parameters), 8 | genome(parameters), 9 | inputNeurons(parameters.numberOfInputs), 10 | outputNeurons(parameters.numberOfOutputs) 11 | { 12 | BuildNetworkFromGenes(); 13 | } 14 | 15 | NeuralNetwork::NeuralNetwork(const TrainingParameters & parameters, const Genome& genome): 16 | parameters(parameters), 17 | genome(genome), 18 | inputNeurons(parameters.numberOfInputs), 19 | outputNeurons(parameters.numberOfOutputs) 20 | { 21 | BuildNetworkFromGenes(); 22 | } 23 | 24 | NeuralNetwork::NeuralNetwork(const TrainingParameters & parameters, Genome&& genome): 25 | parameters(parameters), 26 | genome(genome), 27 | inputNeurons(parameters.numberOfInputs), 28 | outputNeurons(parameters.numberOfOutputs) 29 | { 30 | BuildNetworkFromGenes(); 31 | } 32 | 33 | NeuralNetwork::NeuralNetwork(const NeuralNetwork& other) : 34 | parameters(other.parameters), 35 | genome(other.genome), 36 | neurons(other.neurons), 37 | inputNeurons(other.inputNeurons.size()), 38 | outputNeurons(other.outputNeurons.size()) 39 | { 40 | InterpretInputsAndOutputs(); 41 | } 42 | 43 | NeuralNetwork::NeuralNetwork(NeuralNetwork&& other) : 44 | parameters(std::move(other.parameters)), 45 | genome(std::move(other.genome)), 46 | neurons(std::move(other.neurons)), 47 | inputNeurons(std::move(other.inputNeurons.size())), 48 | outputNeurons(std::move(other.outputNeurons.size())) 49 | { 50 | InterpretInputsAndOutputs(); 51 | } 52 | 53 | NeuralNetwork& NeuralNetwork::operator=(const NeuralNetwork& other) 54 | { 55 | genome = other.genome; 56 | neurons = other.neurons; 57 | inputNeurons.resize(other.inputNeurons.size()); 58 | outputNeurons.resize(other.outputNeurons.size()); 59 | 60 | InterpretInputsAndOutputs(); 61 | return *this; 62 | } 63 | 64 | 65 | void NeuralNetwork::BuildNetworkFromGenes() { 66 | DeleteAllNeurons(); 67 | 68 | neurons.resize(genome.ExtrapolateNeuronCount()); 69 | for (const auto& gene : genome) { 70 | if (gene.isEnabled) { 71 | Neuron::IncomingConnection connection; 72 | connection.incoming = &neurons[gene.from]; 73 | connection.weight = gene.weight; 74 | neurons[gene.to].AddConnection(std::move(connection)); 75 | } 76 | } 77 | 78 | InterpretInputsAndOutputs(); 79 | } 80 | 81 | void NeuralNetwork::SetInputs(const std::vector& inputs) 82 | { 83 | if (inputNeurons.size() != inputs.size()) 84 | { 85 | throw std::out_of_range("Number of inputs provided doesn't match genetic information"); 86 | } 87 | for(size_t i = 0U; i < inputNeurons.size(); ++i){ 88 | inputNeurons[i]->SetInput(inputs[i]); 89 | }; 90 | } 91 | 92 | std::vector NeuralNetwork::GetOutputs() 93 | { 94 | std::vector outputs(outputNeurons.size()); 95 | for(size_t i = 0U; i < outputs.size(); ++i){ 96 | outputs[i] = outputNeurons[i]->RequestDataAndGetActionPotential(); 97 | } 98 | return outputs; 99 | } 100 | 101 | void NeuralNetwork::DeleteAllNeurons() { 102 | neurons.clear(); 103 | for (auto in : inputNeurons) { 104 | in = nullptr; 105 | } 106 | for (auto out : outputNeurons) { 107 | out = nullptr; 108 | } 109 | } 110 | 111 | void NeuralNetwork::InterpretInputsAndOutputs() 112 | { 113 | for (auto i = 0U; i < parameters.numberOfInputs; i++) { 114 | inputNeurons[i] = &neurons[i]; 115 | } 116 | for (auto i = 0U; i < parameters.numberOfOutputs; i++) { 117 | outputNeurons[i] = &neurons[genome[i * parameters.numberOfOutputs].to]; 118 | } 119 | } -------------------------------------------------------------------------------- /JNF_NEAT/neural_network_trainer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "neural_network_trainer.h" 4 | 5 | NeuralNetworkTrainer::NeuralNetworkTrainer(std::vector& population, const TrainingParameters& parameters) : 6 | parameters(parameters) 7 | { 8 | SetPopulation(population); 9 | } 10 | 11 | NeuralNetworkTrainer::NeuralNetworkTrainer(std::vector& population, TrainingParameters&& parameters) : 12 | parameters(parameters) 13 | { 14 | SetPopulation(population); 15 | } 16 | 17 | NeuralNetwork NeuralNetworkTrainer::Breed(ITrainable* mother, ITrainable* father) const 18 | { 19 | Genome childGenome(parameters); 20 | 21 | if (mother->GetOrCalculateFitness() == father->GetOrCalculateFitness()) { 22 | // TODO jnf 23 | // Do Stuff with the genes 24 | } else { 25 | // TODO jnf 26 | // Do Stuff with the genes 27 | } 28 | 29 | childGenome.MutateGenes(); 30 | 31 | NeuralNetwork child(parameters, std::move(childGenome)); 32 | // It may look ineffective to return this by value, accessing the copy constructor 33 | // But don't worry, RVO will take care of this. 34 | // If your compiler doesn't optimize this, I'd recommend using what you'd call an "out parameter" in C# 35 | return child; 36 | } 37 | 38 | 39 | 40 | void NeuralNetworkTrainer::ResetPopulation() 41 | { 42 | for (auto& individuum : population) { 43 | individuum.Reset(); 44 | } 45 | } 46 | 47 | void NeuralNetworkTrainer::SetPopulation(std::vector& population) 48 | { 49 | this->population.clear(); 50 | this->population.reserve(population.size()); 51 | for (auto& currTrainable : population) { 52 | // TODO jnf 53 | // Every Individual generates Genes with historical markings up to population.size() * parameters.numberOfInputs * parameters.NumberOfOutputs 54 | // Instead, the historical markings should only go to parameters.numberOfInputs * parameters.NumberOfOutputs 55 | // and be identical to every other individuals genes (but still having random weights) 56 | this->population.push_back({ currTrainable, parameters }); 57 | } 58 | CategorizePopulationIntoSpecies(); 59 | } 60 | 61 | 62 | void NeuralNetworkTrainer::TrainUntilFitnessEquals(int fitnessToReach) { 63 | LetGenerationLive(); 64 | while (GetFittestSpecimen().GetOrCalculateFitness() < fitnessToReach) { 65 | Repopulate(); 66 | ResetPopulation(); 67 | for (unsigned int i = 0; i < parameters.updatesPerGeneration; ++i) { 68 | LetGenerationLive(); 69 | } 70 | } 71 | } 72 | 73 | void NeuralNetworkTrainer::TrainUntilGenerationEquals(unsigned int generationsToTrain) { 74 | for(auto generation = 0U; generation < generationsToTrain; generation++){ 75 | Repopulate(); 76 | LetGenerationLive(); 77 | } 78 | } 79 | 80 | Individual& NeuralNetworkTrainer::GetFittestSpecimen() { 81 | if (population.empty()) { 82 | throw std::out_of_range("Your population is empty"); 83 | } 84 | 85 | auto compareFitness = [](Individual& lhs, Individual& rhs) { 86 | return lhs.GetOrCalculateFitness() < rhs.GetOrCalculateFitness(); 87 | }; 88 | // TODO jnf 89 | // cache this 90 | return *std::max_element(population.begin(), population.end(), compareFitness); 91 | } 92 | 93 | void NeuralNetworkTrainer::LetGenerationLive() { 94 | for (auto& individual : population){ 95 | individual.Update(); 96 | } 97 | } 98 | 99 | void NeuralNetworkTrainer::Repopulate() { 100 | // TODO jnf 101 | // Implementation 102 | CategorizePopulationIntoSpecies(); 103 | // TODO jnf 104 | // Add Concurrency 105 | } 106 | 107 | 108 | void NeuralNetworkTrainer::CategorizePopulationIntoSpecies() 109 | { 110 | for (auto& individual : population) { 111 | bool isCompatibleWithExistingSpecies = false; 112 | for (auto& currSpecies : species) { 113 | if (currSpecies.IsCompatible(individual.GetGenome())) { 114 | individual.CoupleWithSpecies(currSpecies); 115 | isCompatibleWithExistingSpecies = true; 116 | break; 117 | } 118 | } 119 | if (!isCompatibleWithExistingSpecies) { 120 | Species newSpecies(parameters); 121 | species.push_back(std::move(newSpecies)); 122 | individual.CoupleWithSpecies(species.back()); 123 | } 124 | } 125 | // TODO jnf 126 | // Clear empty species 127 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JNF_NEAT 2 | 3 | My implementation of Kenneth Stanley and Risto Miikkulainen's NEAT (NeuroEvolution 4 | of Augmenting Topologies, http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf). 5 | 6 | It focuses (in contrast to other implementations) on 7 | 8 | - Speed - through modern and efficient C++14 9 | - Clean Code - through constant ongoing refactoring and a deep care for aesthetics 10 | - Usability - through being able to be used without much knowledge of Neural Networks 11 | - Platform Independence - written on three different operating systems (Windows, Ubuntu, MacOS X) and two different IDEs (Visual Studio 2015, CLion), it is safe to say, that it will work on multiple platforms, flawlessly. 12 | 13 | ##Foreword 14 | 15 | ###Motivation 16 | One of the problems of machine learning is its steep learning curve. If you want to let your code learn, 17 | you've got few choices: Use expensive proprietary modules or use libraries that are aimed at people with experience in AI. 18 | If you want to learn how machine learning works, you've got to read scientific papers with tons of buzzwords. 19 | The provided code is often made by people who are brilliant at researching, but have only got poor programming skills. 20 | 21 | We think this is a shame. A programmer shouldn't have to learn about the internals of a class. 22 | He should be able to use it intuitively, in a matter that it relieves him from work, not set him up for more. 23 | That's the age old principle of encapsulation! 24 | 25 | Another problem we've encountered, was platform dependency. Despite being conceived as a platform independent language, 26 | we encountered various implementations of NEAT, that managed to break this. Examples included code with for loops looking like this: 27 | ```sh 28 | for( i = 0; i < 10; i++ ){ 29 | ... 30 | } 31 | ``` 32 | Notice the `i` not having been declared? Some compilers permit this. Another, more subtle one was the `abstract` keyword 33 | of Microsoft Visual Studio. It's actually not part of the language. The official way is to write an (admittedly more arbitrary) `= 0` 34 | at the end of a function. 35 | 36 | ###What is NEAT? 37 | 38 | TODO 39 | 40 | ##Usage 41 | First, you have to instantiate a `NeuralNetworkTrainer`. This class will take care of everything. It uses standard training values if not provided with a parameter. 42 | If you know what you're doing, you can provide it with a `NeuralNetworkTrainer::RuleSet` instance to tweak the learning process. 43 | 44 | You then have to provide an implementation of the `ITrainable` interface. It's methods are 45 | - Update() 46 | - GetOrCalculateFitness() 47 | - ReceiveNetworkOutputs() 48 | - ProvideNetworkWithInputs() 49 | 50 | ###Update() 51 | This method gets called automatically multiple times during training. 52 | > default updatesPerGeneration: 1 53 | > Imagine this value as **number of actions per lifetime** 54 | 55 | The actions of your object should take place here. This almost always boils down to **executing the command the Neural Network decides to use**. (Remember: You get this Information by calling `LoadNeuralNetworkOutputs()`). 56 | 57 | **Example**: Say you want to train an artificial player for Super Mario World. This method should then take care of actually pressing the buttons your network want you to. In this specific case, it should also update the whole game for a frame, so enemies and items can react to Mario. 58 | 59 | ###GetOrCalculateFitness() 60 | This method tells the trainer how good this specific instance is compared to others. 61 | It gets called automatically when the `ITrainable` object dies 62 | > It's used to generate this objects offspring, with a fitness score of zero or lower meaning that this individuals genes are not going to get passed on 63 | 64 | > default minFitness: -2147483646 65 | > default maxFitness: 100 66 | 67 | Note that in very analog programs such as real world simulations, true perfection should be unreachable 68 | 69 | **Example**: A simulated chess player could have a fitness method implemented like this: 70 | ```sh 71 | unsigned int ChessSim::GetOrCalculateFitness() { 72 | unsigned int fitness = 0; 73 | for (const auto & piece : enemyKilledPieces) { 74 | fitness += piece.GetImportance(); 75 | } 76 | for (const auto & piece : ownKilledPieces) { 77 | fitness -= piece.GetImportance(); 78 | } 79 | return fitness; 80 | } 81 | ``` 82 | 83 | ###ReceiveNetworkOutputs() 84 | This method returns the conclusions of your neural network as a series of floats 85 | > default minNeuralCharge = 0.0; 86 | > default maxNeuralCharge = 1.0; 87 | > It is **highly** recommended to leave these values like this (see advanced FAQ for details) 88 | 89 | Almost always you'll want to translate these values into something your program can work with and store in a member 90 | 91 | **Example**: TODO 92 | 93 | ###ProvideNetworkWithInputs() 94 | This method describes what your network "sees". It get's called automatically whenever your network needs updated real world knowledge. 95 | Remember that it works (just like `ReceiveNetworkOutputs()`) with a vector of doubles, so most of the time you'll want to translate your 96 | inputs by dividing them by their maximally possible values. 97 | > default minNeuralCharge = 0.0; 98 | > default maxNeuralCharge = 1.0; 99 | > It is **highly** recommended to leave these values like this (see advanced FAQ for details) 100 | 101 | **Example**: Let's assume you want to create a handwriting reader. 102 | Your input would be a 20 pixels wide and 20 pixels high image of a hand drawn letter. 103 | In order to feed the neural network with this information, 104 | we'll create a vector with 20 * 20 = 400 inputs, each one having a value between 0.0 and 1.0 that represents this pixels blackness. 105 | We can do this in a variety of ways. One of them would be to add the RGB values of the pixel up and divide them by 106 | the maximum possible, 255+255+255 = 765. By this method, a bright red pixel(255,0,0) would be represented in our 400 element vector by 107 | the number 255 / 765 = 0.3333. 108 | 109 | ###Full Example 110 | 111 | TODO 112 | 113 | ## FAQ 114 | 115 | TODO 116 | 117 | ## Advanced FAQ 118 | 119 | TODO 120 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### OSX template 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk 27 | ### Linux template 28 | *~ 29 | 30 | # temporary files which can be created if a process still has a handle open of a deleted file 31 | .fuse_hidden* 32 | 33 | # KDE directory preferences 34 | .directory 35 | 36 | # Linux trash folder which might appear on any partition or disk 37 | .Trash-* 38 | ### VisualStudio template 39 | ## Ignore Visual Studio temporary files, build results, and 40 | ## files generated by popular Visual Studio add-ons. 41 | 42 | # User-specific files 43 | *.suo 44 | *.user 45 | *.userosscache 46 | *.sln.docstates 47 | 48 | # User-specific files (MonoDevelop/Xamarin Studio) 49 | *.userprefs 50 | 51 | # Build results 52 | [Dd]ebug/ 53 | [Dd]ebugPublic/ 54 | [Rr]elease/ 55 | [Rr]eleases/ 56 | x64/ 57 | x86/ 58 | bld/ 59 | [Bb]in/ 60 | [Oo]bj/ 61 | [Ll]og/ 62 | 63 | # Visual Studio 2015 cache/options directory 64 | .vs/ 65 | # Uncomment if you have tasks that create the project's static files in wwwroot 66 | #wwwroot/ 67 | 68 | # MSTest test Results 69 | [Tt]est[Rr]esult*/ 70 | [Bb]uild[Ll]og.* 71 | 72 | # NUNIT 73 | *.VisualState.xml 74 | TestResult.xml 75 | 76 | # Build Results of an ATL Project 77 | [Dd]ebugPS/ 78 | [Rr]eleasePS/ 79 | dlldata.c 80 | 81 | # DNX 82 | project.lock.json 83 | artifacts/ 84 | 85 | *_i.c 86 | *_p.c 87 | *_i.h 88 | *.ilk 89 | *.meta 90 | *.obj 91 | *.pch 92 | *.pdb 93 | *.pgc 94 | *.pgd 95 | *.rsp 96 | *.sbr 97 | *.tlb 98 | *.tli 99 | *.tlh 100 | *.tmp 101 | *.tmp_proj 102 | *.log 103 | *.vspscc 104 | *.vssscc 105 | .builds 106 | *.pidb 107 | *.svclog 108 | *.scc 109 | 110 | # Chutzpah Test files 111 | _Chutzpah* 112 | 113 | # Visual C++ cache files 114 | ipch/ 115 | *.aps 116 | *.ncb 117 | *.opendb 118 | *.opensdf 119 | *.sdf 120 | *.cachefile 121 | *.VC.db 122 | *.VC.VC.opendb 123 | 124 | # Visual Studio profiler 125 | *.psess 126 | *.vsp 127 | *.vspx 128 | *.sap 129 | 130 | # TFS 2012 Local Workspace 131 | $tf/ 132 | 133 | # Guidance Automation Toolkit 134 | *.gpState 135 | 136 | # ReSharper is a .NET coding add-in 137 | _ReSharper*/ 138 | *.[Rr]e[Ss]harper 139 | *.DotSettings.user 140 | 141 | # JustCode is a .NET coding add-in 142 | .JustCode 143 | 144 | # TeamCity is a build add-in 145 | _TeamCity* 146 | 147 | # DotCover is a Code Coverage Tool 148 | *.dotCover 149 | 150 | # NCrunch 151 | _NCrunch_* 152 | .*crunch*.local.xml 153 | nCrunchTemp_* 154 | 155 | # MightyMoose 156 | *.mm.* 157 | AutoTest.Net/ 158 | 159 | # Web workbench (sass) 160 | .sass-cache/ 161 | 162 | # Installshield output folder 163 | [Ee]xpress/ 164 | 165 | # DocProject is a documentation generator add-in 166 | DocProject/buildhelp/ 167 | DocProject/Help/*.HxT 168 | DocProject/Help/*.HxC 169 | DocProject/Help/*.hhc 170 | DocProject/Help/*.hhk 171 | DocProject/Help/*.hhp 172 | DocProject/Help/Html2 173 | DocProject/Help/html 174 | 175 | # Click-Once directory 176 | publish/ 177 | 178 | # Publish Web Output 179 | *.[Pp]ublish.xml 180 | *.azurePubxml 181 | # but database connection strings (with potential passwords) will be unencrypted 182 | *.pubxml 183 | *.publishproj 184 | 185 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 186 | # checkin your Azure Web App publish settings, but sensitive information contained 187 | # in these scripts will be unencrypted 188 | PublishScripts/ 189 | 190 | # NuGet Packages 191 | *.nupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/packages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/packages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/packages/repositories.config 198 | # NuGet v3's project.json files produces more ignoreable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *.dbmdl 226 | *.dbproj.schemaview 227 | *.pfx 228 | *.publishsettings 229 | node_modules/ 230 | orleans.codegen.cs 231 | 232 | # Since there are multiple workflows, uncomment next line to ignore bower_components 233 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 234 | #bower_components/ 235 | 236 | # RIA/Silverlight projects 237 | Generated_Code/ 238 | 239 | # Backup & report files from converting an old project file 240 | # to a newer Visual Studio version. Backup files are not needed, 241 | # because we have git ;-) 242 | _UpgradeReport_Files/ 243 | Backup*/ 244 | UpgradeLog*.XML 245 | UpgradeLog*.htm 246 | 247 | # SQL Server files 248 | *.mdf 249 | *.ldf 250 | 251 | # Business Intelligence projects 252 | *.rdl.data 253 | *.bim.layout 254 | *.bim_*.settings 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | 265 | # Visual Studio 6 build log 266 | *.plg 267 | 268 | # Visual Studio 6 workspace options file 269 | *.opt 270 | 271 | # Visual Studio LightSwitch build output 272 | **/*.HTMLClient/GeneratedArtifacts 273 | **/*.DesktopClient/GeneratedArtifacts 274 | **/*.DesktopClient/ModelManifest.xml 275 | **/*.Server/GeneratedArtifacts 276 | **/*.Server/ModelManifest.xml 277 | _Pvt_Extensions 278 | 279 | # Paket dependency manager 280 | .paket/paket.exe 281 | paket-files/ 282 | 283 | # FAKE - F# Make 284 | .fake/ 285 | 286 | # JetBrains Rider 287 | .idea/ 288 | *.sln.iml 289 | ### C template 290 | # Object files 291 | *.o 292 | *.ko 293 | *.elf 294 | 295 | # Precompiled Headers 296 | *.gch 297 | 298 | # Libraries 299 | *.lib 300 | *.a 301 | *.la 302 | *.lo 303 | 304 | # Shared objects (inc. Windows DLLs) 305 | *.dll 306 | *.so 307 | *.so.* 308 | *.dylib 309 | 310 | # Executables 311 | *.exe 312 | *.out 313 | *.app 314 | *.i*86 315 | *.x86_64 316 | *.hex 317 | 318 | # Debug files 319 | *.dSYM/ 320 | ### JetBrains template 321 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 322 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 323 | 324 | # User-specific stuff: 325 | .idea/workspace.xml 326 | .idea/tasks.xml 327 | .idea/dictionaries 328 | .idea/vcs.xml 329 | .idea/jsLibraryMappings.xml 330 | 331 | # Sensitive or high-churn files: 332 | .idea/dataSources.ids 333 | .idea/dataSources.xml 334 | .idea/dataSources.local.xml 335 | .idea/sqlDataSources.xml 336 | .idea/dynamic.xml 337 | .idea/uiDesigner.xml 338 | 339 | # Gradle: 340 | .idea/gradle.xml 341 | .idea/libraries 342 | 343 | # Mongo Explorer plugin: 344 | .idea/mongoSettings.xml 345 | 346 | ## File-based project format: 347 | *.iws 348 | 349 | ## Plugin-specific files: 350 | 351 | # IntelliJ 352 | /out/ 353 | 354 | # mpeltonen/sbt-idea plugin 355 | .idea_modules/ 356 | 357 | # JIRA plugin 358 | atlassian-ide-plugin.xml 359 | 360 | # Crashlytics plugin (for Android Studio and IntelliJ) 361 | com_crashlytics_export_strings.xml 362 | crashlytics.properties 363 | crashlytics-build.properties 364 | fabric.properties 365 | ### C++ template 366 | # Compiled Object files 367 | *.slo 368 | 369 | # Precompiled Headers 370 | 371 | # Compiled Dynamic libraries 372 | 373 | # Fortran module files 374 | *.mod 375 | 376 | # Compiled Static libraries 377 | *.lai 378 | 379 | # Executables 380 | ### Windows template 381 | # Windows image file caches 382 | Thumbs.db 383 | ehthumbs.db 384 | 385 | # Folder config file 386 | Desktop.ini 387 | 388 | # Recycle Bin used on file shares 389 | $RECYCLE.BIN/ 390 | 391 | # Windows Installer files 392 | *.cab 393 | *.msi 394 | *.msm 395 | *.msp 396 | 397 | # Windows shortcuts 398 | *.lnk 399 | ### CMake template 400 | CMakeCache.txt 401 | CMakeFiles 402 | CMakeScripts 403 | Makefile 404 | cmake_install.cmake 405 | install_manifest.txt 406 | -------------------------------------------------------------------------------- /JNF_NEAT/JNF_NEAT.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {5D622DAF-A669-4390-B6DC-8BD3C9BAF04C} 23 | Win32Proj 24 | JNF_NEAT 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 91 | true 92 | 93 | 94 | Console 95 | true 96 | 97 | 98 | 99 | 100 | 101 | 102 | Level3 103 | Disabled 104 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 105 | true 106 | 107 | 108 | Console 109 | true 110 | 111 | 112 | 113 | 114 | Level3 115 | 116 | 117 | MaxSpeed 118 | true 119 | true 120 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | 123 | 124 | Console 125 | true 126 | true 127 | true 128 | 129 | 130 | 131 | 132 | Level3 133 | 134 | 135 | MaxSpeed 136 | true 137 | true 138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | Speed 141 | 142 | 143 | Console 144 | true 145 | true 146 | true 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | TERMS AND CONDITIONS 10 | 11 | 0. Definitions. 12 | 13 | "This License" refers to version 3 of the GNU General Public License. 14 | 15 | "Copyright" also means copyright-like laws that apply to other kinds of 16 | works, such as semiconductor masks. 17 | 18 | "The Program" refers to any copyrightable work licensed under this 19 | License. Each licensee is addressed as "you". "Licensees" and 20 | "recipients" may be individuals or organizations. 21 | 22 | To "modify" a work means to copy from or adapt all or part of the work 23 | in a fashion requiring copyright permission, other than the making of an 24 | exact copy. The resulting work is called a "modified version" of the 25 | earlier work or a work "based on" the earlier work. 26 | 27 | A "covered work" means either the unmodified Program or a work based 28 | on the Program. 29 | 30 | To "propagate" a work means to do anything with it that, without 31 | permission, would make you directly or secondarily liable for 32 | infringement under applicable copyright law, except executing it on a 33 | computer or modifying a private copy. Propagation includes copying, 34 | distribution (with or without modification), making available to the 35 | public, and in some countries other activities as well. 36 | 37 | To "convey" a work means any kind of propagation that enables other 38 | parties to make or receive copies. Mere interaction with a user through 39 | a computer network, with no transfer of a copy, is not conveying. 40 | 41 | An interactive user interface displays "Appropriate Legal Notices" 42 | to the extent that it includes a convenient and prominently visible 43 | feature that (1) displays an appropriate copyright notice, and (2) 44 | tells the user that there is no warranty for the work (except to the 45 | extent that warranties are provided), that licensees may convey the 46 | work under this License, and how to view a copy of this License. If 47 | the interface presents a list of user commands or options, such as a 48 | menu, a prominent item in the list meets this criterion. 49 | 50 | 1. Source Code. 51 | 52 | The "source code" for a work means the preferred form of the work 53 | for making modifications to it. "Object code" means any non-source 54 | form of a work. 55 | 56 | A "Standard Interface" means an interface that either is an official 57 | standard defined by a recognized standards body, or, in the case of 58 | interfaces specified for a particular programming language, one that 59 | is widely used among developers working in that language. 60 | 61 | The "System Libraries" of an executable work include anything, other 62 | than the work as a whole, that (a) is included in the normal form of 63 | packaging a Major Component, but which is not part of that Major 64 | Component, and (b) serves only to enable use of the work with that 65 | Major Component, or to implement a Standard Interface for which an 66 | implementation is available to the public in source code form. A 67 | "Major Component", in this context, means a major essential component 68 | (kernel, window system, and so on) of the specific operating system 69 | (if any) on which the executable work runs, or a compiler used to 70 | produce the work, or an object code interpreter used to run it. 71 | 72 | The "Corresponding Source" for a work in object code form means all 73 | the source code needed to generate, install, and (for an executable 74 | work) run the object code and to modify the work, including scripts to 75 | control those activities. However, it does not include the work's 76 | System Libraries, or general-purpose tools or generally available free 77 | programs which are used unmodified in performing those activities but 78 | which are not part of the work. For example, Corresponding Source 79 | includes interface definition files associated with source files for 80 | the work, and the source code for shared libraries and dynamically 81 | linked subprograms that the work is specifically designed to require, 82 | such as by intimate data communication or control flow between those 83 | subprograms and other parts of the work. 84 | 85 | The Corresponding Source need not include anything that users 86 | can regenerate automatically from other parts of the Corresponding 87 | Source. 88 | 89 | The Corresponding Source for a work in source code form is that 90 | same work. 91 | 92 | 2. Basic Permissions. 93 | 94 | All rights granted under this License are granted for the term of 95 | copyright on the Program, and are irrevocable provided the stated 96 | conditions are met. This License explicitly affirms your unlimited 97 | permission to run the unmodified Program. The output from running a 98 | covered work is covered by this License only if the output, given its 99 | content, constitutes a covered work. This License acknowledges your 100 | rights of fair use or other equivalent, as provided by copyright law. 101 | 102 | You may make, run and propagate covered works that you do not 103 | convey, without conditions so long as your license otherwise remains 104 | in force. You may convey covered works to others for the sole purpose 105 | of having them make modifications exclusively for you, or provide you 106 | with facilities for running those works, provided that you comply with 107 | the terms of this License in conveying all material for which you do 108 | not control copyright. Those thus making or running the covered works 109 | for you must do so exclusively on your behalf, under your direction 110 | and control, on terms that prohibit them from making any copies of 111 | your copyrighted material outside their relationship with you. 112 | 113 | Conveying under any other circumstances is permitted solely under 114 | the conditions stated below. Sublicensing is not allowed; section 10 115 | makes it unnecessary. 116 | 117 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 118 | 119 | No covered work shall be deemed part of an effective technological 120 | measure under any applicable law fulfilling obligations under article 121 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 122 | similar laws prohibiting or restricting circumvention of such 123 | measures. 124 | 125 | When you convey a covered work, you waive any legal power to forbid 126 | circumvention of technological measures to the extent such circumvention 127 | is effected by exercising rights under this License with respect to 128 | the covered work, and you disclaim any intention to limit operation or 129 | modification of the work as a means of enforcing, against the work's 130 | users, your or third parties' legal rights to forbid circumvention of 131 | technological measures. 132 | 133 | 4. Conveying Verbatim Copies. 134 | 135 | You may convey verbatim copies of the Program's source code as you 136 | receive it, in any medium, provided that you conspicuously and 137 | appropriately publish on each copy an appropriate copyright notice; 138 | keep intact all notices stating that this License and any 139 | non-permissive terms added in accord with section 7 apply to the code; 140 | keep intact all notices of the absence of any warranty; and give all 141 | recipients a copy of this License along with the Program. 142 | 143 | You may charge any price or no price for each copy that you convey, 144 | and you may offer support or warranty protection for a fee. 145 | 146 | 5. Conveying Modified Source Versions. 147 | 148 | You may convey a work based on the Program, or the modifications to 149 | produce it from the Program, in the form of source code under the 150 | terms of section 4, provided that you also meet all of these conditions: 151 | 152 | a) The work must carry prominent notices stating that you modified 153 | it, and giving a relevant date. 154 | 155 | b) The work must carry prominent notices stating that it is 156 | released under this License and any conditions added under section 157 | 7. This requirement modifies the requirement in section 4 to 158 | "keep intact all notices". 159 | 160 | c) You must license the entire work, as a whole, under this 161 | License to anyone who comes into possession of a copy. This 162 | License will therefore apply, along with any applicable section 7 163 | additional terms, to the whole of the work, and all its parts, 164 | regardless of how they are packaged. This License gives no 165 | permission to license the work in any other way, but it does not 166 | invalidate such permission if you have separately received it. 167 | 168 | d) If the work has interactive user interfaces, each must display 169 | Appropriate Legal Notices; however, if the Program has interactive 170 | interfaces that do not display Appropriate Legal Notices, your 171 | work need not make them do so. 172 | 173 | A compilation of a covered work with other separate and independent 174 | works, which are not by their nature extensions of the covered work, 175 | and which are not combined with it such as to form a larger program, 176 | in or on a volume of a storage or distribution medium, is called an 177 | "aggregate" if the compilation and its resulting copyright are not 178 | used to limit the access or legal rights of the compilation's users 179 | beyond what the individual works permit. Inclusion of a covered work 180 | in an aggregate does not cause this License to apply to the other 181 | parts of the aggregate. 182 | 183 | 6. Conveying Non-Source Forms. 184 | 185 | You may convey a covered work in object code form under the terms 186 | of sections 4 and 5, provided that you also convey the 187 | machine-readable Corresponding Source under the terms of this License, 188 | in one of these ways: 189 | 190 | a) Convey the object code in, or embodied in, a physical product 191 | (including a physical distribution medium), accompanied by the 192 | Corresponding Source fixed on a durable physical medium 193 | customarily used for software interchange. 194 | 195 | b) Convey the object code in, or embodied in, a physical product 196 | (including a physical distribution medium), accompanied by a 197 | written offer, valid for at least three years and valid for as 198 | long as you offer spare parts or customer support for that product 199 | model, to give anyone who possesses the object code either (1) a 200 | copy of the Corresponding Source for all the software in the 201 | product that is covered by this License, on a durable physical 202 | medium customarily used for software interchange, for a price no 203 | more than your reasonable cost of physically performing this 204 | conveying of source, or (2) access to copy the 205 | Corresponding Source from a network server at no charge. 206 | 207 | c) Convey individual copies of the object code with a copy of the 208 | written offer to provide the Corresponding Source. This 209 | alternative is allowed only occasionally and noncommercially, and 210 | only if you received the object code with such an offer, in accord 211 | with subsection 6b. 212 | 213 | d) Convey the object code by offering access from a designated 214 | place (gratis or for a charge), and offer equivalent access to the 215 | Corresponding Source in the same way through the same place at no 216 | further charge. You need not require recipients to copy the 217 | Corresponding Source along with the object code. If the place to 218 | copy the object code is a network server, the Corresponding Source 219 | may be on a different server (operated by you or a third party) 220 | that supports equivalent copying facilities, provided you maintain 221 | clear directions next to the object code saying where to find the 222 | Corresponding Source. Regardless of what server hosts the 223 | Corresponding Source, you remain obligated to ensure that it is 224 | available for as long as needed to satisfy these requirements. 225 | 226 | e) Convey the object code using peer-to-peer transmission, provided 227 | you inform other peers where the object code and Corresponding 228 | Source of the work are being offered to the general public at no 229 | charge under subsection 6d. 230 | 231 | A separable portion of the object code, whose source code is excluded 232 | from the Corresponding Source as a System Library, need not be 233 | included in conveying the object code work. 234 | 235 | A "User Product" is either (1) a "consumer product", which means any 236 | tangible personal property which is normally used for personal, family, 237 | or household purposes, or (2) anything designed or sold for incorporation 238 | into a dwelling. In determining whether a product is a consumer product, 239 | doubtful cases shall be resolved in favor of coverage. For a particular 240 | product received by a particular user, "normally used" refers to a 241 | typical or common use of that class of product, regardless of the status 242 | of the particular user or of the way in which the particular user 243 | actually uses, or expects or is expected to use, the product. A product 244 | is a consumer product regardless of whether the product has substantial 245 | commercial, industrial or non-consumer uses, unless such uses represent 246 | the only significant mode of use of the product. 247 | 248 | "Installation Information" for a User Product means any methods, 249 | procedures, authorization keys, or other information required to install 250 | and execute modified versions of a covered work in that User Product from 251 | a modified version of its Corresponding Source. The information must 252 | suffice to ensure that the continued functioning of the modified object 253 | code is in no case prevented or interfered with solely because 254 | modification has been made. 255 | 256 | If you convey an object code work under this section in, or with, or 257 | specifically for use in, a User Product, and the conveying occurs as 258 | part of a transaction in which the right of possession and use of the 259 | User Product is transferred to the recipient in perpetuity or for a 260 | fixed term (regardless of how the transaction is characterized), the 261 | Corresponding Source conveyed under this section must be accompanied 262 | by the Installation Information. But this requirement does not apply 263 | if neither you nor any third party retains the ability to install 264 | modified object code on the User Product (for example, the work has 265 | been installed in ROM). 266 | 267 | The requirement to provide Installation Information does not include a 268 | requirement to continue to provide support service, warranty, or updates 269 | for a work that has been modified or installed by the recipient, or for 270 | the User Product in which it has been modified or installed. Access to a 271 | network may be denied when the modification itself materially and 272 | adversely affects the operation of the network or violates the rules and 273 | protocols for communication across the network. 274 | 275 | Corresponding Source conveyed, and Installation Information provided, 276 | in accord with this section must be in a format that is publicly 277 | documented (and with an implementation available to the public in 278 | source code form), and must require no special password or key for 279 | unpacking, reading or copying. 280 | 281 | 7. Additional Terms. 282 | 283 | "Additional permissions" are terms that supplement the terms of this 284 | License by making exceptions from one or more of its conditions. 285 | Additional permissions that are applicable to the entire Program shall 286 | be treated as though they were included in this License, to the extent 287 | that they are valid under applicable law. If additional permissions 288 | apply only to part of the Program, that part may be used separately 289 | under those permissions, but the entire Program remains governed by 290 | this License without regard to the additional permissions. 291 | 292 | When you convey a copy of a covered work, you may at your option 293 | remove any additional permissions from that copy, or from any part of 294 | it. (Additional permissions may be written to require their own 295 | removal in certain cases when you modify the work.) You may place 296 | additional permissions on material, added by you to a covered work, 297 | for which you have or can give appropriate copyright permission. 298 | 299 | Notwithstanding any other provision of this License, for material you 300 | add to a covered work, you may (if authorized by the copyright holders of 301 | that material) supplement the terms of this License with terms: 302 | 303 | a) Disclaiming warranty or limiting liability differently from the 304 | terms of sections 15 and 16 of this License; or 305 | 306 | b) Requiring preservation of specified reasonable legal notices or 307 | author attributions in that material or in the Appropriate Legal 308 | Notices displayed by works containing it; or 309 | 310 | c) Prohibiting misrepresentation of the origin of that material, or 311 | requiring that modified versions of such material be marked in 312 | reasonable ways as different from the original version; or 313 | 314 | d) Limiting the use for publicity purposes of names of licensors or 315 | authors of the material; or 316 | 317 | e) Declining to grant rights under trademark law for use of some 318 | trade names, trademarks, or service marks; or 319 | 320 | f) Requiring indemnification of licensors and authors of that 321 | material by anyone who conveys the material (or modified versions of 322 | it) with contractual assumptions of liability to the recipient, for 323 | any liability that these contractual assumptions directly impose on 324 | those licensors and authors. 325 | 326 | All other non-permissive additional terms are considered "further 327 | restrictions" within the meaning of section 10. If the Program as you 328 | received it, or any part of it, contains a notice stating that it is 329 | governed by this License along with a term that is a further 330 | restriction, you may remove that term. If a license document contains 331 | a further restriction but permits relicensing or conveying under this 332 | License, you may add to a covered work material governed by the terms 333 | of that license document, provided that the further restriction does 334 | not survive such relicensing or conveying. 335 | 336 | If you add terms to a covered work in accord with this section, you 337 | must place, in the relevant source files, a statement of the 338 | additional terms that apply to those files, or a notice indicating 339 | where to find the applicable terms. 340 | 341 | Additional terms, permissive or non-permissive, may be stated in the 342 | form of a separately written license, or stated as exceptions; 343 | the above requirements apply either way. 344 | 345 | 8. Termination. 346 | 347 | You may not propagate or modify a covered work except as expressly 348 | provided under this License. Any attempt otherwise to propagate or 349 | modify it is void, and will automatically terminate your rights under 350 | this License (including any patent licenses granted under the third 351 | paragraph of section 11). 352 | 353 | However, if you cease all violation of this License, then your 354 | license from a particular copyright holder is reinstated (a) 355 | provisionally, unless and until the copyright holder explicitly and 356 | finally terminates your license, and (b) permanently, if the copyright 357 | holder fails to notify you of the violation by some reasonable means 358 | prior to 60 days after the cessation. 359 | 360 | Moreover, your license from a particular copyright holder is 361 | reinstated permanently if the copyright holder notifies you of the 362 | violation by some reasonable means, this is the first time you have 363 | received notice of violation of this License (for any work) from that 364 | copyright holder, and you cure the violation prior to 30 days after 365 | your receipt of the notice. 366 | 367 | Termination of your rights under this section does not terminate the 368 | licenses of parties who have received copies or rights from you under 369 | this License. If your rights have been terminated and not permanently 370 | reinstated, you do not qualify to receive new licenses for the same 371 | material under section 10. 372 | 373 | 9. Acceptance Not Required for Having Copies. 374 | 375 | You are not required to accept this License in order to receive or 376 | run a copy of the Program. Ancillary propagation of a covered work 377 | occurring solely as a consequence of using peer-to-peer transmission 378 | to receive a copy likewise does not require acceptance. However, 379 | nothing other than this License grants you permission to propagate or 380 | modify any covered work. These actions infringe copyright if you do 381 | not accept this License. Therefore, by modifying or propagating a 382 | covered work, you indicate your acceptance of this License to do so. 383 | 384 | 10. Automatic Licensing of Downstream Recipients. 385 | 386 | Each time you convey a covered work, the recipient automatically 387 | receives a license from the original licensors, to run, modify and 388 | propagate that work, subject to this License. You are not responsible 389 | for enforcing compliance by third parties with this License. 390 | 391 | An "entity transaction" is a transaction transferring control of an 392 | organization, or substantially all assets of one, or subdividing an 393 | organization, or merging organizations. If propagation of a covered 394 | work results from an entity transaction, each party to that 395 | transaction who receives a copy of the work also receives whatever 396 | licenses to the work the party's predecessor in interest had or could 397 | give under the previous paragraph, plus a right to possession of the 398 | Corresponding Source of the work from the predecessor in interest, if 399 | the predecessor has it or can get it with reasonable efforts. 400 | 401 | You may not impose any further restrictions on the exercise of the 402 | rights granted or affirmed under this License. For example, you may 403 | not impose a license fee, royalty, or other charge for exercise of 404 | rights granted under this License, and you may not initiate litigation 405 | (including a cross-claim or counterclaim in a lawsuit) alleging that 406 | any patent claim is infringed by making, using, selling, offering for 407 | sale, or importing the Program or any portion of it. 408 | 409 | 11. Patents. 410 | 411 | A "contributor" is a copyright holder who authorizes use under this 412 | License of the Program or a work on which the Program is based. The 413 | work thus licensed is called the contributor's "contributor version". 414 | 415 | A contributor's "essential patent claims" are all patent claims 416 | owned or controlled by the contributor, whether already acquired or 417 | hereafter acquired, that would be infringed by some manner, permitted 418 | by this License, of making, using, or selling its contributor version, 419 | but do not include claims that would be infringed only as a 420 | consequence of further modification of the contributor version. For 421 | purposes of this definition, "control" includes the right to grant 422 | patent sublicenses in a manner consistent with the requirements of 423 | this License. 424 | 425 | Each contributor grants you a non-exclusive, worldwide, royalty-free 426 | patent license under the contributor's essential patent claims, to 427 | make, use, sell, offer for sale, import and otherwise run, modify and 428 | propagate the contents of its contributor version. 429 | 430 | In the following three paragraphs, a "patent license" is any express 431 | agreement or commitment, however denominated, not to enforce a patent 432 | (such as an express permission to practice a patent or covenant not to 433 | sue for patent infringement). To "grant" such a patent license to a 434 | party means to make such an agreement or commitment not to enforce a 435 | patent against the party. 436 | 437 | If you convey a covered work, knowingly relying on a patent license, 438 | and the Corresponding Source of the work is not available for anyone 439 | to copy, free of charge and under the terms of this License, through a 440 | publicly available network server or other readily accessible means, 441 | then you must either (1) cause the Corresponding Source to be so 442 | available, or (2) arrange to deprive yourself of the benefit of the 443 | patent license for this particular work, or (3) arrange, in a manner 444 | consistent with the requirements of this License, to extend the patent 445 | license to downstream recipients. "Knowingly relying" means you have 446 | actual knowledge that, but for the patent license, your conveying the 447 | covered work in a country, or your recipient's use of the covered work 448 | in a country, would infringe one or more identifiable patents in that 449 | country that you have reason to believe are valid. 450 | 451 | If, pursuant to or in connection with a single transaction or 452 | arrangement, you convey, or propagate by procuring conveyance of, a 453 | covered work, and grant a patent license to some of the parties 454 | receiving the covered work authorizing them to use, propagate, modify 455 | or convey a specific copy of the covered work, then the patent license 456 | you grant is automatically extended to all recipients of the covered 457 | work and works based on it. 458 | 459 | A patent license is "discriminatory" if it does not include within 460 | the scope of its coverage, prohibits the exercise of, or is 461 | conditioned on the non-exercise of one or more of the rights that are 462 | specifically granted under this License. You may not convey a covered 463 | work if you are a party to an arrangement with a third party that is 464 | in the business of distributing software, under which you make payment 465 | to the third party based on the extent of your activity of conveying 466 | the work, and under which the third party grants, to any of the 467 | parties who would receive the covered work from you, a discriminatory 468 | patent license (a) in connection with copies of the covered work 469 | conveyed by you (or copies made from those copies), or (b) primarily 470 | for and in connection with specific products or compilations that 471 | contain the covered work, unless you entered into that arrangement, 472 | or that patent license was granted, prior to 28 March 2007. 473 | 474 | Nothing in this License shall be construed as excluding or limiting 475 | any implied license or other defenses to infringement that may 476 | otherwise be available to you under applicable patent law. 477 | 478 | 12. No Surrender of Others' Freedom. 479 | 480 | If conditions are imposed on you (whether by court order, agreement or 481 | otherwise) that contradict the conditions of this License, they do not 482 | excuse you from the conditions of this License. If you cannot convey a 483 | covered work so as to satisfy simultaneously your obligations under this 484 | License and any other pertinent obligations, then as a consequence you may 485 | not convey it at all. For example, if you agree to terms that obligate you 486 | to collect a royalty for further conveying from those to whom you convey 487 | the Program, the only way you could satisfy both those terms and this 488 | License would be to refrain entirely from conveying the Program. 489 | 490 | 13. Use with the GNU Affero General Public License. 491 | 492 | Notwithstanding any other provision of this License, you have 493 | permission to link or combine any covered work with a work licensed 494 | under version 3 of the GNU Affero General Public License into a single 495 | combined work, and to convey the resulting work. The terms of this 496 | License will continue to apply to the part which is the covered work, 497 | but the special requirements of the GNU Affero General Public License, 498 | section 13, concerning interaction through a network will apply to the 499 | combination as such. 500 | 501 | 14. Revised Versions of this License. 502 | 503 | The Free Software Foundation may publish revised and/or new versions of 504 | the GNU General Public License from time to time. Such new versions will 505 | be similar in spirit to the present version, but may differ in detail to 506 | address new problems or concerns. 507 | 508 | Each version is given a distinguishing version number. If the 509 | Program specifies that a certain numbered version of the GNU General 510 | Public License "or any later version" applies to it, you have the 511 | option of following the terms and conditions either of that numbered 512 | version or of any later version published by the Free Software 513 | Foundation. If the Program does not specify a version number of the 514 | GNU General Public License, you may choose any version ever published 515 | by the Free Software Foundation. 516 | 517 | If the Program specifies that a proxy can decide which future 518 | versions of the GNU General Public License can be used, that proxy's 519 | public statement of acceptance of a version permanently authorizes you 520 | to choose that version for the Program. 521 | 522 | Later license versions may give you additional or different 523 | permissions. However, no additional obligations are imposed on any 524 | author or copyright holder as a result of your choosing to follow a 525 | later version. 526 | 527 | 15. Disclaimer of Warranty. 528 | 529 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 530 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 531 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 532 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 533 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 534 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 535 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 536 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 537 | 538 | 16. Limitation of Liability. 539 | 540 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 541 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 542 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 543 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 544 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 545 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 546 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 547 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 548 | SUCH DAMAGES. 549 | 550 | 17. Interpretation of Sections 15 and 16. 551 | 552 | If the disclaimer of warranty and limitation of liability provided 553 | above cannot be given local legal effect according to their terms, 554 | reviewing courts shall apply local law that most closely approximates 555 | an absolute waiver of all civil liability in connection with the 556 | Program, unless a warranty or assumption of liability accompanies a 557 | copy of the Program in return for a fee. 558 | 559 | END OF TERMS AND CONDITIONS 560 | --------------------------------------------------------------------------------