main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
int
exec
when.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
* Last modified:
10
* $Date: 2017-03-01 04:28:36 +0100 (Wed, 01 Mar 2017) $ by $Author: schulte $
11
* $Revision: 15541 $
12
*
13
* This file is part of Gecode, the generic constraint
14
* development environment:
15
* http://www.gecode.org
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining
18
* a copy of this software and associated documentation files (the
19
* "Software"), to deal in the Software without restriction, including
20
* without limitation the rights to use, copy, modify, merge, publish,
21
* distribute, sublicense, and/or sell copies of the Software, and to
22
* permit persons to whom the Software is furnished to do so, subject to
23
* the following conditions:
24
*
25
* The above copyright notice and this permission notice shall be
26
* included in all copies or substantial portions of the Software.
27
*
28
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
*
36
*/
37
38
#include <
gecode/int/exec.hh
>
39
40
namespace
Gecode
{
namespace
Int {
namespace
Exec {
41
42
Actor
*
43
When::copy
(
Space
& home,
bool
share) {
44
return
new
(home)
When
(home,share,*
this
);
45
}
46
47
ExecStatus
48
When::propagate
(
Space
& home,
const
ModEventDelta
&) {
49
if
(
x0
.
zero
()) {
50
GECODE_VALID_FUNCTION
(
e
());
51
e
()(home);
52
}
else
{
53
assert(
x0
.
one
());
54
GECODE_VALID_FUNCTION
(
t
());
55
t
()(home);
56
}
57
if
(home.
failed
())
58
return
ES_FAILED
;
59
return
home.
ES_SUBSUMED
(*
this
);
60
}
61
62
size_t
63
When::dispose
(
Space
& home) {
64
home.
ignore
(*
this
,
AP_DISPOSE
);
65
t
.~SharedData<std::function<void(
Space
& home)>>();
66
e
.~SharedData<std::function<void(
Space
& home)>>();
67
(void)
UnaryPropagator<BoolView,PC_BOOL_VAL>::dispose
(home);
68
return
sizeof
(*this);
69
}
70
71
}}}
72
73
// STATISTICS: int-prop
74
Gecode::Int::BoolView::zero
bool zero(void) const
Test whether view is assigned to be zero.
Definition:
bool.hpp:214
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3614
Gecode::Int::BoolView::one
bool one(void) const
Test whether view is assigned to be one.
Definition:
bool.hpp:218
Gecode::Int::Exec::When::t
SharedData< std::function< void(Space &home)> > t
Then function.
Definition:
exec.hh:60
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Int::Exec::When::copy
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition:
when.cpp:43
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:696
GECODE_VALID_FUNCTION
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition:
macros.hpp:98
Gecode
Gecode toplevel namespace
Gecode::Int::Exec::When::dispose
virtual size_t dispose(Space &home)
Dispose propagator.
Definition:
when.cpp:63
Gecode::AP_DISPOSE
@ AP_DISPOSE
Actor must always be disposed.
Definition:
core.hpp:630
Gecode::Int::Exec::When::e
SharedData< std::function< void(Space &home)> > e
Else function pointer.
Definition:
exec.hh:62
Gecode::Space::failed
bool failed(void) const
Check whether space is failed.
Definition:
core.hpp:4095
exec.hh
Gecode::UnaryPropagator
Unary propagator.
Definition:
propagator.hpp:59
Gecode::Space::ignore
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition:
core.hpp:4141
Gecode::Int::Exec::When::When
When(Space &home, bool share, When &p)
Constructor for cloning p.
Definition:
when.hpp:49
Gecode::ES_FAILED
@ ES_FAILED
Execution has resulted in failure.
Definition:
core.hpp:542
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:169
Gecode::UnaryPropagator< BoolView, PC_BOOL_VAL >::x0
BoolView x0
Single view.
Definition:
propagator.hpp:62
Gecode::Int::Exec::When::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
when.cpp:48
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:540