Gecode::Search::Par::PBS< Collect > Class Template Reference

Parallel portfolio engine implementation. More...

`#include <pbs.hh>`

## Public Member Functions

| PBS (Engine **s, Stop **so, unsigned int n, const Statistics &stat)
| Initialize.
virtual Space * | next (void)
| Return next solution (NULL, if none exists or search has been stopped).
virtual Statistics | statistics (void) const
| Return statistics.
virtual bool | stopped (void) const
| Check whether engine has been stopped.
virtual void | constrain (const Space &b)
| Constrain future solutions to be better than b.
virtual | ~PBS (void)
| Destructor.
Public Member Functions inherited from Gecode::Search::Par::Engine< Tracer >
const Options & | opt (void) const
| Provide access to search options.
unsigned int | workers (void) const
| Return number of workers.
Cmd | cmd (void) const
| Return current command.
void | block (void)
| Block all workers.
void | release (Cmd c)
| Release all workers.
void | wait (void)
| Ensure that worker waits.
void | ack_terminate (void)
| For worker to acknowledge termination command.
virtual void | terminated (void)
| For worker to register termination.
void | wait_terminate (void)
| For worker to wait until termination is legal.
void | terminate (void)
| For engine to peform thread termination.
void | ack_reset_start (void)
| For worker to acknowledge start of reset cycle.
void | ack_reset_stop (void)
| For worker to acknowledge stop of reset cycle.
void | wait_reset (void)
| For worker to wait for all workers to reset.
void | idle (void)
| Report that worker is idle.
void | busy (void)
| Report that worker is busy.
void | stop (void)
| Report that worker has been stopped.
| Engine (const Options &o)
| Initialize with options o.
Public Member Functions inherited from Gecode::Search::Engine
virtual void | reset (Space *s)
| Reset engine to restart at space s (does nothing).
virtual NoGoods & | nogoods (void)
| Return no-goods (the no-goods are empty).
virtual | ~Engine (void)
| Destructor.
Public Member Functions inherited from Gecode::Support::Terminator
virtual | ~Terminator ()
| Destructor.

## Protected Member Functions

bool | report (Slave< Collect > *slave, Space *s)
| Process report from slave, return false if solution was ignored.
bool | signal (void) const
| Whether search state changed such that signal is needed.

## Protected Attributes

Statistics | stat
| Master statistics.
Slave< Collect > ** | slaves
| Slave engines.
unsigned int | n_slaves
| Number of slave engines.
unsigned int | n_active
| Number of active slave engines.
bool | slave_stop
| Whether a slave has been stopped.
volatile bool | tostop
| Shared stop flag.
Collect | solutions
| Collect solutions in this.
Support::Mutex | m
| Mutex for synchronization.
unsigned int | n_busy
| Number of busy slaves.
Support::Event | idle
| Signal that number of busy slaves becomes zero.
Protected Attributes inherited from Gecode::Search::Par::Engine< Tracer >
Options | _opt
| Search options.
volatile Cmd | _cmd
| The current command.
Support::Mutex | _m_wait
| Mutex for forcing workers to wait.
Support::Mutex | _m_term
| Mutex for access to termination information.
volatile unsigned int | _n_term_not_ack
| Number of workers that have not yet acknowledged termination.
Support::Event | _e_term_ack
| Event for termination acknowledgment.
Support::Mutex | _m_wait_terminate
| Mutex for waiting for termination.
volatile unsigned int | _n_not_terminated
| Number of not yet terminated workers.
Support::Event | _e_terminate
| Event for termination (all threads have terminated).
Support::Mutex | _m_reset
| Mutex for access to reset information.
volatile unsigned int | _n_reset_not_ack
| Number of workers that have not yet acknowledged reset.
Support::Event | e_reset_ack_start
| Event for reset acknowledgment started.
Support::Event | e_reset_ack_stop
| Event for reset acknowledgment stopped.
Support::Mutex | m_wait_reset
| Mutex for waiting for reset.
Support::Mutex | m_search
| Mutex for search.
Support::Event | e_search
| Event for search (solution found, no more solutions, search stopped).
Support::DynamicQueue< Space *, Heap > | solutions
| Queue of solutions.
volatile unsigned int | n_busy
| Number of busy workers.
volatile bool | has_stopped
| Whether a worker had been stopped.

## Additional Inherited Members

Public Types inherited from Gecode::Search::Par::Engine< Tracer >
enum | Cmd { C_WORK , C_WAIT , C_RESET , C_TERMINATE }
| Commands from engine to workers. More...
Static Public Member Functions inherited from Gecode::HeapAllocated
static void * | operator new (size_t s)
| Memory management.
static void | operator delete (void *p)
| Free memory allocated from heap.

