Generated on for Gecode by doxygen 1.17.0
complete.hh
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Jip J. Dekker <jip.dekker@monash.edu>
5 *
6 * Copyright:
7 * Jip J. Dekker, 2023
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.dev
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#ifndef FLATZINC_COMPLETE_HH
35#define FLATZINC_COMPLETE_HH
36
37#include <gecode/flatzinc.hh>
38#include <gecode/int.hh>
39
40using namespace Gecode::Int;
41
42namespace Gecode { namespace FlatZinc {
43
44 class Complete : public UnaryPropagator<BoolView, PC_BOOL_VAL> {
45 protected:
47
52 public:
54 virtual Actor* copy(Space& home){ return new (home) Complete(home,*this); }
56 virtual PropCost cost(const Space& /* home */, const ModEventDelta& /* med */) const { return PropCost::record(); }
58 virtual ExecStatus propagate(Space& home, const ModEventDelta& /* med */) {
59 assert(x0.assigned());
60 if (x0.val()) {
61 static_cast<FlatZincSpace&>(home).restart_data().mark_complete = true;
62 }
63 return home.ES_SUBSUMED(*this);
64 }
65
67 if (x0.assigned()) {
68 home.restart_data().mark_complete = x0.val();
69 } else {
70 (void) new (home) Complete(home, x0);
71 }
72 return ES_OK;
73 }
74 };
75
76}}
77
78#endif // FLATZINC_COMPLETE_HH
79
80// STATISTICS: flatzinc-branch
Base-class for both propagators and branchers.
Definition core.hpp:635
static ExecStatus post(FlatZincSpace &home, BoolView x0)
Definition complete.hh:66
virtual PropCost cost(const Space &, const ModEventDelta &) const
Cost function.
Definition complete.hh:56
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition complete.hh:54
Complete(FlatZincSpace &home, BoolView x0)
Constructor for posting.
Definition complete.hh:51
virtual ExecStatus propagate(Space &home, const ModEventDelta &)
Perform propagation.
Definition complete.hh:58
Complete(Space &home, Complete &p)
Constructor for cloning p.
Definition complete.hh:49
A space that can be initialized with a FlatZinc model.
Definition flatzinc.hh:424
Boolean view for Boolean variables.
Definition view.hpp:1378
Propagation cost.
Definition core.hpp:493
static PropCost record(void)
For recording information (no propagation allowed).
Definition core.hpp:4941
friend class Space
Definition core.hpp:1075
UnaryPropagator(Space &home, UnaryPropagator &p)
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
Definition core.hpp:3672
int ModEventDelta
Modification event deltas.
Definition core.hpp:94
Interpreter for the FlatZinc language.
Finite domain integers.
Definition lastval.hh:52
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:134
Gecode toplevel namespace
ExecStatus
Definition core.hpp:479
@ ES_OK
Execution is okay.
Definition core.hpp:483