فهرست منبع

change optimizer

Willi Zschiebsch 4 سال پیش
والد
کامیت
409e73625f

+ 1 - 1
lib/include/IOptimizer.h

@@ -12,7 +12,7 @@ namespace mdd {
 			virtual bool connect(std::shared_ptr<IModule> module) = 0;
 			
 			virtual bool setEvaluation(std::string func) = 0;
-			virtual std::vector<std::vector<double>> update() = 0;
+			virtual double update() = 0;
 	};
 }
 #endif // !IOPTIMIZER_H

+ 7 - 4
lib/include/OptimizerEvolutionary.h

@@ -1,4 +1,5 @@
 #pragma once
+
 #include "OptimizerBase.h"
 #include <iostream>
 
@@ -10,9 +11,10 @@ namespace mdd {
 			std::vector<std::vector<double>> dna;
 			double fitness = 0;
 			bool operator== (const Individual& ind) {
-				return (dna == ind.dna) && (fitness == ind.fitness);
+				return (dna == ind.dna);
 			};
 		};
+
 	protected:
 		static int random_num(double min, double max, double inc = 1.0)
 		{
@@ -24,11 +26,12 @@ namespace mdd {
 		Individual combine(Individual par1, Individual par2);
 
 		std::vector<Individual> _children;
-		Individual _best;
+		std::vector<Individual> _bests;
 		int _min_generations;
 		double _max_fitness;
 		size_t _grow_generation;
 		size_t _converges;
+		double _precision;
 
 		void evolve(std::vector<Individual> parents);
 		void evaluate(size_t ignore_len = 0);
@@ -45,8 +48,8 @@ namespace mdd {
 			double max_fitness = 0.0,
 			int min_generations = -1
 		*/
-		std::vector<std::vector<double>> update() override;
-		Individual getBest();
+		double update() override;
+		std::vector<Individual> getBests();
 		double evaluateFitness(const Individual& ind);
 	};
 }

+ 47 - 34
lib/src/OptimizerEvolutionary.cpp

@@ -23,9 +23,26 @@ namespace mdd {
 		double min = _children[0].fitness;
 		for (size_t i = 1; i < _children.size(); i++)
 		{
-			if (min > _children[i].fitness) {
+			if (round(min/_precision)*_precision > round(_children[i].fitness / _precision) * _precision) {
 				min = _children[i].fitness;
-				_best = _children[i];
+				_bests.clear();
+				_bests.push_back(_children[i]);
+			}
+			else if(round(min / _precision) * _precision == round(_children[i].fitness / _precision) * _precision)
+			{
+				bool found = false;
+				for (size_t j = 0; j < _bests.size(); j++)
+				{
+					if (_children[i] == _bests[j])
+					{
+						found = true;
+						break;
+					}
+				}
+				if (!found)
+				{
+					_bests.push_back(_children[i]);
+				}
 			}
 		}
 	}
@@ -43,6 +60,9 @@ namespace mdd {
         },{
             "name":"min generations",
             "value": -1
+        },{
+            "name":"precission",
+            "value": 0.001
         }])JSON")
 	{
 		//_module = module;
@@ -50,6 +70,7 @@ namespace mdd {
 		_grow_generation = 20;
 		_max_fitness = 0.0;
 		_min_generations = -1;
+		_precision = 0.001;
 	}
 
 	bool OptimizerEvolutionary::configure(const std::string& config) {
@@ -79,13 +100,18 @@ namespace mdd {
 					_min_generations = config_parsed[i]["value"].get<int>();
 					found = true;
 				}
+				else if (config_parsed[i]["name"].get<std::string>() == "precision")
+				{
+					_precision = config_parsed[i]["value"].get<double>();
+					found = true;
+				}
 			}
 		}
 
 		return found;
 	}
 
