/// <summary> /// Provides a model for component. /// </summary> /// <param name="componentName">A component name.</param> /// <param name="simulation">Simulation.</param> /// <param name="model">A model for component.</param> /// <returns> /// If a model is stochastic (dev, lot) then a copy of model with be returned. /// If a model is not stochastic then a raw model is returned. /// </returns> public Model ProvideStochasticModel(string componentName, Simulation simulation, Model model) { if (ModelsGenerators.Any(m => m.Key == model.Name)) { var modelForComponentGenerator = ModelsGenerators.First(m => m.Key == model.Name); string modelId = $"{model.Name}#{componentName}_{simulation.Name}"; var modelForComponent = modelForComponentGenerator.Value(modelId); if (!StochasticModels.ContainsKey(simulation)) { StochasticModels[simulation] = new Dictionary <string, List <Model> >(); } if (!StochasticModels[simulation].ContainsKey(model.Name)) { StochasticModels[simulation][model.Name] = new List <Model>(); } StochasticModels[simulation][model.Name].Add(modelForComponent); return(modelForComponent); } return(model); }
/// <summary> /// Provides a model for component. /// </summary> /// <param name="componentName">A component name.</param> /// <param name="simulation">Simulation.</param> /// <param name="model">A model for component.</param> /// <returns> /// If a model is stochastic (dev, lot) then a copy of model with be returned. /// If a model is not stochastic then a raw model is returned. /// </returns> public Model ProvideStochasticModel(string componentName, BaseSimulation simulation, Model model) { if (ModelsGenerators.ContainsKey(model)) { string modelId = $"{model.Name}#{componentName}_{simulation.Name}"; var modelForComponent = ModelsGenerators[model](modelId); if (!StochasticModels.ContainsKey(simulation)) { StochasticModels[simulation] = new Dictionary <Model, List <Model> >(); } if (!StochasticModels[simulation].ContainsKey(model)) { StochasticModels[simulation][model] = new List <Model>(); } StochasticModels[simulation][model].Add(modelForComponent); return(modelForComponent); } return(model); }
/// <summary> /// Gets the stochastic models. /// </summary> /// <returns> /// A dictionary of base models and their stochastic models. /// </returns> public Dictionary <Model, List <Model> > GetStochasticModels(BaseSimulation simulation) { return(StochasticModels.ContainsKey(simulation) ? StochasticModels[simulation] : new Dictionary <Model, List <Model> >()); }