本文整理汇总了C++中Assignment::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Assignment::size方法的具体用法?C++ Assignment::size怎么用?C++ Assignment::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assignment
的用法示例。
在下文中一共展示了Assignment::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_merged_assignment
Assignment get_merged_assignment(const Subset &s, const Assignment &ss0,
const Ints &i0, const Assignment &ss1,
const Ints &i1) {
Ints ret(s.size(), -1);
IMP_USAGE_CHECK(ss0.size() == i0.size(),
"The size of the subset and "
<< "the index don't match: " << ss0.size() << " vs "
<< i0.size());
IMP_USAGE_CHECK(ss1.size() == i1.size(),
"The size of the subset and "
<< "the index don't match: " << ss1.size() << " vs "
<< i1.size());
for (unsigned int i = 0; i < i0.size(); ++i) {
ret[i0[i]] = ss0[i];
}
for (unsigned int i = 0; i < i1.size(); ++i) {
ret[i1[i]] = ss1[i];
}
IMP_IF_CHECK(USAGE) {
for (unsigned int i = 0; i < ret.size(); ++i) {
IMP_USAGE_CHECK(ret[i] >= 0, "Not all set");
}
}
return Assignment(ret);
}
示例2: solution
/// Check whether \a x is solution
virtual bool solution(const Assignment& x) const {
for (int i=0; i<x.size(); i++)
for (int j=i+1; j<x.size(); j++)
if (x[i]+i==x[j]+j)
return false;
return true;
}
示例3: solution
/// %Test whether \a x is solution
virtual MaybeType solution(const Assignment& x) const {
if (x.size() == 1) {
return cmp(x[0],frt,c);
} else {
return cmp(x[0],frt,c) & cmp(x[1],frt,c);
}
}
示例4: solution
/// %Test whether \a x is solution
virtual MaybeType solution(const Assignment& x) const {
if (max < min)
return MT_FALSE;
for (int i=x.size(); i--; )
if ((x[i].max() > max) || (x[i].min() < min))
return MT_FALSE;
return MT_TRUE;
}
示例5: check_bitstring
bool CNFClause::check_bitstring(const Assignment & bitstring) const {
bool ok = false;
// we check whether an assignment is compatible with the clause literal by literal
for(const auto & lit : clause){
ok = ok || (lit.variable >= bitstring.size()) || (lit.value == bitstring[lit.variable]);
}
return ok;
}
示例6: solution
/// %Test whether \a x is solution
virtual bool solution(const Assignment& x) const {
for (int i=x.size(); i--; )
if (!(((x[i] >= -4) && (x[i] <= -3)) ||
((x[i] >= -1) && (x[i] <= -1)) ||
((x[i] >= 1) && (x[i] <= 1)) ||
((x[i] >= 3) && (x[i] <= 5))))
return false;
return true;
}
示例7: solution
/// %Test whether \a x is solution
virtual bool solution(const Assignment& x) const {
int n[4];
for (int i=4; i--; )
n[i]=0;
for (int i=x.size(); i--; )
n[x[i]-1]++;
if ((n[0] < 2) || (n[1] < 2) || (n[2] > 0) || (n[3] > 0))
return false;
return true;
}
示例8: solution
/// %Test whether \a x is solution
virtual bool solution(const Assignment& x) const {
int n = x.size();
for (int i = 0 ; i < n ; i++) {
if (x[i] == t)
return false;
if (x[i] == s)
return true;
}
return true;
}
示例9: is_compatible
bool Assignment::is_compatible(const Assignment & partial) const{
int maxsize = std::max(partial.size(), size());
for(int i = 0; i<maxsize; i++){
if(partial[i] == -1){
continue;
}
if(partial[i] != assignment[i]){
return false;
}
}
return true;
}
示例10: solution
/// %Test whether \a x is solution
virtual MaybeType solution(const Assignment& x) const {
Gecode::FloatVal e = 0.0;
for (int i=x.size(); i--; )
e += a[i]*x[i];
switch (cmp(e, frt, Gecode::FloatVal(c))) {
case MT_FALSE: {
Gecode::FloatVal eError = e;
for (int i=x.size(); i--; )
eError -= a[i]*x[i];
if (cmp(e+eError, frt, Gecode::FloatVal(c)) == MT_FALSE)
return MT_FALSE;
else
return MT_MAYBE;
}
case MT_TRUE:
return MT_TRUE;
case MT_MAYBE:
return MT_MAYBE;
}
GECODE_NEVER;
return MT_FALSE;
}
示例11: solution
/// %Test whether \a xy is solution
virtual bool solution(const Assignment& xy) const {
int n = xy.size() / 2;
for (int i=0; i<n; i++) {
int xi=xy[2*i+0], yi=xy[2*i+1];
for (int j=i+1; j<n; j++) {
int xj=xy[2*j+0], yj=xy[2*j+1];
if (!((xi + w[i] <= xj) || (xj + w[j] <= xi) ||
(yi + h[i] <= yj) || (yj + h[j] <= yi)))
return false;
}
}
return true;
}
示例12: solution
/// %Test whether \a x is solutionin
virtual bool solution(const Assignment& x) const {
for (int i=0; i< (x.size() - q + 1); i++ ) {
int total = 0;
for (int j=i; j < i + q; j++ ) {
if (s.in(x[j]))
total++;
if (total > u)
return false;
}
if ( total < l )
return false;
}
return true;
}
示例13: solution
/// %Test whether \a x is solution
virtual bool solution(const Assignment& x) const {
int n = x.size();
bool* v = new bool[n+1];
for (int i=n+1; i--; )
v[i] = false;
int k = 0;
for (int i=n; i--; )
if (!v[x[i]]) {
k++;
v[x[i]] = true;
}
delete [] v;
return cmp(k,irt,m);
}
示例14: solution
/// Check whether \a x is solution
virtual bool solution(const Assignment& x) const {
int n = x.size()-1;
for (int i=n; i--; )
if ((x[i] != 0) && (x[i] != 1))
return false;
int k=x[n]-o;
if ((k<0) || (k>=n))
return false;
for (int i=0; i<k; i++)
if (x[i] != 0)
return false;
for (int i=k+1; i<n; i++)
if (x[i] != 0)
return false;
return x[k] == 1;
}
示例15: apply_assignment
bool Configuration::apply_assignment(Assignment &assignment){
/* This method apply each individual assignment in order.
* If one of them fails, the complete process fails.
*/
for(int i=0;i<assignment.size();i++){
switch(assignment[i].second){
case SELECTED:
if(!this->apply_selection(assignment[i].first))
return false;
break;
case DESELECTED:
if(!this->apply_deselection(assignment[i].first))
return false;
break;
}
}
return true;
}