bool CQLNAWidget::saveTask() { CLNATask * pTask = dynamic_cast< CLNATask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); CLNAProblem * pProblem = dynamic_cast< CLNAProblem * >(mpTask->getProblem()); if (!pProblem) return false; if (mpCheckSteadyState->isChecked() != pProblem->isSteadyStateRequested()) { pProblem->setSteadyStateRequested(mpCheckSteadyState->isChecked()); mChanged = true; } assert(CCopasiRootContainer::getDatamodelList()->size() > 0); if (mChanged) CCopasiRootContainer::getDatamodelList()->operator[](0).changed(); mChanged = false; return true; }
/* * Function to save actual changes of the Task */ bool CQCrossSectionTaskWidget::saveTask() { // check the existence of Task CCrossSectionTask * pTask = dynamic_cast< CCrossSectionTask * >(mpTask); if (!pTask) return false; // save functions from the Parent, TaskWidget saveCommon(); saveMethod(); // check the existence of Problem CCrossSectionProblem* pProblem = dynamic_cast<CCrossSectionProblem *>(pTask->getProblem()); assert(pProblem); // save the actual changes if (mpCheckSimConvergence->isChecked()) pProblem->setCrossingsLimit(mpTxtCrossings->text().toULong()); pProblem->setPositiveDirection(mpDirectionPositive->isChecked()); pProblem->setThreshold(mpLineEditValue->text().toDouble()); //if (mpCheckLT->isChecked()) pProblem->setTimeLimit(mpTxtTime->text().toDouble()); pProblem->setSingleObjectCN(mpSingleVariable); pProblem->setFlagLimitOutTime(mpCheckOutputDelay->isChecked()); if (mpCheckOutputDelay->isChecked()) { pProblem->setOutputStartTime(mpTxtOutTime->text().toDouble()); } pProblem->setFlagLimitCrossings(mpCheckSimCrossings->isChecked()); pProblem->setCrossingsLimit(mpTxtCrossings->text().toULong()); pProblem->setFlagLimitOutCrossings(mpCheckOutputCrossings->isChecked()); pProblem->setOutCrossingsLimit(mpTxtOutCrossings->text().toULong()); pProblem->setFlagLimitConvergence(mpCheckSimConvergence->isChecked()); pProblem->setConvergenceTolerance(mpTxtConvergence->text().toDouble()); pProblem->setFlagLimitOutConvergence(mpCheckOutputConvergence->isChecked()); pProblem->setConvergenceOutTolerance(mpTxtOutConvergence->text().toDouble()); mpValidatorCrossing->saved(); mpValidatorTolerance->saved(); mpValidatorOutTolerance->saved(); mpValidatorLC->saved(); mpValidatorOutLC->saved(); mpValidatorTime->saved(); mpValidatorOutTime->saved(); return true; }
bool CQEFMWidget::saveTask() { CEFMTask * pTask = dynamic_cast< CEFMTask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); return true; }
bool CQTSSAWidget::saveTask() { CTSSATask * pTask = dynamic_cast< CTSSATask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); CTSSAProblem* tssaproblem = dynamic_cast<CTSSAProblem *>(pTask->getProblem()); assert(tssaproblem); //numbers if (tssaproblem->getStepSize() != mpEditIntervalSize->text().toDouble()) { tssaproblem->setStepSize(mpEditIntervalSize->text().toDouble()); mChanged = true; } else if (tssaproblem->getStepNumber() != mpEditIntervals->text().toULong()) { tssaproblem->setStepNumber(mpEditIntervals->text().toLong()); mChanged = true; } if (tssaproblem->getDuration() != mpEditDuration->text().toDouble()) { tssaproblem->setDuration(mpEditDuration->text().toDouble()); mChanged = true; } if (tssaproblem->timeSeriesRequested() != mpCheckSave->isChecked()) { tssaproblem->setTimeSeriesRequested(mpCheckSave->isChecked()); mChanged = true; } mpValidatorDuration->saved(); mpValidatorIntervalSize->saved(); return true; }
bool SteadyStateWidget::saveTask() { saveCommon(); saveMethod(); CSteadyStateTask* mSteadyStateTask = dynamic_cast<CSteadyStateTask *>(CCopasiRootContainer::getKeyFactory()->get(mKey)); if (mSteadyStateTask == NULL) return false; CSteadyStateProblem* steadystateproblem = dynamic_cast<CSteadyStateProblem *>(mSteadyStateTask->getProblem()); if (steadystateproblem == NULL) return false; CSteadyStateMethod* steadystatemethod = dynamic_cast<CSteadyStateMethod *>(mSteadyStateTask->getMethod()); if (steadystatemethod == NULL) return false; bool bJacobian = taskJacobian->isChecked(); bool bStatistics = taskStability->isChecked(); steadystateproblem->setJacobianRequested(bJacobian); steadystateproblem->setStabilityAnalysisRequested(bStatistics); if (mChanged) { if (mpDataModel != NULL) { mpDataModel->changed(); } mChanged = false; } return true; }
bool CQTrajectoryWidget::saveTask() { CTrajectoryTask * pTask = dynamic_cast< CTrajectoryTask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); CTrajectoryProblem* trajectoryproblem = dynamic_cast<CTrajectoryProblem *>(pTask->getProblem()); assert(trajectoryproblem); //numbers if (mpEditIntervalSize->hasAcceptableInput() && trajectoryproblem->getStepSize() != mpEditIntervalSize->text().toDouble()) { trajectoryproblem->setStepSize(mpEditIntervalSize->text().toDouble()); mChanged = true; } else if (mpEditIntervals->hasAcceptableInput() && trajectoryproblem->getStepNumber() != mpEditIntervals->text().toULong()) { trajectoryproblem->setStepNumber(mpEditIntervals->text().toLong()); mChanged = true; } if (mpEditDuration->hasAcceptableInput() && trajectoryproblem->getDuration() != mpEditDuration->text().toDouble()) { trajectoryproblem->setDuration(mpEditDuration->text().toDouble()); mChanged = true; } C_FLOAT64 StartTime = mpEditDelay->text().toDouble(); if (mpCheckDelay->isChecked()) { if (mpEditDelay->hasAcceptableInput() && StartTime != trajectoryproblem->getOutputStartTime()) { trajectoryproblem->setOutputStartTime(StartTime); mChanged = true; } } else { assert(CCopasiRootContainer::getDatamodelList()->size() > 0); C_FLOAT64 InitialTime = (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getInitialTime(); if (trajectoryproblem->getStepSize() > 0.0) { if (StartTime > InitialTime) { trajectoryproblem->setOutputStartTime(InitialTime); mChanged = true; } } else { if (StartTime < InitialTime) { trajectoryproblem->setOutputStartTime(InitialTime); mChanged = true; } } } if (trajectoryproblem->timeSeriesRequested() != mpCheckSave->isChecked()) { trajectoryproblem->setTimeSeriesRequested(mpCheckSave->isChecked()); mChanged = true; } mpValidatorDuration->saved(); mpValidatorIntervalSize->saved(); mpValidatorIntervals->saved(); mpValidatorDelay->saved(); return true; }
bool CQFittingWidget::saveTask() { CFitTask * pTask = dynamic_cast< CFitTask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); CFitProblem * pProblem = dynamic_cast<CFitProblem *>(mpTask->getProblem()); if (!pProblem) return false; std::map<std::string, std::string> ExperimentMap; std::map<std::string, std::string> CrossValidationMap; // Save experiment set CExperimentSet * pExperimentSet = dynamic_cast<CExperimentSet *>(pProblem->getGroup("Experiment Set")); std::string Name; CExperiment * pExperiment; size_t i, imax; std::set<CExperiment *> DealtWith; for (i = pExperimentSet->getExperimentCount() - 1; i != C_INVALID_INDEX; i--) { pExperiment = dynamic_cast<CExperiment *>(CCopasiRootContainer::getKeyFactory()->get(mExperimentKeyMap[pExperimentSet->getExperiment(i)->CCopasiParameter::getKey()])); if (pExperiment && pExperiment == mpExperimentSet->getExperiment(pExperiment->getObjectName())) { if (!(*pExperimentSet->getExperiment(i) == *pExperiment)) { *pExperimentSet->getExperiment(i) = *pExperiment; mChanged = true; } DealtWith.insert(pExperiment); } else { mExperimentKeyMap.erase(pExperimentSet->getExperiment(i)->CCopasiParameter::getKey()); pExperimentSet->removeExperiment(i); mChanged = true; } } for (i = 0, imax = mpExperimentSet->getExperimentCount(); i < imax; i++) { pExperiment = mpExperimentSet->getExperiment(i); if (DealtWith.count(pExperiment)) continue; pExperiment = pExperimentSet->addExperiment(*pExperiment); mExperimentKeyMap[pExperiment->CCopasiParameter::getKey()] = mpExperimentSet->getExperiment(i)->CCopasiParameter::getKey(); mChanged = true; } // We need to invert the key map for saving! std::map<std::string, std::string>::iterator it = mExperimentKeyMap.begin(); std::map<std::string, std::string>::iterator end = mExperimentKeyMap.end(); for (; it != end; ++it) ExperimentMap[it->second] = it->first; // Save cross validation experiment set CCrossValidationSet * pCrossValidationSet = dynamic_cast<CCrossValidationSet *>(pProblem->getGroup("Validation Set")); if (pCrossValidationSet->getWeight() != mpCrossValidationSet->getWeight()) { pCrossValidationSet->setWeight(mpCrossValidationSet->getWeight()); mChanged = true; } if (pCrossValidationSet->getThreshold() != mpCrossValidationSet->getThreshold()) { pCrossValidationSet->setThreshold(mpCrossValidationSet->getThreshold()); mChanged = true; } DealtWith.clear(); for (i = pCrossValidationSet->getExperimentCount() - 1; i != C_INVALID_INDEX; i--) { pExperiment = dynamic_cast<CExperiment *>(CCopasiRootContainer::getKeyFactory()->get(mCrossValidationKeyMap[pCrossValidationSet->getExperiment(i)->CCopasiParameter::getKey()])); if (pExperiment && pExperiment == mpCrossValidationSet->getExperiment(pExperiment->getObjectName())) { if (!(*pCrossValidationSet->getExperiment(i) == *pExperiment)) { *pCrossValidationSet->getExperiment(i) = *pExperiment; mChanged = true; } DealtWith.insert(pExperiment); } else { mCrossValidationKeyMap.erase(pCrossValidationSet->getExperiment(i)->CCopasiParameter::getKey()); pCrossValidationSet->removeExperiment(i); mChanged = true; } } for (i = 0, imax = mpCrossValidationSet->getExperimentCount(); i < imax; i++) { pExperiment = mpCrossValidationSet->getExperiment(i); if (DealtWith.count(pExperiment)) continue; pExperiment = pCrossValidationSet->addExperiment(*pExperiment); mCrossValidationKeyMap[pExperiment->CCopasiParameter::getKey()] = mpCrossValidationSet->getExperiment(i)->CCopasiParameter::getKey(); mChanged = true; } // We need to invert the key map for saving! it = mCrossValidationKeyMap.begin(); end = mCrossValidationKeyMap.end(); for (; it != end; ++it) CrossValidationMap[it->second] = it->first; if (mpCheckRandomize->isChecked() != pProblem->getRandomizeStartValues()) { mChanged = true; pProblem->setRandomizeStartValues(mpCheckRandomize->isChecked()); } if (mpCreateParameterSets->isChecked() != pProblem->getCreateParameterSets()) { mChanged = true; pProblem->setCreateParameterSets(mpCreateParameterSets->isChecked()); } if (mpCheckStatistics->isChecked() != pProblem->getCalculateStatistics()) { mChanged = true; pProblem->setCalculateStatistics(mpCheckStatistics->isChecked()); } mChanged |= mpParameters->save(&ExperimentMap, &CrossValidationMap); mChanged |= mpConstraints->save(&ExperimentMap, &CrossValidationMap); assert(mpDataModel != NULL); if (mChanged) mpDataModel->changed(); mChanged = false; return true; }
bool CQOptimizationWidget::saveTask() { COptTask * pTask = dynamic_cast< COptTask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); COptProblem * pProblem = dynamic_cast<COptProblem *>(mpTask->getProblem()); if (!pProblem) return false; // expression if (pProblem->getObjectiveFunction() != mpExpressionEMW->mpExpressionWidget->getExpression()) { if (!pProblem->setObjectiveFunction(mpExpressionEMW->mpExpressionWidget->getExpression())) { CCopasiMessage(CCopasiMessage::ERROR, MCOptimization + 5); return false; } mChanged = true; } if (mpBoxSubtask->currentText() != FROM_UTF8(CCopasiTask::TypeName[pProblem->getSubtaskType()])) { mChanged = true; pProblem->setSubtaskType((CCopasiTask::Type) mSubtaskMap[TO_UTF8(mpBoxSubtask->currentText())]); } if (mpBtnMaximize->isChecked() != pProblem->maximize()) { mChanged = true; pProblem->setMaximize(mpBtnMaximize->isChecked()); } if (mpCheckRandomize->isChecked() != pProblem->getRandomizeStartValues()) { mChanged = true; pProblem->setRandomizeStartValues(mpCheckRandomize->isChecked()); } if (mpCheckStatistics->isChecked() != pProblem->getCalculateStatistics()) { mChanged = true; pProblem->setCalculateStatistics(mpCheckStatistics->isChecked()); } mChanged |= mpParameters->save(NULL, NULL); mChanged |= mpConstraints->save(NULL, NULL); if (mChanged) { assert(CCopasiRootContainer::getDatamodelList()->size() > 0); (*CCopasiRootContainer::getDatamodelList())[0]->changed(); } mChanged = false; return true; }