LANDIS-II-Foundation / Extension-Base-Harvest

Base Harvest extension for the LANDIS-II landscape change model.
https://sites.google.com/site/landismodel/extensions/base-harvest
Apache License 2.0
0 stars 7 forks source link

Widgets replicator fails after initial run #5

Closed lbross closed 6 years ago

lbross commented 8 years ago

Internal error occurred within the program: The given key was not present in the dictionary.

Stack trace: at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Landis.Library.SiteHarvest.CohortCounts.get_Item(ISpecies species) at Landis.Extension.BaseHarvest.PlugIn.WriteLogEntry(ManagementArea mgmtArea, Stand stand) at Landis.Extension.BaseHarvest.PlugIn.Run() at Landis.Model.Run(ExtensionMain extension) at Landis.Model.Run(String scenarioPath, IUserInterface ui) at Replicator.Replicator.BtnRun_Click(Object sender, EventArgs e)

lbross commented 8 years ago

I suspect this error was introduced in v3.0 of the harvest extensions. It was not a problem when the Widgets were written in summer 2014. Something in the stand.DamageTable is not being cleared out or populated when the simulation runs multiple times. This is not a problem for the Launcher or the command line interface. This is likely a problem with Biomass Harvest too although I have not confirmed this.

lbross commented 8 years ago

This may be due to the Model.Core in the site-harvest-library not being re-initialized after the model is re-initialized. There is code in the site-harvest lib to only initialize once. Checking with Jimm.

lbross commented 8 years ago

There is a working solution to this issue checked into the Widgets branch. It requires new versions of the core, site-harvest-lib, and harvest-mgmt-lib. Changes to these shared libraries need to be approved by the TAC. The land-use extension should also be calling the new CleanUp() method because it could run into the same issue when used with the replicator. Also Biomass Harvest.

bmarron18 commented 7 years ago

Recent changes to fix the Widgets issue has prevented BaseHarvest from rebuilding in Visual Studio:

C:\Users\bmarr\Desktop\BaseHarvest\Extension-Base-Harvest\src\PlugIn.cs(300,45,300,53): error CS0117: 'Main' does not contain a definition for 'ResetLib' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

bmarron18 commented 7 years ago

ResetLib() for InitilizePhase2() and CleanUp() methods were added to Library-Site-Harvest and Landis.Library.SiteHarvest-v1.dll was rebuilt. The freshly-rebuilt Landis.Library.SiteHarvest-v1.dll was included in a rebuild of Base Harvest (Landis.Extension.BaseHarvest.dll) and a rebuild of the Base Harvest installer. Base Harvest was uninstalled and re-installed. QAQC_Example, AgeOnlySuccession_s1e1 (which calls Base Harvest) was opened in the widget, Landis-II Replicator. Two replicate runs were selected. The first run was completed; the second run failed. The errorLog.txt gives the following:

Internal error occurred within the program: The given key was not present in the dictionary.

Stack trace: at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Landis.Library.SiteHarvest.CohortCounts.get_Item(ISpecies species) at Landis.Extension.BaseHarvest.PlugIn.WriteLogEntry(ManagementArea mgmtArea, Stand stand) at Landis.Extension.BaseHarvest.PlugIn.Run() at Landis.Model.Run(ExtensionMain extension) at Landis.Model.Run(String scenarioPath, IUserInterface ui) at Replicator.Replicator.BtnRun_Click(Object sender, EventArgs e)

rmscheller commented 6 years ago

Widgets will be retired as soon as Bruce gives us R code.