Browse Source

changed Input and outout for opti and replaced json with std::vector<double>

Willi Zschiebsch 4 years ago
parent
commit
af95fd349a

+ 6 - 2
CMakeLists.txt

@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 17)
 
 include(cmake/configure_msvc.cmake)
 configure_msvc_runtime()
-install(FILES cmake/auslegung-config.cmake DESTINATION .)
+install(FILES cmake/mdd-config.cmake DESTINATION .)
 
 if(${TESTS_ENABLED})
     enable_testing()
@@ -26,4 +26,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cpp-httplib)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/exprtk)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/sqlite3)
 
-add_subdirectory(lib)
+add_subdirectory(lib)
+
+install(FILES thirdparty/json/single_include/json.hpp DESTINATION include)
+
+install(FILES thirdparty/json/single_include/nlohmann/json.hpp DESTINATION include/nlohmann)

cmake/auslegung-config.cmake → cmake/mdd-config.cmake


+ 2 - 3
lib/CMakeLists.txt

@@ -1,14 +1,13 @@
-
-
 cmake_minimum_required(VERSION 3.8.0)
 project(mdd_lib)
 
-add_library(${PROJECT_NAME} STATIC
+add_library(${PROJECT_NAME}
         include/HandlerModule
 	include/IConnector.h
         include/IInput.h
         include/IModule.h
         include/Input.h
+	include/IOptimizable.h
 	include/IOptimizer.h
         include/IOutput.h
         include/IProcessor.h

+ 14 - 4
lib/include/IInput.h

@@ -1,23 +1,33 @@
 #ifndef MDD_IINPUT_H
 #define MDD_IINPUT_H
 
-#include "json.hpp"
+//#include "json.hpp"
 #include <memory>
 #include "IOutput.h"
 #include "IUnique.h"
 #include "IState.h"
 #include "IConnector.h"
+#include "IOptimizable.h"
+#include <vector>
 
 namespace mdd{
+    struct limits {
+        std::vector<double> min;
+        std::vector<double> max;
+        std::vector<double> step;
+        std::string rule;
+        std::vector<std::vector<double>> elements;
+    };
+
     class IInput 
         : public IUnique
         , public IState
         , public IConnector<IOutput>
+        , public IOptimizable
     {
     public:
-        virtual const json& getValue() = 0;
-        virtual json& setDefaultValue() = 0;
-        virtual bool verify(const json & data) = 0;
+        virtual const limits& getLimits() = 0;
+        virtual limits& setLimits() = 0;
         virtual std::shared_ptr<IOutput> getConnection() = 0;
         virtual ~IInput() = default;
     };

+ 2 - 0
lib/include/IModule.h

@@ -24,6 +24,8 @@ namespace mdd {
         virtual std::shared_ptr<IInput> getInput(std::string input_id) = 0;
         virtual std::vector <std::shared_ptr<IOutput>> getInputConnections() = 0;
         virtual std::vector <std::vector <std::shared_ptr<IInput>>> getOutputConnections() = 0;
+        virtual std::vector <std::shared_ptr<IInput>> getOptimizableInputs() = 0;
+        virtual std::vector <std::shared_ptr<IOutput>> getOptimizableOutputs() = 0;
         virtual state update() = 0;
         virtual ~IModule() = default;
     };

+ 18 - 0
lib/include/IOptimizable.h

@@ -0,0 +1,18 @@
+#ifndef IOPTIMIZABLE_H
+#define IOPTIMIZABLE_H
+
+#include <vector>
+
+namespace mdd {
+	class IOptimizable {
+	public:
+		virtual const std::vector<double>& getValue() = 0;
+		virtual std::vector<double>& setValue() = 0;
+		virtual state setValue(const std::vector<double>& val) = 0;
+		virtual bool isOptimizable() = 0;
+		virtual void setOptimizability(bool state) = 0;
+		virtual ~IOptimizable() = default;
+	};
+}
+
+#endif // !IOPTIMIZABLE_H

+ 3 - 27
lib/include/IOptimizer.h

@@ -8,35 +8,11 @@ namespace mdd {
 		public:
 			//virtual bool connect(std::shared_ptr<IModule> module) = 0;
 			/*
-			limit{
-				("min": []
-				"max": []
-				("step": []
-				or
-				"rule": string))
-				nor
-				"elements": [[],[],[]]
-			}
+			
 			*/
-			virtual bool addModifier(std::string input_id, const json& limit) = 0;
-			virtual bool addReader(std::string output_id) = 0;
-
-			/*
-			limit{
-				("min": []
-				"max": []
-				("step": []
-				or
-				"rule": string))
-				nor
-				"elements": [[],[],[]]
-			}
-			*/
-			virtual bool changeModifier(std::string input_id, const json& limit) = 0;
-			virtual void removeModifier(std::string input_id) = 0;
-			virtual void removeReader(std::string output_id) = 0;
+			
 			virtual bool setEvaluation(std::string func) = 0;
-			virtual json update() = 0;
+			virtual std::vector<std::vector<double>> update() = 0;
 	};
 }
 #endif // !IOPTIMIZER_H

+ 7 - 3
lib/include/IOutput.h

@@ -5,6 +5,7 @@
 #include "IUnique.h"
 #include "IState.h"
 //#include "IInput.h"
+#include "IOptimizable.h"
 #include "IConnector.h"
 
 namespace mdd
@@ -12,10 +13,13 @@ namespace mdd
     class IInput;
     class IModule;
 
-    class IOutput : public IUnique, public IState, public IConnector<IInput>{
+    class IOutput 
+        : public IUnique
+        , public IState
+        , public IConnector<IInput>
+        , public IOptimizable
+    {
     public:
-        virtual const json& getValue() = 0;
-        virtual json& getValueInternal() = 0;
         virtual std::vector<std::shared_ptr<IInput>> getConnections() = 0;
         virtual ~IOutput() = default;
     };

+ 17 - 9
lib/include/Input.h

@@ -15,17 +15,17 @@ namespace mdd {
         std::string _type;
         int _appendix;
 
-        json _value;
-        std::function<bool(const json &)> _verification;
+        std::vector<double> _value;
+        //std::function<bool(const json &)> _verification;
         std::shared_ptr <IOutput> _output;
-
+        bool _optimizable;
+        limits _limit;
     protected:
        
 
     public:
-        Input(const std::string &type, int appendix, const json &default_value,
-              const std::function<bool(const json &)> &verification = [](
-                      const json &) { return true; });
+        Input(const std::string &type, int appendix, const std::vector<double>& default_value);
+        //const std::function<bool(const json &)> &verification = [](const json&) { return true; }
         std::string setType(std::string type) override;
         std::string getType() override;
         std::string getID() override;
@@ -35,10 +35,18 @@ namespace mdd {
         state getState() override;
         void resetState() override;
 
-        const json& getValue() override;
+        const std::vector<double>& getValue() override;
+        std::vector<double>& setValue() override;
+        state setValue(const std::vector<double>& val) override;
+        bool isOptimizable() override;
+        void setOptimizability(bool state) override;
+
+        const limits& getLimits() override;
+        limits& setLimits() override;
+
         std::shared_ptr<IOutput> getConnection() override;
-        json& setDefaultValue() override;
-        bool verify(const json & data) override;
+        
+        //bool verify(const json & data) override;
         int addConnection(std::shared_ptr<IOutput> output) override;
         int removeConnection(std::shared_ptr<IOutput> output) override;
         bool connect(std::shared_ptr<IOutput> output) override;

+ 7 - 7
lib/include/ModuleBase.h

@@ -9,19 +9,17 @@ namespace mdd {
 
 class ModuleBase : public  IModule{
     private:
-        std::string _prefix;
-        std::string _type;
-        int _appendix;
+        std::string _prefix = "";
+        std::string _type = "";
+        int _appendix = 0;
         std::vector<std::shared_ptr<Input>> _inputs;
         std::vector<std::shared_ptr<Output>> _outputs;
 
     protected:
         std::shared_ptr<IOutput> getOutput(int handle);
         std::shared_ptr<IInput> getInput(int handle);
-        int addInput(const std::string& type, const json& value,
-                         const std::function<bool(const json&)>& verification = [](
-                                 const json&) { return true; });
-        int addOutput(const std::string& type, const json& initial);
+        int addInput(const std::string& type, const std::vector<double>& value);
+        int addOutput(const std::string& type, const std::vector<double>& initial);
 
         int pop_backInput();
         int pop_backOutput();
@@ -41,6 +39,8 @@ class ModuleBase : public  IModule{
         std::vector<state> getOutputStates() override;
         std::vector<std::shared_ptr<IOutput>> getInputConnections() override;
         std::vector <std::vector <std::shared_ptr<IInput>>> getOutputConnections() override;
+        std::vector <std::shared_ptr<IInput>> getOptimizableInputs() override;
+        std::vector <std::shared_ptr<IOutput>> getOptimizableOutputs() override;
         std::shared_ptr<IOutput> getOutput(std::string output_id) override;
         std::shared_ptr<IInput> getInput(std::string input_id) override;
         std::string setType(std::string type) override;

+ 8 - 2
lib/include/ModuleHTTP.h

@@ -3,7 +3,13 @@
 
 #include "ModuleBase.h"
 #include <httplib.h>
-#include <boost/process.hpp>
+#include <memory>
+
+namespace boost {
+    namespace process{
+        class child;
+    }
+};
 using namespace boost::process;
 
 
@@ -15,7 +21,7 @@ namespace mdd{
         std::string _fname;
         std::string _id;
         int _port;
-        child _child;
+        std::unique_ptr<child> _child;
 
     protected:
         bool connect();

+ 10 - 10
lib/include/ModuleMath.h

@@ -20,16 +20,16 @@ namespace mdd {
     private:
         MathOperation _operation;
 
-        static json add(const json &val1, const json &val2);
-        static json subtract(const json &val1, const json &val2);
-        static json multiply(const json &val1, const json &val2);
-        static json divide(const json &val1, const json &val2);
-        static json power(const json &val1, const json &val2);
-        static json logarithm(const json &val1, const json &val2);
-        static json minimum(const json &val1, const json &val2);
-        static json maximum(const json &val1, const json &val2);
-        static json less(const json &val1, const json &val2);
-        static json greater(const json &val1, const json &val2);
+        static std::vector<double> add(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> subtract(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> multiply(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> divide(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> power(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> logarithm(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> minimum(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> maximum(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> less(const std::vector<double>&val1, const std::vector<double>&val2);
+        static std::vector<double> greater(const std::vector<double>&val1, const std::vector<double>&val2);
 
     public:
         explicit ModuleMath(MathOperation operation = MathOperation::ADD);

+ 3 - 8
lib/include/OptimizerBase.h

@@ -13,7 +13,6 @@ namespace mdd {
 	protected:
 		std::shared_ptr<IModule> _module;
 		std::vector<std::shared_ptr<IInput>> _inputs;
-		std::vector<json> _input_limits;
 		std::vector<std::shared_ptr<IOutput>> _outputs;
 		std::vector<double> _output_vals;
 		exprtk::expression<double> _func_expr;
@@ -22,14 +21,10 @@ namespace mdd {
 			state module_state = state::STATE_ERROR;
 			double opt_value = 0;
 		};
-		opt_state updateReader();
-
+		opt_state updateOutputs();
+		
 	public:
-		bool addModifier(std::string input_id, const json& limit) override;
-		bool addReader(std::string output_id) override;
-		bool changeModifier(std::string input_id, const json& limit) override;
-		void removeModifier(std::string input_id) override;
-		void removeReader(std::string output_id) override;
+		void updateLayout();
 		bool setEvaluation(std::string func) override;
 		//state update() override;
 	};

+ 3 - 3
lib/include/OptimizerEvolutionary.h

@@ -13,7 +13,7 @@ namespace mdd {
 
 		struct Individual {
 		public:
-			json dna;
+			std::vector<std::vector<double>> dna;
 			double fitness = 0;
 			bool operator== (const Individual& ind) {
 				return (dna == ind.dna) && (fitness == ind.fitness);
@@ -32,7 +32,7 @@ namespace mdd {
 
 		void evolve(std::vector<Individual> parents);
 		void evaluate(size_t ignore_len = 0);
-		json mutateGene(json limit, json seed = json());
+		std::vector<double> mutateGene(std::shared_ptr<IInput> input, std::vector<double> seed = std::vector<double>());
 
 	public:
 		OptimizerEvolutionary(std::shared_ptr<IModule> module,
@@ -40,7 +40,7 @@ namespace mdd {
 			size_t grow_generation = 20,
 			double max_fitness = 0.0,
 			int min_generations = -1);
-		json update() override;
+		std::vector<std::vector<double>> update() override;
 	};
 }
 #endif

+ 8 - 4
lib/include/Output.h

@@ -8,18 +8,22 @@ namespace mdd {
     class Output : public IOutput{
     private:
         state _state;
-        json _value;
+        std::vector<double> _value;
         std::string _prefix;
         std::string _type;
         int _appendix;
         std::vector<std::shared_ptr<IInput>> _connections;
+        bool _optimizable;
 
     protected:
 
     public:
-        Output(const std::string& type, int appendix, const json& initial);
-        const json& getValue() override;
-        json& getValueInternal() override;
+        Output(const std::string& type, int appendix, const std::vector<double>& initial);
+        const std::vector<double>& getValue() override;
+        std::vector<double>& setValue() override;
+        state setValue(const std::vector<double>& val) override;
+        bool isOptimizable();
+        void setOptimizability(bool state);
         state getState() override;
         void resetState() override;
         std::string setType(std::string type) override;

+ 5 - 4
lib/include/ProcessorBase.h

@@ -33,10 +33,8 @@ namespace mdd {
         std::vector<std::shared_ptr<IModule>> _modules;
 
     protected:
-        int addProcesorInput(const std::string& type, const json& value,
-        const std::function<bool(const json&)>& verification = [](
-                const json&) { return true; });
-        int addProcessorOutput(const std::string& type, const json& initial);
+        int addProcesorInput(const std::string& type, const std::vector<double>& value);
+        int addProcessorOutput(const std::string& type, const std::vector<double>& initial);
         std::shared_ptr<IOutput> getProcessorOutput(int handle);
         std::shared_ptr<IInput> getProcessorInput(int handle);
         std::shared_ptr<IModule> getModule(int handle);
@@ -70,6 +68,9 @@ namespace mdd {
         std::vector<std::shared_ptr<IOutput>> getInputConnections() override;
         std::vector <std::vector <std::shared_ptr<IInput>>> getOutputConnections() override;
 
+        std::vector <std::shared_ptr<IInput>> getOptimizableInputs() override;
+        std::vector <std::shared_ptr<IOutput>> getOptimizableOutputs() override;
+
         std::shared_ptr<IOutput> getOutput(std::string output_id) override;
         std::shared_ptr<IInput> getInput(std::string input_id) override;
         std::shared_ptr<IModule> getModule(std::string module_id) override;

+ 33 - 13
lib/src/Input.cpp

@@ -11,13 +11,13 @@ namespace mdd{
         _output = nullptr;
         return 0;
     }
-    Input::Input(const std::string& type, int appendix, const json& default_value,
-                 const std::function<bool(const json&)>& verification) {
+    Input::Input(const std::string& type, int appendix, const std::vector<double>& default_value) {
         _type = type;
         _value = default_value;
-        _verification = std::move(verification);
         _prefix = "";
         _appendix = appendix;
+        _optimizable = false;
+
     }
 
     std::string Input::setType(std::string type){
@@ -54,7 +54,7 @@ namespace mdd{
 
     }
 
-    const json& Input::getValue() {
+    const std::vector<double>& Input::getValue() {
         if(_output == nullptr){
             return _value;
         } else{
@@ -64,20 +64,40 @@ namespace mdd{
 
     std::shared_ptr<IOutput> Input::getConnection() { return _output; }
 
-    json& Input::setDefaultValue(){
+    std::vector<double>& Input::setValue(){
         return _value;
     }
 
-    bool Input::verify(const json & data){
-        return _verification(data);
+    state Input::setValue(const std::vector<double>& val) {
+        if (val != _value)
+        {
+            _value = val;
+            return state::CHANGED;
+        }
+        else {
+            return state::UNCHANGED;
+        }
     }
 
     bool Input::connect(std::shared_ptr<IOutput> output){
-        if (verify(output->getValue())) {
-            _output = output;
-            _output->addConnection(std::make_shared<Input>((*this)));
-            return true;
-        }
-        return false;
+        _output = output;
+        _output->addConnection(std::make_shared<Input>((*this)));
+        return true;
+    }
+
+    bool Input::isOptimizable() {
+        return _optimizable;
+    }
+
+    void Input::setOptimizability(bool state) {
+        _optimizable = state;
+    }
+    const limits& Input::getLimits()
+    {
+        return _limit;
+    }
+    limits& Input::setLimits()
+    {
+        return _limit;
     }
 }

+ 29 - 4
lib/src/ModuleBase.cpp

@@ -69,9 +69,8 @@ namespace mdd {
         return ret;
     }
 
-    int ModuleBase::addInput(const std::string& type , const json& value,
-                             const std::function<bool(const json&)>& verification) {
-        _inputs.emplace_back(std::make_shared<Input>(type, _inputs.size(), value, verification));
+    int ModuleBase::addInput(const std::string& type , const std::vector<double>& value) {
+        _inputs.emplace_back(std::make_shared<Input>(type, _inputs.size(), value));
         _inputs.back()->setPrefix(getID());
         return _inputs.size() - 1;
     }
@@ -86,6 +85,32 @@ namespace mdd {
         return ret;
     }
 
+    std::vector<std::shared_ptr<IInput>> ModuleBase::getOptimizableInputs()
+    {
+        std::vector<std::shared_ptr<IInput>> ret;
+        for (auto& it = _inputs.begin(); it != _inputs.end();  ++it)
+        {
+            if ((*it)->isOptimizable())
+            {
+                ret.push_back((*it));
+            }
+        }
+        return ret;
+    }
+
+    std::vector<std::shared_ptr<IOutput>> ModuleBase::getOptimizableOutputs()
+    {
+        std::vector<std::shared_ptr<IOutput>> ret;
+        for (auto& it = _outputs.begin(); it != _outputs.end(); ++it)
+        {
+            if ((*it)->isOptimizable())
+            {
+                ret.push_back((*it));
+            }
+        }
+        return ret;
+    }
+
     std::shared_ptr<IOutput> ModuleBase::getOutput(std::string output_id) {
         for(auto& output : _outputs){
                 if (output->getID() == output_id) {
@@ -112,7 +137,7 @@ namespace mdd {
         return _inputs[handle];
     }
 
-    int ModuleBase::addOutput(const std::string& type, const json& initial) {
+    int ModuleBase::addOutput(const std::string& type, const std::vector<double>& initial) {
         _outputs.push_back(std::make_shared<Output>( type, _outputs.size(), initial));
         _outputs.back()->setPrefix(getID());
         return  _outputs.size()-1;

+ 34 - 14
lib/src/ModuleHTTP.cpp

@@ -2,6 +2,8 @@
 #include <httplib.h>
 #include <iostream>
 #include <thread>
+#include <boost/process.hpp>
+#include <filesystem>
 
 //#include <wait.h>
 
@@ -68,12 +70,17 @@ namespace mdd{
         for(size_t i=0; i < getInputs().size(); i++){
             getInput(i)->setType(inputs[i]["type"].get<std::string>());
             getInput(i)->setAppendix(i);
-            getInput(i)->setDefaultValue() = inputs[i];
+            getInput(i)->setValue() = inputs[i]["value"].get<std::vector<double>>();
         }
         for(int index = getInputs().size(); index < inputs.size(); ++index){
-            json val;
-            val["value"] = inputs[index]["value"];
-            addInput(inputs[index]["type"].get<std::string>(),val);
+            if (inputs[index]["value"].is_array())
+            {
+                addInput(inputs[index]["type"].get<std::string>(), inputs[index]["value"].get<std::vector<double>>());
+            }
+            else {
+                addInput(inputs[index]["type"].get<std::string>(), { inputs[index]["value"].get<double>() });
+                std::cout << "Warning: Server expects single values, but mdd work with arrays!" << std::endl;
+            }
         }
         return state::UNCHANGED;
     }
@@ -100,15 +107,20 @@ namespace mdd{
             //getOutput(i)->setType(outputs[i]["type"].get<std::string>());
             //getOutput(i)->setAppendix(i);
             getOutput(i)->resetState();
-            if (outputs[i].dump() != getOutput(i)->getValue().dump()) {
-                getOutput(i)->getValueInternal() = outputs[i];
+            if (outputs[i]["value"].get<std::vector<double>>() != getOutput(i)->getValue()) {
+                getOutput(i)->setValue() = outputs[i]["value"].get<std::vector<double>>();
                 output_state = getOutput(i)->getState();
             }
         }
         for(int index = getOutputs().size(); index < outputs.size(); ++index){
-            json val;
-            val["value"] = outputs[index]["value"];
-            addOutput(outputs[index]["type"].get<std::string>(),val);
+            if (outputs[index]["value"].is_array()) {
+                addOutput(outputs[index]["type"].get<std::string>(), outputs[index]["value"].get<std::vector<double>>());
+            }
+            else
+            {
+                addOutput(outputs[index]["type"].get<std::string>(), { outputs[index]["value"].get<double>() });
+                std::cout << "Warning: Server delivers single values, but mdd work with arrays!" << std::endl;
+            }
             output_state = state::CHANGED;
         }
         return output_state;
@@ -127,7 +139,11 @@ namespace mdd{
         setType("HTTP");
 
         if(!fname.empty()){
-            _child = child("python3 " + fname + " " + std::to_string(port));
+            if (std::filesystem::exists(fname))
+            {
+                *_child = child("python3 " + fname + " " + std::to_string(port));
+            }
+            std::cout << "ERROR Couldnt find: " << fname << std::endl;
         }
         while(!connect()){
             std::this_thread::sleep_for(std::chrono::microseconds(500));
@@ -137,16 +153,20 @@ namespace mdd{
 
     ModuleHTTP::~ModuleHTTP()
     {
-        _child.terminate();
-        _child.join();
-        
+        if (_child != nullptr)
+        {
+            _child->terminate();
+            _child->join();
+        }
     }
 
     state ModuleHTTP::update() {
         Client cli(_id, _port);
         json new_inputs;
         for (int i = 0; i < getInputs().size(); ++i) {
-            new_inputs.push_back(getInput(i)->getValue());
+            json input;
+            input["value"] = getInput(i)->getValue();
+            new_inputs.push_back(input);
         }
         std::string content = new_inputs.dump();
         auto res = cli.Post("/update",content.size(),

+ 121 - 554
lib/src/ModuleMath.cpp

@@ -5,663 +5,230 @@
 namespace mdd {
     ModuleMath::ModuleMath(MathOperation operation) {
         _operation = operation;
-        json default_val;
-        default_val["value"] = { 1 };
+        std::vector<double> default_val = {1};
         addInput("Value", default_val);
         addInput("Value", default_val);
         addOutput("Value", default_val);
         setType("Math");
     }
 
-    json ModuleMath::add(const json &val1, const json &val2) {
-        json ret; //= json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(add(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(add(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(add(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(add(val1[i],val2));
-                }
+    std::vector<double> ModuleMath::add(const std::vector<double>&val1, const std::vector<double>&val2) {
+        std::vector<double> ret; //= json::array();
+        size_t length= std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] + val2[i]);
             }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(add(val1,val2[i]));
-                }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<double>() + val2.get<double>();
-                        } else {
-                            ret = val1.get<float>() + val2.get<int>();
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<int>() + val2.get<double>();
-                        } else {
-                            ret = val1.get<int>() + val2.get<int>();
-                        }
-                    }
-
-                } else {
-
-                }
-
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] + val2[i]);
+            }
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] + val2[0]);
             }
         }
         return ret;
     }
 
-    json ModuleMath::subtract(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(subtract(val1[i],val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(subtract(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(subtract(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(subtract(val1[i],val2));
-                }
+    std::vector<double> ModuleMath::subtract(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] - val2[i]);
             }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(subtract(val1,val2[i]));
-                }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<double>() - val2.get<double>();
-                        } else {
-                            ret = val1.get<double>() - val2.get<int>();
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<int>() - val2.get<double>();
-                        } else {
-                            ret = val1.get<int>() - val2.get<int>();
-                        }
-                    }
-
-                } else {
-
-                }
-
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] - val2[i]);
+            }
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] - val2[0]);
             }
         }
         return ret;
     }
 
-    json ModuleMath::multiply(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(multiply(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(multiply(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(multiply(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(multiply(val1[i],val2));
-                }
+    std::vector<double> ModuleMath::multiply(const std::vector<double>&val1, const std::vector<double> &val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] * val2[i]);
             }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(multiply(val1,val2[i]));
-                }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<double>() * val2.get<double>();
-                        } else {
-                            ret = val1.get<double>() * val2.get<int>();
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<int>() * val2.get<float>();
-                        } else {
-                            ret = val1.get<int>() * val2.get<int>();
-                        }
-                    }
-
-                } else {
-
-                }
-
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] * val2[i]);
+            }
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] * val2[0]);
             }
         }
         return ret;
     }
 
-    json ModuleMath::divide(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(divide(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(divide(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(divide(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(divide(val1[i],val2));
-                }
+    std::vector<double> ModuleMath::divide(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] / val2[i]);
             }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(divide(val1,val2[i]));
-                }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<double>() / val2.get<double>();
-                        } else {
-                            ret = val1.get<double>() / val2.get<int>();
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            ret = val1.get<int>() / val2.get<double>();
-                        } else {
-                            ret = val1.get<int>()*1.0 / val2.get<int>();
-                        }
-                    }
-
-                } else {
-
-                }
-
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] / val2[i]);
+            }
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] / val2[0]);
             }
         }
         return ret;
     }
 
-    json ModuleMath::power(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(power(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(power(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(power(val1[i], val2[1]));
-                    }
-                }
-                else {
-                    ret.push_back(power(val1[i], val2));
-                }
+    std::vector<double> ModuleMath::power(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(pow(val1[i] , val2[i]));
             }
-
-        }
-        else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(power(val1, val2[i]));
-                }
+            else if (1 == val1.size()) {
+                ret.push_back(pow(val1[0] , val2[i]));
             }
-            else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = pow(val1.get<double>(), val2.get<double>());
-                        }
-                        else {
-                            ret = pow(val1.get<double>(), val2.get<int>());
-                        }
-                    }
-                    else {
-                        if (val2.is_number_float()) {
-                            ret = pow(val1.get<int>(), val2.get<double>());
-                        }
-                        else {
-                            ret = pow(val1.get<int>(), val2.get<int>());
-                        }
-                    }
-
-                }
-                else {
-
-                }
-
+            else if (1 == val2.size()) {
+                ret.push_back(pow(val1[i] , val2[0]));
             }
         }
         return ret;
     }
 
-    json ModuleMath::logarithm(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(logarithm(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(logarithm(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(logarithm(val1[i], val2[1]));
-                    }
-                }
-                else {
-                    ret.push_back(logarithm(val1[i], val2));
-                }
+    std::vector<double> ModuleMath::logarithm(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                
+                ret.push_back(log(val2[i]) / log(val1[i]));
             }
-
-        }
-        else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(logarithm(val1, val2[i]));
-                }
+            else if (1 == val1.size()) {
+                ret.push_back(log(val2[i]) / log(val1[0]));
             }
-            else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            ret = log(val2.get<double>())/log(val2.get<double>());
-                        }
-                        else {
-                            ret = log(val2.get<int>()) / log(val1.get<double>());
-                        }
-                    }
-                    else {
-                        if (val2.is_number_float()) {
-                            ret = log(val2.get<double>()) / log(val1.get<int>());
-                        }
-                        else {
-                            ret = log(val2.get<int>()) / log(val1.get<int>());
-                        }
-                    }
-
-                }
-                else {
-
-                }
-
+            else if (1 == val2.size()) {
+                ret.push_back(log(val2[0]) / log(val1[i]));
             }
         }
         return ret;
     }
 
