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


C++ strvec::begin方法代码示例

本文整理汇总了C++中strvec::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ strvec::begin方法的具体用法?C++ strvec::begin怎么用?C++ strvec::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在strvec的用法示例。


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

示例1: elModes

void SplitLP::elModes(solvec& solutions, int num, strvec& fixcols){
    srand (unsigned(time(NULL)));
    double fixrate = 1/this->vmax;
    for (strvec::iterator it = fixcols.begin(); it != fixcols.end(); ++it){
        fix(*it, fixrate, true);
        fix(get_opp_name(*it), 0, true);
    }
    int kind = getKind() == MILP ? INT : CONT;
    void (MtxLP::*optimise)(stomap*, bool, strvec, bool, bool) = \
        (kind == INT) ? &MtxLP::optLenSol : &MtxLP::optSumSol;
    int i;
    for (i = 0; i < num; i++){
        stomap sol;
        (this->*optimise)(&sol, false, getColNames(), false, true);
        if (sol.empty())
            break;
        if (fixrate != 0) mul(&sol, vmax);
        solutions.push_back(sol);
        if (i < num - 1){
            sol.clear();
            MtxLP::getSolution(&sol, getColNames(kind), kind, false);
            if (kind == INT) cutSolution(&sol, true);
            else {
                for (strvec::iterator it = fixcols.begin();  it != fixcols.end(); ++it)
                     sol.erase(*it);
                int nblock = rand() % sol.size();
                stomap::iterator itblock = sol.begin();
                for (int i = 0; i < nblock; i++)itblock++;
                string sblock = itblock->first;
                block(sblock, true);
            }
        }
    }
    cleanTmpRows();//fixcols.size() * 2 + i - 1);
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:35,代码来源:SplitLP.cpp

示例2: get_int_names

strvec MtxLP::get_int_names(strvec names){
    strvec rv(names.size());
    strvec::iterator it = names.begin(), it2 = rv.begin();
    while (it != names.end())
        *it2++ = get_int_name(*it++);
    return rv;
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:7,代码来源:MtxLP.cpp

示例3: del_cols

void Matrix::del_cols(strvec &names){
    for (strvec::iterator it = names.begin(); it != names.end(); ++it){
        del(*it);
        std::remove(cols.begin(), cols.end(), *it);
    }
    cols.resize(cols.size() - names.size());
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:7,代码来源:Matrix.cpp

示例4: select

void Matrix::select(strvec &rv, strvec &names, bool(Matrix::*fun)(string)const, strvec &ignore)const {
    if (names.empty())
        names = rows;
    elmap::iterator end = map->end();
    string name;
    strvec::iterator igbeg = ignore.begin(), igend = ignore.end();
    for (strvec::iterator it = names.begin(); it != names.end(); ++it){        
        if (std::find(igbeg, igend, *it) == igend){
            name = *it;
            if (map->find(*it) == end)
                throw runtime_error(string("No such row or column: ") + name);
            if ((*this.*fun)(name))
                rv.push_back(name);
        }
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:16,代码来源:Matrix.cpp

示例5: involved_with

void Matrix::involved_with(strvec& result, string name) const{
    stomap* sto = (*this)[name]->get_sto();
    for (stomap::iterator jt = sto->begin(); jt != sto->end(); ++jt){
        string name2 = jt->first;
        if (std::find(result.begin(), result.end(), name2) == result.end())
            result.push_back(name2);
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:8,代码来源:Matrix.cpp

示例6: getUnblockedVars

strvec MtxLP::getUnblockedVars(strvec q, bool presolve){
    strvec rv;
    for (strvec::iterator it = q.begin(); it != q.end(); ++it){
        if (isUnBlocked(*it, presolve))
            rv.push_back(*it);
    }
    return rv;
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:8,代码来源:MtxLP.cpp

示例7: getBottleNecks

strvec MtxLP::getBottleNecks(stomap* obj, strvec q, bool max, bool presolve){
    strvec rv;
    for (strvec::iterator it = q.begin(); it != q.end(); ++it){
        if (isBottleNeck(obj, *it, max, presolve))
            rv.push_back(*it);
    }
    return rv;
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:8,代码来源:MtxLP.cpp

示例8: getSupport

void MtxLP::getSupport(strvec& support, strvec queries, int kind) const{
    stomap sol;
    getSolution(&sol, queries, kind, false);
    support.resize(sol.size());
    strvec::iterator jt = support.begin();
    for (stomap::iterator it = sol.begin(); it != sol.end(); ++it)
        *jt++ = it->first;
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:8,代码来源:MtxLP.cpp

示例9: externalise

void MtxLP::externalise(strvec& names, bool on){
    double lb = on ? -UB : 0;
    double ub = on ? UB : 0;
    for (strvec::iterator it = names.begin(); it != names.end(); ++it){
        if (nrow(*it) != 0)
            setRowBnds(*it, lb, ub);
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:8,代码来源:MtxLP.cpp

示例10: getRanges

void MtxLP::getRanges(rangemap* rm, strvec q, bool presolve){
    OBJSTAT_RANGE range;
    stomap targsto;
    for (strvec::iterator it = q.begin(); it != q.end(); ++it){
        string name = *it;
        getColRange(range, name, presolve);
        (*rm)[name] = range;
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:9,代码来源:MtxLP.cpp

示例11: getSolution

void MtxLP::getSolution(stomap* sol, strvec q, int kind, bool withzeroes) const{
    if (!isSolved()) return;
    for (strvec::iterator i = q.begin(); i != q.end(); i++){
        string name = *i;
        double coef = getColValue(name);
        if (withzeroes || !is_zero(coef))
            (*sol)[name] = coef;
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:9,代码来源:MtxLP.cpp

示例12: processParallelFor

//Returns true if it processes something
//Returns false if it never finds a parallel for
bool processParallelFor()
{
	bool foundPragma = false;

	for (int i = 0; i < input.size(); i++)
	{
		std::string curStr = input.at(i);
		if (curStr.substr(0, 24).compare("#pragma omp parallel for") == 0 ||
			curStr.substr(0, 15).compare("#pragma omp for") == 0)
		{
			foundPragma = true;
			int j = i + 2; //move up to pragma and pass the for loop
			if (input.at(j).substr(0,1).compare("{") == 0) //if the for is contained in brackets. weird case also where trim did not remove tab after bracket
			{
				int brackets = 1;
				//find the end of the parallel region
				while (j < input.size())
				{
					j++;

					std::string tempStr = input.at(j);
					if (tempStr.length() <= 0)
					{
						continue;
					}

					if (tempStr.at(0) == '{')
					{
						brackets++;
					}
					if (tempStr.at(0) == '}')
					{
						brackets--;
					}
					if (brackets == 0)
					{
						break;
					}
				}
			}
			else //if there are no brackets, then j is pointing to the contents of the for loop
			{
				i += 2;
				j += 2;
				input.insert(input.begin() + i, "{");
				input.insert(input.begin() + j, "}");
				i -= 2; //move i back to the pragma
			}
			//at this point, j points to the ending bracket, and i points to the pragma
			parallelForHelper(i, j);
		}
		//otherwise, move on--handle it elsewhere
	}

	return foundPragma;

}
开发者ID:dhganey,项目名称:430p2,代码行数:59,代码来源:main.cpp

示例13: setLenObjective

void MtxLP::setLenObjective(strvec cols, bool tmp){
    if (kind != MILP)
        throw runtime_error("trying to optimise length using a non-MILP solver!");
    emptyObjective();
    int contcoef = isMaximising() ? 1 : -1;
    int intcoef = -contcoef;
    for (strvec::iterator it = cols.begin(); it != cols.end(); ++it){
        string name = *it;
        string intname = get_int_name(name);
        stomap *sto = new stomap;
        (*sto)[name] = contcoef;
        (*sto)[intname] = intcoef * vmax;
        addConstraint(sto, 0, UB, tmp, name + INT_CONSTR_TAG);
        setObjCoef(intname, 1);
        delete sto;
    }
}
开发者ID:kierzek,项目名称:MUFINS,代码行数:17,代码来源:MtxLP.cpp

示例14: declarePrivatesInMain

//Declares the varlist in the main function
void declarePrivatesInMain(strvec& varList)
{
	int mainLine = 0;
	for (mainLine; mainLine < input.size(); mainLine++)
	{
		std::string curStr = input.at(mainLine);
		if (curStr.compare("int main()") == 0)
		{
			break;
		}
	}

	mainLine += 2; //move past brackets
	for (int i = 0; i < varList.size(); i++)
	{
		input.insert(input.begin() + mainLine++, varList.at(i));
	}
}
开发者ID:dhganey,项目名称:430p2,代码行数:19,代码来源:main.cpp

示例15: insertAfterIncludes

//Pushes the vecRef into input after the include statements (at the top)
void insertAfterIncludes(strvec& vecRef)
{
	//move past any includes
	int i;
	for (i = 0; i < input.size(); i++)
	{
		if (input.at(i).length() > 0 && input.at(i).at(0) != '#')
		{
			break;
		}
	}

	//once we're here, we're past the includes and we can copy the new function
	//we need to insert this in reverse order
	for (int j = vecRef.size()-1; j >= 0; j--)
	{
		input.insert(input.begin() + i, vecRef.at(j));
	}
}
开发者ID:dhganey,项目名称:430p2,代码行数:20,代码来源:main.cpp


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