//public void WriteDamage(int RunId, Damage i_Damage, int WeightingschemeId, double Weight, WeightingCombination[] WeightingCombinations) //{ // if (m_YearRegionSectorWeightingSchemeCsv != null) // { // m_YearRegionSectorWeightingSchemeCsv.WriteLine( // (_run.OutputVerbal ? _run.Scenario.Name : _run.Scenario.Id.ToString()) + // ";" + // (_run.OutputVerbal ? (RunId == 0 ? "Best guess" : RunId == -1 ? "Mean" : RunId.ToString()) : RunId.ToString()) + // ";" + // "" + // ";" + // "" + // ";" + // (i_Damage.Year + 1950).ToString() + // ";" + // (_run.OutputVerbal ? LegacyRegionNames.GetName(i_Damage.Region) : i_Damage.Region.ToString()) + // ";" + // (_run.OutputVerbal ? Enum.GetName(typeof(Sector), i_Damage.Sector) : ((int)i_Damage.Sector).ToString()) + // ";" + // (_run.OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString()) + // ";" + // (i_Damage.DamageValue * Weight).ToString("f15") // ); // } //} public TotalDamage(Run runData, string outputPath, Parameters parameters, Timestep emissionYear, Random rand = null) { _parameters = parameters; _run = runData; _outputPath = outputPath; _emissionYear = emissionYear; _rand = rand; }
public TMarginalRun(Run runData, MarginalGas gas, Timestep emissionyear, string outputPath, Parameters parameters, Random rand = null) { _parameters = parameters; _run = runData; _gas = gas; _emissionyear = emissionyear; _outputPath = outputPath; _rand = rand; }
public void Load() { var dom = new System.Xml.XmlDocument(); dom.Load(_fileName); var root = dom.DocumentElement; _randomize = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/Randomize").InnerText); if (root.SelectSingleNode("/Simulation/GlobalParameters/RandomNumberGenerator") != null) { var rngAsString = root.SelectSingleNode("/Simulation/GlobalParameters/RandomNumberGenerator").InnerText.ToLowerInvariant(); switch (rngAsString) { case "dotnet": _rng = RandomNumberGenerator.DotNet; break; case "mersennetwister": _rng = RandomNumberGenerator.MersenneTwister; break; default: throw new InvalidOperationException("The configuration value for the RandomNumberGenerator is not supported"); } } else _rng = RandomNumberGenerator.DotNet; var defaultYearsToAggregate = Convert.ToInt32(root.SelectSingleNode("/Simulation/GlobalParameters/YearsToAggregate").InnerText); var defaultOutputDisaggregated = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/OutputDisaggregatedData").InnerText); var defaultWeightingCombination = root.SelectSingleNode("/Simulation/GlobalParameters/WeightingCombination").InnerText; var defaultMonteCarloRuns = Convert.ToInt32(root.SelectSingleNode("/Simulation/GlobalParameters/MonteCarloRuns").InnerText); _outputVerbal = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/OutputVerbal").InnerText); _outputInputParameters = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/OutputInputParameters").InnerText); if (root.SelectSingleNode("/Simulation/GlobalParameters/SameRandomStreamPerRun") != null) SameRandomStreamPerRun = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/SameRandomStreamPerRun").InnerText); else SameRandomStreamPerRun = false; if (root.SelectSingleNode("/Simulation/GlobalParameters/RunParallel") != null) RunParallel = Convert.ToBoolean(root.SelectSingleNode("/Simulation/GlobalParameters/RunParallel").InnerText); else RunParallel = false; var scenarioNodes = root.SelectNodes("/Simulation/Scenarios/Scenario"); var lScenarios = new Dictionary<string, Scenario>(); var currentScenarioId = 0; foreach (XmlNode scenarioNode in scenarioNodes) { var scenario = new Scenario(); scenario.Name = (scenarioNode as XmlElement).GetAttribute("name"); scenario.Id = currentScenarioId; var excelfileNodes = scenarioNode.SelectNodes("ExcelFile"); foreach (XmlNode excelfileNode in excelfileNodes) { string excelfilename = Path.IsPathRooted(excelfileNode.InnerText) ? excelfileNode.InnerText : Path.Combine(Path.GetDirectoryName(Path.GetFullPath(_fileName)), excelfileNode.InnerText); scenario.ExcelFiles.Add(excelfilename); } lScenarios.Add(scenario.Name, scenario); _scenarios.Add(scenario); currentScenarioId++; } var runNodes = root.SelectNodes("/Simulation/Runs/Run"); foreach (XmlNode runNode in runNodes) { var run = new Run(); run.Scenario = lScenarios[runNode.SelectSingleNode("Scenario").InnerText]; if (runNode.SelectSingleNode("MonteCarloRuns") != null) run.MonteCarloRuns = Convert.ToInt32(runNode.SelectSingleNode("MonteCarloRuns").InnerText); else run.MonteCarloRuns = defaultMonteCarloRuns; switch (runNode.SelectSingleNode("Mode").InnerText) { case "Marginal": run.Mode = RunMode.MarginalRun; break; case "Total": run.Mode = RunMode.TotalRun; break; case "FullMarginal": run.Mode = RunMode.FullMarginalRun; break; default: throw new ApplicationException("Invalid value for Mode in configuration file"); } if (runNode.SelectSingleNode("YearsToAggregate") != null) run.YearsToAggregate = Convert.ToInt32(runNode.SelectSingleNode("YearsToAggregate").InnerText); else run.YearsToAggregate = defaultYearsToAggregate; if (runNode.SelectSingleNode("CalculateMeanForMonteCarlo") != null) run.CalculateMeanForMonteCarlo = Convert.ToBoolean(runNode.SelectSingleNode("CalculateMeanForMonteCarlo").InnerText); else run.CalculateMeanForMonteCarlo = false; if (runNode.SelectSingleNode("OutputAllMonteCarloRuns") != null) run.OutputAllMonteCarloRuns = Convert.ToBoolean(runNode.SelectSingleNode("OutputAllMonteCarloRuns").InnerText); else run.OutputAllMonteCarloRuns = true; if (runNode.SelectSingleNode("WeightingCombination") != null) run.WeightingCombination = runNode.SelectSingleNode("WeightingCombination").InnerText; else run.WeightingCombination = defaultWeightingCombination; if (runNode.SelectSingleNode("OutputDisaggregatedData") != null) run.OutputDisaggregatedData = Convert.ToBoolean(runNode.SelectSingleNode("OutputDisaggregatedData").InnerText); else run.OutputDisaggregatedData = defaultOutputDisaggregated; if (runNode.SelectSingleNode("EmissionYear") != null) run.EmissionYear = Timestep.FromYear(Convert.ToInt32(runNode.SelectSingleNode("EmissionYear").InnerText)); else run.EmissionYear = Timestep.FromYear(2005); if (runNode.SelectSingleNode("MarginalGas") != null) { switch (runNode.SelectSingleNode("MarginalGas").InnerText) { case "C": run.MarginalGas = MarginalGas.C; break; case "CH4": run.MarginalGas = MarginalGas.CH4; break; case "N2O": run.MarginalGas = MarginalGas.N2O; break; case "SF6": run.MarginalGas = MarginalGas.SF6; break; default: throw new ApplicationException("Invalid value for MarginalGas in configuration file"); } } else run.MarginalGas = MarginalGas.C; if (runNode.SelectSingleNode("InitialTax") != null) run.InitialTax = Convert.ToDouble(runNode.SelectSingleNode("InitialTax").InnerText); else run.InitialTax = 0.0; run.OutputVerbal = _outputVerbal; _runs.Add(run); } }