-    json ModuleMath::minimum(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(minimum(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(minimum(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(minimum(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(minimum(val1[i],val2));
+    std::vector<double> ModuleMath::minimum(const std::vector<double>&val1, const std::vector<double>&val2){
+            std::vector<double> ret; //= json::array();
+            size_t length = std::max(val1.size(), val2.size());
+            for (int i = 0; i < length; i++) {
+                if (val1.size() == val2.size()) {
+                    ret.push_back(std::min(val1[i], val2[i]));
                 }
-            }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(minimum(val1,val2[i]));
+                else if (1 == val1.size()) {
+                    ret.push_back(std::min(val1[0], val2[i]));
                 }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            if(val1.get<double>()<= val2.get<double>()){
-                                ret = val1.get<double>();
-                            } else{
-                                ret = val2.get<double>();
-                            }
-                        } else {
-                            if(val1.get<double>()<= val2.get<int>()*1.0){
-                                ret = val1.get<double>();
-                            } else{
-                                ret = val2.get<int>();
-                            }
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            if(val1.get<int>()*1.0 <= val2.get<double>()){
-                                ret = val1.get<int>();
-                            } else{
-                                ret = val2.get<double>();
-                            }
-                        } else {
-                            if(val1.get<int>()<= val2.get<int>()){
-                                ret = val1.get<int>();
-                            } else{
-                                ret = val2.get<int>();
-                            }
-                        }
-                    }
-
-                } else {
-
+                else if (1 == val2.size()) {
+                    ret.push_back(std::min(val1[i], val2[0]));
                 }
-
             }
-        }
-        return ret;
+            return ret;
     }
 
-    json ModuleMath::maximum(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(maximum(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(maximum(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(maximum(val1[i], val2[1]));
-                    }
-                } else {
-                    ret.push_back(maximum(val1[i],val2));
-                }
+    std::vector<double> ModuleMath::maximum(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(std::max(val1[i], val2[i]));
             }
-
-        } else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(maximum(val1,val2[i]));
-                }
-            } else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            if(val1.get<double>()>= val2.get<double>()){
-                                ret = val1.get<double>();
-                            } else{
-                                ret = val2.get<double>();
-                            }
-                        } else {
-                            if(val1.get<float>()>= val2.get<int>()*1.0){
-                                ret = val1.get<double>();
-                            } else{
-                                ret = val2.get<int>();
-                            }
-                        }
-                    } else {
-                        if (val2.is_number_float()) {
-                            if(val1.get<int>()*1.0 >= val2.get<double>()){
-                                ret = val1.get<int>();
-                            } else{
-                                ret = val2.get<double>();
-                            }
-                        } else {
-                            if(val1.get<int>()>= val2.get<int>()){
-                                ret = val1.get<int>();
-                            } else{
-                                ret = val2.get<int>();
-                            }
-                        }
-                    }
-
-                } else {
-
-                }
-
+            else if (1 == val1.size()) {
+                ret.push_back(std::max(val1[0], val2[i]));
+            }
+            else if (1 == val2.size()) {
+                ret.push_back(std::max(val1[i], val2[0]));
             }
         }
         return ret;
     }
 
