main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 24 2020 14:04:04 for Gecode by
doxygen
1.8.17
test
set
exec.cpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2009
8
*
9
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
#include "
test/set.hh
"
35
36
namespace
Test
{
namespace
Set {
37
39
namespace
Exec {
40
46
class
Wait
:
public
SetTest
{
48
protected
:
50
bool
sf
;
51
public
:
53
Wait
(
int
n
,
bool
sf0)
54
:
SetTest
(
"Wait::"
+
str
(
n
)+
"::"
+
55
(sf0 ?
"std::function"
:
"funptr"
),
n
,
56
Gecode
::IntSet(0,
n
),false),
sf
(sf0) {}
58
virtual
bool
solution
(
const
SetAssignment
&
x
)
const
{
59
(void)
x
;
60
return
true
;
61
}
63
virtual
void
post
(
Gecode::Space
& home,
Gecode::SetVarArray
&
x
,
64
Gecode::IntVarArray
&) {
65
using namespace
Gecode
;
66
auto
f
=
static_cast<
std::function<
void
(
Space
&)
>
>
67
([](
Space
& home) {
c
(home); });
68
if
(
x
.size() > 1) {
69
if
(
sf
)
70
Gecode::wait
(home,
x
,
f
);
71
else
72
Gecode::wait
(home,
x
, &
c
);
73
}
else
{
74
if
(
sf
)
75
Gecode::wait
(home,
x
[0],
f
);
76
else
77
Gecode::wait
(home,
x
[0], &
c
);
78
}
79
}
81
static
void
c
(
Gecode::Space
& _home) {
82
SetTestSpace
& home =
static_cast<
SetTestSpace
&
>
(_home);
83
for
(
int
i
=0;
i
<home.
x
.
size
();
i
++)
84
if
(!home.
x
[
i
].
assigned
())
85
home.
fail
();
86
}
87
};
88
89
Wait
w1t
(1,
true
),
w2t
(2,
true
);
90
Wait
w1f
(1,
false
),
w2f
(2,
false
);
91
93
94
}
95
96
}}
97
98
// STATISTICS: test-int
Test::Set::SetTestSpace::x
Gecode::SetVarArray x
Set variables to be tested.
Definition:
set.hh:187
Test::Set::SetTestSpace
Space for executing set tests.
Definition:
set.hh:182
Test::Set::Exec::Wait::Wait
Wait(int n, bool sf0)
Create and register test.
Definition:
exec.cpp:53
Test::Set::Exec::w1f
Wait w1f(1, false)
Test::Set::Exec::Wait::sf
bool sf
Whether to use std::function.
Definition:
exec.cpp:50
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::IntVarArray
Integer variable array.
Definition:
int.hh:763
Gecode::VarArray::size
int size(void) const
Return size of array (number of elements)
Definition:
array.hpp:926
set.hh
Test::Set::SetAssignment
Generate all set assignments.
Definition:
set.hh:142
Gecode::VarArray::assigned
bool assigned(void) const
Test if all variables are assigned.
Definition:
array.hpp:1026
Gecode
Gecode toplevel namespace
Test::Set::Exec::Wait::c
static void c(Gecode::Space &_home)
Continuation to be executed.
Definition:
exec.cpp:81
Test::Set::Exec::Wait::solution
virtual bool solution(const SetAssignment &x) const
Check whether x is solution.
Definition:
exec.cpp:58
x
Node * x
Pointer to corresponding Boolean expression node.
Definition:
bool-expr.cpp:249
Test::Set::SetTest
Base class for tests with set constraints
Definition:
set.hh:273
Test::Set::Exec::w2f
Wait w2f(2, false)
Test::Set::Exec::w2t
Wait w2t(2, true)
Test::Set::Exec::Wait
Simple test for wait (set variables)
Definition:
exec.cpp:47
Test::Set::Exec::Wait::post
virtual void post(Gecode::Space &home, Gecode::SetVarArray &x, Gecode::IntVarArray &)
Post wait on x.
Definition:
exec.cpp:63
Test::Set::SetTest::str
static std::string str(Gecode::SetRelType srt)
Map set relation to string.
Definition:
set.hpp:46
Gecode::wait
void wait(Home home, FloatVar x, std::function< void(Space &home)> c)
Execute c when x becomes assigned.
Definition:
exec.cpp:39
Gecode::Space::fail
void fail(void)
Fail space.
Definition:
core.hpp:4030
Test::Set::Exec::w1t
Wait w1t(1, true)
Test
General test support.
Definition:
afc.cpp:39
Test::Int::Unshare::f
Failed f
Definition:
unshare.cpp:124
Gecode::SetVarArray
Set variable array
Definition:
set.hh:570
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})