Generated on for Gecode by doxygen 1.15.0
blackbox-propagator.cpp
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 * Contributing authors:
7 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
8 *
9 * Copyright:
10 * Jip J. Dekker, 2026
11 *
12 * This file is part of Gecode, the generic constraint
13 * development environment:
14 * http://www.gecode.org
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining
17 * a copy of this software and associated documentation files (the
18 * "Software"), to deal in the Software without restriction, including
19 * without limitation the rights to use, copy, modify, merge, publish,
20 * distribute, sublicense, and/or sell copies of the Software, and to
21 * permit persons to whom the Software is furnished to do so, subject to
22 * the following conditions:
23 *
24 * The above copyright notice and this permission notice shall be
25 * included in all copies or substantial portions of the Software.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 *
35 */
36
39
40#include <atomic>
41#include <cstdint>
42#include <exception>
43#include <string>
44#include <vector>
45
46namespace Gecode {
47namespace FlatZinc {
48
49namespace {
50
51class BlackBoxHandle : public SharedHandle {
52public:
53 explicit BlackBoxHandle(BlackBoxBackend* backend) : SharedHandle() {
54 object(backend);
55 }
56 explicit BlackBoxHandle(const SharedHandle& handle) : SharedHandle(handle) {}
57 BlackBoxHandle(const BlackBoxHandle& handle) : SharedHandle(handle) {}
58 BlackBoxHandle& operator=(const BlackBoxHandle& handle) {
59 return static_cast<BlackBoxHandle&>(SharedHandle::operator=(handle));
60 }
61 BlackBoxBackend* operator()(void) const {
62 return static_cast<BlackBoxBackend*>(object());
63 }
64};
65
66}
67
69protected:
70 class ExecEntry {
71 public:
72 std::string program;
73 std::vector<std::string> args;
74 BlackBoxHandle handle;
75 ExecEntry(const std::string &program0, const std::vector<std::string> &args0,
76 const BlackBoxHandle &handle0)
77 : program(program0), args(args0), handle(handle0) {}
78 };
80 std::vector<ExecEntry> exec;
81 std::exception_ptr exception;
82 std::atomic<bool> error_recorded;
83
84public:
86 BlackBoxHandle backendForConstraint(const std::string& mode,
87 const std::string& target,
88 const std::vector<std::string>& args);
89 void fail(std::exception_ptr e);
90 bool failed(void) const;
91 void rethrow(void) const;
92};
93
94void
96 if (!*this) {
98 }
99}
100
103 const std::string& mode, const std::string& target,
104 const std::vector<std::string>& args) const {
105 return static_cast<BlackBoxContext*>(object())
106 ->backendForConstraint(mode, target, args);
107}
108
109void
110BlackBoxContextHandle::fail(std::exception_ptr e) const {
111 static_cast<BlackBoxContext*>(object())->fail(e);
112}
113
114bool
116 return static_cast<bool>(*this) &&
117 static_cast<BlackBoxContext*>(object())->failed();
118}
119
120void
122 if (*this) {
123 static_cast<BlackBoxContext*>(object())->rethrow();
124 }
125}
126
127BlackBoxHandle
129 const std::string& target,
130 const std::vector<std::string>& args) {
131 if (mode == "exec") {
132 Support::Lock lock(mutex);
133 for (const ExecEntry &e : exec) {
134 if ((e.program == target) && (e.args == args)) {
135 return e.handle;
136 }
137 }
138 BlackBoxHandle handle(new BlackBoxExec(target, args));
139 exec.push_back(ExecEntry(target, args, handle));
140 return handle;
141 }
142 if (mode == "dll") {
143 return BlackBoxHandle(new BlackBoxLibrary(target, args));
144 }
145 throw Error("Blackbox", "Unknown blackbox protocol `" + mode + "'");
146}
147
148void
149BlackBoxContext::fail(std::exception_ptr e) {
150 Support::Lock lock(mutex);
151 if (!error_recorded.load(std::memory_order_relaxed)) {
152 exception = e;
153 error_recorded.store(true, std::memory_order_release);
154 }
155}
156
157bool
159 return error_recorded.load(std::memory_order_acquire);
160}
161
162void
164 if (!error_recorded.load(std::memory_order_acquire)) {
165 return;
166 }
167 std::exception_ptr e;
168 {
169 Support::Lock lock(mutex);
170 e = exception;
171 }
172 if (e != nullptr) {
173 std::rethrow_exception(e);
174 }
175}
176
177namespace {
178
179class BlackBox : public Propagator {
180protected:
181 ViewArray<Int::IntView> int_input;
182 ViewArray<Int::IntView> int_output;
183#ifdef GECODE_HAS_FLOAT_VARS
184 ViewArray<Float::FloatView> float_input;
185 ViewArray<Float::FloatView> float_output;
186#endif
187 BlackBoxHandle backend;
188 BlackBoxContextHandle context;
189
190 BlackBox(Space& home, BlackBox& p)
191 : Propagator(home, p), backend(p.backend), context(p.context) {
192 int_input.update(home, p.int_input);
193 int_output.update(home, p.int_output);
195 float_input.update(home, p.float_input);
196 float_output.update(home, p.float_output);
197#endif
198 }
199
200public:
201 BlackBox(Home home, ViewArray<Int::IntView>& int_in,
206#endif
207 const BlackBoxHandle& backend0,
208 const BlackBoxContextHandle& context0)
209 : Propagator(home), int_input(int_in), int_output(int_out),
211 float_input(float_in), float_output(float_out),
212#endif
213 backend(backend0), context(context0) {
214 int_input.subscribe(home, *this, Int::PC_INT_VAL);
215#ifdef GECODE_HAS_FLOAT_VARS
216 float_input.subscribe(home, *this, Float::PC_FLOAT_VAL);
217#endif
218 home.notice(*this, AP_DISPOSE);
219 }
220
221 PropCost cost(const Space&, const ModEventDelta&) const override {
222 return PropCost::crazy(PropCost::HI, int_input.size()
224 + float_input.size()
225#endif
226 );
227 }
228
229 void reschedule(Space& home) override {
230 int_input.reschedule(home, *this, Int::PC_INT_VAL);
231#ifdef GECODE_HAS_FLOAT_VARS
232 float_input.reschedule(home, *this, Float::PC_FLOAT_VAL);
233#endif
234 }
235
236 size_t dispose(Space& home) override {
237 int_input.cancel(home, *this, Int::PC_INT_VAL);
238#ifdef GECODE_HAS_FLOAT_VARS
239 float_input.cancel(home, *this, Float::PC_FLOAT_VAL);
240#endif
241 home.ignore(*this, AP_DISPOSE);
242 backend.~BlackBoxHandle();
243 context.~BlackBoxContextHandle();
244 (void) Propagator::dispose(home);
245 return sizeof(*this);
246 }
247
248 ExecStatus propagate(Space& home, const ModEventDelta&) override;
249
250 Propagator* copy(Space& home) override {
251 return new (home) BlackBox(home, *this);
252 }
253
254 static ExecStatus post(Home home, ViewArray<Int::IntView>& int_input,
255 ViewArray<Int::IntView>& int_output,
257 ViewArray<Float::FloatView>& float_input,
258 ViewArray<Float::FloatView>& float_output,
259#endif
260 const BlackBoxContextHandle& context,
261 const std::string& mode, const std::string& target,
262 const std::vector<std::string>& args);
263};
264
265class BlackBoxBounds : public Propagator {
266protected:
267 ViewArray<Int::IntView> ivar;
268#ifdef GECODE_HAS_FLOAT_VARS
269 ViewArray<Float::FloatView> fvar;
270#endif
271 SharedArray<bool> sub_int;
272#ifdef GECODE_HAS_FLOAT_VARS
273 SharedArray<bool> sub_float;
274#endif
275 BlackBoxHandle backend;
276 BlackBoxContextHandle context;
277
278 BlackBoxBounds(Space& home, BlackBoxBounds& p)
279 : Propagator(home, p), sub_int(p.sub_int),
281 sub_float(p.sub_float),
282#endif
283 backend(p.backend), context(p.context) {
284 ivar.update(home, p.ivar);
286 fvar.update(home, p.fvar);
287#endif
288 }
289
290public:
291 BlackBoxBounds(Home home, ViewArray<Int::IntView>& ivar0,
293 ViewArray<Float::FloatView>& fvar0,
294#endif
295 SharedArray<bool> sub_int0,
297 SharedArray<bool> sub_float0,
298#endif
299 const BlackBoxHandle& backend0,
300 const BlackBoxContextHandle& context0)
301 : Propagator(home), ivar(ivar0),
303 fvar(fvar0),
304#endif
305 sub_int(sub_int0),
307 sub_float(sub_float0),
308#endif
309 backend(backend0), context(context0) {
310 for (int i = 0; i < ivar.size(); i++)
311 if (sub_int[i])
312 ivar[i].subscribe(home, *this, Int::PC_INT_BND);
313#ifdef GECODE_HAS_FLOAT_VARS
314 for (int i = 0; i < fvar.size(); i++)
315 if (sub_float[i])
316 fvar[i].subscribe(home, *this, Float::PC_FLOAT_BND);
317#endif
318 home.notice(*this, AP_DISPOSE);
319 home.notice(*this, AP_WEAKLY);
320 }
321
322 PropCost cost(const Space&, const ModEventDelta&) const override {
323 return PropCost::crazy(PropCost::HI, ivar.size()
325 + fvar.size()
326#endif
327 );
328 }
329
330 void reschedule(Space& home) override {
331 for (int i = 0; i < ivar.size(); i++)
332 if (sub_int[i])
333 ivar[i].reschedule(home, *this, Int::PC_INT_BND);
334#ifdef GECODE_HAS_FLOAT_VARS
335 for (int i = 0; i < fvar.size(); i++)
336 if (sub_float[i])
337 fvar[i].reschedule(home, *this, Float::PC_FLOAT_BND);
338#endif
339 }
340
341 size_t dispose(Space& home) override {
342 for (int i = 0; i < ivar.size(); i++)
343 if (sub_int[i])
344 ivar[i].cancel(home, *this, Int::PC_INT_BND);
345#ifdef GECODE_HAS_FLOAT_VARS
346 for (int i = 0; i < fvar.size(); i++)
347 if (sub_float[i])
348 fvar[i].cancel(home, *this, Float::PC_FLOAT_BND);
349#endif
350 home.ignore(*this, AP_DISPOSE);
351 home.ignore(*this, AP_WEAKLY);
352 backend.~BlackBoxHandle();
353 context.~BlackBoxContextHandle();
354 sub_int.~SharedArray<bool>();
355#ifdef GECODE_HAS_FLOAT_VARS
356 sub_float.~SharedArray<bool>();
357#endif
358 (void) Propagator::dispose(home);
359 return sizeof(*this);
360 }
361
362 ExecStatus propagate(Space& home, const ModEventDelta&) override;
363 Propagator* copy(Space& home) override {
364 return new (home) BlackBoxBounds(home, *this);
365 }
366
367 static ExecStatus evaluate(Home home, ViewArray<Int::IntView>& ivar,
369 ViewArray<Float::FloatView>& fvar,
370#endif
371 BlackBoxHandle& backend,
372 const BlackBoxContextHandle& context);
373 static ExecStatus post(Home home, ViewArray<Int::IntView>& ivar,
375 ViewArray<Float::FloatView>& fvar,
376#endif
377 SharedArray<bool> sub_int,
379 SharedArray<bool> sub_float,
380#endif
381 const BlackBoxContextHandle& context,
382 const std::string& mode, const std::string& target,
383 const std::vector<std::string>& args);
384};
385
386} // namespace
387
389BlackBox::post(Home home, ViewArray<Int::IntView>& int_input,
390 ViewArray<Int::IntView>& int_output,
392 ViewArray<Float::FloatView>& float_input,
393 ViewArray<Float::FloatView>& float_output,
394#endif
395 const BlackBoxContextHandle& context,
396 const std::string& mode, const std::string& target,
397 const std::vector<std::string>& args) {
398 BlackBoxHandle backend(context.backendForConstraint(mode, target, args));
399 if ((int_input.size() == 0)
401 && (float_input.size() == 0)
402#endif
403 ) {
404 std::vector<int64_t> int_in;
405 std::vector<int64_t> int_out(int_output.size());
406 std::vector<double> float_in;
407 std::vector<double> float_out;
408#ifdef GECODE_HAS_FLOAT_VARS
409 float_out.resize(float_output.size());
410#endif
411 BlackBoxCall call = {int_in, float_in, int_out, float_out};
412 backend()->run(call);
413 for (int i = 0; i < int_output.size(); i++)
414 if (me_failed(int_output[i].eq(home, static_cast<int>(int_out[i]))))
415 return ES_FAILED;
416#ifdef GECODE_HAS_FLOAT_VARS
417 for (int i = 0; i < float_output.size(); i++)
418 if (me_failed(float_output[i].eq(home, float_out[i])))
419 return ES_FAILED;
420#endif
421 return ES_OK;
422 }
423
424 new (home) BlackBox(home, int_input, int_output,
426 float_input, float_output,
427#endif
428 backend, context);
429 return ES_OK;
430}
431
433BlackBoxBounds::post(Home home, ViewArray<Int::IntView>& ivar,
435 ViewArray<Float::FloatView>& fvar,
436#endif
437 SharedArray<bool> sub_int,
439 SharedArray<bool> sub_float,
440#endif
441 const BlackBoxContextHandle& context,
442 const std::string& mode, const std::string& target,
443 const std::vector<std::string>& args) {
444 BlackBoxHandle backend(context.backendForConstraint(mode, target, args));
445 bool has_subscription = false;
446 for (int i = 0; i < ivar.size(); i++)
447 has_subscription = has_subscription || sub_int[i];
448#ifdef GECODE_HAS_FLOAT_VARS
449 for (int i = 0; i < fvar.size(); i++)
450 has_subscription = has_subscription || sub_float[i];
451#endif
452 if (!has_subscription)
453 return evaluate(home, ivar,
455 fvar,
456#endif
457 backend, context);
458
459 new (home) BlackBoxBounds(home, ivar,
461 fvar,
462#endif
463 sub_int,
465 sub_float,
466#endif
467 backend, context);
468 return ES_OK;
469}
470
471ExecStatus BlackBox::propagate(Space &home, const ModEventDelta &) {
472 if (int_input.assigned()
474 && float_input.assigned()
475#endif
476 ) {
477 std::vector<int64_t> int_in(int_input.size());
478 std::vector<int64_t> int_out(int_output.size());
479 for (size_t i = 0; i < int_in.size(); i++) {
480 int_in[i] = static_cast<int64_t>(int_input[i].val());
481 }
482 std::vector<double> float_in;
483 std::vector<double> float_out;
484#ifdef GECODE_HAS_FLOAT_VARS
485 float_in.resize(float_input.size());
486 float_out.resize(float_output.size());
487 for (size_t i = 0; i < float_in.size(); i++) {
488 float_in[i] = float_input[i].val().med();
489 }
490#endif
491
492 try {
493 BlackBoxCall call = {int_in, float_in, int_out, float_out};
494 backend()->run(call);
495 } catch (...) {
496 context.fail(std::current_exception());
497 return ES_FAILED;
498 }
499
500 for (size_t i = 0; i < int_out.size(); i++) {
501 GECODE_ME_CHECK(int_output[i].eq(home, static_cast<int>(int_out[i])));
502 }
503#ifdef GECODE_HAS_FLOAT_VARS
504 for (size_t i = 0; i < float_out.size(); i++) {
505 GECODE_ME_CHECK(float_output[i].eq(home, float_out[i]));
506 }
507#endif
508
509 return home.ES_SUBSUMED(*this);
510 }
511 return ES_FIX;
512}
513
515BlackBoxBounds::evaluate(Home home, ViewArray<Int::IntView> &ivar,
517 ViewArray<Float::FloatView> &fvar,
518#endif
519 BlackBoxHandle& backend,
520 const BlackBoxContextHandle& context) {
521 std::vector<int64_t> int_in(ivar.size() * 2);
522 std::vector<int64_t> int_out(ivar.size() * 2);
523 for (int i = 0; i < ivar.size(); i++) {
524 int_in[i*2] = static_cast<int64_t>(ivar[i].min());
525 int_in[i*2+1] = static_cast<int64_t>(ivar[i].max());
526 }
527 std::vector<double> float_in;
528 std::vector<double> float_out;
529#ifdef GECODE_HAS_FLOAT_VARS
530 float_in.resize(fvar.size() * 2);
531 float_out.resize(fvar.size() * 2);
532 for (int i = 0; i < fvar.size(); i++) {
533 float_in[i*2] = fvar[i].min();
534 float_in[i*2+1] = fvar[i].max();
535 }
536#endif
537
538 try {
539 BlackBoxCall call = {int_in, float_in, int_out, float_out};
540 backend()->run(call);
541 } catch (...) {
542 context.fail(std::current_exception());
543 return ES_FAILED;
544 }
545
546 for (int i = 0; i < ivar.size(); i++) {
547 if (me_failed(ivar[i].gq(home, static_cast<int>(int_out[i*2]))) ||
548 me_failed(ivar[i].lq(home, static_cast<int>(int_out[i*2+1])))) {
549 return ES_FAILED;
550 }
551 }
552#ifdef GECODE_HAS_FLOAT_VARS
553 for (int i = 0; i < fvar.size(); i++) {
554 if (me_failed(fvar[i].gq(home, float_out[i*2])) ||
555 me_failed(fvar[i].lq(home, float_out[i*2+1]))) {
556 return ES_FAILED;
557 }
558 }
559#endif
560
561 return ES_OK;
562}
563
564ExecStatus BlackBoxBounds::propagate(Space &home, const ModEventDelta &) {
565 ExecStatus es = evaluate(home, ivar,
567 fvar,
568#endif
569 backend, context);
570 return (es == ES_OK) ? ES_NOFIX : es;
571}
572
574 const IntVarArgs &int_in, const IntVarArgs &int_out,
576 const FloatVarArgs &float_in, const FloatVarArgs &float_out,
577#endif
578 const std::string &mode, const std::string &target,
579 const std::vector<std::string> &args) {
580 ViewArray<Int::IntView> int_input(home, int_in);
581 ViewArray<Int::IntView> int_output(home, int_out);
582#ifdef GECODE_HAS_FLOAT_VARS
583 ViewArray<Float::FloatView> float_input(home, float_in);
584 ViewArray<Float::FloatView> float_output(home, float_out);
585#endif
586
587 if (home.failed())
588 return;
589 context.init();
590 PostInfo pi(home);
591 ExecStatus es = BlackBox::post(home, int_input, int_output,
593 float_input, float_output,
594#endif
595 context, mode, target, args);
596 GECODE_ES_FAIL(es);
597}
598
607static void reason_subscriptions(const std::vector<int> &reason, int n_int,
608 int n_float, SharedArray<bool> &sub_int,
609 SharedArray<bool> &sub_float) {
610 for (int i = 0; i < n_int; i++) {
611 sub_int[i] = false;
612 }
613 for (int i = 0; i < n_float; i++) {
614 sub_float[i] = false;
615 }
616
617 const int n_total = n_int + n_float;
618 std::vector<bool> explained(n_total, false);
619 size_t pos = 0;
620 auto require = [&](size_t n, const char *what) {
621 if (reason.size() - pos < n) {
622 throw Error("Blackbox", std::string("Malformed blackbox bounds reason: ") +
623 what + ".");
624 }
625 };
626 while (pos < reason.size()) {
627 require(1, "missing explained variable index");
628 int idx = reason[pos++];
629 if ((idx < 1) || (idx > n_total)) {
630 throw Error("Blackbox",
631 "Malformed blackbox bounds reason: explained variable index "
632 "is out of range.");
633 }
634 if (explained[idx - 1]) {
635 throw Error("Blackbox",
636 "Malformed blackbox bounds reason: duplicate explained "
637 "variable index.");
638 }
639 explained[idx - 1] = true;
640 for (int side = 0; side < 2; side++) { // lower- then upper-bound literals
641 require(1, "missing reason literal count");
642 int count = reason[pos++];
643 if (count < 0) {
644 throw Error("Blackbox",
645 "Malformed blackbox bounds reason: negative literal count.");
646 }
647 if (static_cast<size_t>(count) > (reason.size() - pos) / 2) {
648 throw Error("Blackbox",
649 "Malformed blackbox bounds reason: truncated reason "
650 "literals.");
651 }
652 for (int k = 0; k < count; k++) {
653 int var = reason[pos++]; // 1-based combined variable index
654 int bnd = reason[pos++];
655 if (var >= 1 && var <= n_int) {
656 sub_int[var - 1] = true;
657 } else if (var > n_int && var <= n_int + n_float) {
658 sub_float[var - 1 - n_int] = true;
659 } else {
660 throw Error("Blackbox",
661 "Malformed blackbox bounds reason: dependency variable "
662 "index is out of range.");
663 }
664 if (bnd != 1 && bnd != 2) { // MiniZinc PropBnd: PR_LB, PR_UB
665 throw Error("Blackbox",
666 "Malformed blackbox bounds reason: dependency bound "
667 "code is out of range.");
668 }
669 }
670 }
671 }
672 for (int i = 0; i < n_total; i++) {
673 if (!explained[i]) {
674 throw Error("Blackbox",
675 "Malformed blackbox bounds reason: missing explained "
676 "variable entry.");
677 }
678 }
679}
680
682 const IntVarArgs &ivar,
684 const FloatVarArgs &fvar,
685#endif
686 const std::string &mode, const std::string &target,
687 const std::vector<std::string> &args,
688 const std::vector<int> &reason) {
689 ViewArray<Int::IntView> int_var(home, ivar);
690#ifdef GECODE_HAS_FLOAT_VARS
691 ViewArray<Float::FloatView> float_var(home, fvar);
692 int n_float = fvar.size();
693#else
694 int n_float = 0;
695#endif
696
697 // Determine which variables the propagator depends on, so it is only
698 // subscribed (and thus scheduled) on the bounds mentioned in the reason. The
699 // marking is constant and shared between all copies of the propagator.
700 SharedArray<bool> sub_int(ivar.size());
701 SharedArray<bool> sub_float(n_float);
702 reason_subscriptions(reason, ivar.size(), n_float, sub_int, sub_float);
703
704 if (home.failed())
705 return;
706 context.init();
707 PostInfo pi(home);
708 ExecStatus es = BlackBoxBounds::post(home, int_var,
710 float_var,
711#endif
712 sub_int,
714 sub_float,
715#endif
716 context, mode, target, args);
717 GECODE_ES_FAIL(es);
718}
719
720} // namespace FlatZinc
721} // namespace Gecode
722
723// STATISTICS: flatzinc-prop
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3358
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1597
Model-local context shared by blackbox propagators and search support.
Definition blackbox.hh:56
void rethrow(void) const
Rethrow the first recorded propagation exception.
SharedHandle backendForConstraint(const std::string &mode, const std::string &target, const std::vector< std::string > &args) const
Return the backend selected for one constraint as an opaque handle.
void fail(std::exception_ptr e) const
Record the first exception raised during blackbox propagation.
bool failed(void) const
Whether blackbox propagation raised an exception.
void init(void)
Initialize this context if it is empty.
ExecEntry(const std::string &program0, const std::vector< std::string > &args0, const BlackBoxHandle &handle0)
BlackBoxHandle backendForConstraint(const std::string &mode, const std::string &target, const std::vector< std::string > &args)
Persistent-process backend shared by equal executable configurations.
Dynamic-library backend owned by one blackbox constraint.
Exception class for FlatZinc errors
Definition flatzinc.hh:727
Passing float variables.
Definition float.hh:982
Home class for posting propagators
Definition core.hpp:863
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition core.hpp:3301
bool failed(void) const
Check whether corresponding space is failed.
Definition core.hpp:4185
Passing integer variables.
Definition int.hh:680
Class to set group information when a post function is executed.
Definition core.hpp:957
static PropCost crazy(PropCost::Mod m, unsigned int n)
Exponential complexity for modifier m and size measure n.
Definition core.hpp:4945
@ HI
Expensive.
Definition core.hpp:521
Base-class for propagators.
Definition core.hpp:1073
Shared array with arbitrary number of elements.
The shared handle.
SharedHandle & operator=(const SharedHandle &sh)
Assignment operator maintaining reference count.
SharedHandle::Object * object(void) const
Access to the shared object.
Computation spaces.
Definition core.hpp:1775
A lock as a scoped frontend for a mutex.
Definition thread.hpp:114
A mutex for mutual exclausion among several threads.
Definition thread.hpp:78
View arrays.
Definition array.hpp:255
void update(Space &home, ViewArray< View > &a)
Update array to be a clone of array a.
Definition array.hpp:1328
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
Definition array.hpp:1341
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1156
const int * pi[]
Definition photo.cpp:14262
int ModEventDelta
Modification event deltas.
Definition core.hpp:94
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition macros.hpp:52
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition modevent.hpp:54
@ AP_DISPOSE
Actor must always be disposed.
Definition core.hpp:569
@ AP_WEAKLY
Definition core.hpp:575
Interpreter for the FlatZinc language.
void blackbox_bounds(Home home, BlackBoxContextHandle &context, const IntVarArgs &ivar, const FloatVarArgs &fvar, const std::string &mode, const std::string &target, const std::vector< std::string > &args, const std::vector< int > &reason)
void blackbox(Home home, BlackBoxContextHandle &context, const IntVarArgs &int_in, const IntVarArgs &int_out, const FloatVarArgs &float_in, const FloatVarArgs &float_out, const std::string &mode, const std::string &target, const std::vector< std::string > &args)
bool pos(const View &x)
Test whether x is positive.
Definition mult.hpp:41
const Gecode::PropCond PC_FLOAT_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:291
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:300
void subscribe(Space &home, Propagator &p, VY y)
Subscribe propagator p to view y.
Definition rel.hpp:76
void reschedule(Space &home, Propagator &p, VY y)
Schedule propagator p for view y.
Definition rel.hpp:97
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:90
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:99
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition count.cpp:40
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition filter.cpp:138
ExecStatus
Definition core.hpp:479
@ ES_OK
Execution is okay.
Definition core.hpp:483
@ ES_FIX
Propagation has computed fixpoint.
Definition core.hpp:484
@ ES_FAILED
Execution has resulted in failure.
Definition core.hpp:481
@ ES_NOFIX
Propagation has not computed fixpoint.
Definition core.hpp:482
Gecode::IntArgs i({1, 2, 3, 4})
#define GECODE_HAS_FLOAT_VARS
Definition config.hpp:72