本文整理汇总了C++中SpeciesReference::isSetStoichiometryMath方法的典型用法代码示例。如果您正苦于以下问题:C++ SpeciesReference::isSetStoichiometryMath方法的具体用法?C++ SpeciesReference::isSetStoichiometryMath怎么用?C++ SpeciesReference::isSetStoichiometryMath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpeciesReference
的用法示例。
在下文中一共展示了SpeciesReference::isSetStoichiometryMath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkSpeciesRefs
void checkSpeciesRefs(Model* model, ListOfSpeciesReferences* losr, set<string>& components, set<string>& tests, const map<string, vector<double> >& results)
{
for (unsigned int rp=0; rp<losr->size(); rp++) {
SpeciesReference* sr = static_cast<SpeciesReference*>(losr->get(rp));
if (sr->isSetStoichiometry() && sr->getStoichiometry() != 1) {
tests.insert("NonUnityStoichiometry");
}
if (sr->isSetStoichiometryMath()) {
tests.insert("NonUnityStoichiometry");
components.insert("StoichiometryMath");
if (variesIn(sr->getStoichiometryMath()->getMath(), model, results)) {
tests.insert("AssignedVariableStoichiometry");
}
else {
tests.insert("AssignedConstantStoichiometry");
}
}
else if (sr->isSetId()) {
double initialResult = 1;
if (results.find(sr->getId()) != results.end()) {
tests.insert("SpeciesReferenceOutput");
}
if (variesIn(sr->getId(), model, results)) {
tests.insert("AssignedVariableStoichiometry");
tests.insert("NonUnityStoichiometry");
}
else if (initialOverriddenIn(sr->getId(), model, results, tests)) {
tests.insert("AssignedConstantStoichiometry");
if (getInitialResultFor(sr->getId(), results, initialResult)) {
if (initialResult != 1) {
tests.insert("NonUnityStoichiometry");
}
}
else {
//Don't know what the actual initial result is, so we'll assume it's not 1.0.
tests.insert("NonUnityStoichiometry");
}
}
if (initialOverriddenIn(sr->getId(), model, results, tests)) {
tests.insert("InitialValueReassigned");
}
if (foundInMath(sr->getId(), model)) {
tests.insert("SpeciesReferenceInMath");
}
}
}
}
示例2: getReaction
void
Model::convertStoichiometryMath()
{
unsigned int n, j;
Reaction * r;
SpeciesReference *sr;
unsigned int idCount = 0;
char newid[15];
std::string id;
for (n = 0; n < getNumReactions(); n++)
{
r = getReaction(n);
for (j = 0; j < r->getNumReactants(); j++)
{
sr = r->getReactant(j);
if (sr->isSetStoichiometryMath())
{
if (!sr->isSetId())
{
sprintf(newid, "generatedId_%u", idCount);
id.assign(newid);
sr->setId(id);
idCount++;
}
else
{
id = sr->getId();
}
sr->setConstant(false);
AssignmentRule * ar = createAssignmentRule();
ar->setVariable(id);
if (sr->getStoichiometryMath()->isSetMath())
{
ar->setMath(sr->getStoichiometryMath()->getMath());
}
}
}
for (j = 0; j < r->getNumProducts(); j++)
{
sr = r->getProduct(j);
if (sr->isSetStoichiometryMath())
{
if (!sr->isSetId())
{
sprintf(newid, "generatedId_%u", idCount);
id.assign(newid);
sr->setId(id);
idCount++;
}
else
{
id = sr->getId();
}
sr->setConstant(false);
AssignmentRule * ar = createAssignmentRule();
ar->setVariable(id);
if (sr->getStoichiometryMath()->isSetMath())
{
ar->setMath(sr->getStoichiometryMath()->getMath());
}
}
}
}
}
示例3: dealWithAssigningL1Stoichiometry
void dealWithAssigningL1Stoichiometry(Model & m, bool l2)
{
//char newid[15];
std::string id;
for (unsigned int i = 0; i < m.getNumReactions(); i++)
{
Reaction *r = m.getReaction(i);
unsigned int j;
for (j = 0; j < r->getNumReactants(); j++)
{
SpeciesReference *sr = r->getReactant(j);
// we do not get here unless the stoichiometryMath is an integer
// or a rational
if (l2 == true && sr->isSetStoichiometryMath() == true)
{
const ASTNode* ast = sr->getStoichiometryMath()->getMath();
if (ast->isInteger())
{
int num = ast->getInteger();
sr->setStoichiometry(num);
sr->setDenominator(1);
}
else
{
int num = ast->getNumerator();
int denom = ast->getDenominator();
sr->setStoichiometry(num);
sr->setDenominator(denom);
}
sr->unsetStoichiometryMath();
}
else
{
sr->setStoichiometry(sr->getStoichiometry());
sr->setDenominator(1);
}
}
for (j = 0; j < r->getNumProducts(); j++)
{
SpeciesReference *sr = r->getProduct(j);
// we do not get here unless the stoichiometryMath is an integer
// or a rational
if (l2 == true && sr->isSetStoichiometryMath() == true)
{
const ASTNode* ast = sr->getStoichiometryMath()->getMath();
if (ast->isInteger())
{
int num = ast->getInteger();
sr->setStoichiometry(num);
sr->setDenominator(1);
}
else
{
int num = ast->getNumerator();
int denom = ast->getDenominator();
sr->setStoichiometry(num);
sr->setDenominator(denom);
}
sr->unsetStoichiometryMath();
}
else
{
sr->setStoichiometry(sr->getStoichiometry());
sr->setDenominator(1);
}
}
}
}
示例4: getUnitDefinition
void
Model::assignRequiredValues()
{
// when converting to L3 some attributes which have default values in L1/L2
// but are required in L3 are not present or set
unsigned int i, n;
if (getNumUnitDefinitions() > 0)
{
for (i = 0; i < getNumUnitDefinitions(); i++)
{
for (n = 0; n < getUnitDefinition(i)->getNumUnits(); n++)
{
Unit *u = getUnitDefinition(i)->getUnit(n);
if (!u->isSetExponent())
u->setExponent(1.0);
if (!u->isSetScale())
u->setScale(0);
if (!u->isSetMultiplier())
u->setMultiplier(1.0);
}
}
}
if (getNumCompartments() > 0)
{
for (i = 0; i < getNumCompartments(); i++)
{
Compartment *c = getCompartment(i);
c->setConstant(c->getConstant());
}
}
if (getNumSpecies() > 0)
{
for (i = 0; i < getNumSpecies(); i++)
{
Species * s = getSpecies(i);
s->setBoundaryCondition(s->getBoundaryCondition());
s->setHasOnlySubstanceUnits(s->getHasOnlySubstanceUnits());
s->setConstant(s->getConstant());
}
}
if (getNumParameters() > 0)
{
for (i = 0; i < getNumParameters(); i++)
{
Parameter * p = getParameter(i);
p->setConstant(p->getConstant());
}
}
if (getNumReactions() > 0)
{
for (i = 0; i < getNumReactions(); i++)
{
Reaction * r = getReaction(i);
r->setFast(r->getFast());
r->setReversible(r->getReversible());
if (r->getNumReactants() > 0)
{
for (n = 0; n < r->getNumReactants(); n++)
{
SpeciesReference *sr = r->getReactant(n);
if (sr->isSetStoichiometryMath())
{
sr->setConstant(false);
}
else
{
sr->setConstant(true);
}
}
}
if (r->getNumProducts() > 0)
{
for (n = 0; n < r->getNumProducts(); n++)
{
SpeciesReference *sr = r->getProduct(n);
if (sr->isSetStoichiometryMath())
{
sr->setConstant(false);
}
else
{
sr->setConstant(true);
}
}
}
}
}
if (getNumEvents() > 0)
{
for (i = 0; i < getNumEvents(); i++)
{
Event * e = getEvent(i);
e->setUseValuesFromTriggerTime(e->getUseValuesFromTriggerTime());
if (e->isSetTrigger())
{
Trigger *t = e->getTrigger();
t->setPersistent(true);
//.........这里部分代码省略.........
示例5: readSBML
//.........这里部分代码省略.........
Compartment *c = model->getCompartment(i);
cout << "Compartment " << i << ": "
<< UnitDefinition::printUnits(c->getDerivedUnitDefinition())
<< endl;
}
for (i = 0; i < model->getNumParameters(); i++)
{
Parameter *p = model->getParameter(i);
cout << "Parameter " << i << ": "
<< UnitDefinition::printUnits(p->getDerivedUnitDefinition())
<< endl;
}
for (i = 0; i < model->getNumInitialAssignments(); i++)
{
InitialAssignment *ia = model->getInitialAssignment(i);
cout << "InitialAssignment " << i << ": "
<< UnitDefinition::printUnits(ia->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (ia->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
for (i = 0; i < model->getNumEvents(); i++)
{
Event *e = model->getEvent(i);
cout << "Event " << i << ": " << endl;
if (e->isSetDelay())
{
cout << "Delay: "
<< UnitDefinition::printUnits(e->getDelay()->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (e->getDelay()->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
for (j = 0; j < e->getNumEventAssignments(); j++)
{
EventAssignment *ea = e->getEventAssignment(j);
cout << "EventAssignment " << j << ": "
<< UnitDefinition::printUnits(ea->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (ea->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
}
for (i = 0; i < model->getNumReactions(); i++)
{
Reaction *r = model->getReaction(i);
cout << "Reaction " << i << ": " << endl;
if (r->isSetKineticLaw())
{
cout << "Kinetic Law: "
<< UnitDefinition::printUnits(r->getKineticLaw()->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (r->getKineticLaw()->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
for (j = 0; j < r->getNumReactants(); j++)
{
SpeciesReference *sr = r->getReactant(j);
if (sr->isSetStoichiometryMath())
{
cout << "Reactant stoichiometryMath" << j << ": "
<< UnitDefinition::printUnits(sr->getStoichiometryMath()->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (sr->getStoichiometryMath()->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
}
for (j = 0; j < r->getNumProducts(); j++)
{
SpeciesReference *sr = r->getProduct(j);
if (sr->isSetStoichiometryMath())
{
cout << "Product stoichiometryMath" << j << ": "
<< UnitDefinition::printUnits(sr->getStoichiometryMath()->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (sr->getStoichiometryMath()->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
}
}
for (i = 0; i < model->getNumRules(); i++)
{
Rule *r = model->getRule(i);
cout << "Rule " << i << ": "
<< UnitDefinition::printUnits(r->getDerivedUnitDefinition()) << endl;
cout << " undeclared units: ";
cout << (r->containsUndeclaredUnits() ? "yes\n" : "no\n");
}
delete document;
return 0;
}