예제 #1
0
    // Use this for initialization
    void Start()
    {
        //create actual curve visualization
        CurvePoints = new GameObject[numPoints];
        for (int i = 0; i < CurvePoints.Length; i++)
        {
            CurvePoints[i] = Instantiate(curvePrefab);
        }
        updateCurvePoints();

        testInputSets  = new double[numTestPoints, 1];
        testOutputSets = new double[numTestPoints, 1];
        for (int i = 0; i < numTestPoints; i++)
        {
            testInputSets[i, 0]  = testMin + i * (testMax - testMin) / numTestPoints;
            testOutputSets[i, 0] = CurveToFitGA.Function(testInputSets[i, 0]);
        }

        net = new NeuralNet(1, 1, numHiddenLayers, hiddenLayerSize, testInputSets, testOutputSets);//create net with test sets filled

        //create visualization of the net points
        NetPoints = new GameObject[numPoints];
        for (int i = 0; i < NetPoints.Length; i++)
        {
            NetPoints[i] = Instantiate(netPrefab);
        }
        updateNetPoints(net);

        VNet.net = net;
        VNet.Initialize();

        ga = new GeneticAlgorithm(net, populationSize, numParents, environmentalPressure, eliteFraction, numCrossoverPoints, mutationChance, tournamentSize);
    }
예제 #2
0
 void updateCurvePoints()
 {
     for (int i = 0; i < CurvePoints.Length; i++)
     {
         double x = min + i * ((max - min) / numPoints);
         double y = CurveToFitGA.Function(x);
         CurvePoints[i].GetComponent <Transform>().position = new Vector3((float)(coordinateScale * x), (float)(coordinateScale * (float)y), 0);
     }
 }