コード例 #1
0
ファイル: product_builder.hpp プロジェクト: sybila/Parsybone
	/**
	 * Create state of the product as a combination of a single BA and a single UKS state
	 * @param BA_ID	source in the BA
	 * @param transition_count	value which counts the transition for the whole product, will be filled
	 */
	void addSubspaceTransitions(const StateID BA_ID, const size_t trans_no, ProductStructure & product) const {
		const UnparametrizedStructure & structure = product.getStructure();
		const AutomatonStructure & automaton = product.getAutomaton();
		StateID BA_target = automaton.getTargetID(BA_ID, trans_no);

		// List through the states that are allowed by the constraint
		DFS<ConstraintParser> search(automaton.getTransitionConstraint(BA_ID, trans_no));
		while (ConstraintParser *result = search.next()) {
			StateID KS_ID = structure.getID(result->getSolution());
			StateID ID = product.getProductID(KS_ID, BA_ID);

			// Add all the trasient combinations for the kripke structure
			if (!automaton.isStableRequired(BA_ID, trans_no)) {
				for (const size_t trans_no : crange(structure.getTransitionCount(KS_ID))) {
					const StateID KS_target = product.getStructure().getTargetID(KS_ID, trans_no);
					const TransConst & trans_const = product.getStructure().getTransitionConst(KS_ID, trans_no);
					product.states[ID].transitions.push_back({ product.getProductID(KS_target, BA_target), trans_const });
				}
			}
			// Add a self-loop
			if (!automaton.isTransientRequired(BA_ID, trans_no)) 
				product.states[ID].loops.push_back(product.getProductID(KS_ID, BA_target));

			delete result;
		}
	}
コード例 #2
0
ファイル: parsing_manager.hpp プロジェクト: sybila/Parsybone
   /**
    * @brief parseOptions parse user arguments
    */
   UserOptions parseOptions(const int argc, const char* argv[]) {
      UserOptions user_options;

      vector<string> arguments;
      for (const size_t argn : crange(argc))
         arguments.push_back(argv[argn]);

      // Parse arguments
      ArgumentParser parser;
      user_options = parser.parseArguments(arguments);
      user_options.addDefaultFiles();

      if (user_options.use_textfile) {
         output_streamer.createStreamFile(results_str, user_options.datatext_file);
      }

      return user_options;
   }
コード例 #3
0
ファイル: edge_signs.hpp プロジェクト: xstreck1/TREMPPI
	void compute(const RegInfos & reg_infos, const CompID ID, const int step_count, sqlite3pp::query & qry, map<CompID, vector<double> > & freq, map<CompID, vector<char> > & sign) 
	{
		map<Regulation, size_t> column_of_regulation;
		for (const auto & regulator : reg_infos[ID].regulators) 
		{
			for (ActLevel threshold : regulator.second) {
				string column_name = "S_" + reg_infos[regulator.first].name + "_" + to_string(threshold) + "_" + reg_infos[ID].name;
				Regulation regulation = Regulation{ reg_infos[regulator.first].ID, threshold, reg_infos[ID].ID };
				for (const size_t column_i : crange(qry.column_count())) 
				{
					string database_column = qry.column_name(column_i);

					if (database_column == column_name) 
					{
						column_of_regulation[regulation] = column_i;
					}
				}
				if (column_of_regulation.count(regulation) == 0) 
				{
					throw runtime_error("did not find the regulation " + column_name + " in the database");
				}
			}
		}

		// Compute relation to each regulation of this component, step by database rows
		for (const auto & row : qry) 
		{
			for (const auto & regulator : reg_infos[ID].regulators) 
			{
				for (size_t threshold_i : cscope(regulator.second)) 
				{
					const ActLevel threshold = regulator.second[threshold_i];
					Regulation regulation = Regulation{ reg_infos[regulator.first].ID, threshold, reg_infos[ID].ID };
					size_t column_i = column_of_regulation[regulation];
					char label = row.get<const char *>(column_i)[0];
					if (label != '0') 
					{
						freq[regulator.first][threshold_i]++;
						sign[regulator.first][threshold_i] |= label;
					}
				}
			}
		}

		for (auto & freq_pair : freq)
		{
			Statistics::normalize(step_count, freq_pair.second);
		}

		for (const auto & regulator : reg_infos[ID].regulators) 
		{
			for (size_t threshold_i : cscope(regulator.second)) 
			{
				// no active edge at all
				if (sign[regulator.first][threshold_i] == 0) 
				{
					sign[regulator.first][threshold_i] = '0';
				}
				// there were active edges and they were not either only + or only -
				else if (sign[regulator.first][threshold_i] != '+' && sign[regulator.first][threshold_i] != '-') 
				{
					sign[regulator.first][threshold_i] = '1';
				}
			}
		}
	}