public void Test() { BaseClass baseClass = TypeLoader.CreateInstance <BaseClass>("DerivedClass"); DerivedClass derivedClass = baseClass as DerivedClass; Assert.IsNotNull(baseClass); Assert.IsNotNull(derivedClass); }
public static NonTerminalNode CreateNode(Rule rule) { Debug.Assert(rule != null); NonTerminalNode node = _implTypes.ContainsKey(rule.Index) ? _implTypes.CreateInstance(rule.Index) : new NonTerminalNode(); node.Rule = rule; return(node); }
public EvaluationWorkerActor(MultiKey islandKey, Type evaluatorType, ParameterSet parameters) { IslandKey = islandKey; ActorPathName = Self.Path.Name; //Calculator = (IEvaluation)Activator.CreateInstance(settings.Fitness); //Calculator.Init(initData); Evaluation = (EvaluationBase)TypeLoader.CreateInstance(evaluatorType, parameters); Parameters = parameters; Receive <InitEvaluator>(m => Init(m.InitData)); Receive <IEntity>(e => Evaluate(e)); }
public static NonTerminalNode CreateNode(Rule rule) { Debug.Assert(rule != null); NonTerminalNode node = null; if (_nodeImplTypeMap.ContainsKey(rule.Index)) { node = _nodeImplTypeMap.CreateInstance(rule.Index); } else { node = new NonTerminalNode();// if no type is bound to the rule then just create a base non-terminal node } node.Rule = rule; return(node); }
public PeaResult Run(PeaSettings settings, IEvaluationInitData initData, LaunchTravelersDelegate launchTravelers = null) { string[] keys = new string[settings.SubProblemList.Count]; for (int i = 0; i < settings.SubProblemList.Count; i++) { keys[i] = settings.SubProblemList[i].Encoding.Key; } Key = new MultiKey(keys); var islandEngine = IslandEngineFactory.Create(Key, settings, settings.Seed); AddCallbackEvents(islandEngine, settings.NewEntityMergedToBest); Evaluator = (EvaluationBase)TypeLoader.CreateInstance(settings.Evaluation, settings.ParameterSet); Evaluator.Init(initData); islandEngine.Algorithm.SetEvaluationCallback(Evaluate); islandEngine.Init(initData); if (launchTravelers != null) { islandEngine.LaunchTravelers += launchTravelers; } var c = 0; StopDecision stopDecision; while (true) { islandEngine.Algorithm.RunOnce(); stopDecision = islandEngine.StopCriteria.MakeDecision(islandEngine, islandEngine.Algorithm.Population); if (stopDecision.MustStop) { Debug.WriteLine(stopDecision.Reasons[0]); break; } c++; } return(new PeaResult(stopDecision.Reasons, islandEngine.Algorithm.Population.Bests)); }
public IslandActor(Configuration.Implementation.PeaSettings settings, int seed) { var actorPathName = Self.Path.ToString(); Engine = IslandEngineFactory.Create(actorPathName, settings, seed); IslandKey = CreateIslandKey(settings); Engine.Algorithm.SetEvaluationCallback(Evaluate); var evaluatorsCount = Engine.Parameters.GetInt(ParameterNames.EvaluatorsCount); if (evaluatorsCount > 4) { Evaluator = Context.ActorOf(EvaluationSupervisorActor.CreateProps(IslandKey, settings.Evaluation, Engine.Parameters)); } else { LocalEvaluator = (EvaluationBase)TypeLoader.CreateInstance(settings.Evaluation, Engine.Parameters); } Receive <InitEvaluator>(m => InitEvaluator(m)); Receive <Continue>(m => RunOneStep()); Receive <Travel>(m => TravelersArrived(m)); Receive <End>(m => End()); }