public void Reset()
        {
            //TODO move load to Body
            this.body.modelData = GeometryFunctions.Load();

            if (this.solverType == SolverType.Euler)
            {
                this.solver = new FishEulerSolver();
            }
            else
            {
                this.solver = new FishMatrixSolver();
            }
            this.localDelta.Reset();
            this.muscleMCs.Clear();

            this.runtimeList       = this.body.modelData.FishGraph.Nodes.ToList();
            this.runtimeSpringList = this.body.modelData.FishGraph.Edges.ToList();
            this.runtimeMuscleList = this.body.modelData.GetSpringByType(
                new List <Spring.Type> {
                Spring.Type.MuscleBack,
                Spring.Type.MuscleMiddle,
                Spring.Type.MuscleFront
            }
                );

            this.runtimeFinList = this.body.modelData.FishPectoralFins;
        }
                    public float Evaluate(Vector <float> input)
                    {
                        if (this.isDirty)
                        {
                            var logger = new FishLogger();
                            var useSim = true;
                            if (useSim)
                            {
                                //start new simulation to get trajactory
                                var body    = GeometryFunctions.Load();
                                var problem = new FishSimulatorOffline.Problem(body, this.activationData);
                                var dt      = new IterationDelta();
                                var sim     = new FishSimulatorOffline(problem, dt);
                                sim.TryToRun();
                                // wait to finish
                                var sol = sim.CurrentSolution as FishSimulatorOffline.Solution;
                                while (sol.IsDone == false)
                                {
                                }
                                logger = sol.logger.DeepCopy();
                                sim.Dispose();
                            }

                            var e = GetCurrentE(logger, this.activationData);

                            this.LatestE = e;
                            this.isDirty = false;

                            // Debug.Log("end with e = " + this.LatestE);
                        }
                        //cal new E from RandomX2FDiscreteFunction and trajactory

                        return(this.LatestE);
                    }
Exemplo n.º 3
0
 public void Init()
 {
     this.modelData = GeometryFunctions.Load(this.modelFileName);
 }