当前位置: 首页>>代码示例>>C++>>正文


C++ States类代码示例

本文整理汇总了C++中States的典型用法代码示例。如果您正苦于以下问题:C++ States类的具体用法?C++ States怎么用?C++ States使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了States类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: advance_current_states

void Tracematch::advance_current_states(States& current_states, UINT32 symbol_id)
{
    list<Vertex> next_states;
    unordered_set<Vertex> visited_states;

    OutEdgeIterator oei, oei_end;
    list<Vertex>::iterator i = current_states.begin();
    while (i != current_states.end()) {
        if (visited_states.find(*i) == visited_states.end()) {
            /* Unvisited state */
            for (boost::tie(oei, oei_end) = boost::out_edges(*i, graph);
                 oei != oei_end; ++oei) {
                /* Epsilon transition */
                if (graph[*oei].symbol_id == SYMBOL_ID_EPSILON) {
                    current_states.push_back(boost::target(*oei, graph));
                }
                /* Match */
                else if (graph[*oei].symbol_id == symbol_id) {
                    next_states.push_back(boost::target(*oei, graph));
                }
            }
            visited_states.insert(*i);
        }
        /* Erase this element */
        current_states.erase(i++);
    }

    current_states = next_states;
}
开发者ID:eyolfson,项目名称:tracerory,代码行数:29,代码来源:tracematch.cpp

示例2: setVarsInformation

int
setVarsInformation (void)
{
  Var::clearVarsInfo();
  vector<string> labels;
  YAP_Term labelsL = YAP_ARG1;
  while (labelsL != YAP_TermNil()) {
    YAP_Atom atom = YAP_AtomOfTerm (YAP_HeadOfTerm (labelsL));
    labels.push_back ((char*) YAP_AtomName (atom));
    labelsL = YAP_TailOfTerm (labelsL);
  }
  unsigned count = 0;
  YAP_Term stateNamesL = YAP_ARG2;
  while (stateNamesL != YAP_TermNil()) {
    States states;
    YAP_Term namesL = YAP_HeadOfTerm (stateNamesL);
    while (namesL != YAP_TermNil()) {
      YAP_Atom atom = YAP_AtomOfTerm (YAP_HeadOfTerm (namesL));
      states.push_back ((char*) YAP_AtomName (atom));
      namesL = YAP_TailOfTerm (namesL);
    }
    Var::addVarInfo (count, labels[count], states);
    count ++;
    stateNamesL = YAP_TailOfTerm (stateNamesL);
  }
  return TRUE;
}
开发者ID:davidvaz,项目名称:yap-cmake,代码行数:27,代码来源:HorusYap.cpp

示例3: check_question_set

int SVM::check_question_set(States& qset) {
	if (main_equation == NULL) return -1;
	std::cout << " [" << qset.traces_num() << "]";
	for (int i = 0; i < qset.p_index; i++) {
		int pre = -1, cur = 0;
		std::cout << ".";
		//std::cout << "\t\t" << i << ">";
		//gsets[QUESTION].print_trace(i);
		for (int j = qset.index[i]; j < qset.index[i + 1]; j++) {
			cur = Equation::calc(main_equation, qset.values[j]);
			//std::cout << ((cur >= 0) ? "+" : "-");
			if ((pre >= 0) && (cur < 0)) {
				// deal with wrong question trace.
				// Trace back to print out the whole trace and the predicted labels.
				std::cerr << "\t\t[FAIL]\n \t  Predict wrongly on Question traces." << std::endl;
				qset.print_trace(i);
				for (int j = qset.index[i]; j < qset.index[i + 1]; j++) {
					cur = Equation::calc(main_equation, qset.values[j]);
					std::cout << ((cur >= 0) ? "+" : "-");
				}
				std::cout << std::endl;
				return -1;
			}
			pre = cur;
		}
		//std::cout << "END" << std::endl;
	}
	std::cout << " [PASS]";
	return 0;
}
开发者ID:lijiaying,项目名称:InvariantInferenceFramework,代码行数:30,代码来源:svm.cpp

示例4: current_states_is_end