-    json ModuleMath::less(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(less(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(less(val1[1], val2[i]));
-                    }
-                    if (1 == val2.size()) {
-                        ret.push_back(less(val1[i], val2[1]));
-                    }
-                }
-                else {
-                    ret.push_back(less(val1[i], val2));
-                }
+    std::vector<double> ModuleMath::less(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] > val2[i]);
             }
-
-        }
-        else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(less(val1, val2[i]));
-                }
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] > val2[i]);
             }
-            else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            if (val1.get<double>() < val2.get<double>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                        else {
-                            if (val1.get<float>() < val2.get<int>() * 1.0) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                    }
-                    else {
-                        if (val2.is_number_float()) {
-                            if (val1.get<int>() * 1.0 < val2.get<double>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                        else {
-                            if (val1.get<int>() < val2.get<int>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                    }
-
-                }
-                else {
-
-                }
-
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] > val2[0]);
             }
         }
         return ret;
     }
 
-    json ModuleMath::greater(const json &val1, const json &val2){
-        json ret = json::array();
-        if (val1.is_array()) {
-            size_t size = std::max(val1.size(), val2.size());
-            for (int i = 0; i < size; i++) {
-                if (val2.is_array()) {
-                    if (val1.size() == val2.size()) {
-                        ret.push_back(greater(val1[i], val2[i]));
-                    }
-                    else if (1 == val1.size()) {
-                        ret.push_back(greater(val1[1], val2[i]));
-                    }
-                    else if (1 == val2.size()) {
-                        ret.push_back(greater(val1[i], val2[1]));
-                    }
-                }
-                else {
-                    ret.push_back(greater(val1[i], val2));
-                }
+    std::vector<double> ModuleMath::greater(const std::vector<double>&val1, const std::vector<double>&val2){
+        std::vector<double> ret; //= json::array();
+        size_t length = std::max(val1.size(), val2.size());
+        for (int i = 0; i < length; i++) {
+            if (val1.size() == val2.size()) {
+                ret.push_back(val1[i] < val2[i]);
             }
-
-        }
-        else {
-            if (val2.is_array()) {
-                for (int i = 0; i < val2.size(); i++) {
-                    ret.push_back(greater(val1, val2[i]));
-                }
+            else if (1 == val1.size()) {
+                ret.push_back(val1[0] < val2[i]);
             }
-            else {
-                if (val1.is_number() && val2.is_number()) {
-                    if (val1.is_number_float()) {
-                        if (val2.is_number_float()) {
-                            if (val1.get<double>() > val2.get<double>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                        else {
-                            if (val1.get<float>() > val2.get<int>() * 1.0) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                    }
-                    else {
-                        if (val2.is_number_float()) {
-                            if (val1.get<int>() * 1.0 > val2.get<double>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                        else {
-                            if (val1.get<int>() > val2.get<int>()) {
-                                ret = 0;
-                            }
-                            else {
-                                ret = 1;
-                            }
-                        }
-                    }
-
-                }
-                else {
-
-                }
-
+            else if (1 == val2.size()) {
+                ret.push_back(val1[i] < val2[0]);
             }
         }
         return ret;
     }
 
     state ModuleMath::update() {
-        json ret = getOutput(0)->getValue()["value"];
+        std::vector<double> ret = getOutput(0)->getValue();
 
         switch (_operation) {
         case MathOperation::ADD:
-                ret = add(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = add(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::SUBTRACT:
-                ret = subtract(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = subtract(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::MULTIPLY:
-                ret = multiply(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = multiply(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::DIVIDE:
-                ret = divide(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = divide(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::POWER:
-                ret = power(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = power(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::LOGARITHM:
-                ret = logarithm(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = logarithm(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::MINIMUM:
-                ret = minimum(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = minimum(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::MAXIMUM:
-                ret = maximum(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = maximum(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::LESS_THAN:
-                ret = less(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = less(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
 
             case MathOperation::GREATER_THAN:
-                ret = greater(getInput(0)->getValue()["value"], getInput(1)->getValue()["value"]);
+                ret = greater(getInput(0)->getValue(), getInput(1)->getValue());
                 break;
         }
-        getOutput(0)->resetState();
-        if (ret.dump() != getOutput(0)->getValue()["value"].dump()) {
-            getOutput(0)->getValueInternal()["value"] = ret ;
-        }
-        return getOutput(0)->getState();
+        
+        return getOutput(0)->setValue(ret);
     }
 
 

+ 9 - 12
lib/src/ModuleMerge.cpp

@@ -3,17 +3,15 @@
 
 namespace mdd {
 	ModuleMerge::ModuleMerge() {
-		json default_val;
-		default_val["value"] = 1;
+		std::vector<double> default_val = { 1 };
 		addInput("Value", default_val);
 		addInput("Value", default_val);
 		addOutput("Value", default_val);
-		setType("Math");
+		setType("Merge");
 	}
 
 	int ModuleMerge::addModuleInput() {
-		json default_val;
-		default_val["value"] = 1;
+		std::vector<double> default_val = { 1 };
 		return addInput("Value", default_val);
 	}
 
@@ -31,17 +29,16 @@ namespace mdd {
 		return "";
 	}
 	state ModuleMerge::update() {
-		json ret;
+		std::vector<double>  ret;
 		for (size_t i = 0; i < getInputs().size(); i++)
 		{
 			std::string key = getInput(i)->getType();
 			boost::algorithm::to_lower(key);
-			ret.emplace(key, getInput(i)->getValue()["value"]);
-		}
-		getOutput(0)->resetState();
-		if (ret.dump() != getOutput(0)->getValue().dump()) {
-			getOutput(0)->getValueInternal() = ret;
+			for (size_t j = 0; j < getInput(i)->getValue().size(); j++)
+			{
+				ret.push_back(getInput(i)->getValue()[j]);
+			}
 		}
-		return getOutput(0)->getState();
+		return getOutput(0)->setValue(ret);
 	}
 }

+ 2 - 8
lib/src/ModuleParameter.cpp

@@ -2,19 +2,13 @@
 
 namespace mdd {
     ModuleParameter::ModuleParameter() {
-        json default_val;
-        default_val["value"] = 1;
+        std::vector<double> default_val = { 1 };
         addInput("Value", default_val);
         addOutput("Value", default_val);
         setType("Parameter");
     }
 
     state ModuleParameter::update() {
-        json ret = getInput(0)->getValue()["value"];
-        getOutput(0)->resetState();
-        if (ret.dump() != getOutput(0)->getValue()["value"].dump()) {
-            getOutput(0)->getValueInternal()["value"] = ret;
-        }
-        return getOutput(0)->getState();
+        return getOutput(0)->setValue(getInput(0)->getValue());
     }
 }

+ 6 - 14
lib/src/ModuleSQL.cpp

@@ -115,13 +115,10 @@ namespace mdd {
 		}
 		sqlite3_finalize(res);
 
-
-		json default_val;
-		default_val["value"] = { 1 };
-		addInput(_content[0].key, default_val);
+		addInput(_content[0].key, {0});
 		for (auto& cont :_content)
 		{
-			addOutput(cont.key, default_val);
+			addOutput(cont.key, {1});
 		}
 		setType("SQL");
 	}
@@ -134,7 +131,7 @@ namespace mdd {
 		/* Create SQL statement */
 		sql = "SELECT * "\
 			"FROM " + _tbname + " "\
-			"WHERE " + _content[0].key + " = " + getInput(0)->getValue()["value"].dump();
+			"WHERE " + _content[0].key + " = " + std::to_string(getInput(0)->getValue()[0]);
 
 		std::cout << sql << std::endl;
 
@@ -151,19 +148,14 @@ namespace mdd {
 
 		step = sqlite3_step(res);
 		state state = state::UNCHANGED;
-		json ret;
 		if (step == SQLITE_ROW) {
 			int nCol = sqlite3_column_count(res);
 			std::string parse_str = "{\"" + _tbname + "\" : {";
 			for (size_t i = 0; i < nCol; i++)
 			{
-				std::string val = (char*)sqlite3_column_text(res, i);
-				val = "[" + val + "]";
-				getOutput(i)->resetState();
-				if (getOutput(i)->getValue()["value"].dump() != val) {
-					getOutput(i)->getValueInternal()["value"] = val;
-					state = getOutput(i)->getState();
-				}
+				json val = (char*)sqlite3_column_text(res, i);
+				val = "[" + val.dump() + "]";
+				getOutput(i)->setValue(val.get<std::vector<double>>());
 			}
 		}
 		sqlite3_finalize(res);

+ 9 - 26
lib/src/ModuleSwitch.cpp

@@ -3,8 +3,7 @@
 
 namespace mdd{
     ModuleSwitch::ModuleSwitch(){
-        json default_val;
-        default_val["value"] = { 42 };
+        std::vector<double> default_val = { 42 };
         addInput("Switch", default_val);
         addInput("Value", default_val);
         addInput("Default", default_val);
@@ -12,20 +11,11 @@ namespace mdd{
         setType("Switch");
     }
     state ModuleSwitch::update(){
-        json ret;
-        size_t length = 1;
-        if (getInput(0)->getValue()["value"].is_array()) {
-            length = getInput(0)->getValue()["value"].size();
-        }
+        std::vector<double> ret;
+        size_t length = getInput(0)->getValue().size();
         for (size_t i = 0; i < length; i++)
         {
-            int index;
-            if (getInput(0)->getValue()["value"].is_array()) {
-                index = getInput(0)->getValue()["value"][i];
-            }
-            else {
-                index = getInput(0)->getValue()["value"].get<int>();
-            }
+            int index = (int)getInput(0)->getValue()[i];
            
             if (index == 0) {
                 index = 1;
@@ -34,20 +24,13 @@ namespace mdd{
             if (index > getInputs().size() - 1) {
                 index = getInputs().size() - 1;
             }
-
-            if (getInput(0)->getValue()["value"].is_array()) {
-                ret.push_back(getInput(index)->getValue()["value"]);
-            }
-            else {
-                ret = getInput(index)->getValue()["value"];
+            for (size_t j = 0; j < getInput(index)->getValue().size(); j++)
+            {
+                ret.push_back(getInput(index)->getValue()[j]);
             }
+            
         }
-        getOutput(0)->resetState();
-        if (ret.dump() != getOutput(0)->getValue()["value"].dump()) {
-            getOutput(0)->getValueInternal()["value"] = ret;
-        }
-        
-        return getOutput(0)->getState();
+        return getOutput(0)->setValue(ret);
 
     }
 }

+ 9 - 60
lib/src/OptimizerBase.cpp

@@ -2,7 +2,7 @@
 #include <iostream>
 
 namespace mdd{
-	OptimizerBase::opt_state OptimizerBase::updateReader()
+	OptimizerBase::opt_state OptimizerBase::updateOutputs()
 	{
 		opt_state ret;
 		ret.module_state = _module->update();
@@ -10,7 +10,7 @@ namespace mdd{
 		{
 			for (size_t i = 0; i < _output_vals.size(); ++i)
 			{
-				_output_vals[i] = _outputs[i]->getValue()["value"][0].get<double>();
+				_output_vals[i] = _outputs[i]->getValue()[0];
 				//std::cout << "get: " << i << ": " << _output_vals[i] << std::endl;
 			}
 			ret.opt_value = _func_expr.value();
@@ -20,71 +20,20 @@ namespace mdd{
 		return ret;
 	}
 
-	bool OptimizerBase::addModifier(std::string input_id, const json& limit)
+	void OptimizerBase::updateLayout()
 	{
-		if (_module != nullptr)
+		_inputs = _module->getOptimizableInputs();
+		_outputs = _module->getOptimizableOutputs();
+		_output_vals.clear();
+		for (auto& out : _outputs)
 		{
-			auto ptr = _module->getInput(input_id);
-			if (ptr != nullptr)
-			{
-				_inputs.push_back(ptr);
-				_input_limits.push_back(limit);
-				return true;
-			}
-		}
-		return false;
-	}
-
-	bool OptimizerBase::addReader(std::string output_id)
-	{	
-		if (_module != nullptr)
-		{
-			auto ptr = _module->getOutput(output_id);
-			if (ptr != nullptr)
-			{
-				_outputs.push_back(ptr);
-				_output_vals.push_back(ptr->getValue()["value"][0].get<double>());
-				return true;
-			}
-		}
-		return false;
-	}
-
-	bool OptimizerBase::changeModifier(std::string input_id, const json& limit)
-	{
-		for (size_t i = 0; i < _inputs.size(); i++)
-		{
-			if (_inputs[i]->getID() == input_id)
-			{
-				_input_limits[i] = limit;
-				return true;
-			}
-		}
-		return false;
-	}
-
-	void OptimizerBase::removeModifier(std::string input_id)
-	{
-		for (auto it = _inputs.begin(); it != _inputs.end(); ++it) {
-			if ((*it)->getID() == input_id)
-			{
-				_inputs.erase(it);
-			}
-		}
-	}
-	
-	void OptimizerBase::removeReader(std::string output_id)
-	{
-		for (auto it = _outputs.begin(); it != _outputs.end(); ++it) {
-			if ((*it)->getID() == output_id)
-			{
-				_outputs.erase(it);
-			}
+			_output_vals.push_back(out->getValue()[0]);
 		}
 	}
 	
 	bool OptimizerBase::setEvaluation(std::string func)
 	{
+		updateLayout();
 		exprtk::symbol_table<double> symbol_table;
 		for (size_t i = 0; i < _output_vals.size(); ++i)
 		{

+ 45 - 44
lib/src/OptimizerEvolutionary.cpp

@@ -10,9 +10,9 @@ namespace mdd {
 			for (size_t j = 0; j < _inputs.size(); j++)
 			{
 				//std::cout << "set: " << j << ": " << it->dna[j] << std::endl;
-				_inputs[j]->setDefaultValue() = it->dna[j];
+				_inputs[j]->setValue() = it->dna[j];
 			}
-			auto opt = updateReader();
+			auto opt = updateOutputs();
 			if (opt.module_state == state::STATE_ERROR) {
 				_children.erase(it);
 			}
@@ -38,14 +38,20 @@ namespace mdd {
 		_max_fitness = max_fitness;
 		_converges = converges;
 	}
-	json OptimizerEvolutionary::update()
+	std::vector<std::vector<double>> OptimizerEvolutionary::update()
 	{
 		int gen = -1;
 		bool check;
 		Individual old_best;
 		size_t same_counter = 0;
+		if (_inputs.size() == 0)
+		{
+			std::cout << "ERROR: No optimizable inputs detected!" << std::endl;
+			return std::vector<std::vector<double>>();
+		}
 		do
 		{
+			std::cout << _children.size() << " | " << gen << std::endl;
 			if (_children.empty())
 			{
 				for (size_t i = 0; i < _grow_generation*2; i++)
@@ -55,9 +61,15 @@ namespace mdd {
 				evaluate();
 			}
 			else {
-				evolve(_children);
+				if (gen != -1)
+				{
+					evolve(_children);
+				}
+				else {
+					evaluate();
+				}
 			}
-			//std::cout << _children.size() << " | " << gen << std::endl;
+			
 			++gen;
 			check = gen < _min_generations || _best.fitness > _max_fitness;
 			if (!check && _converges > 0)
@@ -80,90 +92,75 @@ namespace mdd {
 		
 		return _best.dna;
 	}
-	json OptimizerEvolutionary::mutateGene(json limit, json seed)
+	std::vector<double> OptimizerEvolutionary::mutateGene(std::shared_ptr<IInput> input, std::vector<double> seed)
 	{
-		/*
-			limit{
-				(("min": []
-				or
-				"max" : [])
-				("step": []
-				or
-				"rule" : string))
-				nor
-				"elements": [[],[],[]]
-		}
-			*/
-		json ret = seed;
-		
+	
+		limits limit = input->getLimits();
+		auto ret = seed;
 		
-		if (limit.contains("elements"))
+		if (!limit.elements.empty())
 		{
-			if (limit["elements"].is_array()) {
-				int i = (int)random_num(0, limit["elements"].size()-1);
-				ret["value"] = limit["elements"][i].is_array();
-			}
-			std::cout << "ERROR in GENE elements!" << std::endl;
+			int i = (int)random_num(0, limit.elements.size() - 1);
+			ret = limit.elements[i];
 			return ret;
 		}
-		if (limit.contains("min") && limit.contains("max")) {
+		if (!limit.min.empty() && !limit.max.empty()) {
 
 			bool check = true;
 			do {
 				if (!ret.empty())
 				{
-					int i = (int)random_num(0, limit["min"].size() - 1);
-					if (limit.contains("step")) {
+					int i = (int)random_num(0, limit.min.size() - 1);
+					if (!limit.step.empty()) {
 						//randomly generate step dx in [min, max]
 						/*std::cout << limit["min"][i].get<double>() << " | ";
 						std::cout << limit["max"][i].dump() << " | ";
 						std::cout << limit["step"][i].dump() << " | ";*/
-						ret["value"][i] = random_num(limit["min"][i].get<double>(), limit["max"][i].get<double>(), limit["step"][i].get<double>());
+						ret[i] = random_num(limit.min[i], limit.max[i], limit.step[i]);
 					}
 					else {
 						int m = (int)random_num(0, 1);
 						if (m == 0)
 						{
-							ret["value"][i] = limit["min"][i];
+							ret[i] = limit.min[i];
 						}
 						else {
-							ret["value"][i] = limit["max"][i];
+							ret[i] = limit.max[i];
 						}
 					}
 				}
 				else
 				{
-					for (size_t i = 0; i < limit["min"].size(); i++)
+					for (size_t i = 0; i < limit.min.size(); i++)
 					{
-						if (limit.contains("step")) {
+						if (!limit.step.empty()) {
 							//randomly generate step dx in [min, max]
-							ret["value"].push_back(random_num(limit["min"][i].get<double>(), limit["max"][i].get<double>(), limit["step"][i].get<double>()));
+							ret.push_back(random_num(limit.min[i], limit.max[i], limit.step[i]));
 						}
 						else {
 							int m = (int)random_num(0, 1);
 							if (m == 0)
 							{
-								ret["value"].push_back(limit["min"][i]);
+								ret.push_back(limit.min[i]);
 							}
 							else {
-								ret["value"].push_back(limit["max"][i]);
+								ret.push_back(limit.max[i]);
 							}
 						}
 					}
 				}
 				
-				if (limit.contains("rule")) {
+				if (!limit.rule.empty()) {
 					//use rule to check
 					exprtk::symbol_table<double> symbol_table;
-					auto vec_temp = ret["value"].get<std::vector<double>>();
 					
-					symbol_table.add_vector("val", vec_temp);
+					symbol_table.add_vector("val", ret);
 					symbol_table.add_constants();
 					exprtk::expression<double> func_expr;
 					func_expr.register_symbol_table(symbol_table);
 
 					exprtk::parser<double> parser;
-					parser.compile(limit["rule"], func_expr);
+					parser.compile(limit.rule, func_expr);
 					check = (bool)func_expr.value();
 				}
 			} while (!check);
@@ -171,7 +168,7 @@ namespace mdd {
 			
 		}
 		std::cout << "ERROR in GENE elements! (END)" << std::endl;
-		return json();//ERROR
+		return input->getValue();//ERROR
 	}
 
 	void OptimizerEvolutionary::evolve(std::vector<Individual> parents)
@@ -191,6 +188,10 @@ namespace mdd {
 		{
 			sum += max - parents[i].fitness;
 		}
+		if (sum == 0)
+		{
+			sum = 1.0;
+		}
 		//multiply fitter parents
 		std::vector<Individual> gen_pool = parents;
 		for (size_t i = 0; i < parents.size(); i++)
@@ -253,7 +254,7 @@ namespace mdd {
 			}
 			else
 			{
-				child.dna.push_back(mutateGene(_input_limits[i]));
+				child.dna.push_back(mutateGene(_inputs[i]));
 			}
 		}
 		return child;
@@ -263,7 +264,7 @@ namespace mdd {
 		Individual ret;
 		for (size_t i = 0; i < _inputs.size(); i++)
 		{
-			ret.dna.push_back(mutateGene(_input_limits[i]));
+			ret.dna.push_back(mutateGene(_inputs[i]));
 		}
 		return ret;
 	}

+ 23 - 9
lib/src/Output.cpp

@@ -15,7 +15,7 @@ namespace mdd {
         }
         return _connections.size();
     }
-    Output::Output( const std::string& type, int appendix, const json& initial) :
+    Output::Output( const std::string& type, int appendix, const std::vector<double>& initial) :
             _state(state::UNCHANGED)
     {
         _appendix = appendix;
@@ -24,13 +24,30 @@ namespace mdd {
         _value = initial;
     }
 
-    const json& Output::getValue() { return _value; }
+    const std::vector<double>& Output::getValue() { return _value; }
 
-    json& Output::getValueInternal() {
+    std::vector<double>& Output::setValue() {
         _state = state::CHANGED;
         return _value;
     }
+    state Output::setValue(const std::vector<double>& val) {
+        if (val != _value)
+        {
+            _value = val;
+            _state = state::CHANGED;
+        }
+        else {
+            _state = state::UNCHANGED;
+        }
+        return _state;
+    }
+    bool Output::isOptimizable() {
+        return _optimizable;
+    }
 
+    void Output::setOptimizability(bool state) {
+        _optimizable = state;
+    }
     std::string Output::getType() { return _type; }
 
     state Output::getState() { return _state; } 
@@ -57,12 +74,9 @@ namespace mdd {
     }
     bool Output::connect(std::shared_ptr<IInput> input)
     {
-        if (input->verify(getValue())) {
-            addConnection(input);
-            input->addConnection(std::make_shared<Output>((*this)));
-            return true;
-        }
-        return false;
+        addConnection(input);
+        input->addConnection(std::make_shared<Output>((*this)));
+        return true;
     }
     std::vector<std::shared_ptr<IInput>> Output::getConnections()
     {

+ 42 - 4
lib/src/ProcessorBase.cpp

@@ -4,14 +4,13 @@
 
 namespace mdd{
 
-    int ProcessorBase::addProcesorInput(const std::string &type, const json &value,
-                                        const std::function<bool(const json &)> &verification){
-        _processor_inputs.push_back(std::make_shared<Input>( type, _processor_inputs.size(), value, verification));
+    int ProcessorBase::addProcesorInput(const std::string &type, const std::vector<double>&value){
+        _processor_inputs.push_back(std::make_shared<Input>( type, _processor_inputs.size(), value));
         _processor_inputs[_processor_inputs.size() - 1]->setPrefix(getID());
         return  _processor_inputs.size()-1;
     }
 
-    int ProcessorBase::addProcessorOutput(const std::string& type, const json& initial){
+    int ProcessorBase::addProcessorOutput(const std::string& type, const std::vector<double>& initial){
         _processor_outputs.push_back(std::make_shared<Output>( type, _processor_outputs.size(), initial));
         _processor_outputs[_processor_outputs.size() - 1]->setPrefix(getID());
         return  _processor_outputs.size()-1;
@@ -236,6 +235,45 @@ namespace mdd{
         return ret;
     }
 
+    std::vector <std::shared_ptr<IInput>> ProcessorBase::getOptimizableInputs() 
+    {
+        std::vector<std::shared_ptr<IInput>> ret;
+        for (auto& input : _processor_inputs) {
+            if (input->isOptimizable())
+            {
+                ret.push_back(input);
+            }
+        }
+        for (auto& input : _module_inputs) {
+            auto in = input.moduleHandler->getOptimizableInputs();
+            for (size_t i = 0; i < in.size(); i++)
+            {
+                ret.push_back(in[i]);
+            }
+        }
+        return ret;
+    }
+
+    std::vector <std::shared_ptr<IOutput>> ProcessorBase::getOptimizableOutputs()
+    {
+        std::vector<std::shared_ptr<IOutput>> ret;
+        for (auto& output : _processor_outputs) {
+            if (output->isOptimizable())
+            {
+                ret.push_back(output);
+            }
+        }
+        for (auto& output : _module_outputs) {
+            auto out = output.moduleHandler->getOptimizableOutputs();
+            for (size_t i = 0; i < out.size(); i++)
+            {
+                ret.push_back(out[i]);
+            }
+        }
+        
+        return ret;
+    }
+
     std::shared_ptr<IOutput> ProcessorBase::getOutput(std::string output_id){
         for (auto& output : _processor_outputs) {
             if(output->getID() == output_id){

+ 5 - 3
lib/src/ProcessorStandard.cpp

@@ -6,7 +6,8 @@ namespace mdd {
         priorityEvaluation(priorityEvaluation),
         maxIterations(maxIterations)
     {
-        addProcessorOutput("Iterator", "{ \"value\": 0 }"_json);
+        setType("StandardProcessor");
+        addProcessorOutput("Iterator", {0});
     }
 
     std::string ProcessorStandard::addModule(std::shared_ptr<IModule> module)
@@ -77,7 +78,8 @@ namespace mdd {
         state group_state = state::CHANGED;
         size_t restart = 0;
         while (group_state == state::CHANGED) {
-            getProcessorOutput(0)->getValueInternal()["value"] = getProcessorOutput(0)->getValue()["value"].get<int>() + 1;
+            getProcessorOutput(0)->setValue()[0] += 1;
+            getProcessorOutput(0)->resetState();
             group_state = state::UNCHANGED;
             for (int i = restart; i < _priority_list.size(); ++i) {
                 auto t_start = Time::now();
@@ -130,7 +132,7 @@ namespace mdd {
                     }
                 }
             }
-            if (maxIterations != -1 && getProcessorOutput(0)->getValueInternal()["value"].get<int>() >= maxIterations)
+            if (maxIterations != -1 && getProcessorOutput(0)->getValue()[0] >= maxIterations)
             {
                 return state::STATE_ERROR;
             }

+ 2 - 1
lib/test/CMakeLists.txt

@@ -1,5 +1,6 @@
 add_executable(auslegung_test
-        test_ModuleHTTP
+	test_Ansys.cpp
+        test_ModuleHTTP.cpp
         test_ModuleMath.cpp
         test_ModuleSQL.cpp
         test_ModuleSwitch.cpp

+ 8 - 8
lib/test/server/server.py

@@ -17,17 +17,17 @@ from ini_logger import *
 #ini_logger(log_dir)
 
 inputs = [
-    {'type': "INPUT", 'value': 0},
-    {'type': "INPUT", 'value': 1},
-    {'type': "INPUT", 'value': 2},
-    {'type': "INPUT", 'value': 3},
-    {'type': "INPUT", 'value': 4}
+    {'type': "INPUT", 'value': [0]},
+    {'type': "INPUT", 'value': [1]},
+    {'type': "INPUT", 'value': [2]},
+    {'type': "INPUT", 'value': [3]},
+    {'type': "INPUT", 'value': [4]}
 ]
 
 outputs = [
-    {'type': "OUTPUT", 'value': 0},
-    {'type': "OUTPUT", 'value': 2},
-    {'type': "OUTPUT", 'value': 4}
+    {'type': "OUTPUT", 'value': [0]},
+    {'type': "OUTPUT", 'value': [2]},
+    {'type': "OUTPUT", 'value': [4]}
 ]
 
 def update():

+ 31 - 0
lib/test/test_Ansys.cpp

@@ -0,0 +1,31 @@
+#include <gtest/gtest.h>
+#include <json.hpp>
+#include <httplib.h>
+//#define private public
+#include <ProcessorStandard.h>
+#include <ModuleHTTP.h>
+#include <ModuleMath.h>
+#include <ModuleSwitch.h>
+#include <math.h>
+#include <thread>
+
+/*
+TEST(ModuleHTTP, test_ansys_server) {
+    ModuleHTTP module("../../../lib/test/server/server-ansys.py", "localhost", 8888);
+
+    auto inputs_types = module.getInputs();
+    auto inputs_ids = module.getInputIDs();
+    EXPECT_EQ(inputs_types[0], "Materials");
+    EXPECT_EQ(inputs_types[1], "Angles");
+
+    module.update();
+
+    auto outputs_types = module.getOutputs();
+    auto outputs_ids = module.getOutputIDs();
+    for (int i = 0; i < outputs_ids.size(); ++i) {
+        std::cout << module.getOutput(outputs_ids[i])->getValue()["value"].dump() << std::endl;;
+    }
+    Client cli("localhost", 8888);
+    cli.Get("/stop");
+}
+*/

+ 21 - 41
lib/test/test_ModuleHTTP.cpp

@@ -22,14 +22,14 @@ void serverThread()
     for (int i = 0; i < 5; ++i) {
         json entity;
         entity["type"] = "INPUT";
-        entity["value"] = i;
+        entity["value"] = { i };
         input.push_back(entity);
     }
 
     for (int i = 0; i < 3; ++i) {
         json entity;
         entity["type"] = "OUTPUT";
-        entity["value"] = i*2;
+        entity["value"] = { i * 2 };
         output.push_back(entity);
     }
 
@@ -66,12 +66,12 @@ void serverThread()
                 for (int i = 0; i < inputs.size(); ++i) {
                     input[i]["value"] = inputs[i]["value"];
                 }
-                output[0]["value"] = input[0]["value"].get<int>() + input[1]["value"].get<int>();
-                output[1]["value"] = input[2]["value"].get<int>() * input[2]["value"].get<int>();
-                output[2]["value"] = input[3]["value"].get<int>() - input[4]["value"].get<int>();
-                std::cout << output[0].dump() << std::endl;
-                std::cout << output[1].dump() << std::endl;
-                std::cout << output[2].dump() << std::endl;
+                output[0]["value"][0] = input[0]["value"][0].get<int>() + input[1]["value"][0].get<int>();
+                output[1]["value"][0] = input[2]["value"][0].get<int>() * input[2]["value"][0].get<int>();
+                output[2]["value"][0] = input[3]["value"][0].get<int>() - input[4]["value"][0].get<int>();
+                //std::cout << output[0].dump() << std::endl;
+                //std::cout << output[1].dump() << std::endl;
+                //std::cout << output[2].dump() << std::endl;
                 res.set_content(output.dump(), "application/json");
                 status = "ready";
              }
@@ -97,14 +97,14 @@ TEST(ModuleHTTP, updateLayout_intern){
     auto inputs_ids = module.getInputIDs();
     for (int i = 0; i < 5; ++i) {
         EXPECT_EQ(inputs_types[i], "INPUT");
-        EXPECT_EQ(module.getInput(inputs_ids[i])->getValue()["value"].get<int>(), i);
+        EXPECT_EQ((int)module.getInput(inputs_ids[i])->getValue()[0], i);
     }
 
     auto outputs_types = module.getOutputs();
     auto outputs_ids = module.getOutputIDs();
     for (int i = 0; i < 3; ++i) {
         EXPECT_EQ(outputs_types[i], "OUTPUT");
-        EXPECT_EQ(module.getOutput(outputs_ids[i])->getValue()["value"].get<int>(), i * 2);
+        EXPECT_EQ((int)module.getOutput(outputs_ids[i])->getValue()[0], i * 2);
     }
 }
 
@@ -115,14 +115,14 @@ TEST(ModuleHTTP, updateLayout_extern){
     auto inputs_ids = module.getInputIDs();
     for(int i = 0; i < 5; ++i){
         EXPECT_EQ(inputs_types[i], "INPUT");
-        EXPECT_EQ(module.getInput(inputs_ids[i])->getValue()["value"].get<int>(), i);
+        EXPECT_EQ((int)module.getInput(inputs_ids[i])->getValue()[0], i);
     }
 
     auto outputs_types = module.getOutputs();
     auto outputs_ids = module.getOutputIDs();
     for(int i = 0; i < 3; ++i){
         EXPECT_EQ(outputs_types[i], "OUTPUT");
-        EXPECT_EQ(module.getOutput(outputs_ids[i])->getValue()["value"].get<int>(), i*2);
+        EXPECT_EQ((int)module.getOutput(outputs_ids[i])->getValue()[0], i*2);
     }
     Client cli("localhost",8889);
     cli.Get("/stop");
@@ -131,11 +131,11 @@ TEST(ModuleHTTP, updateLayout_extern){
 TEST(ModuleHTTP, update_intern){
     std::thread server (serverThread);
     ModuleHTTP module("", "localhost", 8888);
-    std::cout << "WORKED" << std::endl;
+    //std::cout << "WORKED" << std::endl;
     auto inputs_types = module.getInputs();
     auto inputs_ids = module.getInputIDs();
     for (int i = 0; i < 5; ++i) {
-        module.getInput(inputs_ids[i])->setDefaultValue()["value"] = 10-i;
+        module.getInput(inputs_ids[i])->setValue() = { (double)(10 - i) };
     }
     module.update();
 
@@ -147,34 +147,14 @@ TEST(ModuleHTTP, update_intern){
     inputs_ids = module.getInputIDs();
     for (int i = 0; i < 5; ++i) {
         EXPECT_EQ(inputs_types[i], "INPUT");
-        EXPECT_EQ(module.getInput(inputs_ids[i])->getValue()["value"].get<int>(), 10-i);
+        EXPECT_EQ(module.getInput(inputs_ids[i])->getValue()[0], 10-i);
     }
-    std::cout << "WORKED" << std::endl;
+    //std::cout << "WORKED" << std::endl;
     auto outputs_types = module.getOutputs();
     auto outputs_ids = module.getOutputIDs();
-    std::cout << module.getOutput(outputs_ids[0])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(module.getOutput(outputs_ids[0])->getValue()["value"].get<int>(), 19);
-    EXPECT_EQ(module.getOutput(outputs_ids[1])->getValue()["value"].get<int>(), 64);
-    EXPECT_EQ(module.getOutput(outputs_ids[2])->getValue()["value"].get<int>(), 1);
+    //std::cout << module.getOutput(outputs_ids[0])->getValue() << std::endl;
+    EXPECT_EQ((int)module.getOutput(outputs_ids[1])->getValue()[0], 64);
+    EXPECT_EQ((int)module.getOutput(outputs_ids[2])->getValue()[0], 1);
+    EXPECT_EQ((int)module.getOutput(outputs_ids[0])->getValue()[0], 19);
 }
-
-/*
-TEST(ModuleHTTP, test_ansys_server) {
-    ModuleHTTP module("../../../lib/test/server/server-ansys.py", "localhost", 8888);
-
-    auto inputs_types = module.getInputs();
-    auto inputs_ids = module.getInputIDs();
-    EXPECT_EQ(inputs_types[0], "Materials");
-    EXPECT_EQ(inputs_types[1], "Angles");
-  
-    module.update();
-    
-    auto outputs_types = module.getOutputs();
-    auto outputs_ids = module.getOutputIDs();
-    for (int i = 0; i < outputs_ids.size(); ++i) {
-        std::cout << module.getOutput(outputs_ids[i])->getValue()["value"].dump() << std::endl;;
-    }
-    Client cli("localhost", 8888);
-    cli.Get("/stop");
-}
-*/
+//*/

+ 32 - 27
lib/test/test_ModuleMath.cpp

@@ -14,77 +14,82 @@ TEST(ModuleMath, INT_PLUS_INT){
     ModuleMath test = ModuleMath();
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"][0].get<int>(), 2);
+    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()[0], 2.0);
 }
 
 TEST(ModuleMath, FLOAT_PLUS_FLOAT){
     ModuleMath test = ModuleMath();
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 1.25;
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = 3.125;
+    test.getInput(test.getInputIDs()[0])->setValue() = { 1.25 };
+    test.getInput(test.getInputIDs()[1])->setValue() = { 3.125 };
     test.update();
 
-    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"], 4.375);
+    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()[0], 4.375);
 }
 
 TEST(ModuleMath, FLOAT_PLUS_FLOAT_HARDER){
     ModuleMath test = ModuleMath();
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 2.2;
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = -3.4;
+    test.getInput(test.getInputIDs()[0])->setValue() = { 2.2 };
+    test.getInput(test.getInputIDs()[1])->setValue() = { -3.4 };
     test.update();
 
-    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"], -1.2);
+    EXPECT_FLOAT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()[0], -1.2);
 }
 
-TEST(ModuleMath, ARRAY_PLUS_ARRAY){
+TEST(ModuleMath, ARRAY_PLUS_ARRAY) {
     ModuleMath test = ModuleMath();
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {1,2.5,3.75,45};
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {10,31,23,23};
+    test.getInput(test.getInputIDs()[0])->setValue() = { 1,2.5,3.75,45 };
+    test.getInput(test.getInputIDs()[1])->setValue() = { 10,31,23,23 };
+    std::vector<double> expect = { 11, 33.5, 26.75, 68 };
     test.update();
-
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[11,33.5,26.75,68]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }
 
 TEST(ModuleMath, INT_PLUS_ARRAY){
     ModuleMath test = ModuleMath();
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = 2.5;
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {10,31,23,23};
+    test.getInput(test.getInputIDs()[0])->setValue() = { 2.5 };
+    test.getInput(test.getInputIDs()[1])->setValue() = {10,31,23,23};
+    std::vector<double> expect = { 12.5,33.5,25.5,25.5 };
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[12.5,33.5,25.5,25.5]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }
 
 TEST(ModuleMath, ARRAY_PLUS_INT){
     ModuleMath test = ModuleMath();
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,31,23,23};
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = 2.5;
+    test.getInput(test.getInputIDs()[0])->setValue() = {10,31,23,23};
+    test.getInput(test.getInputIDs()[1])->setValue() = { 2.5 };
+    std::vector<double> expect = { 12.5,33.5,25.5,25.5 };
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[12.5,33.5,25.5,25.5]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }
 
 TEST(ModuleMath, ARRAY_MINUS_ARRAY){
     ModuleMath test = ModuleMath(MathOperation::SUBTRACT);
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,31,3,45};
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {1,2.5,23,23};
+    test.getInput(test.getInputIDs()[0])->setValue() = {10,31,3,45};
+    test.getInput(test.getInputIDs()[1])->setValue() = {1,2.5,23,23};
+    std::vector<double> expect = { 9,28.5,-20,22 };
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[9,28.5,-20,22]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }
 
 TEST(ModuleMath, ARRAY_MAL_ARRAY){
     ModuleMath test = ModuleMath(MathOperation::MULTIPLY);
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,30,-3.5,45};
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {1,2.5,2.25,20};
+    test.getInput(test.getInputIDs()[0])->setValue() = {10,30,-3.5,45};
+    test.getInput(test.getInputIDs()[1])->setValue() = {1,2.5,2.25,20};
+    std::vector<double> expect = { 10,75.0,-7.875,900 };
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[10,75.0,-7.875,900]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }
 
 TEST(ModuleMath, ARRAY_DURCH_ARRAY){
     ModuleMath test = ModuleMath(MathOperation::DIVIDE);
-    test.getInput(test.getInputIDs()[0])->setDefaultValue()["value"] = {10,30,-3.5,45};
-    test.getInput(test.getInputIDs()[1])->setDefaultValue()["value"] = {4,2.5,2,20};
+    test.getInput(test.getInputIDs()[0])->setValue() = {10,30,-3.5,45};
+    test.getInput(test.getInputIDs()[1])->setValue() = {4,2.5,2,20};
+    std::vector<double> expect = { 2.5,12.0,-1.75,2.25 };
     test.update();
 
-    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue()["value"].dump(), "[2.5,12.0,-1.75,2.25]");
+    EXPECT_EQ(test.getOutput(test.getOutputIDs()[0])->getValue(), expect);
 }

+ 15 - 14
lib/test/test_ModuleSQL.cpp

@@ -24,7 +24,7 @@ void sqlite3_exec_debug(sqlite3* db, char* sql) {
     char* zErrMsg = 0;
     int rc;
 
-    /* Execute SQL statement */
+    // Execute SQL statement 
     rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
 
     if (rc != SQLITE_OK) {
@@ -41,7 +41,7 @@ void create_test_db() {
         int rc;
         char* sql;
 
-        /* Open database */
+        // Open database
         rc = sqlite3_open("../../../lib/test/db/materials.db", &db);
 
         if (rc) {
@@ -52,7 +52,7 @@ void create_test_db() {
             fprintf(stdout, "Opened database successfully\n");
         }
 
-        /* Create SQL statement */
+        // Create SQL statement
         sql = "CREATE TABLE MATERIAL("  \
             "ID INTEGER PRIMARY KEY     AUTOINCREMENT," \
             "NAME           TEXT    NOT NULL," \
@@ -89,7 +89,7 @@ void create_test_db() {
 
         sqlite3_exec_debug(db, sql);
         
-       /* Create SQL statement */
+       // Create SQL statement
         sql = "INSERT INTO MATERIAL (   NAME,           E11,    E22,    E33,    PR12,   PR13,   PR23,   G12,    G13,    G23,    DENS,       ALP11,  ALP22, ALP33, K11,      K22,    K33,    BET11,  BET22,  BET33,  D11,    D22,    D33) "  \
             "VALUES (                   'EP-E Glas',    42.5,   11,     11,     0.28,   0.28,   0.28,   4.2,    4.2,    2.56,   1950E-6,    5.7E-6, 45E-6, 45E-6, 0.72E3,   0.5E3,  0.5E3,  0E-3,   4E-3,   4E-3,   4.4E3,  3.1E3,  3.1E3); ";
 
@@ -110,7 +110,7 @@ TEST(ModuleSQL, TestSQL) {
     char* sql;
     const char* data = "Callback function called";
 
-    /* Open database */
+    // Open database 
     rc = sqlite3_open("../../../lib/test/db/materials.db", &db);
 
     if (rc) {
@@ -121,10 +121,10 @@ TEST(ModuleSQL, TestSQL) {
         fprintf(stderr, "Opened database successfully\n");
     }
 
-    /* Create SQL statement */
+    // Create SQL statement 
     sql = "SELECT * from MATERIAL";
 
-    /* Execute SQL statement */
+    // Execute SQL statement 
     rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
 
     if (rc != SQLITE_OK) {
@@ -150,7 +150,7 @@ TEST(ModuleSQL, TestGetSQLTableStructure) {
     char* sql;
     const char* data = "Callback function called";
 
-    /* Open database */
+    // Open database 
     rc = sqlite3_open("../../../lib/test/db/materials.db", &db);
 
     if (rc) {
@@ -161,12 +161,12 @@ TEST(ModuleSQL, TestGetSQLTableStructure) {
         fprintf(stderr, "Opened database successfully\n");
     }
 
-    /* Create SQL statement */
+    // Create SQL statement 
     sql =   "SELECT * "\
             "FROM   sqlite_master "\
             "WHERE type = 'table' ";
 
-    /* Execute SQL statement */
+    // Execute SQL statement 
     rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
 
     if (rc != SQLITE_OK) {
@@ -205,7 +205,7 @@ TEST(ModuleSQL, TestDataExists) {
     char* sql;
     const char* data = "Callback function called";
 
-    /* Open database */
+    // Open database 
     rc = sqlite3_open("../../../lib/test/db/materials.db", &db);
 
     if (rc) {
@@ -216,10 +216,10 @@ TEST(ModuleSQL, TestDataExists) {
         fprintf(stderr, "Opened database successfully\n");
     }
 
-    /* Create SQL statement */
+    // Create SQL statement 
     sql = "SELECT * from MATERIAL";
 
-    /* Execute SQL statement */
+    // Execute SQL statement 
     rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
 
     if (rc != SQLITE_OK) {
@@ -232,4 +232,5 @@ TEST(ModuleSQL, TestDataExists) {
     sqlite3_close(db);
 
     EXPECT_TRUE(std::filesystem::exists("../../../lib/test/db/materials.db"));
-}
+}
+//*/

+ 19 - 19
lib/test/test_ModuleSwitch.cpp

@@ -12,46 +12,46 @@ TEST(ModuleSwitch, EasySwitch){
     auto inputs = sModule.getInputIDs();
     auto outputs = sModule.getOutputIDs();
 
-    sModule.getInput(inputs[0])->setDefaultValue()["value"] = 0;
-    sModule.getInput(inputs[1])->setDefaultValue()["value"] = 1;
-    sModule.getInput(inputs[2])->setDefaultValue()["value"] = 2;
+    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()["value"].get<int>(), 1);
+    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
 
-    sModule.getInput(inputs[0])->setDefaultValue()["value"] = 1;
+    sModule.getInput(inputs[0])->setValue() = { 1 };
     sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()["value"].get<int>(), 1);
+    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 1);
 
-    sModule.getInput(inputs[0])->setDefaultValue()["value"] = 2;
+    sModule.getInput(inputs[0])->setValue() = { 2 };
     sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()["value"].get<int>(), 2);
+    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
 
-    sModule.getInput(inputs[0])->setDefaultValue()["value"] = 3;
+    sModule.getInput(inputs[0])->setValue() = { 3 };
     sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()["value"].get<int>(), 2);
-    sModule.getInput(inputs[0])->setDefaultValue()["value"] = 33;
+    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()[0], 2);
+    sModule.getInput(inputs[0])->setValue() = { 33 };
     sModule.update();
-    EXPECT_EQ(sModule.getOutput(outputs[0])->getValue()["value"].get<int>(), 2);
+    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])->setDefaultValue()["value"] = 1;
-    f0.getInput(inputs[1])->setDefaultValue()["value"] = 1;
+    f0.getInput(inputs[0])->setValue() = { 1 };
+    f0.getInput(inputs[1])->setValue() = { 1 };
 
     ModuleMath f1 = ModuleMath(MathOperation::MULTIPLY);
     inputs = f1.getInputIDs();
-    f1.getInput(inputs[0])->setDefaultValue()["value"] = 2;
-    f1.getInput(inputs[1])->setDefaultValue()["value"] = 3;
+    f1.getInput(inputs[0])->setValue() = { 2 };
+    f1.getInput(inputs[1])->setValue() = { 3 };
 
     ModuleMath f2 = ModuleMath(MathOperation::MULTIPLY);
     inputs = f2.getInputIDs();
-    f2.getInput(inputs[0])->setDefaultValue()["value"] = 5;
-    f2.getInput(inputs[1])->setDefaultValue()["value"] = 7;
+    f2.getInput(inputs[0])->setValue() = { 5 };
+    f2.getInput(inputs[1])->setValue() = { 7 };
 
     ModuleSwitch sModule = ModuleSwitch();
     inputs = sModule.getInputIDs();
@@ -65,5 +65,5 @@ TEST(ModuleSwitch, ConnectTest){
     sModule.update();
 
     //std::cout << sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(sModule.getOutput(sModule.getOutputIDs()[0])->getValue()["value"].get<int>(), 6);
+    EXPECT_EQ(sModule.getOutput(sModule.getOutputIDs()[0])->getValue()[0], 6);
 }

+ 33 - 23
lib/test/test_OptimizerEvolutionary.cpp

@@ -11,39 +11,49 @@ TEST(OptimizerEvolutionary, OptimizeSimpleFormula) {
     //optimize f(x)=a*b
     std::vector<std::string> inputs;
     std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    OptimizerEvolutionary optimizer(f1, 3);
     inputs = f1->getInputIDs();
-    json limit;
-    limit["min"] = { -10 };
-    limit["max"] = { 10 };
-    limit["step"] = { 1 };
-    optimizer.addModifier(inputs[0], limit);
-    optimizer.addModifier(inputs[1], limit);
-    optimizer.addReader(f1->getOutputIDs()[0]);
+    limits limit;
+    limit.min = { -10 };
+    limit.max = { 10 };
+    limit.step = { 1 };
+
+    f1->getInput(inputs[0])->setLimits() = limit;
+    f1->getInput(inputs[1])->setLimits() = limit;
+
+    f1->getInput(inputs[0])->setOptimizability(true);
+    f1->getInput(inputs[1])->setOptimizability(true);
+
+    OptimizerEvolutionary optimizer(f1, 3);
     optimizer.setEvaluation("out0");
-    json res = optimizer.update();
+
+    auto res = optimizer.update();
     //std::cout << res.dump() << std::endl;
-    EXPECT_EQ(res[0]["value"][0].get<int>()* res[1]["value"][0].get<int>(),-100);
+    EXPECT_EQ(res[0][0]* res[1][0],-100);
 }
 
 TEST(OptimizerEvolutionary, OptimizeSimpleFormulaWithSimpleRestriction) {
     //optimize f(x)=a*b
     std::vector<std::string> inputs;
     std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
-    OptimizerEvolutionary optimizer(f1, 3);
     inputs = f1->getInputIDs();
-    json limit;
-    limit["min"] = { -10 };
-    limit["max"] = { 10 };
-    limit["step"] = { 1 };
-    limit["rule"] = "val[0] != -10";
-    optimizer.addModifier(inputs[0], limit);
-    optimizer.addModifier(inputs[1], limit);
-    optimizer.addReader(f1->getOutputIDs()[0]);
+    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);
+
+    OptimizerEvolutionary optimizer(f1, 3);
     optimizer.setEvaluation("out0");
-    json res = optimizer.update();
-    std::cout << res.dump() << std::endl;
-    EXPECT_EQ(res[0]["value"][0].get<int>() * res[1]["value"][0].get<int>(), -90);
+
+    auto res = optimizer.update();
+    //std::cout << res.dump() << std::endl;
+    EXPECT_EQ(res[0][0] * res[1][0], -90);
 }
 
 TEST(OptimizerEvolutionary, exprtk) {
@@ -51,7 +61,7 @@ TEST(OptimizerEvolutionary, exprtk) {
     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;
+    //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;

+ 41 - 39
lib/test/test_ProcessorStandard.cpp

@@ -12,13 +12,13 @@ TEST(ProcessorStandard, CalculateSimpleFormula){
     std::vector<std::string> inputs;
     std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
     inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setDefaultValue()["value"] = 5;
-    f1->getInput(inputs[1])->setDefaultValue()["value"] = 3;
+    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])->setDefaultValue()["value"] = 4;
-    f2->getInput(inputs[1])->setDefaultValue()["value"] = 5;
+    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();
@@ -28,39 +28,40 @@ TEST(ProcessorStandard, CalculateSimpleFormula){
     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])->setDefaultValue()["value"] = 2;
+    f4->getInput(inputs[1])->setValue() = { 2 };
 
-    std::shared_ptr<ProcessorStandard> test = std::make_shared<ProcessorStandard>();
-    test->addModule(f1);
-    test->addModule(f2);
-    test->addModule(f3);
-    test->addModule(f4);
-    test->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
-    test->update();
+    std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();
+    processor->addModule(f1);
+    processor->addModule(f2);
+    processor->addModule(f3);
+    processor->addModule(f4);
+    processor->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
+    processor->update();
 
-    EXPECT_EQ(f1->getOutput(f1->getOutputIDs()[0])->getValue()["value"].get<int>(), 15);
+    EXPECT_EQ(f1->getOutput(f1->getOutputIDs()[0])->getValue()[0], 15);
 
-    EXPECT_EQ(f2->getOutput(f2->getOutputIDs()[0])->getValue()["value"].get<int>(), 9);
+    EXPECT_EQ(f2->getOutput(f2->getOutputIDs()[0])->getValue()[0], 9);
 
-    EXPECT_EQ(f3->getOutput(f3->getOutputIDs()[0])->getValue()["value"].get<int>(), 6);
+    EXPECT_EQ(f3->getOutput(f3->getOutputIDs()[0])->getValue()[0], 6);
 
-    EXPECT_EQ(f4->getOutput(f4->getOutputIDs()[0])->getValue()["value"].get<int>(), 3);
+    EXPECT_EQ(f4->getOutput(f4->getOutputIDs()[0])->getValue()[0], 3);
 
-    EXPECT_EQ(test->getOutput(test->getOutputIDs()[1])->getValue()["value"].get<int>(), 3);
+    EXPECT_EQ(processor->getOutput(processor->getOutputIDs()[1])->getValue()[0], 3);
 }
 
+
 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])->setDefaultValue()["value"] = 5;
-    f1->getInput(inputs[1])->setDefaultValue()["value"] = 3;
+    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])->setDefaultValue()["value"] = 4;
-    f2->getInput(inputs[1])->setDefaultValue()["value"] = 5;
+    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();
@@ -70,7 +71,7 @@ TEST(ProcessorStandard, CalculateAdvancedFormula){
     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])->setDefaultValue()["value"] = 2;
+    f4->getInput(inputs[1])->setValue() = { 2 };
 
     std::shared_ptr<ProcessorStandard> test = std::make_shared<ProcessorStandard>();
     test->addModule(f4);
@@ -80,7 +81,7 @@ TEST(ProcessorStandard, CalculateAdvancedFormula){
     test->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
     test->update();
     //std::cout << test->getOutput(test->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(test->getOutput(test->getOutputIDs()[1])->getValue()["value"].get<int>(), 3);
+    EXPECT_EQ(test->getOutput(test->getOutputIDs()[1])->getValue()[0], 3);
 }
 
 TEST(ProcessorStandard, CalculateExtremeFormula){
@@ -93,16 +94,16 @@ TEST(ProcessorStandard, CalculateExtremeFormula){
 
     bool connect;
     connect =switchModule->getInput(switchModule->getInputIDs()[0])->connect(processor->getIteration());
-    switchModule->getInput(switchModule->getInputIDs()[1])->setDefaultValue()["value"] = 8.0;
+    switchModule->getInput(switchModule->getInputIDs()[1])->setValue() = { 8.0 };
     connect = switchModule->getInput(switchModule->getInputIDs()[2])->connect(calcModule->getOutput(calcModule->getOutputIDs()[0]));
 
     calcModule->getInput(calcModule->getInputIDs()[0])->connect(switchModule->getOutput(switchModule->getOutputIDs()[0]));
-    calcModule->getInput(calcModule->getInputIDs()[1])->setDefaultValue()["value"] = 2.0;
+    calcModule->getInput(calcModule->getInputIDs()[1])->setValue() = { 2.0 };
 
     processor->addModuleOutput(calcModule,calcModule->getOutput(calcModule->getOutputIDs()[0]));
     processor->update();
 
-    EXPECT_FLOAT_EQ(processor->getOutput(processor->getOutputIDs()[1])->getValue()["value"].get<double>(), 0.0);
+    EXPECT_FLOAT_EQ(processor->getOutput(processor->getOutputIDs()[1])->getValue()[0], 0.0);
 }
 
 TEST(ProcessorStandard, CalculateAdvancedFormulaWithSTATIC) {
@@ -110,13 +111,13 @@ TEST(ProcessorStandard, CalculateAdvancedFormulaWithSTATIC) {
     std::vector<std::string> inputs;
     std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
     inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setDefaultValue()["value"] = 5;
-    f1->getInput(inputs[1])->setDefaultValue()["value"] = 3;
+    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])->setDefaultValue()["value"] = 4;
-    f2->getInput(inputs[1])->setDefaultValue()["value"] = 5;
+    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();
@@ -126,7 +127,7 @@ TEST(ProcessorStandard, CalculateAdvancedFormulaWithSTATIC) {
     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])->setDefaultValue()["value"] = 2;
+    f4->getInput(inputs[1])->setValue() = { 2 };
 
     std::shared_ptr<ProcessorStandard> process_static = std::make_shared<ProcessorStandard>(STATIC);
     process_static->addModule(f4);
@@ -136,7 +137,7 @@ TEST(ProcessorStandard, CalculateAdvancedFormulaWithSTATIC) {
     process_static->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
     process_static->update();
     //std::cout << test->getOutput(test->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
-    EXPECT_EQ(process_static->getOutput(process_static->getOutputIDs()[1])->getValue()["value"].get<int>(), 3);
+    EXPECT_EQ(process_static->getOutput(process_static->getOutputIDs()[1])->getValue()[0], 3);
 }
 
 TEST(ProcessorStandard, PrioritySTATIC) {
@@ -144,13 +145,13 @@ TEST(ProcessorStandard, PrioritySTATIC) {
     std::vector<std::string> inputs;
     std::shared_ptr<ModuleMath> f1 = std::make_shared<ModuleMath>(MathOperation::MULTIPLY);
     inputs = f1->getInputIDs();
-    f1->getInput(inputs[0])->setDefaultValue()["value"] = 5;
-    f1->getInput(inputs[1])->setDefaultValue()["value"] = 3;
+    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])->setDefaultValue()["value"] = 4;
-    f2->getInput(inputs[1])->setDefaultValue()["value"] = 5;
+    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();
@@ -160,7 +161,7 @@ TEST(ProcessorStandard, PrioritySTATIC) {
     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])->setDefaultValue()["value"] = 2;
+    f4->getInput(inputs[1])->setValue() = { 2 };
 
     std::shared_ptr<ProcessorStandard> process_manual = std::make_shared<ProcessorStandard>();
     process_manual->addModule(f1);
@@ -178,5 +179,6 @@ TEST(ProcessorStandard, PrioritySTATIC) {
     process_static->addModuleOutput(f4, f4->getOutput(f4->getOutputIDs()[0]));
     process_static->update();
     //std::cout << process_static->getOutput(process_static->getOutputIDs()[1])->getValue()["value"].dump() << std::endl;
-    EXPECT_TRUE(process_static->getIteration()->getValue()["value"].get<int>() <= process_manual->getIteration()->getValue()["value"].get<int>());
-}
+    EXPECT_TRUE(process_static->getIteration()->getValue()[0] <= process_manual->getIteration()->getValue()[0]);
+}
+//*/