Esempio n. 1
0
void PRU2MDPprogress::buildActions(const PRUmodule *mod, 
				   map<string,domain_type>::const_iterator iParam,
				   const MDPaction &action, 
				   map<string, domain_type> *SVdomain,
				   PRU2MDPstateStore &states) {
  if (iParam == mod->parameters.end()) {
    // All parameters are instanciated
    MDPaction *act = new MDPaction(action);
    actions.push_back(act);
    
    PRUstate res(stateVariables); // makes a local copy of SV that will be updated with out SVUs
    for (vector<PRUoutcome*>::const_iterator itO = mod->outcomes.begin();
	 itO != mod->outcomes.end(); ++itO) {
      PRUoutcome *out = *itO;
      for (vector<string>::const_iterator itSVU = out->stateVariableUpdate.begin();
	   itSVU != out->stateVariableUpdate.end(); ++itSVU) {
	vector<string> vec;
	boost::algorithm::split(vec, *itSVU, boost::algorithm::is_any_of(":= "), 
				boost::algorithm::token_compress_on );
	if (vec.size()!=2)
	  std::cerr << "Unreadable SVU : " << *itSVU << std::endl;
	else {
	  if (vec[1][0] == '$') {
	    // this is an action parameter
	    string p = vec[1].substr(1);
	    const string &v = act->getParameter(p);
	    if (v == MDPaction::NIL)
	      std::cerr << "Unknown action parameter "<<vec[1]<<std::endl;
	    else
	      res[vec[0]] = v;
	  } else {
	    // res[vec[0]] = vec[1]; // but needs a pointer (no local string !)
	    domain_type &dom = (*SVdomain)[vec[0]];
	    for (domain_type::const_iterator it = dom.begin();
		 it != dom.end(); ++it) {
	      if (*it == vec[1]) {
		res[vec[0]] = (*it);
		break;
	      }
	    } // for *it in this SV domain
	  } // if not an action parameter
	} // if correct SVU element
      } // for itSVU in *itO SV Updates
      // Here, res contains the updated state variables
      MDPstate *s = states.getState(lay->name, act, out, res);
      act->outcomes.insert(s);
    } // for *itO in mod->outcomes
  } else {
    // Some action parameter is to be instanciated yet
    string name = iParam->first;
    domain_type::const_iterator it = iParam->second.begin();
    domain_type::const_iterator itEnd = iParam->second.end();
    ++iParam;
    for (;it != itEnd; ++it) {
      MDPaction ma(action,name,*it);
      buildActions(mod, iParam, ma, SVdomain, states);
    } // for *it in the current parameter's domain
    --iParam;
  } // if more parameters
} // buildActions(*mod, iParam)
NullableAdapterBlockInputStream::NullableAdapterBlockInputStream(
    BlockInputStreamPtr input_,
    const Block & in_sample_, const Block & out_sample_)
{
    buildActions(in_sample_, out_sample_);
    children.push_back(input_);
}
Esempio n. 3
0
PRU2MDPprogress::PRU2MDPprogress(const PRUlayer *l, const PRUstate &sv,
				 map<string, domain_type> *stateVariableDomain,
				 PRU2MDPstateStore &states) 
  : stateVariables(sv) {
  lay = l;
  for (vector<PRUmodule*>::const_iterator iMod = lay->modules.begin(); 
       iMod != lay->modules.end(); ++iMod) {
    PRUmodule *mod = *iMod;
    MDPaction act(mod->actionName); // template for building all those actions
    buildActions(mod, mod->parameters.begin(), act, stateVariableDomain, states);
  } // for *iMod in lay->modules
} // PRU2MDPprogress(*l,&sv)
Esempio n. 4
0
void MathDisplay::buildWidget()
{
	l_main = new QVBoxLayout;
	mathwidget = new MATHWIDGET(context);
	connect(mathwidget, SIGNAL(resized()), this, SLOT(childResized()));
	connect(mathwidget, SIGNAL(s_renderAvailable(const bool&)), this, SLOT(renderAvailable(const bool&)));

	l_main->addWidget(mathwidget);
	l_main->setAlignment(Qt::AlignCenter);
	setLayout(l_main);

	buildActions();
}
void PlayActionEffectComboInstance::start()
{
	assert(m_kActionEffectVector);

	// alloc action list
	m_kActionVector.resize( m_kActionEffectVector->getFrameCount());
	for (int i = 0; i < m_kActionVector.size(); i++)
	{
		m_kActionVector[i] = new ActionList;
		CActionEffectComboFrame* frame = m_kActionEffectVector->getFrame(i);
		assert(frame);

		buildActions( frame->getActionEffect(), m_kActionVector[i], frame->isReverse() );
	}
}
/*
-----------------------------------run--------------------------------
run - executes the library manager.  All actions are processed within
      this function.
      
Preconditions: File present, accessible and in format defined in
               Assignment #3.  Manager.build() must be executed first!
Postconditions: Actions executed on Library and Views if file contains
                valid data.
*/
void Manager::run() {
    buildActions(); 
}