Browse Source

change tests

Willi Zschiebsch 5 years ago
parent
commit
3c8cf9a5a9

+ 3 - 1
lib/CMakeLists.txt

@@ -21,7 +21,9 @@ add_library(${PROJECT_NAME} STATIC
 	include/OptimizerBase.h
 	include/OptimizerEvolutionary.h
         include/Output.h
+	include/Parameter.h
         include/ProcessorBase.h
+	include/ProcessorStandard.h
 	include/Registration.h
 	include/state.h
 
@@ -31,13 +33,13 @@ add_library(${PROJECT_NAME} STATIC
         src/ModuleHTTP.cpp
         src/ModuleMath.cpp
 	src/ModuleMerge.cpp
-	src/Parameter.cpp
 	src/ModuleSplitt.cpp
         src/ModuleSQL.cpp
         src/ModuleSwitch.cpp
 	src/OptimizerBase.cpp
 	src/OptimizerEvolutionary.cpp
         src/Output.cpp
+	src/Parameter.cpp
         src/ProcessorBase.cpp
         src/ProcessorStandard.cpp
 	src/Registration.cpp

+ 1 - 4
lib/include/IOptimizer.h

@@ -9,10 +9,7 @@ namespace mdd {
 		: public IManager
 	{
 		public:
-			//virtual bool connect(std::shared_ptr<IModule> module) = 0;
-			/*
-			
-			*/
+			virtual bool connect(std::shared_ptr<IModule> module) = 0;
 			
 			virtual bool setEvaluation(std::string func) = 0;
 			virtual std::vector<std::vector<double>> update() = 0;

+ 1 - 1
lib/include/IProcessor.h

@@ -1,7 +1,7 @@
 #pragma once
 
 #include "IModule.h"
-#include "Parameter.cpp"
+#include "Parameter.h"
 #include <vector>
 
 namespace mdd

+ 3 - 2
lib/include/OptimizerBase.h

@@ -27,11 +27,12 @@ namespace mdd {
 		opt_state updateOutputs();
 		OptimizerBase(const std::string& base_config);
 	public:
+		bool connect(std::shared_ptr<IModule> module) override;
 		void updateLayout();
 		bool setEvaluation(std::string func) override;
 
-		bool configure(const std::string& config);
-		std::string getBaseConfiguration();
+		bool configure(const std::string& config) override;
+		std::string getConfiguration() override;
 		//virtual std::string getGeneratorID() = 0;
 		void load(const json& j);
 		json dump();

+ 52 - 0
lib/include/OptimizerEvolutionary.h

@@ -0,0 +1,52 @@
+#pragma once
+#include "OptimizerBase.h"
+#include <iostream>
+
+namespace mdd {
+	class OptimizerEvolutionary : public OptimizerBase {
+	public:
+		struct Individual {
+		public:
+			std::vector<std::vector<double>> dna;
+			double fitness = 0;
+			bool operator== (const Individual& ind) {
+				return (dna == ind.dna) && (fitness == ind.fitness);
+			};
+		};
+	protected:
+		static int random_num(double min, double max, double inc = 1.0)
+		{
+			int range = (max - min) / inc + 1;
+			return min + inc * (std::rand() % range);
+		}
+
+		Individual generateIndividual();
+		Individual combine(Individual par1, Individual par2);
+
+		std::vector<Individual> _children;
+		Individual _best;
+		int _min_generations;
+		double _max_fitness;
+		size_t _grow_generation;
+		size_t _converges;
+
+		void evolve(std::vector<Individual> parents);
+		void evaluate(size_t ignore_len = 0);
+		std::vector<double> mutateGene(std::shared_ptr<IInput> input, std::vector<double> seed = std::vector<double>());
+
+
+	public:
+		OptimizerEvolutionary();
+		bool OptimizerEvolutionary::configure(const std::string& config);
+		/*
+		std::shared_ptr<IModule> module,
+			size_t converges = 0,
+			size_t grow_generation = 20,
+			double max_fitness = 0.0,
+			int min_generations = -1
+		*/
+		std::vector<std::vector<double>> update() override;
+		Individual getBest();
+		double evaluateFitness(const Individual& ind);
+	};
+}

+ 16 - 0
lib/include/Parameter.h

@@ -0,0 +1,16 @@
+#pragma once
+#include "ModuleBase.h"
+
+namespace mdd {
+    class Parameter : public ModuleBase {
+    private:
+        IModule* _parent;
+    public:
+        Parameter(IModule* parent);
+        state update() override;
+        std::string setType(const std::string& type) override;
+        std::string setAppendix(int appendix) override;
+        bool configure(const std::string& config) override;
+        std::string getConfiguration() override;
+    };
+}

+ 0 - 1
lib/include/ProcessorBase.h

@@ -1,4 +1,3 @@
-/*
 #pragma once
 
 #include <list>

+ 37 - 0
lib/include/ProcessorStandard.h

@@ -0,0 +1,37 @@
+#pragma once 
+#include "ProcessorBase.h"
+#include <iostream>
+#include "Output.h"
+#include <chrono>
+
+namespace mdd {
+    enum priority {
+        MANUAL,
+        STATIC,
+        DYNAMIC,
+        TIME
+    };
+
+    class ProcessorStandard : public ProcessorBase {
+    private:
+        struct module_priority {
+            std::shared_ptr<IModule> module_ptr;
+            size_t inputCounter;
+            size_t changeCounter;
+            size_t outputCounter;
+            int time_priority;
+            module_priority(std::shared_ptr<IModule> module, size_t inputs = 0, size_t outputs = 0, size_t change = 0);
+        };
+        std::vector<module_priority> _priority_list;
+        int _maxIterations;
+        priority _priorityEvaluation;
+    public:
+        ProcessorStandard();
+        bool configure(const std::string& config) override;
+        std::string addModule(std::shared_ptr<IModule> module) override;
+        void removeModule(std::shared_ptr<IModule> module) override;
+        std::vector<std::shared_ptr<IModule>> getModulePriority();
+        state update() override;
+        std::shared_ptr<IOutput> getIteration();
+    };
+}

+ 7 - 3
lib/src/OptimizerBase.cpp

@@ -2,6 +2,11 @@
 #include <iostream>
 
 namespace mdd{
+	bool OptimizerBase::connect(std::shared_ptr<IModule> module) {
+		_module = module;
+		return true;
+	}
+
 	OptimizerBase::opt_state OptimizerBase::updateOutputs()
 	{
 		opt_state ret;
@@ -21,7 +26,7 @@ namespace mdd{
 	}
 
 	OptimizerBase::OptimizerBase(const std::string& base_config) {
-
+		_base_config = base_config;
 	}
 
 	void OptimizerBase::updateLayout()
@@ -72,10 +77,9 @@ namespace mdd{
 				}
 			}
 		}
-
 		return false;
 	}
-	std::string OptimizerBase::getBaseConfiguration() {
+	std::string OptimizerBase::getConfiguration() {
 		return _base_config;
 	}
 	//virtual std::string getGeneratorID() = 0;

+ 41 - 54
lib/src/OptimizerEvolutionary.cpp

@@ -1,53 +1,6 @@
-#include <iostream>
-#include "OptimizerBase.h"
+#include "OptimizerEvolutionary.h"
 
 namespace mdd {
-	class OptimizerEvolutionary : public OptimizerBase {
-	public:
-		struct Individual {
-		public:
-			std::vector<std::vector<double>> dna;
-			double fitness = 0;
-			bool operator== (const Individual& ind) {
-				return (dna == ind.dna) && (fitness == ind.fitness);
-			};
-		};
-	protected:
-		static int random_num(double min, double max, double inc = 1.0)
-		{
-			int range = (max - min) / inc + 1;
-			return min + inc * (std::rand() % range);
-		}
-
-		Individual generateIndividual();
-		Individual combine(Individual par1, Individual par2);
-
-		std::vector<Individual> _children;
-		Individual _best;
-		int _min_generations;
-		double _max_fitness;
-		size_t _grow_generation;
-		size_t _converges;
-
-		void evolve(std::vector<Individual> parents);
-		void evaluate(size_t ignore_len = 0);
-		std::vector<double> mutateGene(std::shared_ptr<IInput> input, std::vector<double> seed = std::vector<double>());
-
-
-	public:
-		OptimizerEvolutionary();
-		/*
-		std::shared_ptr<IModule> module,
-			size_t converges = 0,
-			size_t grow_generation = 20,
-			double max_fitness = 0.0,
-			int min_generations = -1
-		*/
-		std::vector<std::vector<double>> update() override;
-		Individual getBest();
-		double evaluateFitness(const Individual& ind);
-	};
-
 	void OptimizerEvolutionary::evaluate(size_t ignore_len)
 	{
 		//calculate fitness
@@ -82,22 +35,56 @@ namespace mdd {
             "name":"converges",
             "value": 0
         },{
-            "name":"grow_generation",
+            "name":"grow generation",
             "value": 20
         },{
-            "name":"max_fitness",
+            "name":"max fitness",
             "value": 0.0
         },{
-            "name":"min_generations",
+            "name":"min generations",
             "value": -1
         }])JSON")
 	{
 		//_module = module;
-		_grow_generation = 0;
-		_min_generations = 20;
+		_converges = 0;
+		_grow_generation = 20;
 		_max_fitness = 0.0;
-		_converges = -1;
+		_min_generations = -1;
+	}
+
+	bool OptimizerEvolutionary::configure(const std::string& config) {
+		json config_parsed = json::parse(config);
+		bool found = false;
+		for (size_t i = 0; i < config_parsed.size(); i++)
+		{
+			if (config_parsed[i].contains("name"))
+			{
+				if (config_parsed[i]["name"].get<std::string>() == "converges")
+				{
+					_converges = config_parsed[i]["value"].get<int>();
+					found = true;
+				}
+				else if (config_parsed[i]["name"].get<std::string>() == "grow generation")
+				{
+					_grow_generation = config_parsed[i]["value"].get<int>();
+					found = true;
+				}
+				else if (config_parsed[i]["name"].get<std::string>() == "max fitness")
+				{
+					_max_fitness = config_parsed[i]["value"].get<int>();
+					found = true;
+				}
+				else if (config_parsed[i]["name"].get<std::string>() == "min generations")
+				{
+					_min_generations = config_parsed[i]["value"].get<int>();
+					found = true;
+				}
+			}
+		}
+
+		return found;
 	}
+
 	std::vector<std::vector<double>> OptimizerEvolutionary::update()
 	{
 		int gen = -1;

+ 1 - 12
lib/src/Parameter.cpp

@@ -1,17 +1,6 @@
-#include "ModuleBase.h"
+#include "Parameter.h"
 
 namespace mdd {
-    class Parameter : public ModuleBase {
-    private:
-        IModule* _parent;
-    public:
-        Parameter(IModule* parent);
-        state update() override;
-        std::string setType(const std::string& type) override;
-        std::string setAppendix(int appendix) override;
-        bool configure(const std::string& config) override;
-        std::string getConfiguration() override;
-    };
     Parameter::Parameter(IModule* parent)
         : ModuleBase(R"JSON(
         [{

+ 16 - 14
lib/src/ProcessorBase.cpp

@@ -1,5 +1,5 @@
 #include "ProcessorBase.h"
-/*
+
 namespace mdd{
     ProcessorBase::ProcessorBase(const std::string& base_config)
     : _base_config(base_config)
@@ -17,7 +17,7 @@ namespace mdd{
                 {
                     for (size_t i = 0; i < j["inputs"].size(); i++)
                     {
-                        inputs.emplace_back(this);
+                        inputs.push_back(std::make_shared<Parameter>(this));
                         inputs.back()->setType(j["inputs"][i]["type"].get<std::string>());
                         inputs.back()->setAppendix(j["inputs"][i]["appendix"].get<int>());
                     }
@@ -26,7 +26,7 @@ namespace mdd{
                 {
                     for (size_t i = 0; i < j["outputs"].size(); i++)
                     {
-                        outputs.emplace_back(this);
+                        outputs.push_back(std::make_shared<Parameter>(this));
                         outputs.back()->setType(j["outputs"][i]["type"].get<std::string>());
                         outputs.back()->setAppendix(j["outputs"][i]["appendix"].get<int>());
                     }
@@ -57,27 +57,28 @@ namespace mdd{
         //update module apendix ?
 
         json ret = json::parse(_base_config);
-        ret["params"];
-        ret["params"]["inputs"];
+        json sub_ret;
+        sub_ret["params"];
+        sub_ret["params"]["inputs"];
         for (size_t i = 0; i < inputs.size(); i++)
         {
             json sub;
             sub["type"] = inputs[i]->getType();
             sub["appendix"] = inputs[i]->getAppendix();
-            ret["params"]["inputs"].push_back(sub);
+            sub_ret["params"]["inputs"].push_back(sub);
         }
 
-        ret["params"]["outputs"];
+        sub_ret["params"]["outputs"];
         for (size_t i = 0; i < outputs.size(); i++)
         {
             json sub;
             sub["type"] = outputs[i]->getType();
             sub["appendix"] = outputs[i]->getAppendix();
-            ret["params"]["outputs"].push_back(sub);
+            sub_ret["params"]["outputs"].push_back(sub);
         }
 
-        ret["modules"];
-        ret["connections"];
+        sub_ret["modules"];
+        sub_ret["connections"];
         for (size_t i = 0; i < modules.size(); i++)
         {
             json sub;
@@ -85,7 +86,7 @@ namespace mdd{
             sub["type"] = modules[i]->getType();
             sub["appendix"] = modules[i]->getAppendix();
             sub["configure"] = modules[i]->dump();
-            ret["modules"].push_back(sub);
+            sub_ret["modules"].push_back(sub);
             for (size_t j = 0; j < modules[i]->getNumOutputs(); j++)
             {
                 auto connections = modules[i]->getOutput(j)->getConnections();
@@ -97,10 +98,11 @@ namespace mdd{
                     {
                         connect["inputs"].push_back(connections[k]->getParentID() + "/" + connections[k]->getID());
                     }
-                    ret["connections"].push_back(connect);
+                    sub_ret["connections"].push_back(connect);
                 }
             }
         }
+        ret.push_back(sub_ret);
         return ret.dump();
     }
 
@@ -245,7 +247,7 @@ namespace mdd{
     }
 
     json ProcessorBase::dump() {
-        
+        return json();
     }
 
     std::shared_ptr<IOutput> ProcessorBase::getOutput(size_t index) {
@@ -253,7 +255,7 @@ namespace mdd{
         {
             return processor_outputs[index];
         }
-        index -= processor_inputs.size();
+        index -= processor_outputs.size();
         if (index < outputs.size())
         {
             return outputs[index]->getOutput(0);

+ 26 - 44
lib/src/ProcessorStandard.cpp

@@ -1,45 +1,11 @@
-/*
-#include "ProcessorBase.h"
-#include <iostream>
-#include "Output.h"
-#include <chrono>
+#include "ProcessorStandard.h"
 
 namespace mdd {
-    enum priority {
-        MANUAL,
-        STATIC,
-        DYNAMIC,
-        TIME
-    };
-
-    class ProcessorStandard : public ProcessorBase {
-    private:
-        struct module_priority {
-            std::shared_ptr<IModule> module_ptr;
-            size_t inputCounter;
-            size_t changeCounter;
-            size_t outputCounter;
-            int time_priority;
-            module_priority(std::shared_ptr<IModule> module, size_t inputs = 0, size_t outputs = 0, size_t change = 0);
-        };
-        std::vector<module_priority> _priority_list;
-        int _maxIterations;
-        priority _priorityEvaluation;
-    public:
-        ProcessorStandard();
-        bool configure(const std::string& config) override;
-        std::string addModule(std::shared_ptr<IModule> module) override;
-        void removeModule(std::shared_ptr<IModule> module) override;
-        std::vector<std::shared_ptr<IModule>> getModulePriority();
-        state update() override;
-        std::shared_ptr<IOutput> getIteration();
-    };
-
     ProcessorStandard::ProcessorStandard()
         :ProcessorBase(R"JSON(
         [{
             "name":"priority",
-            "value":"manual"
+            "value":"manual",
             "options":  [
                             "manual",
                             "static",
@@ -100,20 +66,20 @@ namespace mdd {
     std::string ProcessorStandard::addModule(std::shared_ptr<IModule> module)
     {
         std::string id = ProcessorBase::addModule(module);
-        _priority_list.emplace_back(module_priority(module));
+        //_priority_list.emplace_back(module);
         return id;
     }
 
     void ProcessorStandard::removeModule(std::shared_ptr<IModule> module)
     {
         ProcessorBase::removeModule(module);
-        for (auto it = _priority_list.begin(); it != _priority_list.end(); ++it) {
-            if (it->module_ptr == module)
-            {
-                _priority_list.erase(it);
-                return;
-            }
-        }
+        //for (auto it = _priority_list.begin(); it != _priority_list.end(); ++it) {
+        //    if (it->module_ptr == module)
+        //    {
+        //        _priority_list.erase(it);
+        //        return;
+        //    }
+        //}
     }
 
     std::vector<std::shared_ptr<IModule>> ProcessorStandard::getModulePriority()
@@ -126,6 +92,22 @@ namespace mdd {
     }
 
     state ProcessorStandard::update() {
+        _priority_list.clear();
+        for (size_t i = 0; i < inputs.size(); i++)
+        {
+            _priority_list.emplace_back(inputs[i]);
+        }
+
+        for (size_t i = 0; i < modules.size(); i++)
+        {
+            _priority_list.emplace_back(modules[i]);
+        }
+
+        for (size_t i = 0; i < outputs.size(); i++)
+        {
+            _priority_list.emplace_back(outputs[i]);
+        }
+
         if (_priorityEvaluation != MANUAL)
         {
             //update priorities

+ 3 - 3
lib/src/Registration.cpp

@@ -7,11 +7,11 @@
 #include "ModuleHTTP.cpp"
 #include "ModuleMath.cpp"
 #include "ModuleMerge.cpp"
-//#include "ModuleSplitt.cpp"
+#include "ModuleSplitt.cpp"
 #include "ModuleSQL.cpp"
 #include "ModuleSwitch.cpp"
 
-//#include "ProcessorStandard.cpp"
+#include "ProcessorStandard.h"
 
 namespace mdd
 {
@@ -24,7 +24,7 @@ namespace mdd
 		REGISTER(ModuleSQL);
 		REGISTER(ModuleSwitch);
 
-		//REGISTER(ProcessorStandard);
+		REGISTER(ProcessorStandard);
 	}
 	IModule::Ptr Registration::generateModule(const std::string& name)
 	{

+ 169 - 126
lib/test/test_Ansys.cpp

@@ -1,136 +1,179 @@
 #include <gtest/gtest.h>
 #include <json.hpp>
 #include <httplib.h>
-//#define private public
+#include "Registration.h"
+#include "OptimizerEvolutionary.h"
+#include "ProcessorStandard.h"
 #include <math.h>
 #include <thread>
-/*
+
 using namespace mdd;
-TEST(ModuleHTTP, test_ansys_sql_server) {
-    std::shared_ptr<ModuleSQL> sql = std::make_shared<ModuleSQL>("../../../lib/test/db/materials.db");
-    std::shared_ptr<ModuleHTTP> http = std::make_shared<ModuleHTTP>("", "localhost", 8888);//../../../lib/test/server/server-ansys.py
-
-    auto sql_inputs = sql->getInputIDs();
-    auto sql_outputs = sql->getOutputIDs();
-    auto http_inputs = http->getInputIDs();
-    auto http_outputs = http->getOutputIDs();
-    sql->getInput(sql_inputs[0])->setValue() = { 1 };
-
-    //test http
-    std::cout << "http-TEST" << std::endl;
-    for (size_t i = 0; i < http_inputs.size(); i++)
-    {
-        std::cout << http->getInput(http_inputs[i])->getValue()[0] << std::endl;
-    }
-    for (size_t i = 2; i < sql_outputs.size(); i++)//0: ID 1: Name
-    {
-        http->getInput(http_inputs[i - 2])->connect(sql->getOutput(sql_outputs[i]));
-    }
-    http->getInput(http_inputs.back())->setOptimizability(true);
-    limits limit;
-    limit.min = { 0, 0, 0, 0, 0, 0 };
-    limit.max = { 90, 90, 90, 90, 90, 90 };
-    limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
-    http->getInput(http_inputs.back())->setLimits() = limit;
-    //http->getInput(http_inputs.back())->setValue().clear();
-    http->getInput(http_inputs.back())->setValue() = { 90,90,0,90,0,90 };
-
-    http->getOutput(http_outputs[3])->setOptimizability(true);
-
-    sql->update();
-    //test SQL
-    std::cout << "SQL-TEST" << std::endl;
-    for (size_t i = 2; i < sql_outputs.size(); i++)
-    {
-        std::cout<< sql->getOutput(sql_outputs[i])->getValue()[0] <<std::endl;
+namespace TEST_ANSYS {
+
+    auto regi = Registration();
+    TEST(ModuleHTTP, test_ansys_sql_server) {
+        auto sql = regi.generateModule("ModuleSQL");
+        json config = json::parse(sql->getConfiguration());
+        config[0]["value"] = "../../../lib/test/db/materials.db";
+        sql->configure(config.dump());
+
+        auto http = regi.generateModule("ModuleHTTP");// ("", "localhost", 8888);
+        config = json::parse(http->getConfiguration());
+        config[0]["value"] = "";
+        config[1]["value"] = "localhost";
+        config[2]["value"] = 8888;
+        http->configure(config.dump());
+        //../../../lib/test/server/server-ansys.py
+
+        sql->getInput(0)->setValue() = { 1 };
+        
+        for (size_t i = 0; i < http->getNumInputs(); i++)
+        {
+            std::cout << http->getInput(i)->getValue()[0] << std::endl;
+        }
+        for (size_t i = 2; i < sql->getNumOutputs(); i++)//0: ID 1: Name
+        {
+            http->getInput(i - 2)->connect(sql->getOutput(i));
+        }
+        http->getInput(http->getNumInputs() - 1)->setOptimizability(true);
+        limits limit;
+        limit.min = { 0, 0, 0, 0, 0, 0 };
+        limit.max = { 90, 90, 90, 90, 90, 90 };
+        limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
+        http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
+        http->getInput(http->getNumInputs() - 1)->setValue() = { 90,90,0,90,0,90 };
+
+        http->getOutput(3)->setOptimizability(true);
+
+        sql->update();
+        //test SQL
+        std::cout << "SQL-TEST" << std::endl;
+        for (size_t i = 2; i < sql->getNumOutputs(); i++)
+        {
+            std::cout << sql->getOutput(i)->getValue()[0] << std::endl;
+        }
+
+        http->update();
+        EXPECT_FLOAT_EQ(http->getOutput(3)->getValue()[0], 0.31204228291286723);
     }
 
-    http->update();
-    EXPECT_FLOAT_EQ(http->getOutput(http_outputs[3])->getValue()[0], 0.31204228291286723);
-}
-
-TEST(ModuleHTTP, test_configurations) {
-    std::shared_ptr<ModuleSQL> sql = std::make_shared<ModuleSQL>("../../../lib/test/db/materials.db");
-    std::shared_ptr<ModuleHTTP> http = std::make_shared<ModuleHTTP>("", "localhost", 8888);//../../../lib/test/server/server-ansys.py
-
-    auto sql_inputs = sql->getInputIDs();
-    auto sql_outputs = sql->getOutputIDs();
-    auto http_inputs = http->getInputIDs();
-    auto http_outputs = http->getOutputIDs();
-    sql->getInput(sql_inputs[0])->setValue() = { 1 };
-    for (size_t i = 2; i < sql_outputs.size(); i++)//0: ID 1: Name
-    {
-        http->getInput(http_inputs[i - 2])->connect(sql->getOutput(sql_outputs[i]));
+    TEST(ModuleHTTP, test_configurations) {
+        auto sql = regi.generateModule("ModuleSQL");
+        json config = json::parse(sql->getConfiguration());
+        config[0]["value"] = "../../../lib/test/db/materials.db";
+        sql->configure(config.dump());
+
+        auto http = regi.generateModule("ModuleHTTP");// ("", "localhost", 8888);
+        config = json::parse(http->getConfiguration());
+        config[0]["value"] = "";
+        config[1]["value"] = "localhost";
+        config[2]["value"] = 8888;
+        http->configure(config.dump());
+        //../../../lib/test/server/server-ansys.py
+
+        sql->getInput(0)->setValue() = { 1 };
+
+        for (size_t i = 0; i < http->getNumInputs(); i++)
+        {
+            std::cout << http->getInput(i)->getValue()[0] << std::endl;
+        }
+        for (size_t i = 2; i < sql->getNumOutputs(); i++)//0: ID 1: Name
+        {
+            http->getInput(i - 2)->connect(sql->getOutput(i));
+        }
+        http->getInput(http->getNumInputs() - 1)->setOptimizability(true);
+        limits limit;
+        limit.min = { 0, 0, 0, 0, 0, 0 };
+        limit.max = { 90, 90, 90, 90, 90, 90 };
+        limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
+        http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
+
+        http->getOutput(3)->setOptimizability(true);
+
+        std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
+        processor->addModule(sql);
+        processor->addModule(http);
+
+        OptimizerEvolutionary optimizer;
+        config = json::parse(optimizer.getConfiguration());
+        config[0]["value"] = 3;
+        config[1]["value"] = 20;
+        config[2]["value"] = 0.13;
+        config[3]["value"] = 5;
+        optimizer.configure(config.dump());
+        optimizer.connect(processor);
+        optimizer.setEvaluation("out0");
+
+        //auto res = optimizer.update();
+        OptimizerEvolutionary::Individual ind;
+        ind.dna = { { 0,90,90,90,90,90 } };
+        std::cout << "{ 0,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 90,90,90,90,90,0 } };
+        std::cout << "{ 90,90,90,90,90,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 90,0,0,0,0,0 } };
+        std::cout << "{ 90,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 0,0,0,0,0,90 } };
+        std::cout << "{ 0,0,0,0,0,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 0,0,0,0,0,0 } };
+        std::cout << "{ 0,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 90,90,90,90,90,90 } };
+        std::cout << "{ 90,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        ind.dna = { { 0,0,90,90,90,90 } };
+        std::cout << "{ 0,0,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        EXPECT_TRUE(ind.fitness <= 100.0);
     }
-    http->getInput(http_inputs.back())->setOptimizability(true);
-    limits limit;
-    limit.min = { 0, 0, 0, 0, 0, 0 };
-    limit.max = { 90, 90, 90, 90, 90, 90 };
-    limit.rule = "val[0] != val[5] or val[1] != val[4] or val[2] != val[3]";
-    http->getInput(http_inputs.back())->setLimits() = limit;
-
-    http->getOutput(http_outputs[3])->setOptimizability(true);
-
-    std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
-    processor->addModule(sql);
-    processor->addModule(http);
-    auto mods = processor->getModuleIDs();
-
-    OptimizerEvolutionary optimizer(processor, 3, 20, 0.13, 5);
-    optimizer.setEvaluation("out0");
-
-    //auto res = optimizer.update();
-    OptimizerEvolutionary::Individual ind;
-    ind.dna = { { 0,90,90,90,90,90 } };
-    std::cout << "{ 0,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 90,90,90,90,90,0 } };
-    std::cout << "{ 90,90,90,90,90,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 90,0,0,0,0,0 } };
-    std::cout << "{ 90,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 0,0,0,0,0,90 } };
-    std::cout << "{ 0,0,0,0,0,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 0,0,0,0,0,0 } };
-    std::cout << "{ 0,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 90,90,90,90,90,90 } };
-    std::cout << "{ 90,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    ind.dna = { { 0,0,90,90,90,90 } };
-    std::cout << "{ 0,0,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
-    EXPECT_TRUE(ind.fitness <= 100.0);
-}
-
-TEST(ModuleHTTP, test_ansys_server) {
-    std::shared_ptr<ModuleSQL> sql = std::make_shared<ModuleSQL>("../../../lib/test/db/materials.db");
-    std::shared_ptr<ModuleHTTP> http = std::make_shared<ModuleHTTP>("", "localhost", 8888);//../../../lib/test/server/server-ansys.py
-
-    auto sql_inputs = sql->getInputIDs();
-    auto sql_outputs = sql->getOutputIDs();
-    auto http_inputs = http->getInputIDs();
-    auto http_outputs = http->getOutputIDs();
-    sql->getInput(sql_inputs[0])->setValue() = { 1 };
-    for (size_t i = 2; i < sql_outputs.size(); i++)//0: ID 1: Name
-    {
-        http->getInput(http_inputs[i - 2])->connect(sql->getOutput(sql_outputs[i]));
+
+    TEST(ModuleHTTP, test_ansys_server) {
+        auto sql = regi.generateModule("ModuleSQL");
+        json config = json::parse(sql->getConfiguration());
+        config[0]["value"] = "../../../lib/test/db/materials.db";
+        sql->configure(config.dump());
+
+        auto http = regi.generateModule("ModuleHTTP");// ("", "localhost", 8888);
+        config = json::parse(http->getConfiguration());
+        config[0]["value"] = "";
+        config[1]["value"] = "localhost";
+        config[2]["value"] = 8888;
+        http->configure(config.dump());
+        //../../../lib/test/server/server-ansys.py
+
+        sql->getInput(0)->setValue() = { 1 };
+
+        for (size_t i = 0; i < http->getNumInputs(); i++)
+        {
+            std::cout << http->getInput(i)->getValue()[0] << std::endl;
+        }
+        for (size_t i = 2; i < sql->getNumOutputs(); i++)//0: ID 1: Name
+        {
+            http->getInput(i - 2)->connect(sql->getOutput(i));
+        }
+        http->getInput(http->getNumInputs() - 1)->setOptimizability(true);
+        limits limit;
+        limit.min = { 0, 0, 0, 0, 0, 0 };
+        limit.max = { 90, 90, 90, 90, 90, 90 };
+        limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
+        http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
+
+        http->getOutput(3)->setOptimizability(true);
+
+        std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
+        processor->addModule(sql);
+        processor->addModule(http);
+
+        OptimizerEvolutionary optimizer;
+        config = json::parse(optimizer.getConfiguration());
+        config[0]["value"] = 3;
+        config[1]["value"] = 20;
+        config[2]["value"] = 0.13;
+        config[3]["value"] = 5;
+        optimizer.configure(config.dump());
+        optimizer.connect(processor);
+        optimizer.setEvaluation("out0");
+
+        auto res = optimizer.update();
+        std::cout << optimizer.getBest().fitness << std::endl;
+        std::cout << optimizer.evaluateFitness(optimizer.getBest()) << std::endl;
+        EXPECT_TRUE(optimizer.getBest().fitness <= 100.0);
     }
-    http->getInput(http_inputs.back())->setOptimizability(true);
-    limits limit;
-    limit.min = { 0, 0, 0, 0, 0, 0 };
-    limit.max = { 90, 90, 90, 90, 90, 90 };
-    limit.rule = "val[0] != val[5] or val[1] != val[4] or val[2] != val[3]";
-    http->getInput(http_inputs.back())->setLimits() = limit;
-
-    http->getOutput(http_outputs[3])->setOptimizability(true);
-   
-    std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
-    processor->addModule(sql);
-    processor->addModule(http);
-    auto mods = processor->getModuleIDs();
-
-    OptimizerEvolutionary optimizer(processor, 3, 20, 0.13, 5);
-    optimizer.setEvaluation("out0");
-
-    auto res = optimizer.update();
-    std::cout << optimizer.getBest().fitness << std::endl;
-    std::cout << optimizer.evaluateFitness(optimizer.getBest()) << std::endl;
-    EXPECT_TRUE(optimizer.getBest().fitness <= 100.0);
-}
-//*/
+    //*/
+}

+ 1 - 1
lib/test/test_ModuleSQL.cpp

@@ -188,7 +188,7 @@ namespace TEST_MODULE_SQL {
         if (!std::filesystem::exists("../../../lib/test/db/materials.db")) {
             create_test_db();
         }
-        IModule::Ptr mod = regi.generateModule("ModuleMath");
+        IModule::Ptr mod = regi.generateModule("ModuleSQL");
         json config = json::parse(mod->getConfiguration());
         config[0]["value"] = "../../../lib/test/db/materials.db";
         mod->configure(config.dump());

+ 76 - 61
lib/test/test_ModuleSwitch.cpp

@@ -5,64 +5,79 @@
 
 
 using namespace mdd;
-/*
-TEST(ModuleSwitch, EasySwitch){
-    ModuleSwitch sModule = ModuleSwitch();
-    auto inputs = sModule.getInputIDs();
-    auto outputs = sModule.getOutputIDs();
-
-    sModule.getInput(inputs[0])->setValue() = { 0 };
-    sModule.getInput(inputs[1])->setValue() = { 1 };
-    sModule.getInput(inputs[2])->setValue() = { 2 };
-
-    sModule.update();
-
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
-
-    sModule.getInput(inputs[0])->setValue() = { 1 };
-    sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
-
-    sModule.getInput(inputs[0])->setValue() = { 2 };
-    sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
-
-    sModule.getInput(inputs[0])->setValue() = { 3 };
-    sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
-    sModule.getInput(inputs[0])->setValue() = { 33 };
-    sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
-}
-
-TEST(ModuleSwitch, ConnectTest){
-
-    ModuleMath f0 = ModuleMath(MathOperation::MULTIPLY);
-    auto inputs = f0.getInputIDs();
-    f0.getInput(inputs[0])->setValue() = { 1 };
-    f0.getInput(inputs[1])->setValue() = { 1 };
-
-    ModuleMath f1 = ModuleMath(MathOperation::MULTIPLY);
-    inputs = f1.getInputIDs();
-    f1.getInput(inputs[0])->setValue() = { 2 };
-    f1.getInput(inputs[1])->setValue() = { 3 };
-
-    ModuleMath f2 = ModuleMath(MathOperation::MULTIPLY);
-    inputs = f2.getInputIDs();
-    f2.getInput(inputs[0])->setValue() = { 5 };
-    f2.getInput(inputs[1])->setValue() = { 7 };
-
-    ModuleSwitch sModule = ModuleSwitch();
-    inputs = sModule.getInputIDs();
-    sModule.getInput(inputs[0])->connect(f0.getOutput(f0.getOutputIDs()[0]));
-    sModule.getInput(inputs[1])->connect(f1.getOutput(f1.getOutputIDs()[0]));
-    sModule.getInput(inputs[2])->connect(f2.getOutput(f2.getOutputIDs()[0]));
-
-    f0.update();
-    f1.update();
-    f2.update();
-    sModule.update();
-
-    //std::cout << sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(sModule.getOutput(sModule.getOutputIDs()[0])->getValue()[0], 6);
-}*/
+namespace TEST_MODULE_SWITCH {
+
+    auto regi = Registration();
+    TEST(ModuleSwitch, EasySwitch){
+        IModule::Ptr sModule = regi.generateModule("ModuleSwitch");
+        json config = json::parse(sModule->getConfiguration());
+        config[0]["value"] = 2;
+        sModule->configure(config.dump());
+
+        sModule->getInput(0)->setValue() = { 0 };
+        sModule->getInput(1)->setValue() = { 1 };
+        sModule->getInput(2)->setValue() = { 2 };
+
+        sModule->update();
+
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 1);
+
+        sModule->getInput(0)->setValue() = { 1 };
+        sModule->update();
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 1);
+
+        sModule->getInput(0)->setValue() = { 2 };
+        sModule->update();
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2);
+
+        sModule->getInput(0)->setValue() = { 3 };
+        sModule->update();
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2);
+        sModule->getInput(0)->setValue() = { 33 };
+        sModule->update();
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 2);
+    }
+
+    TEST(ModuleSwitch, ConnectTest){
+        IModule::Ptr f0 = regi.generateModule("ModuleMath");
+        json config = json::parse(f0->getConfiguration());
+        config[0]["value"] = "multiply";
+        f0->configure(config.dump());
+       
+        f0->getInput(0)->setValue() = { 1 };
+        f0->getInput(1)->setValue() = { 1 };
+
+        IModule::Ptr f1 = regi.generateModule("ModuleMath");
+        config = json::parse(f1->getConfiguration());
+        config[0]["value"] = "multiply";
+        f1->configure(config.dump());
+
+        f1->getInput(0)->setValue() = { 2 };
+        f1->getInput(1)->setValue() = { 3 };
+
+        IModule::Ptr f2 = regi.generateModule("ModuleMath");
+        config = json::parse(f2->getConfiguration());
+        config[0]["value"] = "multiply";
+        f2->configure(config.dump());
+
+        f2->getInput(0)->setValue() = { 5 };
+        f2->getInput(1)->setValue() = { 7 };
+
+        IModule::Ptr sModule = regi.generateModule("ModuleSwitch");
+        config = json::parse(sModule->getConfiguration());
+        config[0]["value"] = 2;
+        sModule->configure(config.dump());
+
+        sModule->getInput(0)->connect(f0->getOutput(0));
+        sModule->getInput(1)->connect(f1->getOutput(0));
+        sModule->getInput(2)->connect(f2->getOutput(0));
+
+        f0->update();
+        f1->update();
+        f2->update();
+        sModule->update();
+
+        //std::cout << sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].dump() << std::endl;
+        EXPECT_EQ(sModule->getOutput(0)->getValue()[0], 6);
+    }//*/
+}

+ 69 - 71
lib/test/test_OptimizerEvolutionary.cpp

@@ -1,79 +1,77 @@
 #include <gtest/gtest.h>
 #include <json.hpp>
 //#define private public
+#include <OptimizerEvolutionary.h>
 #include <Registration.h>
 
-/*
 using namespace mdd;
-TEST(OptimizerEvolutionary, OptimizeSimpleFormula) {
-    //optimize f(x)=a*b
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    auto inputs = f1->getInputIDs();
-    auto outputs = f1->getOutputIDs();
-    limits limit;
-    limit.min = { -10 };
-    limit.max = { 10 };
-    limit.step = { 1 };
+namespace TEST_OPTIMIZER_EVOLUTION {
 
-    f1->getInput(inputs[0])->setLimits() = limit;
-    f1->getInput(inputs[1])->setLimits() = limit;
-
-    f1->getInput(inputs[0])->setOptimizability(true);
-    f1->getInput(inputs[1])->setOptimizability(true);
-    f1->getOutput(outputs[0])->setOptimizability(true);
-
-    OptimizerEvolutionary optimizer(f1, 5);
-    optimizer.setEvaluation("out0");
-
-    auto res = optimizer.update();
-    //std::cout << res.dump() << std::endl;
-    EXPECT_EQ(res[0][0]* res[1][0],-100);
-}
-
-TEST(OptimizerEvolutionary, OptimizeSimpleFormulaWithSimpleRestriction) {
-    //optimize f(x)=a*b
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    auto inputs = f1->getInputIDs();
-    auto outputs = f1->getOutputIDs();
-    limits limit;
-    limit.min = { -10 };
-    limit.max = { 10 };
-    limit.step = { 1 };
-    limit.rule = "val[0] != -10";
-
-    f1->getInput(inputs[0])->setLimits() = limit;
-    f1->getInput(inputs[1])->setLimits() = limit;
-
-    f1->getInput(inputs[0])->setOptimizability(true);
-    f1->getInput(inputs[1])->setOptimizability(true);
-    f1->getOutput(outputs[0])->setOptimizability(true);
-    OptimizerEvolutionary optimizer(f1, 3);
-    optimizer.setEvaluation("out0");
-
-    auto res = optimizer.update();
-    //std::cout << res.dump() << std::endl;
-    EXPECT_EQ(res[0][0] * res[1][0], -90);
-}
-
-TEST(OptimizerEvolutionary, exprtk) {
-    json a;
-    a["value"] = { 1,2,3 };
-    exprtk::symbol_table<double> symbol_table;
-    auto v = a["value"].get<std::vector<double>>();
-    //std::cout << v[0] << "|" << v[1] << "|" << v[2] << std::endl;
-    symbol_table.add_vector("in" + std::to_string(0), v);
-    symbol_table.add_constants();
-    exprtk::expression<double> _func_expr;
-    _func_expr.register_symbol_table(symbol_table);
-
-    exprtk::parser<double> parser;
-    //"in0[1]==in0[1]"=>1
-    //"in0[1]!=in0[1]"=>0
+    auto regi = Registration();
+    
+    TEST(OptimizerEvolutionary, OptimizeSimpleFormula) {
+        //optimize f(x)=a*b
+        IModule::Ptr f1 = regi.generateModule("ModuleMath");
+    
+        json config = json::parse(f1->getConfiguration());
+        config[0]["value"] = "multiply";
+        f1->configure(config.dump());
+        limits limit;
+        limit.min = { -10 };
+        limit.max = { 10 };
+        limit.step = { 1 };
+    
+        f1->getInput(0)->setLimits() = limit;
+        f1->getInput(1)->setLimits() = limit;
+    
+        f1->getInput(0)->setOptimizability(true);
+        f1->getInput(1)->setOptimizability(true);
+        f1->getOutput(0)->setOptimizability(true);
+    
+        OptimizerEvolutionary optimizer;
+        optimizer.connect(f1);
+        config = json::parse(optimizer.getConfiguration());
+        config[0]["value"] = 3;
+        optimizer.configure(config.dump());
+    
+        optimizer.setEvaluation("out0");
+    
+        auto res = optimizer.update();
+        //std::cout << res.dump() << std::endl;
+        EXPECT_EQ(res[0][0]* res[1][0],-100);
+    }
+    
+    TEST(OptimizerEvolutionary, OptimizeSimpleFormulaWithSimpleRestriction) {
+        //optimize f(x)=a*b
+        IModule::Ptr f1 = regi.generateModule("ModuleMath");
+    
+        json config = json::parse(f1->getConfiguration());
+        config[0]["value"] = "multiply";
+        f1->configure(config.dump());
+        limits limit;
+        limit.min = { -10 };
+        limit.max = { 10 };
+        limit.step = { 1 };
+        limit.rule = "val[0] != -10";
+    
+        f1->getInput(0)->setLimits() = limit;
+        f1->getInput(1)->setLimits() = limit;
+    
+        f1->getInput(0)->setOptimizability(true);
+        f1->getInput(1)->setOptimizability(true);
+        f1->getOutput(0)->setOptimizability(true);
+    
+        OptimizerEvolutionary optimizer;
+        optimizer.connect(f1);
+        config = json::parse(optimizer.getConfiguration());
+        config[0]["value"] = 3;
+        optimizer.configure(config.dump());
+    
+        optimizer.setEvaluation("out0");
     
-    //std::cout << _func_expr.value() << std::endl;
-    //std::cout << res.dump() << std::endl;
-    parser.compile("in0[1]==in0[1]", _func_expr);
-    EXPECT_EQ(_func_expr.value(), 1);
-    parser.compile("in0[1]!=in0[1]", _func_expr);
-    EXPECT_EQ(_func_expr.value(), 0);
-}*/
+        auto res = optimizer.update();
+        //std::cout << res.dump() << std::endl;
+        EXPECT_EQ(res[0][0]* res[1][0],-90);
+    }
+//*/
+}

+ 184 - 123
lib/test/test_ProcessorStandard.cpp

@@ -1,182 +1,243 @@
 #include <gtest/gtest.h>
 #include <json.hpp>
 #include <Registration.h>
+#include "ProcessorStandard.h"
+
 //#define private public
-/*
+
 
 using namespace mdd;
+namespace TEST_PROCESSOR_STANDARD {
+
+    auto regi = Registration();
+
 TEST(ProcessorStandard, CalculateSimpleFormula){
     //f4:(f3:(f1:(5*3)-f2:(4+5))/2)==(15-9)/2==6/2==3
-    std::vector<std::string> inputs;
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setValue() = { 5 };
-    f1->getInput(inputs[1])->setValue() = { 3 };
-
-    std::shared_ptr<ModuleMath> f2 = std::make_shared<ModuleMath>(MathOperation::ADD);
-    inputs = f2->getInputIDs();
-    f2->getInput(inputs[0])->setValue() = { 4 };
-    f2->getInput(inputs[1])->setValue() = { 5 };
-
-    std::shared_ptr<ModuleMath> f3 = std::make_shared<ModuleMath>(MathOperation::SUBTRACT);
-    inputs = f3->getInputIDs();
-    f3->getInput(inputs[0])->connect(f1->getOutput(f1->getOutputIDs()[0]));
-    f3->getInput(inputs[1])->connect(f2->getOutput(f2->getOutputIDs()[0]));
-
-    std::shared_ptr<ModuleMath> f4 = std::make_shared<ModuleMath>(MathOperation::DIVIDE);
-    inputs = f4->getInputIDs();
-    f4->getInput(inputs[0])->connect(f3->getOutput(f3->getOutputIDs()[0]));
-    f4->getInput(inputs[1])->setValue() = { 2 };
-
-    std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();
+    auto f1 = regi.generateModule("ModuleMath");
+    json config = json::parse(f1->getConfiguration());
+    config[0]["value"] = "multiply";
+    f1->configure(config.dump());
+    f1->getInput(0)->setValue() = { 5 };
+    f1->getInput(1)->setValue() = { 3 };
+
+    auto f2 = regi.generateModule("ModuleMath");
+    config = json::parse(f2->getConfiguration());
+    config[0]["value"] = "add";
+    f2->configure(config.dump());
+    f2->getInput(0)->setValue() = { 4 };
+    f2->getInput(1)->setValue() = { 5 };
+
+    auto f3 = regi.generateModule("ModuleMath");
+    config = json::parse(f3->getConfiguration());
+    config[0]["value"] = "subtract";
+    f3->configure(config.dump());
+    f3->getInput(0)->connect(f1->getOutput(0));
+    f3->getInput(1)->connect(f2->getOutput(0));
+
+    auto f4 = regi.generateModule("ModuleMath");
+    config = json::parse(f4->getConfiguration());
+    config[0]["value"] = "divide";
+    f4->configure(config.dump());
+    f4->getInput(0)->connect(f3->getOutput(0));
+    f4->getInput(1)->setValue() = { 2 };
+
+    auto processor = std::make_shared<ProcessorStandard>();
+        //regi.generateModule("ProcessorStandard");;
     processor->addModule(f1);
     processor->addModule(f2);
     processor->addModule(f3);
     processor->addModule(f4);
-    processor->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
+
+    processor->getOutputParams().push_back(std::make_shared<Parameter>(&(*processor)));
+    processor->getOutputParams().at(0)->getInput(0)->connect(f4->getOutput(0));
+   
     processor->update();
 
-    EXPECT_EQ(f1->getOutput(f1->getOutputIDs()[0])->getValue()[0], 15);
+    EXPECT_EQ(f1->getOutput(0)->getValue()[0], 15);
 
-    EXPECT_EQ(f2->getOutput(f2->getOutputIDs()[0])->getValue()[0], 9);
+    EXPECT_EQ(f2->getOutput(0)->getValue()[0], 9);
 
-    EXPECT_EQ(f3->getOutput(f3->getOutputIDs()[0])->getValue()[0], 6);
+    EXPECT_EQ(f3->getOutput(0)->getValue()[0], 6);
 
-    EXPECT_EQ(f4->getOutput(f4->getOutputIDs()[0])->getValue()[0], 3);
+    EXPECT_EQ(f4->getOutput(0)->getValue()[0], 3);
 
-    EXPECT_EQ(processor->getOutput(processor->getOutputIDs()[1])->getValue()[0], 3);
+    EXPECT_EQ(processor->getOutput(1)->getValue()[0], 3);
+    //processor->disconnect();
 }
 
-
 TEST(ProcessorStandard, CalculateAdvancedFormula){
     //f4:(f3:(f1:(5*3)-f2:(4+5))/2)==(15-9)/2==6/2==3
-    std::vector<std::string> inputs;
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setValue() = { 5 };
-    f1->getInput(inputs[1])->setValue() = { 3 };
-
-    std::shared_ptr<ModuleMath> f2 = std::make_shared<ModuleMath>(MathOperation::ADD);
-    inputs = f2->getInputIDs();
-    f2->getInput(inputs[0])->setValue() = { 4 };
-    f2->getInput(inputs[1])->setValue() = { 5 };
-
-    std::shared_ptr<ModuleMath> f3 = std::make_shared<ModuleMath>(MathOperation::SUBTRACT);
-    inputs = f3->getInputIDs();
-    f3->getInput(inputs[0])->connect(f1->getOutput(f1->getOutputIDs()[0]));
-    f3->getInput(inputs[1])->connect(f2->getOutput(f2->getOutputIDs()[0]));
-
-    std::shared_ptr<ModuleMath> f4 = std::make_shared<ModuleMath>(MathOperation::DIVIDE);
-    inputs = f4->getInputIDs();
-    f4->getInput(inputs[0])->connect(f3->getOutput(f3->getOutputIDs()[0]));
-    f4->getInput(inputs[1])->setValue() = { 2 };
-
-    std::shared_ptr<ProcessorStandard> test = std::make_shared<ProcessorStandard>();
-    test->addModule(f4);
-    test->addModule(f3);
-    test->addModule(f2);
-    test->addModule(f1);
-    test->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
-    test->update();
+    auto f1 = regi.generateModule("ModuleMath");
+    json config = json::parse(f1->getConfiguration());
+    config[0]["value"] = "multiply";
+    f1->configure(config.dump());
+    f1->getInput(0)->setValue() = { 5 };
+    f1->getInput(1)->setValue() = { 3 };
+
+    auto f2 = regi.generateModule("ModuleMath");
+    config = json::parse(f2->getConfiguration());
+    config[0]["value"] = "add";
+    f2->configure(config.dump());
+    f2->getInput(0)->setValue() = { 4 };
+    f2->getInput(1)->setValue() = { 5 };
+
+    auto f3 = regi.generateModule("ModuleMath");
+    config = json::parse(f3->getConfiguration());
+    config[0]["value"] = "subtract";
+    f3->configure(config.dump());
+    f3->getInput(0)->connect(f1->getOutput(0));
+    f3->getInput(1)->connect(f2->getOutput(0));
+
+    auto f4 = regi.generateModule("ModuleMath");
+    config = json::parse(f4->getConfiguration());
+    config[0]["value"] = "divide";
+    f4->configure(config.dump());
+    f4->getInput(0)->connect(f3->getOutput(0));
+    f4->getInput(1)->setValue() = { 2 };
+
+    auto processor = std::make_shared<ProcessorStandard>();
+
+    processor->addModule(f4);
+    processor->addModule(f3);
+    processor->addModule(f2);
+    processor->addModule(f1);
+    processor->getOutputParams().push_back(std::make_shared<Parameter>(&(*processor)));
+    processor->getOutputParams().at(0)->getInput(0)->connect(f4->getOutput(0));
+    processor->update();
     //std::cout << test->getOutput(test->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(test->getOutput(test->getOutputIDs()[1])->getValue()[0], 3);
+    EXPECT_EQ(processor->getOutput(1)->getValue()[0], 3);
 }
 
 TEST(ProcessorStandard, CalculateExtremeFormula){
     //x_0=8, x_i=x_{i-1}/2
-    std::shared_ptr<ModuleSwitch> switchModule =  std::make_shared<ModuleSwitch>();
-    std::shared_ptr<ModuleMath> calcModule = std::make_shared<ModuleMath>(MathOperation::DIVIDE);
+    auto switchModule = regi.generateModule("ModuleSwitch");
+    json config = json::parse(switchModule->getConfiguration());
+    config[0]["value"] = 2;
+    switchModule->configure(config.dump());  
+
+    auto calcModule = regi.generateModule("ModuleMath");
+    config = json::parse(calcModule->getConfiguration());
+    config[0]["value"] = "divide";
+    calcModule->configure(config.dump());
+
     std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();
     processor->addModule(switchModule);
     processor->addModule(calcModule);
 
     bool connect;
-    connect =switchModule->getInput(switchModule->getInputIDs()[0])->connect(processor->getIteration());
-    switchModule->getInput(switchModule->getInputIDs()[1])->setValue() = { 8.0 };
-    connect = switchModule->getInput(switchModule->getInputIDs()[2])->connect(calcModule->getOutput(calcModule->getOutputIDs()[0]));
+    connect =switchModule->getInput(0)->connect(processor->getIteration());
+    switchModule->getInput(1)->setValue() = { 8.0 };
+    connect = switchModule->getInput(2)->connect(calcModule->getOutput(0));
 
-    calcModule->getInput(calcModule->getInputIDs()[0])->connect(switchModule->getOutput(switchModule->getOutputIDs()[0]));
-    calcModule->getInput(calcModule->getInputIDs()[1])->setValue() = { 2.0 };
+    calcModule->getInput(0)->connect(switchModule->getOutput(0));
+    calcModule->getInput(1)->setValue() = { 2.0 };
 
-    processor->addModuleOutput(calcModule,calcModule->getOutput(calcModule->getOutputIDs()[0]));
+    processor->getOutputParams().push_back(std::make_shared<Parameter>(&(*processor)));
+    processor->getOutputParams().at(0)->getInput(0)->connect(calcModule->getOutput(0));
     processor->update();
 
-    EXPECT_FLOAT_EQ(processor->getOutput(processor->getOutputIDs()[1])->getValue()[0], 0.0);
+    EXPECT_FLOAT_EQ(processor->getOutput(1)->getValue()[0], 0.0);
 }
 
 TEST(ProcessorStandard, CalculateAdvancedFormulaWithSTATIC) {
     //f4:(f3:(f1:(5*3)-f2:(4+5))/2)==(15-9)/2==6/2==3
-    std::vector<std::string> inputs;
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setValue() = { 5 };
-    f1->getInput(inputs[1])->setValue() = { 3 };
-
-    std::shared_ptr<ModuleMath> f2 = std::make_shared<ModuleMath>(MathOperation::ADD);
-    inputs = f2->getInputIDs();
-    f2->getInput(inputs[0])->setValue() = { 4 };
-    f2->getInput(inputs[1])->setValue() = { 5 };
-
-    std::shared_ptr<ModuleMath> f3 = std::make_shared<ModuleMath>(MathOperation::SUBTRACT);
-    inputs = f3->getInputIDs();
-    f3->getInput(inputs[0])->connect(f1->getOutput(f1->getOutputIDs()[0]));
-    f3->getInput(inputs[1])->connect(f2->getOutput(f2->getOutputIDs()[0]));
-
-    std::shared_ptr<ModuleMath> f4 = std::make_shared<ModuleMath>(MathOperation::DIVIDE);
-    inputs = f4->getInputIDs();
-    f4->getInput(inputs[0])->connect(f3->getOutput(f3->getOutputIDs()[0]));
-    f4->getInput(inputs[1])->setValue() = { 2 };
-
-    std::shared_ptr<ProcessorStandard> process_static = std::make_shared<ProcessorStandard>(STATIC);
-    process_static->addModule(f4);
-    process_static->addModule(f3);
-    process_static->addModule(f2);
-    process_static->addModule(f1);
-    process_static->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
-    process_static->update();
+    auto f1 = regi.generateModule("ModuleMath");
+    json config = json::parse(f1->getConfiguration());
+    config[0]["value"] = "multiply";
+    f1->configure(config.dump());
+    f1->getInput(0)->setValue() = { 5 };
+    f1->getInput(1)->setValue() = { 3 };
+
+    auto f2 = regi.generateModule("ModuleMath");
+    config = json::parse(f2->getConfiguration());
+    config[0]["value"] = "add";
+    f2->configure(config.dump());
+    f2->getInput(0)->setValue() = { 4 };
+    f2->getInput(1)->setValue() = { 5 };
+
+    auto f3 = regi.generateModule("ModuleMath");
+    config = json::parse(f3->getConfiguration());
+    config[0]["value"] = "subtract";
+    f3->configure(config.dump());
+    f3->getInput(0)->connect(f1->getOutput(0));
+    f3->getInput(1)->connect(f2->getOutput(0));
+
+    auto f4 = regi.generateModule("ModuleMath");
+    config = json::parse(f4->getConfiguration());
+    config[0]["value"] = "divide";
+    f4->configure(config.dump());
+    f4->getInput(0)->connect(f3->getOutput(0));
+    f4->getInput(1)->setValue() = { 2 };
+
+    auto processor = std::make_shared<ProcessorStandard>();
+    config = json::parse(processor->getConfiguration());
+    config[0]["value"] = "static";
+    processor->configure(config.dump());
+
+    processor->addModule(f4);
+    processor->addModule(f3);
+    processor->addModule(f2);
+    processor->addModule(f1);
+    processor->getOutputParams().push_back(std::make_shared<Parameter>(&(*processor)));
+    processor->getOutputParams().at(0)->getInput(0)->connect(f4->getOutput(0));
+    processor->update();
     //std::cout << test->getOutput(test->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(process_static->getOutput(process_static->getOutputIDs()[1])->getValue()[0], 3);
+    EXPECT_EQ(processor->getOutput(1)->getValue()[0], 3);
 }
 
 TEST(ProcessorStandard, PrioritySTATIC) {
     //f4:(f3:(f1:(5*3)-f2:(4+5))/2)==(15-9)/2==6/2==3
-    std::vector<std::string> inputs;
-    std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setValue() = { 5 };
-    f1->getInput(inputs[1])->setValue() = { 3 };
-
-    std::shared_ptr<ModuleMath> f2 = std::make_shared<ModuleMath>(MathOperation::ADD);
-    inputs = f2->getInputIDs();
-    f2->getInput(inputs[0])->setValue() = { 4 };
-    f2->getInput(inputs[1])->setValue() = { 5 };
-
-    std::shared_ptr<ModuleMath> f3 = std::make_shared<ModuleMath>(MathOperation::SUBTRACT);
-    inputs = f3->getInputIDs();
-    f3->getInput(inputs[0])->connect(f1->getOutput(f1->getOutputIDs()[0]));
-    f3->getInput(inputs[1])->connect(f2->getOutput(f2->getOutputIDs()[0]));
-
-    std::shared_ptr<ModuleMath> f4 = std::make_shared<ModuleMath>(MathOperation::DIVIDE);
-    inputs = f4->getInputIDs();
-    f4->getInput(inputs[0])->connect(f3->getOutput(f3->getOutputIDs()[0]));
-    f4->getInput(inputs[1])->setValue() = { 2 };
-
-    std::shared_ptr<ProcessorStandard> process_manual = std::make_shared<ProcessorStandard>();
+    auto f1 = regi.generateModule("ModuleMath");
+    json config = json::parse(f1->getConfiguration());
+    config[0]["value"] = "multiply";
+    f1->configure(config.dump());
+    f1->getInput(0)->setValue() = { 5 };
+    f1->getInput(1)->setValue() = { 3 };
+
+    auto f2 = regi.generateModule("ModuleMath");
+    config = json::parse(f2->getConfiguration());
+    config[0]["value"] = "add";
+    f2->configure(config.dump());
+    f2->getInput(0)->setValue() = { 4 };
+    f2->getInput(1)->setValue() = { 5 };
+
+    auto f3 = regi.generateModule("ModuleMath");
+    config = json::parse(f3->getConfiguration());
+    config[0]["value"] = "subtract";
+    f3->configure(config.dump());
+    f3->getInput(0)->connect(f1->getOutput(0));
+    f3->getInput(1)->connect(f2->getOutput(0));
+
+    auto f4 = regi.generateModule("ModuleMath");
+    config = json::parse(f4->getConfiguration());
+    config[0]["value"] = "divide";
+    f4->configure(config.dump());
+    f4->getInput(0)->connect(f3->getOutput(0));
+    f4->getInput(1)->setValue() = { 2 };
+
+    auto process_manual = std::make_shared<ProcessorStandard>();
+    auto process_static = std::make_shared<ProcessorStandard>();
+    config = json::parse(process_static->getConfiguration());
+    config[0]["value"] = "static";
+    process_static->configure(config.dump());
+
     process_manual->addModule(f1);
     process_manual->addModule(f2);
     process_manual->addModule(f3);
     process_manual->addModule(f4);
-    process_manual->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
+    process_manual->getOutputParams().push_back(std::make_shared<Parameter>(&(*process_manual)));
+    process_manual->getOutputParams().at(0)->getInput(0)->connect(f4->getOutput(0));
     process_manual->update();
 
-    std::shared_ptr<ProcessorStandard> process_static = std::make_shared<ProcessorStandard>(STATIC);
     process_static->addModule(f4);
     process_static->addModule(f3);
     process_static->addModule(f2);
     process_static->addModule(f1);
-    process_static->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
+    process_static->getOutputParams().push_back(std::make_shared<Parameter>(&(*process_static)));
+    process_static->getOutputParams().at(0)->getInput(0)->connect(f4->getOutput(0));
     process_static->update();
     //std::cout << process_static->getOutput(process_static->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
     EXPECT_TRUE(process_static->getIteration()->getValue()[0] <= process_manual->getIteration()->getValue()[0]);
 }
-//*/
+//*/
+}