## Detailed Description

template<class Collect>
class Gecode::Search::Par::PBS< Collect >

Parallel portfolio engine implementation.

Definition at line 138 of file pbs.hh.

## Constructor & Destructor Documentation

## PBS()

template<class Collect>

Gecode::Search::Par::PBS< Collect >::PBS | ( | Engine ** | s,
|  | Stop ** | so,
|  | unsigned int | n,
|  | const Statistics & | stat )

inline

Initialize.

The key invariant of the engine is as follows:

- n_busy is always zero outside the next() function.
- that entails, that locking is only needed insided next().
- the slaves 0..n_active-1 still might not have exausted their search space.
- the slaves n_active..n_slaves-1 have exhausted their search space.

Definition at line 155 of file pbs.hpp.

## ~PBS()

template<class Collect>

Gecode::Search::Par::PBS< Collect >::~PBS | ( | void |  | ) |

virtual

Destructor.

Definition at line 284 of file pbs.hpp.

## Member Function Documentation

## report()

template<class Collect>

bool Gecode::Search::Par::PBS< Collect >::report | ( | Slave< Collect > * | slave,
|  | Space * | s )

inline protected

Process report from slave, return false if solution was ignored.

Definition at line 170 of file pbs.hpp.

## next()

template<class Collect>

Space * Gecode::Search::Par::PBS< Collect >::next | ( | void |  | ) |

virtual

Return next solution (NULL, if none exists or search has been stopped).

Reimplemented from Gecode::Search::Par::Engine< Tracer >.

Definition at line 210 of file pbs.hpp.

## statistics()

template<class Collect>

Statistics Gecode::Search::Par::PBS< Collect >::statistics | ( | void |  | ) | const

virtual

Return statistics.

Implements Gecode::Search::Engine.

Definition at line 262 of file pbs.hpp.

## stopped()

template<class Collect>

bool Gecode::Search::Par::PBS< Collect >::stopped | ( | void |  | ) | const

virtual

Check whether engine has been stopped.

Reimplemented from Gecode::Search::Par::Engine< Tracer >.

Definition at line 256 of file pbs.hpp.

## constrain()

template<class Collect>

void Gecode::Search::Par::PBS< Collect >::constrain | ( | const Space & | b | ) |

virtual

Constrain future solutions to be better than b.

Reimplemented from Gecode::Search::Engine.

Definition at line 272 of file pbs.hpp.

## Member Data Documentation

## stat

template<class Collect>

Statistics Gecode::Search::Par::PBS< Collect >::stat

protected

Master statistics.

Definition at line 142 of file pbs.hh.

## slaves

template<class Collect>

Slave<Collect>** Gecode::Search::Par::PBS< Collect >::slaves

protected

Slave engines.

Definition at line 144 of file pbs.hh.

## n_slaves

template<class Collect>

unsigned int Gecode::Search::Par::PBS< Collect >::n_slaves

protected

Number of slave engines.

Definition at line 146 of file pbs.hh.

## n_active

template<class Collect>

unsigned int Gecode::Search::Par::PBS< Collect >::n_active

protected

Number of active slave engines.

Definition at line 148 of file pbs.hh.

## slave_stop

template<class Collect>

bool Gecode::Search::Par::PBS< Collect >::slave_stop

protected

Whether a slave has been stopped.

Definition at line 150 of file pbs.hh.

## tostop

template<class Collect>

volatile bool Gecode::Search::Par::PBS< Collect >::tostop

protected

Shared stop flag.

Definition at line 152 of file pbs.hh.

## solutions

template<class Collect>

Collect Gecode::Search::Par::PBS< Collect >::solutions

protected

Collect solutions in this.

Definition at line 154 of file pbs.hh.

## m

template<class Collect>

Support::Mutex Gecode::Search::Par::PBS< Collect >::m

protected

Mutex for synchronization.

Definition at line 156 of file pbs.hh.

## n_busy

template<class Collect>

unsigned int Gecode::Search::Par::PBS< Collect >::n_busy

protected

Number of busy slaves.

Definition at line 158 of file pbs.hh.

## idle

template<class Collect>

Support::Event Gecode::Search::Par::PBS< Collect >::idle | ( | void |  | ) |

protected

Signal that number of busy slaves becomes zero.

Definition at line 160 of file pbs.hh.

The documentation for this class was generated from the following files:

- gecode/search/par/pbs.hh
- gecode/search/par/pbs.hpp