本文整理汇总了C++中Strategy::isFalse方法的典型用法代码示例。如果您正苦于以下问题:C++ Strategy::isFalse方法的具体用法?C++ Strategy::isFalse怎么用?C++ Strategy::isFalse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strategy
的用法示例。
在下文中一共展示了Strategy::isFalse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char * const argv[]) {
int depth = 5; // Size of the matrix is 2^depth. Larger values may take long to solve...
int nbDecisionVar = 2*depth;
int nbScope = nbDecisionVar+1;
bool* qtScopes = new bool[nbScope];
for (int i=0;i<nbScope;i++) {
qtScopes[i] = ((i%2) != 0);
// cout << (((i%2) != 0)?"true":"false")<<endl;
}
int boardSize = (int)pow((double)2,(double)depth);
std::srand(std::time(NULL));
IntArgs board(boardSize*boardSize);
for (int i=0; i<boardSize; i++)
for (int j=0; j<boardSize; j++)
board[j*boardSize+i] = (int)( (double)rand() / ((double)RAND_MAX + 1) * 50 ) < 25 ? 0:1;
IntArgs access(nbDecisionVar);
access[nbDecisionVar-1]=1;
access[nbDecisionVar-2]=boardSize;
for (int i=nbDecisionVar-3; i>=0; i--)
access[i]=access[i+2]*2;
// debug
for (int i=0; i<boardSize; i++)
{
for (int j=0; j<boardSize; j++)
cout << board[j*boardSize+i] << " ";
cout << endl;
}
cout << endl;
// for (int i=0; i<nbDecisionVar; i++)
// cout << access[i] << " ";
// cout << endl;
// end debug
int * scopesSize = new int[nbScope];
for (int i=0; i<nbScope-1; i++)
scopesSize[i]=1;
scopesSize[nbScope-1]=2;
Qcop p(nbScope, qtScopes, scopesSize);
// Defining the variable of the n first scopes ...
for (int i=0; i<nbDecisionVar; i++)
{
p.QIntVar(i, 0, 1);
IntVarArgs b(i+1);
for (int plop=0;plop<(i+1);plop++)
b[plop] = p.var(plop);
branch(*(p.space()),b,INT_VAR_SIZE_MIN(),INT_VAL_MIN());
p.nextScope();
}
// Declaring last scope variables ...
p.QIntVar(nbDecisionVar, 0, 1);
p.QIntVar(nbDecisionVar+1, 0, boardSize*boardSize);
IntVarArgs b(nbDecisionVar+2);
for (int plop=0;plop<(nbDecisionVar+2);plop++)
b[plop] = p.var(plop);
branch(*(p.space()),b,INT_VAR_SIZE_MIN(),INT_VAL_MIN());
p.nextScope();
// Body
rel(*(p.space()), p.var(nbDecisionVar) == 1);
IntVarArgs X(nbDecisionVar);
for (int i=0; i<nbDecisionVar; i++)
X[i]=p.var(i);
linear(*(p.space()), access, X, IRT_EQ, p.var(nbDecisionVar+1));
// MiniModel::LinRel R(E, IRT_EQ, MiniModel::LinExpr(p.var(nbDecisionVar+1)));
element(*(p.space()), board, p.var(nbDecisionVar+1), p.var(nbDecisionVar));
// Note : declaring a brancher for the goal is not mandatory, as the goal will be tested only when all variables are assigned.
// When every variables and constraints have been declared, the makeStructure method
// must be called in order to lead the problem ready for solving.
p.makeStructure();
// So, we build a quantified solver for our problem p, using the heuristic we just created.
QCSP_Solver solver(&p);
unsigned long int nodes=0;
// then we solve the problem. Nodes and Steps will contain the number of nodes encountered and
// of propagation steps achieved during the solving.
Strategy outcome = solver.solve(nodes);
cout << " outcome: " << ( outcome.isFalse()? "FALSE" : "TRUE") << endl;
cout << " nodes visited: " << nodes << endl;
}