Skip to content

Commit

Permalink
Mods for 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rklasky committed Feb 6, 2023
1 parent 93ca158 commit 212214e
Show file tree
Hide file tree
Showing 32 changed files with 2,149 additions and 40,858 deletions.
23 changes: 15 additions & 8 deletions MSSPM_GuiDiagnostic/nmfDiagnosticTab01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,6 @@ nmfDiagnostic_Tab1::calculateFitness(const int& SpeciesOrGuildNum,
isAggProdStr,growthParameters,
offset,GrowthRateOffset,GrowthRateShapeOffset,GrowthRateCovarOffset,
CarryingCapacityOffset,CarryingCapacityCovarOffset);
//std::cout << "GrowthRateOffset: " << GrowthRateOffset << std::endl;
//std::cout << "GrowthRateCovarOffset: " << GrowthRateCovarOffset << std::endl;
//std::cout << "CarryingCapacityOffset: " << CarryingCapacityOffset << std::endl;
//std::cout << "CarryingCapacityCovarOffset: " << CarryingCapacityCovarOffset << std::endl;

offset = CarryingCapacityCovarOffset;
loadHarvestParameters(NumSpeciesOrGuilds,Algorithm,Minimizer,ObjectiveCriterion,Scaling,
Expand All @@ -809,15 +805,26 @@ nmfDiagnostic_Tab1::calculateFitness(const int& SpeciesOrGuildNum,
offset += competitionParameters.size();
loadPredationParameters(NumSpeciesOrGuilds,Algorithm,Minimizer,ObjectiveCriterion,Scaling,isAggProdStr,predationParameters);
offset += predationParameters.size();
// SurveyQOffset = offset;
loadOutputParameters(nmfConstantsMSSPM::TableOutputSurveyQ,NumSpeciesOrGuilds,
Algorithm,Minimizer,ObjectiveCriterion,Scaling,isAggProdStr,surveyQParameters);
Algorithm,Minimizer,ObjectiveCriterion,Scaling,isAggProdStr,
surveyQParameters);
SurveyQCovarOffset = offset + surveyQParameters.size();
loadOutputParameters(nmfConstantsMSSPM::TableOutputSurveyQCovariateCoeffs,NumSpeciesOrGuilds,
Algorithm,Minimizer,ObjectiveCriterion,Scaling,isAggProdStr,surveyQCovCoeffParameters);
//qDebug() << "RSK - TBD implement surveyQCovCoeff logic";
//qDebug() << "SurveyQCovarOffset: " << SurveyQCovarOffset;

// Check that no survey q numbers are 0
for (unsigned i=0; i<surveyQParameters.size(); ++i) {
if (surveyQParameters[i] == 0) {
msg = "Error: Found Survey Q value of 0 for Species: " + std::to_string(i) + ".";
msg += " Check the outputsurveyq table for a 0 value. If found, investigate why. ";
msg += "It could be the format used to write the values to the table is inadequate.";
m_Logger->logMsg(nmfConstants::Error,msg);
return -1;
}
}

// Append all of the Estimated Parameters to: parameters
InitBiomassOffset = parameters.size();
nmfUtils::append(initBiomassParameters,parameters);
Expand Down Expand Up @@ -1300,7 +1307,7 @@ nmfDiagnostic_Tab1::updateParameterTable(const int& NumSpeciesOrGuilds,
",'" + std::get<0>(DiagnosticTupleVector[m]).toStdString() +
"'," + QString::number(std::get<1>(DiagnosticTupleVector[m])).toStdString() +
"," + QString::number(std::get<2>(DiagnosticTupleVector[m])).toStdString() +
"," + QString::number(std::get<3>(DiagnosticTupleVector[m])).toStdString() + "),";
"," + QString::number(std::get<3>(DiagnosticTupleVector[m]),'f',6).toStdString() + "),";
}
cmd = cmd.substr(0,cmd.size()-1);
errorMsg = m_DatabasePtr->nmfUpdateDatabase(cmd);
Expand Down Expand Up @@ -1358,7 +1365,7 @@ nmfDiagnostic_Tab1::updateParameterTable(const std::string& Algorithm,
"','" + SurfaceType +
"'," + QString::number(std::get<1>(DiagnosticTupleVector[m])).toStdString() +
"," + QString::number(std::get<2>(DiagnosticTupleVector[m])).toStdString() +
"," + QString::number(std::get<3>(DiagnosticTupleVector[m])).toStdString() + "),";
"," + QString::number(std::get<3>(DiagnosticTupleVector[m]),'f',6).toStdString() + "),";
++m;
}
cmd = cmd.substr(0,cmd.size()-1);
Expand Down
35 changes: 18 additions & 17 deletions MSSPM_GuiEstimation/nmfEstimationTab01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,17 +1094,18 @@ nmfEstimation_Tab1::isInitBiomassLessThanSpeciesKMin(const bool& showPopup)
SpeciesKMin = valueWithoutComma.toDouble();

if (InitBiomass > SpeciesKMin) {
briefMsg = "InitBiomass must be less than SpeciesKMin.";
errorMsg = "\nFound: InitBiomass (" + QString::number(InitBiomass).toStdString() +
") > SpeciesKMin (" + QString::number(SpeciesKMin).toStdString() +
briefMsg = "InitBiomass should be less than SpeciesKMin.";
errorMsg = "\nFound: InitBiomass (" + QString::number(InitBiomass,'f',6).toStdString() +
") > SpeciesKMin (" + QString::number(SpeciesKMin,'f',6).toStdString() +
") for Species: " + SpeName.toStdString();
errorMsg += "\n\n" + briefMsg + "\n";
errorMsg += "\n\n" + briefMsg +
"\n\nThis is allowed, but please recheck all species and confirm that this is what's desired.\n";
m_Logger->logMsg(nmfConstants::Error,"nmfEstimation_Tab1::isInitBiomassLessThanSpeciesKMin: " + briefMsg);
if (showPopup) {
QMessageBox::warning(Estimation_Tabs,"Warning", QString::fromStdString(errorMsg),
QMessageBox::Ok);
}
return false;
return true;
}
}
return true;
Expand Down Expand Up @@ -1312,18 +1313,18 @@ nmfEstimation_Tab1::savePopulationParameters(const bool& showPopup)
cmd += "InitBiomass=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["InitBiomass"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "InitBiomassMin=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["InitBiomassMin"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "InitBiomassMax=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["InitBiomassMax"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRate=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRate"]).data().toString().remove(",") + ",";
cmd += "GrowthRateMin=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRateMin"]).data().toString().remove(",") + ",";
cmd += "GrowthRateMax=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRateMax"]).data().toString().remove(",") + ",";
cmd += "GrowthRateShape=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShape"]).data().toString().remove(",") + ",";
cmd += "GrowthRateShapeMin=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShapeMin"]).data().toString().remove(",") + ",";
cmd += "GrowthRateShapeMax=" + m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShapeMax"]).data().toString().remove(",") + ",";
cmd += "SpeciesK=" + m_SpeciesModel->index(i,m_ColumnMap["SpeciesK"]).data().toString().remove(",") + ",";
cmd += "SpeciesKMin=" + m_SpeciesModel->index(i,m_ColumnMap["SpeciesKMin"]).data().toString().remove(",") + ",";
cmd += "SpeciesKMax=" + m_SpeciesModel->index(i,m_ColumnMap["SpeciesKMax"]).data().toString().remove(",") + ",";
cmd += "SurveyQ=" + m_SpeciesModel->index(i,m_ColumnMap["SurveyQ"]).data().toString().remove(",") + ",";
cmd += "SurveyQMin=" + m_SpeciesModel->index(i,m_ColumnMap["SurveyQMin"]).data().toString().remove(",") + ",";
cmd += "SurveyQMax=" + m_SpeciesModel->index(i,m_ColumnMap["SurveyQMax"]).data().toString().remove(",") + ",";
cmd += "GrowthRate=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRate"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRateMin=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRateMin"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRateMax=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRateMax"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRateShape=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShape"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRateShapeMin=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShapeMin"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "GrowthRateShapeMax=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["GrowthRateShapeMax"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "SpeciesK=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SpeciesK"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "SpeciesKMin=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SpeciesKMin"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "SpeciesKMax=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SpeciesKMax"]).data().toString().remove(",").toDouble(),'f',6) + ",";
cmd += "SurveyQ=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SurveyQ"]).data().toString().remove(",").toDouble(),'f',16) + ",";
cmd += "SurveyQMin=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SurveyQMin"]).data().toString().remove(",").toDouble(),'f',16) + ",";
cmd += "SurveyQMax=" + QString::number(m_SpeciesModel->index(i,m_ColumnMap["SurveyQMax"]).data().toString().remove(",").toDouble(),'f',16) + ",";
cmd += "Catchability=" + m_SpeciesModel->index(i,m_ColumnMap["Catchability"]).data().toString().remove(",") + ",";
cmd += "CatchabilityMin=" + m_SpeciesModel->index(i,m_ColumnMap["CatchabilityMin"]).data().toString().remove(",") + ",";
cmd += "CatchabilityMax=" + m_SpeciesModel->index(i,m_ColumnMap["CatchabilityMax"]).data().toString().remove(",");
Expand Down
2 changes: 1 addition & 1 deletion MSSPM_GuiEstimation/nmfEstimationTab05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ nmfEstimation_Tab5::updateInitialObservedBiomass(const std::string& tableName,
initObsBiomassValue = (tableName == nmfConstantsMSSPM::TableBiomassAbsolute) ?
initAbsBiomass :
initSurveyQ * initAbsBiomass;
item = new QStandardItem(QString::number(initObsBiomassValue));
item = new QStandardItem(QString::number(initObsBiomassValue,'f',6));
item->setTextAlignment(Qt::AlignCenter);
smodel->setItem(0, j, item);
for (int k=1; k<RunLength; ++k) {
Expand Down
22 changes: 11 additions & 11 deletions MSSPM_GuiEstimation/nmfEstimationTab06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ nmfEstimation_Tab6::saveCovariateTable()
valueScaled.clear();
if (! value.isEmpty()) {
// valueScaled = (diff == 0.0) ? "0.0" : QString::number(2.0*(value.toDouble()-min)/diff - 1.0); // scales from -1 to 1
valueScaled = (diff == 0.0) ? "0.0" : QString::number((value.toDouble()-min)/diff); // scales from 0 to 1
valueScaled = (diff == 0.0) ? "0.0" : QString::number((value.toDouble()-min)/diff,'f',6); // scales from 0 to 1
}
saveCmd += "('" + m_ProjectName +
"','" + m_ModelName +
Expand Down Expand Up @@ -1108,9 +1108,9 @@ nmfEstimation_Tab6::populateCells(const double& initial,
for (int col=0; col<numCols; col+=3) {
item = m_smodelIR->item(row,col);
if (item->isEditable()) {
initialItem = new QStandardItem(QString::number(initial));
minItem = new QStandardItem(QString::number(min));
maxItem = new QStandardItem(QString::number(max));
initialItem = new QStandardItem(QString::number(initial,'f',6));
minItem = new QStandardItem(QString::number(min,'f',6));
maxItem = new QStandardItem(QString::number(max,'f',6));
initialItem->setTextAlignment(Qt::AlignCenter);
minItem->setTextAlignment(Qt::AlignCenter);
maxItem->setTextAlignment(Qt::AlignCenter);
Expand All @@ -1129,13 +1129,13 @@ nmfEstimation_Tab6::populateCells(const double& initial,
if (item->isEditable()) {
switch (col%3) {
case 0:
item->setText(QString::number(initial));
item->setText(QString::number(initial,'f',6));
break;
case 1:
item->setText(QString::number(min));
item->setText(QString::number(min,'f',6));
break;
case 2:
item->setText(QString::number(max));
item->setText(QString::number(max,'f',6));
break;
}
}
Expand Down Expand Up @@ -1495,13 +1495,13 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "min only")) {
newValue = valueWithoutComma.toDouble()*(1.0-pctVal);
minItem = new QStandardItem(QString::number(newValue));
minItem = new QStandardItem(QString::number(newValue,'f',6));
minItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col+1,minItem);
}
if ((rangeType == "min/max") || (rangeType == "max only")) {
newValue = valueWithoutComma.toDouble()*(1.0+pctVal);
maxItem = new QStandardItem(QString::number(newValue));
maxItem = new QStandardItem(QString::number(newValue,'f',6));
maxItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col+2,maxItem);
}
Expand All @@ -1520,7 +1520,7 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "min only")) {
newValue = valueWithoutComma.toDouble()*(1.0-pctVal);
minItem = new QStandardItem(QString::number(newValue));
minItem = new QStandardItem(QString::number(newValue,'f',6));
minItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col,minItem);
}
Expand All @@ -1530,7 +1530,7 @@ nmfEstimation_Tab6::callback_SpeciesRangeSB(int pct)
valueWithoutComma = initialIndex.data().toString().remove(",");
if ((rangeType == "min/max") || (rangeType == "max only")) {
newValue = valueWithoutComma.toDouble()*(1.0+pctVal);
maxItem = new QStandardItem(QString::number(newValue));
maxItem = new QStandardItem(QString::number(newValue,'f',6));
maxItem->setTextAlignment(Qt::AlignCenter);
m_smodelIR->setItem(row,col,maxItem);
}
Expand Down
Loading

0 comments on commit 212214e

Please sign in to comment.