void Awake() { signalControl = new ControlSignal(); path = "Save/DroneSession/" + "Task-" + task + "/Seed-" + fromSeed + "/"; rndGenerator = new SystemRandomSource(fromSeed); taskObject = (DroneTask)Activator.CreateInstance(Type.GetType("Lexmou.MachineLearning.Drone" + task), rndGenerator, task); mlp = new MultiLayerMathsNet(fromSeed, null, taskObject.shapes, 1, 0); float[] floatArr = new float[taskObject.individualSize]; //float[] floatArr = new float[] {0,-0.33f,0,0,-0.33f,0,0,0,0,0,0.5f,0,0,-1,0,0,-1,0,0,0.5f,0,1,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0.5f}; Genetic.LoadBest(path, fromGeneration, floatArr); BuildCustomWeights(mlp.weights, taskObject.shapes, Vector <float> .Build.DenseOfArray(floatArr)); //Debug.Log(mlp.weights[0]); /*if (stabilizationGeneration != 0) * { * Debug.Log("Gene Move"); * gene = new Genetic(stabilizationSeed, null, 100, 40, 1.0f, 0.1f, 0.1f, 0.1f, 0.1f, "Save/DroneSession/Task-stabilization/", false); * } * if (moveGeneration != 0) * { * Debug.Log("Gene Move"); * gene = new Genetic(moveSeed, null, 100, 52, 1.0f, 0.1f, 0.1f, 0.1f, 0.1f, "Save/DroneSession/Task-move/", false); * } * deltaDistribution = new ContinuousUniform(-2, 2); * tmpBuildCustomWeights = new List<Matrix<float>>();*/ Restart(); }
public void SaveTest() { Vector <float> externalEvaluations = Vector <float> .Build.DenseOfArray(new float[2] { 0.0f, 1.0f }); geneRndGenerator.Evaluation(externalEvaluations, "max"); geneRndGenerator.SaveGeneration(); float[,] floatArr = new float[geneRndGenerator.individualSize, geneRndGenerator.populationSize]; float[] floatArrBest = new float[geneRndGenerator.individualSize]; geneRndGenerator.LoadGeneration(1, floatArr); geneRndGenerator.LoadBest(1, floatArrBest); Matrix <float> result = Matrix <float> .Build.DenseOfArray(floatArr); Vector <float> resultBest = Vector <float> .Build.DenseOfArray(floatArrBest); Assert.AreEqual(geneRndGenerator.GetPopulation(), result); Assert.AreEqual(geneRndGenerator.GetBestIndividual(), resultBest); Debug.Log(geneRndGenerator.GetPopulation()); Debug.Log(result); }