From 05e0816d04d1f118f38452f274476cc81424df4f Mon Sep 17 00:00:00 2001 From: Ron Date: Tue, 21 Feb 2023 09:56:15 -0500 Subject: [PATCH] Mods for 1.6.1 --- MSSPM_GuiEstimation/nmfEstimationTab02.cpp | 15 ++-- MSSPM_Main/nmfMainWindow.cpp | 7 +- .../NLopt_Estimator.cpp | 49 ++++++++---- MSSPM_SimulatedData/nmfSimulatedData.cpp | 78 +++++++++---------- 4 files changed, 86 insertions(+), 63 deletions(-) diff --git a/MSSPM_GuiEstimation/nmfEstimationTab02.cpp b/MSSPM_GuiEstimation/nmfEstimationTab02.cpp index e1c5c75..67c0b0f 100755 --- a/MSSPM_GuiEstimation/nmfEstimationTab02.cpp +++ b/MSSPM_GuiEstimation/nmfEstimationTab02.cpp @@ -904,7 +904,8 @@ nmfEstimation_Tab2::saveFitWeights(const bool& verbose) std::string tableName = nmfConstantsMSSPM::TableFitWeights; std::string cmd; std::string errorMsg = m_DatabasePtr->nmfUpdateDatabase(cmd); - QModelIndex indexBiomass,indexCatch; + std::string biomassStr = ""; + std::string catchStr = ""; QStringList SpeciesList; QStandardItemModel* smodel = qobject_cast(Estimation_Tab2_WeightsFTCTV->model()); @@ -936,12 +937,16 @@ nmfEstimation_Tab2::saveFitWeights(const bool& verbose) cmd = "INSERT INTO " + tableName + " (ProjectName,ModelName,SpeName,Biomass,Catch) VALUES "; for (int i=0; irowCount(); ++i) { // Species - indexBiomass = smodel->index(i,0); - indexCatch = smodel->index(i,1); + biomassStr = smodel->index(i,0).data().toString().toStdString(); + catchStr = smodel->index(i,1).data().toString().toStdString(); + if (biomassStr.empty() || catchStr.empty()) { + biomassStr = "1.0"; + catchStr = "0.0"; + } cmd += "('" + m_ProjectName + "','" + m_ModelName + "','" + SpeciesList[i].toStdString() + - "', " + indexBiomass.data().toString().toStdString() + - ", " + indexCatch.data().toString().toStdString() + "),"; + "', " + biomassStr + + ", " + catchStr + "),"; } cmd = cmd.substr(0,cmd.size()-1); diff --git a/MSSPM_Main/nmfMainWindow.cpp b/MSSPM_Main/nmfMainWindow.cpp index bc5278c..9dd0638 100755 --- a/MSSPM_Main/nmfMainWindow.cpp +++ b/MSSPM_Main/nmfMainWindow.cpp @@ -2161,7 +2161,7 @@ void nmfMainWindow::menu_about() { QString name = "Multi-Species Surplus Production Model"; - QString version = "MSSPM v1.6.0 "; + QString version = "MSSPM v1.6.1 "; QString specialAcknowledgement = ""; QString cppVersion = "C++??"; QString mysqlVersion = "?"; @@ -6170,7 +6170,8 @@ nmfMainWindow::updateOutputBiomassTable(std::string& ForecastName, EstCarryingCapacities[species], EstCarryingCapacityCovariateCoeffs[species], CarryingCapacitiesCovariate(timeMinus1,species)); - HarvestTerm = harvestFormPtr->evaluate(CovariateAlgorithmType, + + HarvestTerm = harvestFormPtr->evaluate(CovariateAlgorithmType, timeMinus1,species, EstBiomassTMinus1, Catch,Effort,Exploitation, @@ -11062,7 +11063,7 @@ nmfMainWindow::callback_RunEstimation(bool showDiagnosticsChart) QString multiRunSpeciesFilename; QString multiRunModelFilename; QString msg; -qDebug() <<"isAMultiOrMohnsRhoRun: " << isAMultiRun; + saveSettings(); loadAllWidgets(); readSettings(); diff --git a/MSSPM_ParameterEstimationNLoptAlgorithm/NLopt_Estimator.cpp b/MSSPM_ParameterEstimationNLoptAlgorithm/NLopt_Estimator.cpp index feae89c..0c475e2 100755 --- a/MSSPM_ParameterEstimationNLoptAlgorithm/NLopt_Estimator.cpp +++ b/MSSPM_ParameterEstimationNLoptAlgorithm/NLopt_Estimator.cpp @@ -160,36 +160,45 @@ NLopt_Estimator::extractParameters(const nmfStructsQt::ModelDataStruct& NLoptDat } offset += NumSpeciesOrGuilds; + // Always extract growth rate covariates + for (int i=0; i Num Parameters Extracted: " << offset; // Calculate MSY, BMSY, and FMSY values for (int i=0; i lowerBounds(NumEstParameters); std::vector upperBounds(NumEstParameters); +//qDebug() << "---> Num Parameter Bounds: " << NumEstParameters; + // Set parameter bounds for all parameters for (int i=0; i