本文整理汇总了C#中Parameters.ReadExcelFile方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.ReadExcelFile方法的具体用法?C# Parameters.ReadExcelFile怎么用?C# Parameters.ReadExcelFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.ReadExcelFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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);
}
示例3: 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();
}
}
示例4: Run
//.........这里部分代码省略.........
lDimYearCsv.Write(";");
lDimYearCsv.Write(lYearStr.Substring(0, 2));
lDimYearCsv.Write("xx;");
lDimYearCsv.Write(lYearStr.Substring(0, 3));
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);
示例5: 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();
}
}