44 template<
class View,
bool p,
bool f>
123 int size(
void)
const;
138 template<
class View,
bool p,
bool f>
196 template<
class Char,
class Traits>
197 std::basic_ostream<Char,Traits>&
206 template<
class View,
bool p,
bool f>
210 :
Advisor(home,r,
c),
_info(static_cast<unsigned int>(i) << 2U) {}
211 template<
class View,
bool p,
bool f>
216 template<
class View,
bool p,
bool f>
221 template<
class View,
bool p,
bool f>
226 template<
class View,
bool p,
bool f>
229 return (
_info & 1U) != 0;
231 template<
class View,
bool p,
bool f>
234 return (
_info & 2U) != 0;
236 template<
class View,
bool p,
bool f>
241 template<
class View,
bool p,
bool f>
244 return static_cast<int>(
_info >> 2);
252 template<
class View,
bool p,
bool f>
258 for (
int i=0; i<
x.size(); i++)
259 if (!
x[i].assigned())
260 x[i].subscribe(home,*
new (home)
Idx(home,*
this,
c,i),
true);
263 template<
class View,
bool p,
bool f>
283 for (
int i=0; i<
n; i++) {
284 typename View::VarType xi(x[i].varimp());
285 a[i] = bm(home,xi,i);
288 for (
int i=0; i<
n; i++)
297 assert((i >= 0) && (i <
n));
298 a[i] =
invd * (
a[i] + 1.0);
300 for (
int j=0; j<
n; j++)
326 assert((i >= 0) && (i <
object().n));
379 template<
class Char,
class Traits>
380 std::basic_ostream<Char,Traits>&
383 std::basic_ostringstream<Char,Traits> s;
384 s.copyfmt(os); s.width(0);
388 for (
int i=1; i<a.size(); i++)
392 return os << s.str();
400 template<
class View,
bool p,
bool f>
407 template<
class View,
bool p,
bool f>
413 template<
class View,
bool p,
bool f>
421 x[as.advisor().idx()].cancel(home,as.advisor(),
true);
424 return sizeof(*this);
427 template<
class View,
bool p,
bool f>
433 template<
class View,
bool p,
bool f>
439 template<
class View,
bool p,
bool f>
442 Idx&
a =
static_cast<Idx&
>(_a);
451 template<
class View,
bool p,
bool f>
454 Idx&
a =
static_cast<Idx&
>(_a);
459 template<
class View,
bool p,
bool f>
465 int i = as.advisor().idx();
466 if (p && as.advisor().propagated()) {
467 as.advisor().clear();
470 as.advisor().dispose(home,
c);
472 if (f && as.advisor().failed()) {
473 as.advisor().clear();
476 as.advisor().dispose(home,
c);
Advisor with index and change information.
void propagate(void)
Mark index as propagated.
void clear(void)
Clear any information.
bool failed(void) const
Whether index has been failed.
unsigned int _info
Index and mark/failed information.
Idx(Space &home, Propagator &r, Council< Idx > &c, int i)
Constructor for creation.
void fail(void)
Mark index as failed.
int idx(void) const
Get index of view.
bool propagated(void) const
Whether index has been propagated.
Propagator for recording action information.
Council< Idx > c
The advisor council.
Recorder(Space &home, Recorder< View, p, f > &r)
Constructor for cloning r.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual Propagator * copy(Space &home)
Copy propagator during cloning.
static ExecStatus post(Home home, ViewArray< View > &x, Action &a)
Post action recorder propagator.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Action a
Access to action information.
virtual void reschedule(Space &home)
Schedule function.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (record so that propagator runs last).
Object for storing action values.
void update(int i)
Update action value at position i.
double invd
Inverse decay factor.
double * a
Action values (more follow).
static Support::Mutex m
Mutex to synchronize globally shared access.
~Storage(void)
Delete object.
Storage(Home home, ViewArray< View > &x, double d, typename BranchTraits< typename View::VarType >::Merit bm)
Initialize action values.
int n
Number of action values.
Class for action management.
Storage & object(void) const
Return object of correct type.
void init(Home home, ViewArray< View > &x, double d, bool p, bool f, typename BranchTraits< typename View::VarType >::Merit bm)
Initialize for views x and decay factor d and action as defined by bm.
void update(int i)
Update action value at position i.
Action & operator=(const Action &a)
Assignment operator.
Action(const Action &a)
Copy constructor.
int size(void) const
Return number of action values.
double operator[](int i) const
Return action value at position i.
void acquire(void)
Acquire mutex.
void release(void)
Release mutex.
static const Action def
Default (empty) action information.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Action &a)
Print action values enclosed in curly brackets.
Action(void)
Construct as not yet initialized.
double decay(const Space &home) const
Return decay factor.
void decay(Space &home, double d)
Set decay factor to d.
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
Class to iterate over advisors of a council.
Generic domain change information to be supplied to advisors.
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
NaryPropagator(Space &home, NaryPropagator &p)
static PropCost record(void)
For recording information (no propagation allowed).
Base-class for propagators.
ModEventDelta med
A set of modification events (used during propagation).
Propagator(Home home)
Constructor for posting.
SharedHandle(void)
Create shared handle with no object pointing to.
SharedHandle::Object * object(void) const
Access to the shared object.
A mutex for mutual exclausion among several threads.
void release(void)
Release the mutex.
void acquire(void)
Acquire the mutex and possibly block.
Heap heap
The single global heap.
ExecStatus ES_FIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
int ModEventDelta
Modification event deltas.
@ AP_DISPOSE
Actor must always be disposed.
#define GECODE_KERNEL_EXPORT
const double rescale_limit
Rescale action and afc values when larger than this.
const double rescale
Rescale factor for action and afc values.
Gecode toplevel namespace
Archive & operator<<(Archive &e, FloatNumBranch nl)
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_NOFIX
Propagation has not computed fixpoint.
const ModEvent ME_GEN_ASSIGNED
Generic modification event: variable is assigned a value.
const PropCond PC_GEN_NONE
Propagation condition to be ignored (convenience).
#define GECODE_VTABLE_EXPORT