public void Remove(IOptimizable item) { lock (this) { _items.Remove(item); } }
public void Add(IOptimizable item) { lock (this) { _items.Add(item); } }
public BruteForceTest(IOptimizable Optimizable) : base(Optimizable) { // Coordinate descent normal constructor fType = EOptimizerType.BruteForce; Console.WriteLine("BruteForceTest Construct"); }
public GPOptimizer(IOptimizable Optimizable) : base(Optimizable) { // Coordinate descent normal constructor fType = EOptimizerType.GeneticAlgorithm; //GPStrategy.SignalInit += OnSignalInit; //GPStrategy.SignalBar += OnSignalBar; //GPStrategy.SignalTrade += OnSignalTrade; //GPStrategy.SignalQuote += OnSignalQuote; //Console.WriteLine("GPOptimizer Construct"); //meta = Optimizable as ATSMetaStrategy; //sb = meta.Strategies["ATS"]; //sb.Global.Add("Individual", null); }
private void PerturbParams() { // Get params from winner and use as basis for perturbing // Only update params if they were better than before, else reuse old if (m_currentBestCandidate > -1) { IOptimizable best = m_optimizables[m_currentBestCandidate]; m_lastBestParams = best.GetParams(); } // Perturb and assign to candidates for (int i = 0; i < m_optimizables.Length; i++) { IOptimizable opt = m_optimizables[i]; List <float> newObjParams = m_changer.change(m_lastBestParams); // Debug.Log("new params for "+i+" sample at i=10: _" + newObjParams[10]+"_"); opt.SetParams(newObjParams); } }
public Optimizer(IOptimizable optimizable) : base() { this.fOptimizable = optimizable; this.Init(); }
public CoordinateDescent(IOptimizable optimizable) : base(optimizable) { this.fType = EOptimizerType.CoordinateDescent; this.DescentStepSize = 0.01; }
public SimulatedAnnealing(IOptimizable Optimizable) : base(Optimizable) { this.ieAakAK1q(); }
void Init() { if (m_sampleCounter == 0) { m_testCount++; Debug.Log("Starting new iteration (no." + m_testCount + ")"); } m_sampleCounter++; Debug.Log("Sample " + m_sampleCounter); GameObject[] controllerObjects = GameObject.FindGameObjectsWithTag("optimizable"); GameObject bestScoreVisualizerObject = GameObject.FindGameObjectWithTag("bestscore"); m_optimizableControllers = new Controller[controllerObjects.Length]; for (int i = 0; i < controllerObjects.Length; i++) { m_optimizableControllers[i] = controllerObjects[i].GetComponent <Controller>(); //Debug.Log("cobjsC" + m_optimizableControllers[i]); } m_bestScoreController = bestScoreVisualizerObject.GetComponent <Controller>(); if (!m_inited) { m_changer = new ParamChanger(); m_currentParams = new List <List <float> >(); m_totalScores = new double[m_optimizableControllers.Length]; // get bounds for perturbation m_paramsMax = m_optimizableControllers[0].GetParamsMax(); m_paramsMin = m_optimizableControllers[0].GetParamsMin(); // StoreParams(); m_lastBestParams = new List <float>(m_currentParams[0]); PerturbParams(2); for (int i = 2; i < m_optimizableControllers.Length; i++) { IOptimizable opt = m_optimizableControllers[i]; List <float> paramslist = new List <float>(); paramslist.AddRange(m_currentParams[i]); //Debug.Log("opt "+opt); // Debug.Log("params " + m_currentParams[i]); opt.ConsumeParams(paramslist); // consume it to controller } ResetScores(); m_inited = true; } else { for (int i = 0; i < m_optimizableControllers.Length; i++) { IOptimizable opt = m_optimizableControllers[i]; //if (opt != null && i<m_currentParams.Count) { List <float> paramslist = new List <float>(); paramslist.AddRange(m_currentParams[i]); //Debug.Log("current params "+m_currentParams[i]); opt.ConsumeParams(paramslist); // consume it to controller } } if (m_bestScoreController && m_lastBestParams != null && m_lastBestParams.Count > 0) { // and the best score visualizer IOptimizable opt = m_bestScoreController; List <float> paramslist = new List <float>(); paramslist.AddRange(m_lastBestParams); opt.ConsumeParams(paramslist); } } }
public BruteForce(IOptimizable optimizable) : base(optimizable) { this.fType = EOptimizerType.BruteForce; }
public BruteForce(IOptimizable optimizable) : base(optimizable) { this.fType = EOptimizerType.BruteForce; }
public CoordinateDescent(IOptimizable optimizable) : base(optimizable) { this.fType = EOptimizerType.CoordinateDescent; this.DescentStepSize = 0.01; }
public SimulatedAnnealing(IOptimizable Optimizable) : base(Optimizable) { this.ieAakAK1q(); }
public Optimizer(IOptimizable optimizable) : base() { this.fOptimizable = optimizable; this.Init(); }