bool Tracematch::current_states_is_end(const States& current_states)
{
    States states = current_states;
    unordered_set<Vertex> visited_states;

    OutEdgeIterator oei, oei_end;
    list<Vertex>::iterator i = states.begin();
    while (i != states.end()) {

        if (visited_states.find(*i) == visited_states.end()) {
            /* Unvisited state */
            if (*i == graph_properties.end) {
                return true;
            }

            for (boost::tie(oei, oei_end) = boost::out_edges(*i, graph); oei != oei_end; ++oei) {
                /* Epsilon transition */
                if (graph[*oei].symbol_id == SYMBOL_ID_EPSILON) {
                    states.push_back(boost::target(*oei, graph));
                }
            }
            visited_states.insert(*i);
        }

        /* Erase this element */
        states.erase(i++);
    }

    return false;
}
开发者ID:eyolfson,项目名称:tracerory,代码行数:30,代码来源:tracematch.cpp

示例5: build

bool DFAConverter::build(int start, int last,
		const std::vector<NFATran>& trans,
		const std::map<size_t, Tag>& tags) {
	States lasts;
	lasts.insert(last);

	return build(start, lasts, trans, tags);
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:8,代码来源:dfa_converter.cpp

示例6: fillState

States Database::fillState()
{
    States s;
    this->query.first();
    this->record = this->query.record();
    s.setId(this->query.value(this->record.indexOf("id")).toUInt());
    s.setDescription(this->query.value(this->record.indexOf("name")).toString());
    return s;
}
开发者ID:gavaza,项目名称:pacca,代码行数:9,代码来源:database.cpp

示例7:

 /**
  * 
  * @brief returns all targets that correspond with the given source 
  *
  * @param - source: the source whose targets to look for
  * @return the set of all targets that correspond with the given source 
  *
  */
 const TransitionStorage::States TransitionStorage::getTargets( State source ) const
 {
   States targets;
   const Info::Internals & src = T_info.fromTrans(source);
   for( Info::InternalIterator it = src.begin(); it != src.end(); it++ )
   {
     targets.insert(getTarget(*it));
   }
   return targets;
 }
开发者ID:pohmann,项目名称:WALi-OpenNWA,代码行数:18,代码来源:TransitionStorage.cpp

示例8: map_ids

void map_ids(const States& o){
	Container::map_id_to_number()[o.getId()] = Container::get_id_counter();
	if(not o.calls.empty()){
		for(std::vector<Call>::const_iterator i=o.calls.begin();i!=o.calls.end();i++){
			i->lib=o.lib;
			i->id = o.getId();
			map_ids(*i);
		}
	}
}
开发者ID:AGV-IIT-KGP,项目名称:eklavya-2015,代码行数:10,代码来源:FSMConstructor_for_Dot.cpp

示例9: R70

void R70(std::vector<Dynamic>& __ret) {
	//arguments
 Dynamic  hllr__0 =  Dynamic (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        States x;
        x.push_back(ptr<State>(StateArgScope((States&)hllr__0)));
        retval = x;
    
	__ret.push_back(retval);
}
开发者ID:deltaluca,项目名称:caxe,代码行数:11,代码来源:parse.cpp

示例10: R81

void R81(std::vector<Dynamic>& __ret) {
	//arguments
 ptr<int>          hllr__0 =  ptr<int>         (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        States x;
        x.push_back(ptr<State>(StateSymbol(*hllr__0)));
        retval = x;
    
	__ret.push_back(retval);
}
开发者ID:deltaluca,项目名称:caxe,代码行数:11,代码来源:parse.cpp

示例11: R82

void R82(std::vector<Dynamic>& __ret) {
	//arguments
 ptr<std::string>  hllr__0 =  ptr<std::string> (__ret.back()); __ret.pop_back();
	 Dynamic  retval;

        States x;
        x.push_back(ptr<State>(StateNoise(*hllr__0)));
        retval = x;
    
	__ret.push_back(retval);
}
开发者ID:deltaluca,项目名称:caxe,代码行数:11,代码来源:parse.cpp

示例12: R27

void R27(std::vector<Dynamic>& __ret) {
	//arguments
 ptr<int>          hllr__1 =  ptr<int>         (__ret.back()); __ret.pop_back();
Dynamic hllr__0 = __ret.back(); __ret.pop_back();
	 Dynamic  retval;

        States list;
        list.push_back(ptr<State>(StateSymbol(*hllr__1)));
        retval = StateMBrack(dMScopeBrack(list));
    
	__ret.push_back(retval);
}
开发者ID:deltaluca,项目名称:caxe,代码行数:12,代码来源:parse.cpp

示例13: merge_tags

static void merge_tags(const States& states,
		const std::map<size_t, Tag>& from,
		int s, std::map<size_t, Tag> *to) {
	size_t size = states.size();
	for (States::const_iterator it = states.begin();
			it != states.end(); ++it) {
		assert(*it >= 0);
		std::map<size_t, Tag>::const_iterator fit = from.find(*it);
		if (fit != from.end()) {
			Tag& tag = (*to)[s];
			tag.insert(fit->second.begin(), fit->second.end());
		}
	}
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:14,代码来源:dfa_converter.cpp

示例14: validate

	/* Name: validate
	* Purpose: To find if the all of the transtions are valid.
	* Operation: This method it checks that each transition is based on the class States,
		Tape_Alphabet, and moves R or L.
	*/
void Transition_Function::validate(const Tape_Alphabet &tape_alphabet, States states, bool & valid){

		// Prevent two transitions from having the same source_state and Read_Character
	for (unsigned int i = 0; i < transitions.size(); i++){		
		for(unsigned int z = i + 1; z < transitions.size(); z++){			
			if(transitions[i].Source_State() == transitions[z].Source_State()
			&& transitions[i].Read_Character() == transitions[z].Read_Character()){
				valid = false;
				cout << "Error: Two transitions have the same source state '" << transitions[i].Source_State() << "' and read character '" << transitions[i].Read_Character() << "'.\n";
			}			
		}		
	}

		// Validate the the tape alphabet elements.
	for (unsigned int i = 0; i < transitions.size(); i++){

			// The read character is not contained within the tape alphabet.
		if (!tape_alphabet.is_element(transitions[i].Read_Character())){			
			cout << "Error: Transition read character '" << transitions[i].Read_Character() << "' is not in tape alphabet.\n";
			valid = false;
		}

			// The write character is not contained within the tape alphabet.
		if (!tape_alphabet.is_element(transitions[i].Write_Character())){
			cout << "Error: Transition write character '" << transitions[i].Write_Character() << "' is not in tape alphabet.\n";
			valid = false;
		}
	}

		// Validate that all of the states are in the list of states.
	for (unsigned int i = 0; i < transitions.size(); i++){

			// The source state is not in the list of states.
		if (!states.is_element(transitions[i].Source_State())){
			cout << "Error: Transition source state '" << transitions[i].Source_State() << "' is not in states.\n";

			valid = false;
		}

			// The destination state is not in the list of states. 
		if (!states.is_element(transitions[i].Destination_State())){
			cout << "Error: Transition destination state '" << transitions[i].Destination_State() << "' is not in states.\n";

			valid = false;
		}
	}
	
}
开发者ID:SkullCrusher,项目名称:Rex-The-Biplane,代码行数:53,代码来源:Transition_Function.cpp

示例15: sample_hmm_posterior

double sample_hmm_posterior(
    int blocklen, const LocalTree *tree, const States &states,
    const TransMatrix *matrix, const double *const *fw, int *path)
{
    // NOTE: path[n-1] must already be sampled

    const int nstates = max(states.size(), (size_t)1);
    double A[nstates];
    double trans[nstates];
    int last_k = -1;
    double lnl = 0.0;

    // recurse
    for (int i=blocklen-2; i>=0; i--) {
        int k = path[i+1];

        // recompute transition probabilities if state (k) changes
        if (k != last_k) {
            for (int j=0; j<nstates; j++)
                trans[j] = matrix->get(tree, states, j, k);
            last_k = k;
        }

        for (int j=0; j<nstates; j++)
            A[j] = fw[i][j] * trans[j];
        path[i] = sample(A, nstates);
        //lnl += log(A[path[i]]);

        // DEBUG
        assert(trans[path[i]] != 0.0);
    }

    return lnl;
}
开发者ID:jbkinney,项目名称:argweaver,代码行数:34,代码来源:sample_thread.cpp


注:本文中的States类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。