예제 #1
0
int CEvaluator::getArgumentValue(const string& name){
	if(m_vContext.size()>0) 
	{
		if(m_vContext.back()->find(name)==m_vContext.back()->end()){
			throw(EvaluationError("argument \""+name+"\" does not have an associated value."));
		}
		return (*m_vContext.back())[name];
	}
	throw(EvaluationError("getArgumentValue(): no argument defined."));
}
예제 #2
0
파일: bo_base.hpp 프로젝트: resibots/limbo
 /// Add a new sample / observation pair
 /// - does not update the model!
 /// - we don't add NaN and inf observations
 void add_new_sample(const Eigen::VectorXd& s, const Eigen::VectorXd& v)
 {
     if (tools::is_nan_or_inf(v))
         throw EvaluationError();
     _samples.push_back(s);
     _observations.push_back(v);
 }
예제 #3
0
void CEvaluator::visit ( CApply* e )
{
	CFunction *f= getFunction(e->getFunction());
	if(!f) {
		throw(EvaluationError("function \""+e->getFunction()+"\" is not defined."));
	}
	if(!f || (f->getNumArguments() != e->getNumArguments())) {
		throw(EvaluationError("number of arguments for function \""+e->getFunction()+"\" does not match declaration."));
	}
	map<string,int> *newContext= new map<string,int>();
	for(int i=0; i<f->getNumArguments();i++) {
		string tmp=f->getArgument(i)->getName();
		e->getArgument(i)->accept(this);
		int value=result;
	//	cout << "  "<< tmp <<"="<<value<<endl;
		(*newContext)[tmp]=value;
	}
	pushContext(newContext);
	CExpr *e2 = f->getExpression();
	e2->accept(this);
	delete popContext();
	//return result;
}
예제 #4
0
void CEvaluator::visit ( CFunction* e )
{
	throw EvaluationError("tried to visit function"+e->getName());
}