public MyLocalVariableHistory(MyRootDecisionSpace rds, MyModuleParams setup, IDecisionSpace ds) { m_rds = rds; m_setup = setup; changes = new Dictionary <int, float>(); // all potential variables added by default for (int i = 0; i < rds.VarManager.GetMaxVariables(); i++) { changes.Add(i, INIT_VAL); } }
/// <summary> /// Size is given by the no of variables , but only in case that the variable is contained in the ds. /// </summary> /// <returns></returns> private int ReadSize(IDecisionSpace ds, MyVariable v, int varInd, String predictorName) { if (ds.IsVariableIncluded(varInd)) { if (variableWarned.ContainsKey(predictorName + v.GetLabel())) { variableWarned.Remove(predictorName + v.GetLabel()); } return(v.Values.Count); } if (!variableWarned.ContainsKey(predictorName + v.GetLabel())) { variableWarned.Add(predictorName + v.GetLabel(), v); MyLog.DEBUG.WriteLine("Observer Warning: variable " + v.GetLabel() + " not contained in the DS: " + predictorName); } return(1); }
public static T Execute(Func <T, double> target, IDecisionSpace <T> space, HLOptions opt) { _flog.Clear(); double eps = opt.Eps; T x = space.GetStarted(); double f = target(x); _flog.Add(f); do { bool found = false; for (int i = 0; i < opt.K; i++) { T y = space.GetNext(x, eps); double fNew = target(y); if (fNew < f) { f = fNew; x = y; found = true; _flog.Add(f); //System.Console.WriteLine(x.ToString() + " " + f); break; } } if (found) { eps *= opt.Inc; } else { eps *= opt.Dec; } } while (eps > opt.Min); return(x); }
public MyLocalVariableHistory(MyRootDecisionSpace rds, MyModuleParams setup, IDecisionSpace ds) { m_rds = rds; m_setup = setup; changes = new Dictionary<int, float>(); // all potential variables added by default for (int i = 0; i < rds.VarManager.GetMaxVariables(); i++) { changes.Add(i, INIT_VAL); } }