本文整理汇总了C++中strvec类的典型用法代码示例。如果您正苦于以下问题:C++ strvec类的具体用法?C++ strvec怎么用?C++ strvec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了strvec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: achievable_from
void Matrix::achievable_from(strvec &nodes, strvec from) const{
int was = nodes.size();
involved_with(nodes, from);
if (nodes.size() == was)
return;
achievable_from(nodes, nodes);
}
示例2: srand
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);
}
示例3: printVector
//Just outputs vecRef
void printVector(strvec& vecRef)
{
for (int i = 0; i < vecRef.size(); i++)
{
std::cout << vecRef.at(i) << std::endl;
}
}
示例4: 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());
}
示例5: rv
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;
}
示例6: add
//Simple vector move function, pushes from from to to
void add(strvec& from, strvec& to)
{
for (int i = 0; i < from.size(); i++)
{
to.push_back(from.at(i));
}
}
示例7: 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;
}
示例8: 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;
}
示例9: getSolution
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;
}
示例10: 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);
}
}
示例11: optimiseLen
void MtxLP::optimiseLen(bool max, strvec q, bool presolve){
if (q.empty())
q = getColNames();
setObjDir(max);
setLenObjective(q, true);
Solve(presolve);
cleanTmpRows(q.size());
}
示例12: 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);
}
}
示例13: 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;
}
}
示例14: optimiseSum
void MtxLP::optimiseSum(bool max, strvec q, bool presolve){
setObjDir(max);
if (q.empty())
q = getColNames();
setObjective(q);
Solve(presolve);
}
示例15: runtime_error
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;
}
}