/// <summary>Gets the next job to run</summary> public Simulation NextSimulationToRun(bool fullFactorial = true) { if (allCombinations == null || allCombinations.Count == 0) { return(null); } if (serialisedBase == null) { Initialise(fullFactorial); } var combination = allCombinations[0]; allCombinations.RemoveAt(0); string newSimulationName = Name; foreach (FactorValue value in combination) { newSimulationName += value.Name; } Simulation newSimulation = Apsim.DeserialiseFromStream(serialisedBase) as Simulation; newSimulation.Name = newSimulationName; newSimulation.Parent = null; newSimulation.FileName = parentSimulations.FileName; Apsim.ParentAllChildren(newSimulation); // Make substitutions and issue Loaded event parentSimulations.MakeSubsAndLoad(newSimulation); foreach (FactorValue value in combination) { value.ApplyToSimulation(newSimulation); } PushFactorsToReportModels(newSimulation, combination); StoreFactorsInDataStore(newSimulation, combination); return(newSimulation); }
/// <summary> /// Create a specific simulation. /// </summary> public Simulation CreateSpecificSimulation(string name) { List <List <FactorValue> > allCombinations = AllCombinations(); Simulation baseSimulation = Apsim.Child(this, typeof(Simulation)) as Simulation; Simulations parentSimulations = Apsim.Parent(this, typeof(Simulations)) as Simulations; foreach (List <FactorValue> combination in allCombinations) { string newSimulationName = Name; foreach (FactorValue value in combination) { newSimulationName += value.Name; } if (newSimulationName == name) { Simulation newSimulation = Apsim.Clone(baseSimulation) as Simulation; newSimulation.Name = newSimulationName; newSimulation.Parent = null; newSimulation.FileName = parentSimulations.FileName; Apsim.ParentAllChildren(newSimulation); // Make substitutions and issue "Loaded" event parentSimulations.MakeSubsAndLoad(newSimulation); foreach (FactorValue value in combination) { value.ApplyToSimulation(newSimulation); } PushFactorsToReportModels(newSimulation, combination); return(newSimulation); } } return(null); }