Generated on for Gecode by doxygen 1.17.0
open-propagator.hpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main author:
4 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
5 *
6 * Copyright:
7 * Mikael Zayenz Lagerkvist, 2026
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 GECODE_INT_OPEN_PROPAGATOR_HPP
35#define GECODE_INT_OPEN_PROPAGATOR_HPP
36
37#include <gecode/int.hh>
38
39namespace Gecode { namespace Int {
40
42 template<class View>
44 protected:
48
50 : Propagator(home), list(list0),
51 length(list0.length()),
52 processed(0) {
53 length.subscribe(home,*this,PC_INT_BND);
54 list.subscribe(home,*this);
55 }
56
58 : Propagator(home,p), processed(p.processed) {
59 list.update(home,p.list);
60 length.update(home,p.length);
61 }
62
63 bool
64 closed(void) const {
65 return length.max() == list.known_length();
66 }
67
68 void
70 length.cancel(home,*this,PC_INT_BND);
71 list.cancel(home,*this);
72 list.~OpenViewList();
73 (void) Propagator::dispose(home);
74 }
75
76 public:
77 virtual PropCost
78 cost(const Space&, const ModEventDelta&) const {
79 return PropCost::linear(PropCost::LO,list.known_length()-processed);
80 }
81
82 virtual void
84 length.reschedule(home,*this,PC_INT_BND);
85 list.reschedule(home,*this);
86 }
87 };
88
89}}
90
91#endif
92
93// STATISTICS: int-prop
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3430
Home class for posting propagators
Definition core.hpp:863
Integer view for integer variables.
Definition view.hpp:129
OpenListPropagator(Space &home, OpenListPropagator &p)
virtual void reschedule(Space &home)
Schedule function.
virtual PropCost cost(const Space &, const ModEventDelta &) const
Cost function.
OpenListPropagator(Home home, OpenViewList< View > list0)
View interface to a space-local list with an open length.
Definition int.hh:1044
Propagation cost.
Definition core.hpp:493
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Definition core.hpp:5080
friend class Space
Definition core.hpp:1075
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3707
int ModEventDelta
Modification event deltas.
Definition core.hpp:94
Finite domain integers.
Definition lastval.hh:52
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:99
Gecode toplevel namespace