-	std::vector<std::vector<double>> OptimizerEvolutionary::update()
+	double OptimizerEvolutionary::update()
 	{
 		int gen = -1;
 		bool check;
@@ -94,7 +120,7 @@ namespace mdd {
 		if (_inputs.size() == 0)
 		{
 			std::cout << "ERROR: No optimizable inputs detected!" << std::endl;
-			return std::vector<std::vector<double>>();
+			return -1.0;
 		}
 		do
 		{
@@ -118,16 +144,25 @@ namespace mdd {
 			}
 			
 			++gen;
-			check = gen < _min_generations || _best.fitness > _max_fitness;
+			check = gen < _min_generations || _bests[0].fitness > _max_fitness;
 			if (!check && _converges > 0)
 			{
-				if (_best == old_best)
+				bool found = false;
+				for (size_t i = 0; i < _bests.size(); i++)
+				{
+					if (_bests[i] == old_best)
+					{
+						found = true;
+						break;
+					}
+				}
+				if (found)
 				{
 					++same_counter;
 				}
 				else
 				{
-					old_best = _best;
+					old_best = _bests[0];
 					same_counter = 0;
 				}
 				if (same_counter < _converges)
@@ -137,7 +172,7 @@ namespace mdd {
 			}
 		} while (check);
 		
-		return _best.dna;
+		return _bests[0].fitness;
 	}
 	std::vector<double> OptimizerEvolutionary::mutateGene(std::shared_ptr<IInput> input, std::vector<double> seed)
 	{
@@ -251,30 +286,8 @@ namespace mdd {
 			}
 		}
 		//fittest parents will also be new childrens
-		_children.clear();
-		double min = parents[0].fitness;
-		for (size_t i = 1; i < parents.size(); i++)
-		{
-			if (max > parents[i].fitness) {
-				min = parents[i].fitness;
-			}
-		}
-		for (size_t i = 0; i < parents.size(); i++)
-		{
-			if (max == parents[i].fitness) {
-				bool exist = false;
-				for (size_t j = 0; j < _children.size(); j++)
-				{
-					if (_children[j].dna == parents[i].dna) {
-						exist = true;
-						break;
-					}
-				}
-				if (!exist) {
-					_children.push_back(parents[i]);
-				}
-			}
-		}
+		_children = _bests;
+		
 		//breed
 		size_t init_len = _children.size();
 		for (size_t i = 0; i < _grow_generation; i++)
@@ -315,8 +328,8 @@ namespace mdd {
 		}
 		return ret;
 	}
-	OptimizerEvolutionary::Individual OptimizerEvolutionary::getBest() {
-		return _best;
+	std::vector<OptimizerEvolutionary::Individual> OptimizerEvolutionary::getBests() {
+		return _bests;
 	}
 	double OptimizerEvolutionary::evaluateFitness(const Individual& ind) {
 		for (size_t j = 0; j < _inputs.size(); j++)

BIN
lib/test/db/materials.db


+ 97 - 35
lib/test/server/gfk_plate.py

@@ -6,7 +6,7 @@ import os
 import time
 
 
-def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thickness=5, omega=1):
+def sim_rotor(materials, angles, outer_diameter=0.250, inner_diameter=0.050, thickness=0.005, omega=1):
     layers = len(angles)
     layer_thickness = thickness / layers
 
@@ -17,8 +17,8 @@ def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thicknes
     mapdl.finish()
     mapdl.clear()
 
-    th = 200  # [°C]        Herstellungstemperatur
-    tn = 20  # [°C]         Nutzungstemperatur
+    th = 50  # [°C]        Herstellungstemperatur
+    tn = 50  # [°C]        Nutzungstemperatur
 
     mapdl.prep7()
     # define Material
@@ -86,6 +86,7 @@ def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thicknes
     mapdl.csys(1)
     mapdl.cyl4(0, 0, inner_diameter / 2, 0, outer_diameter / 2, 180)
     mapdl.cyl4(0, 0, inner_diameter / 2, 180, outer_diameter / 2, 360)
+    # mapdl.aplot()
     mapdl.nsel("S", "LOC", "Y", 0)
     mapdl.nummrg("ALL")
     mapdl.nsel("S", "LOC", "Y", 180)
@@ -113,22 +114,81 @@ def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thicknes
     mapdl.outres("ALL", "ALL")
     # mapdl.open_gui()
     mapdl.solve()
-
     mapdl.finish()
-    #mapdl.post1()
-    #mapdl.open_gui()
 
+    mapdl.run("/Post1")
+
+    result = mapdl.result
+    mapdl.aplot()
+    # result.plot_principal_nodal_stress(0, '1', show_edges=True, show_axes=True)
+    result.plot_nodal_solution(0, 'x')
+    result.plot_principal_nodal_stress(0, '1', show_edges=True, show_axes=True)
+    # """
+    nodenump, stress = result.principal_nodal_stress(0)
 
-    # plot_rotor(mapdl)
+    # von first principle stress is the first column
+    # must be nanmax as the shell element stress is not recorded
 
+
+    mapdl.run('*GET, NODE_COUNT, NODE, ,COUNT')
+    mapdl.run('*GET, ELEM_COUNT, ELEM, ,COUNT')
+    mapdl.load_parameters()
+    print(mapdl.parameters['NODE_COUNT'])
+    print(mapdl.parameters['ELEM_COUNT'])
+
+    s1max = angles
+    s2max = angles
+    srmax = angles
+    stmax = angles
+
+    for i in range(0, len(angles)):
+        mapdl.run("LAYER, " + str(i + 1))  #
+        mapdl.run("*DIM, DIM_TEST, ARRAY, ELEM_COUNT, 2")
+        mapdl.run("ETABLE, TEST, S, 1, MAX")
+        mapdl.run("*VGET, DIM_TEST(1,1), ETAB, TEST")
+
+        mapdl.run("*DIM, OUT_STRESS, ARRAY, NODE_COUNT, 4")
+        mapdl.run("*VGET, OUT_STRESS(1, 1), NODE,, S, 1")
+        mapdl.run("*VGET, OUT_STRESS(1, 2), NODE,, S, 2")
+        mapdl.run("*VGET, OUT_STRESS(1, 3), NODE,, S, X")
+        mapdl.run("*VGET, OUT_STRESS(1, 4), NODE,, S, Y")
+        params, arrays = mapdl.load_parameters()
+        print(arrays['TEST'][0])
+        s1max[i] = np.nanmax(arrays['OUT_STRESS'][:, 0])
+        s2max[i] = np.nanmax(arrays['OUT_STRESS'][:, 1])
+        srmax[i] = np.nanmax(arrays['OUT_STRESS'][:, 2])
+        stmax[i] = np.nanmax(arrays['OUT_STRESS'][:, 3])
+
+        # print(str(element_stress[0]))
+        # s1max = np.nanmax(stresses)
+        # nodenump, stress = result.principal_nodal_stress(0)
+        # s1max[i] = np.nanmax(element_stress[:, -5])
+
+    s1max = np.nanmax(s1max)
+    s2max = np.nanmax(s2max)
+    srmax = np.nanmax(srmax)
+    stmax = np.nanmax(stmax)
+
+    # von second principle stress is the first column
+    # must be nanmax as the shell element stress is not recorded
+    #s2max = np.nanmax(stress[:, -4])
+
+    #nodenum, stress = result.nodal_stress(0)
+    # von Mises stress is the last column
+    # must be nanmax as the shell element stress is not recorded
+    #srmax = np.nanmax(stress[:, -6])
+    #stmax = np.nanmax(stress[:, -5])
+
+    print(str(s1max))
+
+    # """
+
+    """
     # access results using ANSYS object
     resultfile = os.getcwd() + '\\ws\\file.rst'
-
     result = pyansys.read_binary(resultfile)
-    # result = mapdl.result
-    #result.plot_nodal_solution(0, 'x')
 
-# plot_nodal_solution doesnt work
+    # plot_nodal_solution doesnt work
     nodenump, stress = result.principal_nodal_stress(0)
 
     # von first principle stress is the first column
@@ -145,35 +205,37 @@ def sim_rotor(materials, angles, outer_diameter=250, inner_diameter=50, thicknes
     srmax = np.nanmax(stress[:, -6])
     stmax = np.nanmax(stress[:, -5])
 
+    print(str(s1max))
+    # result.plot_nodal_solution(0)
+    # """
     mapdl.exit()
     time.sleep(0.5)
 
     return s1max, s2max, srmax, stmax
 
-"""
+
 print(sim_rotor(
     [{
-        "e11": 42.5,
-        "e22": 11,
-        "e33": 11,
-        "pr12": 0.28,
-        "pr13": 0.28,
-        "pr23": 0.28,
-        "dens": 1950E-6,
-        "g12": 4.2,
-        "g13": 4.2,
-        "g23": 2.56,
-        "alp11": 5.7E-6,
-        "alp22": 45E-6,
-        "alp33": 45E-6,
-        "k11": 0.72E3,
-        "k22": 0.5E3,
-        "k33": 0.5E3,
-        "bet11": 0E-3,
-        "bet22": 4E-3,
-        "bet33": 4E-3,
-        "d11": 4.4E3,
-        "d22": 3.1E3,
-        "d33": 3.1E3
+        "e11":      42.5E9  ,
+        "e22":      11E9    ,
+        "e33":      11E9    ,
+        "pr12":     0.28    ,
+        "pr13":     0.28    ,
+        "pr23":     0.28    ,
+        "dens":     1950    ,
+        "g12":      4.2E9   ,
+        "g13":      4.2E9   ,
+        "g23":      2.56E9  ,
+        "alp11":    5.7E-6  ,
+        "alp22":    45E-6   ,
+        "alp33":    45E-6   ,
+        "k11":      0.72E3  ,
+        "k22":      0.5E3   ,
+        "k33":      0.5E3   ,
+        "bet11":    0E-3,
+        "bet22":    4E-3,
+        "bet33":    4E-3,
+        "d11":      4.4E-3,
+        "d22":      3.1E-3,
+        "d33":      3.1E-3
     }], [90, 0, 0, 0, 0, 0]))
-"""

+ 14 - 14
lib/test/server/server-ansys.py

@@ -21,16 +21,16 @@ from ini_logger import *
 # ini_logger(log_dir)
 
 inputs = [
-    {'type': "e11", 'value': [42.5]},
-    {'type': "e22", 'value': [11]},
-    {'type': "e33", 'value': [11]},
+    {'type': "e11", 'value': [42.5E9]},
+    {'type': "e22", 'value': [11E9]},
+    {'type': "e33", 'value': [11E9]},
     {'type': "pr12", 'value': [0.28]},
     {'type': "pr13", 'value': [0.28]},
     {'type': "pr23", 'value': [0.28]},
-    {'type': "g12", 'value': [4.2]},
-    {'type': "g13", 'value': [4.2]},
-    {'type': "g23", 'value': [2.56]},
-    {'type': "dens", 'value': [1950E-6]},
+    {'type': "g12", 'value': [4.2E9]},
+    {'type': "g13", 'value': [4.2E9]},
+    {'type': "g23", 'value': [2.56E9]},
+    {'type': "dens", 'value': [1950]},
     {'type': "alp11", 'value': [5.7E-6]},
     {'type': "alp22", 'value': [45E-6]},
     {'type': "alp33", 'value': [45E-6]},
@@ -40,17 +40,17 @@ inputs = [
     {'type': "bet11", 'value': [0E-3]},
     {'type': "bet22", 'value': [4E-3]},
     {'type': "bet33", 'value': [4E-3]},
-    {'type': "d11", 'value': [4.4E3]},
-    {'type': "d22", 'value': [3.1E3]},
-    {'type': "d33", 'value': [3.1E3]},
+    {'type': "d11", 'value': [4.4E-3]},
+    {'type': "d22", 'value': [3.1E-3]},
+    {'type': "d33", 'value': [3.1E-3]},
     {'type': "angles", 'value': [90, 0, 0, 0, 0, 0]}
 ]
 
 outputs = [
-    {'type': "Srmax", 'value': [0]},
-    {'type': "Stmax", 'value': [2]},
-    {'type': "S1max", 'value': [4]},
-    {'type': "S2max", 'value': [4]}
+    {'type': "S1max", 'value': [0]},
+    {'type': "S2max", 'value': [2]},
+    {'type': "Srmax", 'value': [4]},
+    {'type': "Stmax", 'value': [4]}
 ]
 
 status = {

+ 79 - 22
lib/test/test_Ansys.cpp

@@ -1,5 +1,6 @@
 #include <gtest/gtest.h>
 #include <json.hpp>
+#include <chrono>
 #include <httplib.h>
 #include "Registration.h"
 #include "OptimizerEvolutionary.h"
@@ -8,8 +9,7 @@
 #include <thread>
 
 using namespace mdd;
-namespace TEST_ANSYS {
-
+namespace TEST_ANSYS { 
     auto regi = Registration();
     TEST(ModuleHTTP, test_ansys_sql_server) {
         auto sql = regi.generateModule("ModuleSQL");
@@ -43,7 +43,7 @@ namespace TEST_ANSYS {
         http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
         http->getInput(http->getNumInputs() - 1)->setValue() = { 90,90,0,90,0,90 };
 
-        http->getOutput(3)->setOptimizability(true);
+        http->getOutput(0)->setOptimizability(true);
 
         sql->update();
         //test SQL
@@ -54,7 +54,7 @@ namespace TEST_ANSYS {
         }
 
         http->update();
-        EXPECT_FLOAT_EQ(http->getOutput(3)->getValue()[0], 0.31204228291286723);
+        EXPECT_FLOAT_EQ(http->getOutput(3)->getValue()[0], 31.204228291286723);
     }
 
     TEST(ModuleHTTP, test_configurations) {
@@ -88,7 +88,7 @@ namespace TEST_ANSYS {
         limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
         http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
 
-        http->getOutput(3)->setOptimizability(true);
+        http->getOutput(0)->setOptimizability(true);
 
         std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
         processor->addModule(sql);
@@ -106,20 +106,75 @@ namespace TEST_ANSYS {
 
         //auto res = optimizer.update();
         OptimizerEvolutionary::Individual ind;
-        ind.dna = { { 0,90,90,90,90,90 } };
-        std::cout << "{ 0,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
-        ind.dna = { { 90,90,90,90,90,0 } };
-        std::cout << "{ 90,90,90,90,90,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
-        ind.dna = { { 90,0,0,0,0,0 } };
-        std::cout << "{ 90,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
-        ind.dna = { { 0,0,0,0,0,90 } };
-        std::cout << "{ 0,0,0,0,0,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        auto start = std::chrono::steady_clock::now();
+        auto end = std::chrono::steady_clock::now();
+
+        /*
         ind.dna = { { 0,0,0,0,0,0 } };
-        std::cout << "{ 0,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 0,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
         ind.dna = { { 90,90,90,90,90,90 } };
-        std::cout << "{ 90,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+        //*/
+        ind.dna = { { 90,0,0,0,0,0 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,0,0,0,0,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
+        ind.dna = { { 0,0,0,0,0,90 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 0,0,0,0,0,90 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
+        ind.dna = { { 0,90,90,90,90,90 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 0,90,90,90,90,90 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count() << "ms" << std::endl;
+
+        ind.dna = { { 90,90,90,90,90,0 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,90,90,90,90,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
+        ind.dna = { { 90,0,0,0,90,0 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,0,0,0,90,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
+        ind.dna = { { 90,0,0,0,90,0 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,0,0,0,90,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+     
+        ind.dna = { { 90,0,0,0,90,0 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 90,0,0,0,90,0 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
         ind.dna = { { 0,0,90,90,90,90 } };
-        std::cout << "{ 0,0,90,90,90,90 }: " << optimizer.evaluateFitness(ind) << std::endl;
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 0,0,90,90,90,90 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+
+        ind.dna = { { 0,0,90,90,90,90 } };
+        start = std::chrono::steady_clock::now();
+        std::cout << "{ 0,0,90,90,90,90 }: " << optimizer.evaluateFitness(ind);
+        end = std::chrono::steady_clock::now();
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
         EXPECT_TRUE(ind.fitness <= 100.0);
     }
 
@@ -154,7 +209,7 @@ namespace TEST_ANSYS {
         limit.rule = "val[0] != val[5] || val[1] != val[4] || val[2] != val[3]";
         http->getInput(http->getNumInputs() - 1)->setLimits() = limit;
 
-        http->getOutput(3)->setOptimizability(true);
+        http->getOutput(0)->setOptimizability(true);
 
         std::shared_ptr<ProcessorStandard> processor = std::make_shared<ProcessorStandard>();;
         processor->addModule(sql);
@@ -164,16 +219,18 @@ namespace TEST_ANSYS {
         config = json::parse(optimizer.getConfiguration());
         config[0]["value"] = 3;
         config[1]["value"] = 20;
-        config[2]["value"] = 0.13;
+        config[2]["value"] = 13.4;
         config[3]["value"] = 5;
         optimizer.configure(config.dump());
         optimizer.connect(processor);
         optimizer.setEvaluation("out0");
-
+        auto start = std::chrono::steady_clock::now();
         auto res = optimizer.update();
-        std::cout << optimizer.getBest().fitness << std::endl;
-        std::cout << optimizer.evaluateFitness(optimizer.getBest()) << std::endl;
-        EXPECT_TRUE(optimizer.getBest().fitness <= 100.0);
+        auto end = std::chrono::steady_clock::now();
+        std::cout << optimizer.getBests()[0].fitness;
+        std::cout << " | " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+        std::cout << optimizer.evaluateFitness(optimizer.getBests()[0]) << std::endl;
+        EXPECT_TRUE(optimizer.getBests()[0].fitness <= 100.0);
     }
     //*/
 }

+ 2 - 2
lib/test/test_ModuleSQL.cpp

@@ -91,8 +91,8 @@ namespace TEST_MODULE_SQL {
             sqlite3_exec_debug(db, sql);
 
            // 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); ";
+            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.5E9, 11E9, 11E9, 0.28, 0.28, 0.28, 4.2E9, 4.2E9, 2.56E9, 1950, 5.7E-6, 45E-6, 45E-6, 0.72E3, 0.5E3, 0.5E3, 0E-3,  4E-3,  4E-3,  4.4E-3, 3.1E-3, 3.1E-3); ";
 
             sqlite3_exec_debug(db, sql);
 

+ 4 - 2
lib/test/test_OptimizerEvolutionary.cpp

@@ -36,7 +36,8 @@ namespace TEST_OPTIMIZER_EVOLUTION {
     
         optimizer.setEvaluation("out0");
     
-        auto res = optimizer.update();
+        optimizer.update();
+        auto res = optimizer.getBests()[0].dna;
         //std::cout << res.dump() << std::endl;
         EXPECT_EQ(res[0][0]* res[1][0],-100);
     }
@@ -69,7 +70,8 @@ namespace TEST_OPTIMIZER_EVOLUTION {
     
         optimizer.setEvaluation("out0");
     
-        auto res = optimizer.update();
+        optimizer.update();
+        auto res = optimizer.getBests()[0].dna;
         //std::cout << res.dump() << std::endl;
         EXPECT_EQ(res[0][0]* res[1][0],-90);
     }