本文整理汇总了C++中CCopasiParameter::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiParameter::setValue方法的具体用法?C++ CCopasiParameter::setValue怎么用?C++ CCopasiParameter::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiParameter
的用法示例。
在下文中一共展示了CCopasiParameter::setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
// create a new one
pTrajectoryTask = new CTrajectoryTask(& TaskList);
// add the new time course task to the task list
TaskList.add(pTrajectoryTask, true);
}
// run a deterministic time course
pTrajectoryTask->setMethodType(CTaskEnum::deterministic);
// Activate the task so that it will be run when the model is saved
// and passed to CopasiSE
pTrajectoryTask->setScheduled(true);
// set the report for the task
pTrajectoryTask->getReport().setReportDefinition(pReport);
// set the output filename
pTrajectoryTask->getReport().setTarget("example3.txt");
// don't append output if the file exists, but overwrite the file
pTrajectoryTask->getReport().setAppend(false);
// get the problem for the task to set some parameters
CTrajectoryProblem* pProblem = dynamic_cast<CTrajectoryProblem*>(pTrajectoryTask->getProblem());
// simulate 100 steps
pProblem->setStepNumber(100);
// start at time 0
pDataModel->getModel()->setInitialTime(0.0);
// simulate a duration of 10 time units
pProblem->setDuration(10);
// tell the problem to actually generate time series data
pProblem->setTimeSeriesRequested(true);
// set some parameters for the LSODA method through the method
CTrajectoryMethod* pMethod = dynamic_cast<CTrajectoryMethod*>(pTrajectoryTask->getMethod());
CCopasiParameter* pParameter = pMethod->getParameter("Absolute Tolerance");
assert(pParameter != NULL);
pParameter->setValue(1.0e-12);
try
{
// initialize the trajectory task
// we want complete output (HEADER, BODY and FOOTER)
//
// The output has to be set to OUTPUT_UI, otherwise the time series will not be
// kept in memory and some of the assert further down will fail
// If it is OK that the output is only written to file, the output type can
// be set to OUTPUT_SE
pTrajectoryTask->initialize(CCopasiTask::OUTPUT_UI, pDataModel, NULL);
// now we run the actual trajectory
pTrajectoryTask->process(true);
}
catch (...)
{
std::cerr << "Error. Running the time course simulation failed." << std::endl;
// check if there are additional error messages
if (CCopasiMessage::size() > 0)
{
// print the messages in chronological order
std::cerr << CCopasiMessage::getAllMessageText(true);
}
CCopasiRootContainer::destroy();
return 1;
}
// restore the state of the trajectory
pTrajectoryTask->restore();
// look at the timeseries
const CTimeSeries* pTimeSeries = &pTrajectoryTask->getTimeSeries();
// we simulated 100 steps, including the initial state, this should be
// 101 step in the timeseries
assert(pTimeSeries->getRecordedSteps() == 101);
std::cout << "The time series consists of " << pTimeSeries->getRecordedSteps() << "." << std::endl;
std::cout << "Each step contains " << pTimeSeries->getNumVariables() << " variables." << std::endl;
std::cout << "The final state is: " << std::endl;
iMax = pTimeSeries->getNumVariables();
size_t lastIndex = pTimeSeries->getRecordedSteps() - 1;
for (i = 0; i < iMax; ++i)
{
// here we get the particle number (at least for the species)
// the unit of the other variables may not be particle numbers
// the concentration data can be acquired with getConcentrationData
std::cout << pTimeSeries->getTitle(i) << ": " << pTimeSeries->getData(lastIndex, i) << std::endl;
}
}
else
{
std::cerr << "Usage: example3 SBMLFILE" << std::endl;
CCopasiRootContainer::destroy();
return 1;
}
// clean up the library
CCopasiRootContainer::destroy();
}
示例2: updateModel
// virtual
bool CModelParameter::updateModel()
{
bool success = true;
if (mpObject != NULL)
{
switch (mType)
{
case Model:
{
CModel * pModel = static_cast< CModel * >(mpObject);
if (!pModel->isAutonomous())
{
pModel->setInitialValue(mValue);
}
else
{
pModel->setInitialValue(0.0);
}
}
break;
case Compartment:
case Species:
case ModelValue:
{
CModelEntity * pEntity = static_cast< CModelEntity * >(mpObject);
if (pEntity->getStatus() != CModelEntity::ASSIGNMENT)
{
pEntity->setInitialValue(mValue);
if (mIsInitialExpressionValid)
{
pEntity->setInitialExpression(getInitialExpression());
}
}
}
break;
case ReactionParameter:
{
CCopasiParameter * pParameter = static_cast< CCopasiParameter * >(mpObject);
CReaction * pReaction = static_cast< CReaction * >(mpObject->getObjectAncestor("Reaction"));
if (mIsInitialExpressionValid &&
getInitialExpression() != "")
{
CModel * pModel = mpParent->getModel();
assert(pModel != NULL);
std::vector< CCopasiContainer * > ListOfContainer;
ListOfContainer.push_back(pModel);
CCopasiObjectName CN = static_cast< CEvaluationNodeObject * >(mpInitialExpression->getRoot())->getObjectCN();
CCopasiObject * pObject = pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, CN);
assert(pObject != NULL);
// We assign the object value
pParameter->setValue(* (C_FLOAT64 *) pObject->getValuePointer());
// We map the parameter to the global quantity
pReaction->setParameterMapping(pParameter->getObjectName(), pObject->getObjectParent()->getKey());
}
else
{
pParameter->setValue(mValue);
// We need to remove the existing mapping to a global quantity1.
pReaction->setParameterMapping(pParameter->getObjectName(), pParameter->getKey());
}
}
break;
default:
success = false;
break;
}
}
return success;
}
示例3: slotBtnOk
void CQPreferenceDialog::slotBtnOk()
{
// We need to commit the changes
unsigned C_INT32 newMaxFiles = 0;
CConfigurationFile * configFile = CCopasiRootContainer::getConfiguration();
QList< QTreeWidgetItem *> Items = mpTreeWidget->findItems("Max Last Visited Files", 0, 0);
CCopasiParameter * pParameter = configFile->getRecentFiles().getParameter("MaxFiles");
if (Items.size() > 0 &&
pParameter != NULL)
{
newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;
if (newMaxFiles > 0 && newMaxFiles <= 20)
pParameter->setValue(newMaxFiles);
else
{
CQMessageBox::critical(this, "Incorrect Setting",
"Max Last Visited Files should be a number between 1 and 20.",
QMessageBox::Ok, QMessageBox::Ok);
Items[0]->setText(COL_VALUE, QString::number(maxFiles));
return;
}
}
Items = mpTreeWidget->findItems("Max Last Visited SBML Files", 0, 0);
pParameter = configFile->getRecentSBMLFiles().getParameter("MaxFiles");
if (Items.size() > 0 &&
pParameter != NULL)
{
newMaxFiles = Items[0]->text(COL_VALUE).toUInt();
unsigned C_INT32 maxFiles = *pParameter->getValue().pUINT;
if (newMaxFiles > 0 && newMaxFiles <= 20)
pParameter->setValue(newMaxFiles);
else
{
CQMessageBox::critical(this, "Incorrect Setting", "Max Last Visited SBML Files should be a number between 1 and 20.",
QMessageBox::Ok, QMessageBox::Ok);
Items[0]->setText(COL_VALUE, QString::number(maxFiles));
return;
}
}
Items = mpTreeWidget->findItems("Application for opening URLs", 0, 0);
pParameter = configFile->getParameter("Application for opening URLs");
if (Items.size() > 0 &&
pParameter != NULL)
{
if (Items[0]->text(COL_VALUE) != FROM_UTF8(*pParameter->getValue().pSTRING))
pParameter->setValue(std::string(TO_UTF8(Items[0]->text(COL_VALUE))));
}
Items = mpTreeWidget->findItems("Validate Units", 0, 0);
pParameter = configFile->getParameter("Validate Units");
if (Items.size() > 0 &&
pParameter != NULL)
{
pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
}
Items = mpTreeWidget->findItems("Use OpenGL", 0, 0);
pParameter = configFile->getParameter("Use OpenGL");
if (Items.size() > 0 &&
pParameter != NULL)
{
pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
}
Items = mpTreeWidget->findItems("Use Advanced Editing", 0, 0);
pParameter = configFile->getParameter("Use Advanced Editing");
if (Items.size() > 0 &&
pParameter != NULL)
{
pParameter->setValue(Items[0]->text(COL_VALUE).toUpper() == "YES");
}
done(1);
}