Esempio n. 1
0
/*
*  get Assignment Rule
*/
void SbmlReader::getRules()
{
	unsigned int nr = model_->getNumRules();
	//cout<<"no of rules:"<<nr<<endl;
	for ( unsigned int r = 0;r < nr;r++ )
	{
		Rule * rule = model_->getRule(r);
		//cout << "rule :" << rule->getFormula() << endl;
		bool assignRule = rule->isAssignment();
		//cout << "is assignment :" << assignRule << endl;
		if ( assignRule ){
			string rule_variable = rule->getVariable();
			//cout << "variable :" << rule_variable << endl;
			map< string,Eref >::iterator v_iter;
			map< string,Eref >::iterator m_iter;
			v_iter = elmtMap_.find( rule_variable );
			if ( v_iter != elmtMap_.end() ){
				
				Eref rVariable = elmtMap_.find(rule_variable)->second;
				const ASTNode * ast = rule->getMath();
				vector< string > ruleMembers;
				ruleMembers.clear();
				printMembers( ast,ruleMembers );
				for ( unsigned int rm = 0; rm < ruleMembers.size(); rm++ )
				{
					m_iter = elmtMap_.find( ruleMembers[rm] );	
					if ( m_iter != elmtMap_.end() ){				
						Eref rMember = elmtMap_.find(ruleMembers[rm])->second;				
						rMember.add( "nSrc",rVariable,"sumTotal",ConnTainer::Default ); 
					}
					else{
						cerr << "SbmlReader::getRules: Assignment rule member is not a species" << endl;
						errorFlag_ = true;
					}	
				}
			}
			else{
				cerr << "SbmlReader::getRules: for now Assignment rule for parameter/compartment is not handled" << endl;
				errorFlag_ = true;
			}
		}
		bool rateRule = rule->isRate();
		if ( rateRule ){
			cout << "warning : for now Rate Rule is not handled " << endl;
			errorFlag_ = true;
		}
		bool  algebRule = rule->isAlgebraic(); 
		if ( algebRule ){
			cout << "warning: for now Algebraic Rule is not handled" << endl;
			errorFlag_ = true;
		}
	}
}
Esempio n. 2
0
/**
 * This operation turns the target element e into a zombie controlled
 * by the hub/solver. It gets rid of any process message coming into 
 * the zombie and replaces it with one from the solver.
 */
void HSolveHub::zombify( 
	Eref hub, Eref e,
	const Finfo* hubFinfo, Finfo* solveFinfo )
{
	// Replace the original procFinfo with one from the hub.
	const Finfo* procFinfo = e->findFinfo( "process" );
	e.dropAll( procFinfo->msg() );
	bool ret = hub.add( hubFinfo->msg(), e, procFinfo->msg(), 
		ConnTainer::Default );
	assert( ret );

	// Redirect original messages from the zombie to the hub.
	// Pending.

	// Replace the 'ThisFinfo' on the solved element
	e->setThisFinfo( solveFinfo );
}