本文整理汇总了C++中VarVector类的典型用法代码示例。如果您正苦于以下问题:C++ VarVector类的具体用法?C++ VarVector怎么用?C++ VarVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VarVector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: out
vector<double> BPMPDModel::getVarValues(const VarVector& vars) const {
vector<double> out(vars.size());
for (int i=0; i < vars.size(); ++i) {
int varind = vars[i].var_rep->index;
out[i] = m_soln[varind];
}
return out;
}
开发者ID:Hongxiao321321,项目名称:trajopt-1,代码行数:8,代码来源:bpmpd_interface.cpp
示例2: _GetVars
VarVector _GetVars(py::list ijs, const VarArray& vars) {
VarVector out;
int n = py::len(ijs);
for (int k=0; k < n; ++k) {
int i = py::extract<int>(ijs[k][0]);
int j = py::extract<int>(ijs[k][1]);
out.push_back(vars(i,j));
}
return out;
}
开发者ID:bryongloden,项目名称:trajopt,代码行数:10,代码来源:trajoptpy.cpp
示例3: Cost
RotationContinuityQuadraticCost::RotationContinuityQuadraticCost(const VarVector& vars, double coeff, NeedleProblemHelperPtr helper) : Cost("RotationContinuity"), vars(vars), coeff(coeff), helper(helper)
{
for (int i = 1; i < vars.size(); ++i)
{
exprInc(expr, exprMult(exprSquare(exprSub(AffExpr(vars[i]), AffExpr(vars[i-1]))), coeff));
}
}
开发者ID:panjia1983,项目名称:channel_backward,代码行数:7,代码来源:costs.cpp
示例4: unify
bool Variable::unify(const GlobalStorage *g, const Value& t, const VarVector& vars, ValueVector& vals) const
{
// TODO: constant access would be nice
for (size_t i = 0; i < vars.size(); ++i)
{
// if variable is bound
if (vars[i] == uid_)
{
// variable is not set, then set, else compare
if (vals[i].type_ == Value::UNDEF)
{
vals[i] = t;
return true;
}
else
return vals[i].equal(t);
}
}
FAIL(true);
}
开发者ID:grote,项目名称:Online-ASP,代码行数:20,代码来源:variable.cpp
示例5: getVec1
inline OutVecType getVec1(const vector<double>& x, const VarVector& vars) {
OutVecType out(vars.size());
for (unsigned i=0; i < vars.size(); ++i) out[i] = x[vars[i].var_rep->index];
return out;
}
开发者ID:Hongxiao321321,项目名称:trajopt-1,代码行数:5,代码来源:modeling.hpp
示例6: setVec
inline void setVec(DblVec& x, const VarVector& vars, const VecType& vals) {
assert(vars.size() == vals.size());
for (int i = 0; i < vars.size(); ++i) {
x[vars[i].var_rep->index] = vals[i];
}
}
开发者ID:Hongxiao321321,项目名称:trajopt-1,代码行数:6,代码来源:modeling.hpp
示例7: getSinBasis
void PushObject::updateModel(const Eigen::MatrixXd& traj, GRBQuadExpr& objective) {
VectorXd& times = m_problem->m_times;
MatrixXd perts_tk = getSinBasis(times/times.maxCoeff(), fmin(6, times.size()/2));
MatrixXd pinvperts_tk = perts_tk * (perts_tk.transpose() * perts_tk).inverse();
m_exactObjective = simulateTraj2(traj, true); // current value
LOG_INFO_FMT("current val: %.3f", m_exactObjective);
MatrixXd dy_jk(traj.cols(), perts_tk.cols());
double eps = 3e-4; // scale for joint angle change
Matrix3d A;
A << sq(eps/2), eps/2, 1,
0, 0, 1,
sq(eps/2), -eps/2, 1;
Matrix3d Ainv = A.inverse();
MatrixXd grad_tj(traj.rows(), traj.cols());
m_obj = GRBQuadExpr(0);
for (int j = 0; j < traj.cols(); ++j) {
VarVector v;
VectorXd vactual(traj.rows()-1);
for (int t=1; t < traj.rows(); ++t) {
v.push_back(m_problem->m_trajVars.at(t,j));
vactual(t-1) = traj(t,j);
}
for (int k = 0; k < perts_tk.cols(); ++k) {
MatrixXd newTraj = traj;
newTraj.col(j) = traj.col(j) + (eps/2)*perts_tk.col(k);
double plusVal = simulateTraj2(newTraj, false);
newTraj.col(j) = traj.col(j) - (eps/2)*perts_tk.col(k);
double minusVal = simulateTraj2(newTraj, false);
LOG_DEBUG_FMT("joint %i, basis %i, pert vals: %.4e %.4e ", j, k, plusVal-m_exactObjective,minusVal-m_exactObjective);
dy_jk(j,k) = (plusVal - minusVal)/eps;
Vector3d y;
y << plusVal-m_exactObjective, 0, minusVal - m_exactObjective;
Vector3d abc = Ainv*y;
GRBLinExpr q;
int T = traj.rows()-1;
VectorXd pertVec=perts_tk.block(1,k,T, 1);
q.addTerms(pertVec.data(),v.data(), T);
double qactual = pertVec.dot(vactual);
m_obj += fmax(abc(0),0)*(q-qactual)*(q-qactual) + abc(1)*(q-qactual);
}
// grad_tj.col(j) = pinvperts_tk * dy_jk.row(j).transpose();
}
m_obj += m_exactObjective;
// cout << "dy_jk:" << endl;
// cout << dy_jk << endl;
// cout << "grad_tj:" << endl;
// cout << grad_tj << endl;
// m_obj.addTerms(grad_tj.data()+7, m_problem->m_trajVars.m_data.data()+7, (traj.rows()-1)*traj.cols());
// m_obj += m_exactObjective - (grad_tj.middleRows(1, traj.rows()-1).array() * traj.middleRows(1, traj.rows()-1).array()).sum();
objective += m_obj;
}
开发者ID:NaohiroHayashi,项目名称:bulletsim,代码行数:63,代码来源:physics_aware.cpp
示例8: getDblVec
DblVec getDblVec(const vector<double>& x, const VarVector& vars) {
DblVec out(vars.size());
for (unsigned i=0; i < vars.size(); ++i) out[i] = x[vars[i].var_rep->index];
return out;
}
开发者ID:asbroad,项目名称:trajopt,代码行数:5,代码来源:modeling_utils.cpp
示例9: removeVars
void BPMPDModel::removeVars(const VarVector& vars) {
vector<int>inds = vars2inds(vars);
for (int i=0; i < vars.size(); ++i) vars[i].var_rep->removed = true;
}
开发者ID:Hongxiao321321,项目名称:trajopt-1,代码行数:4,代码来源:bpmpd_interface.cpp
示例10: sortByName
/**
* @brief Sorts the given vector by the name of its elements (case-insensitively).
*/
void sortByName(VarVector &vec) {
std::sort(vec.begin(), vec.end(), compareVars);
}
开发者ID:SchuckBeta,项目名称:retdec,代码行数:6,代码来源:ir.cpp
示例11: getValue
Token getValue(Token t)
{
if(t.tkntype == TKN_NUMBER)
return t;
else
{
t.tkntype = TKN_NUMBER;
t.number = varv.getVar(t.str);
return t;
}
}
开发者ID:Schumix,项目名称:Schumix,代码行数:11,代码来源:Calkulator.cpp
示例12: calculate
void IRCSession::calculate(string privmsg)
{
sk = TokenStack();
while(!q.empty())
{
Token t = q.get();
if(t.tkntype == TKN_NUMBER || t.tkntype == TKN_NAME)
sk.put(t);
else if(t.tkntype == TKN_OPERATOR)
{
if(t.str == "+")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, o1.number+o2.number, "");
sk.put(e);
}
else if(t.str == "-")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, o1.number-o2.number, "");
sk.put(e);
}
else if(t.str == "*")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, o1.number*o2.number, "");
sk.put(e);
}
else if(t.str == "/")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, o1.number/o2.number, "");
sk.put(e);
}
else if(t.str == "%")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, cast_int(o1.number)%cast_int(o2.number), "");
sk.put(e);
}
else if(t.str == "^" || t.str == "**")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, pow(o1.number, o2.number), "");
sk.put(e);
}
/*else if(t.str == "sin")
{
Token o1, o2;
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o2 = getValue(sk.get());
if(!sk.empty() && (sk.seek().tkntype == TKN_NUMBER || sk.seek().tkntype == TKN_NAME))
o1 = getValue(sk.get());
Token e = Token(TKN_NUMBER, sin(12), "");
sk.put(e);
}*/
}
}
double d;
if(!sk.empty())
//.........这里部分代码省略.........
开发者ID:Schumix,项目名称:Schumix,代码行数:101,代码来源:Calkulator.cpp
示例13: setConsts
void IRCSession::setConsts()
{
varv.setVar("pi", 3.1415926535897932384626433832795f, true);
}
开发者ID:Schumix,项目名称:Schumix,代码行数:4,代码来源:Calkulator.cpp
注:本文中的VarVector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论