本文整理汇总了C++中Var::domain方法的典型用法代码示例。如果您正苦于以下问题:C++ Var::domain方法的具体用法?C++ Var::domain怎么用?C++ Var::domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Var
的用法示例。
在下文中一共展示了Var::domain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testEraseRanges
void testEraseRanges(Var< IntSet > set, int nElems, int nTests)
{
for (int i = 1; i < (int)sqrt(nTests); i++)
{
int elem = (int)((double) nElems * (rand() / (double)RAND_MAX));
set.domain().insert(elem);
}
std::set<int> toErase;
for (int i = 1; i <= nElems; i++)
{
toErase.insert(i);
}
for (int i = 1; i < (int)sqrt(nTests); i++)
{
/*
int startPos = (int)((double) set.domain().possSize() * (rand() / (double)RAND_MAX));
int finishPos = min((int)((double) (set.domain().possSize() - startPos) * (rand() / (double)RAND_MAX)),10);
CurSetFD<int>::PIterator b = set.domain().beginPoss();
while (startPos-- > 0)
b++;
CurSetFD<int>::PIterator start = b;
while (finishPos-- > 0)
b++;
CurSetFD<int>::PIterator finish = b;
*/
int start = max(1,(int)((double) nElems * (rand() / (double)RAND_MAX)));
int finish = min(start + min((int)((double) nElems * (rand() / (double)RAND_MAX)),(int)(nElems / sqrt(nTests))),nElems);
std::set<int>::iterator b = toErase.find(start), e = toErase.find(finish);
timer.resume();
Detail::setEraseRange(set.domain(), b, e);
timer.pause();
}
}
示例2: testFindLUB
void testFindLUB(Var< IntSet > set, int nElems, int nTests)
{
for (int i = 1; i <= nTests / 2; i++)
{
int elem = (int)((double) set.domain().possSize() * (rand() / (double)RAND_MAX));
set.domain().insert(elem);
}
timer.resume();
for (int i = 1; i <= nTests; i++)
{
int elem = (int)((double)nElems * (rand() / (double)RAND_MAX));
if (set.domain().findInIn(elem) == set.domain().endIn())
set.domain().findInPoss(elem);
}
timer.pause();
}
示例3: testInserts
void testInserts(Var< IntSet > set, int nElems, int nTests)
{
timer.resume();
for (int i = 1; i <= min(nTests,nElems); i++)
{
int elem = (int)((double) nElems * (rand() / (double)RAND_MAX));
set.domain().insert(elem);
}
timer.pause();
}
示例4: testFindPoss
void testFindPoss(Var< IntSet > set, int nElems, int nTests)
{
timer.resume();
for (int i = 1; i <= nTests; i++)
{
int elem = (int)((double)nElems * (rand() / (double)RAND_MAX));
set.domain().findInPoss(elem);
}
timer.pause();
}
示例5: testFindGLB
void testFindGLB(Var< IntSet > set, int nElems, int nTests)
{
set.solver().post(cardinal(set) == nElems);
set.solver().solve(setLabel(set,true));
timer.resume();
for (int i = 1; i <= nTests; i++)
{
int elem = (int)((double)nElems * (rand() / (double)RAND_MAX));
set.domain().findInIn(elem);
}
timer.pause();
}