本文整理汇总了C#中Parameters.GetBestGuess方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.GetBestGuess方法的具体用法?C# Parameters.GetBestGuess怎么用?C# Parameters.GetBestGuess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.GetBestGuess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
// Load parameters
var parameters = new Parameters();
parameters.ReadExcelFile(@"Data\Parameter - base.xlsm");
// Get best guess parameter values
var parameterValues = parameters.GetBestGuess();
// Create a new model that inits itself from the parameters just loaded
var model = new Esmf.Model.ModelTyped<FundWorkflow>();
// Run the model
var rs = model.Run(parameterValues);
// Display all variables in interactive window
OutputHelper.ShowModel(rs);
}
示例2: Run
public void Run()
{
// Load parameters
var parameters = new Parameters();
parameters.ReadDirectory(@"Data\Base");
// Get best guess parameter values
var parameterValues = parameters.GetBestGuess();
// Create a new model that inits itself from the parameters just loaded
var model = FundModel.GetModel();
// Run the model
var rs = model.Run(parameterValues);
// Display all variables in interactive window
OutputHelper.ShowModel(rs);
}
示例3: Run
public static void Run()
{
int monteCarloRuns = 10000;
// Load parameters
var parameters = new Parameters();
parameters.ReadExcelFile(@"Data\Parameter - base.xlsm");
// Do one best guess run
{
var model = new Esmf.Model.ModelTyped<FundWorkflow>();
//var model = new FundWorkflow(parameters.GetBestGuess());
model.Run(parameters.GetBestGuess());
}
int currentRun = 0;
var stopwatch = new Stopwatch();
stopwatch.Start();
ParallelMonteCarlo.DoParallelRun(
parameters,
monteCarloRuns,
p =>
{
var m = new Esmf.Model.ModelTyped<FundWorkflow>();
m.Run(p);
int tempCurrentCount = Interlocked.Increment(ref currentRun);
Console.Write("\rRun {0} ", tempCurrentCount);
return 0.0;
},
d => 0.0);
stopwatch.Stop();
Console.WriteLine();
Console.WriteLine(stopwatch.Elapsed);
}
示例4: TestMigrationDeterministic
public void TestMigrationDeterministic()
{
var parameterDefinition = new Parameters();
parameterDefinition.ReadExcelFile("Parameter - Base.xlsm");
var p = parameterDefinition.GetBestGuess();
var m = new Esmf.Model.ModelTyped<FundWorkflow>();
var res = m.Run(p);
var c = new Clock(Timestep.FromYear(1951), Timestep.FromYear(2999));
while (!c.IsLastTimestep)
{
var regions = res.Dimensions.GetValues<Region>();
double totalLeave = (from r in regions select res.RootComponent.ImpactSeaLevelRise.leave[c.Current, r]).Sum();
double totalEnter = (from r in regions select res.RootComponent.ImpactSeaLevelRise.enter[c.Current, r]).Sum();
Assert.IsTrue(Math.Abs(totalLeave - totalEnter) < 1.0, "Migration doesn't even out");
c.Advance();
}
}
示例5: Run
//.........这里部分代码省略.........
lDimYearCsv.Write("x;");
lDimYearCsv.Write(lYearStr.Substring(0, 4));
lDimYearCsv.WriteLine();
}
}
var lDimEmissionYear = new ConcurrentBag<Timestep>();
if (lSimulationManager.OutputInputParameters)
{
lGlobalInputCsv = TextWriter.Synchronized(new StreamWriter(Path.Combine(ConsoleApp.OutputPath, "Output - Fact Parameter.csv")));
lRegionInputCsv = TextWriter.Synchronized(new StreamWriter(Path.Combine(ConsoleApp.OutputPath, "Output - Fact ParameterRegion.csv")));
lYearInputCsv = TextWriter.Synchronized(new StreamWriter(Path.Combine(ConsoleApp.OutputPath, "Output - Fact ParameterYear.csv")));
lRegionYearInputCsv = TextWriter.Synchronized(new StreamWriter(Path.Combine(ConsoleApp.OutputPath, "Output - Fact ParameterYearRegion.csv")));
}
if (lSimulationManager.RunParallel && !lSimulationManager.SameRandomStreamPerRun)
{
throw new ArgumentException("Cannot run in parallel but without random stream per run");
}
var parallelOptions = new System.Threading.Tasks.ParallelOptions()
{
MaxDegreeOfParallelism = lSimulationManager.RunParallel ? -1 : 1
};
if (lSimulationManager.RunParallel)
{
var parameterDefinition = new Parameters();
parameterDefinition.ReadExcelFile(@"Data\Parameter - base.xlsm");
// Create a new model that inits itself from the parameters just loaded
var model = new Esmf.Model.ModelTyped<FundWorkflow>();
model.Run(parameterDefinition.GetBestGuess());
}
System.Threading.Tasks.Parallel.ForEach<Run, object>(
lSimulationManager.Runs,
parallelOptions,
() =>
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
return null;
},
(lRun, loopState, dummy) =>
{
var tlRandom = lSimulationManager.SameRandomStreamPerRun ? GetNewRandom(lSimulationManager) : lRandom;
var lParam = new Parameters();
foreach (string filename in lRun.Scenario.ExcelFiles)
lParam.ReadExcelFile(filename);
Console.WriteLine(lRun.Scenario.Name);
if (lRun.Mode == RunMode.MarginalRun)
{
var lMarginalRun = new TMarginalRun(lRun, lRun.MarginalGas, lRun.EmissionYear, ConsoleApp.OutputPath, lParam, lRandom);
lDimEmissionYear.Add(lRun.EmissionYear);
lMarginalRun.AggregateDamageCsv = lAggregateMarginalDamage;
lMarginalRun.SummaryCsv = lSummaryDamage;
if (lRun.OutputDisaggregatedData)
示例6: GetSCGasMonteCarlo
private static Tuple<double, double> GetSCGasMonteCarlo(MarginalGas gas, double prtp, bool equityWeights, int monteCarloRuns)
{
var parameters = new Parameters();
parameters.ReadDirectory(@"Data\Base");
var fm = FundModel.GetModel();
fm.Run(parameters.GetBestGuess());
var rand = new jp.takel.PseudoRandom.MersenneTwister();
var sccs = new System.Collections.Concurrent.ConcurrentBag<double>();
Parallel.ForEach(parameters.GetRandom(rand, monteCarloRuns), pv =>
{
var m = new MarginalDamage3()
{
EmissionYear = Timestep.FromYear(2010),
Eta = 1.0,
Gas = gas,
Parameters = pv,
Prtp = prtp,
UseEquityWeights = equityWeights,
YearsToAggregate = 290
};
double scc = m.Start();
sccs.Add(scc);
});
var stats = new DescriptiveStatistics(sccs);
return Tuple.Create(stats.Mean, Math.Sqrt(stats.Variance) / Math.Sqrt(stats.Count));
}
示例7: GetSCGas
private static double GetSCGas(MarginalGas gas, double prtp, bool equityWeights)
{
var parameters = new Parameters();
parameters.ReadDirectory(@"Data\Base");
var m = new MarginalDamage3()
{
EmissionYear = Timestep.FromYear(2010),
Eta = 1.0,
Gas = gas,
Parameters = parameters.GetBestGuess(),
Prtp = prtp,
UseEquityWeights = equityWeights
};
double scc = m.Start();
return scc;
}
示例8: TestMigrationProbabalistic
public void TestMigrationProbabalistic()
{
var parameterDefinition = new Parameters();
parameterDefinition.ReadExcelFile("Parameter - Base.xlsm");
var p = parameterDefinition.GetBestGuess();
var m = FundModel.GetModel();
var res = m.Run(p);
var c = new Clock(Timestep.FromYear(1951), Timestep.FromYear(2999));
while (!c.IsLastTimestep)
{
var regions = res.Dimensions.GetValues<Region>();
double totalLeave = (from r in regions select (double)res["ImpactSeaLevelRise", "leave"][c.Current, r]).Sum();
double totalEnter = (from r in regions select (double)res["ImpactSeaLevelRise", "enter"][c.Current, r]).Sum();
Assert.IsTrue(Math.Abs(totalLeave - totalEnter) < 1.0, "Migration doesn't even out");
c.Advance();
}
}