Generated on Tue Apr 18 10:23:00 2017 for Gecode by doxygen 1.6.3

Grocery Class Reference
[Example scripts (models)]

Example: Grocery puzzle More...

List of all members.

Public Member Functions

 Grocery (const Options &opt)
 The actual model.
 Grocery (bool share, Grocery &s)
 Constructor for cloning s.
virtual Spacecopy (bool share)
 Copy during cloning.
virtual void print (std::ostream &os) const
 Print solution.

Protected Attributes

IntVarArray abcd
 The price of each item.

Static Protected Attributes

static const int s = 711
 Sum and product of prices.
static const int p = 711 * 100 * 100 * 100
 Decimal product of prices.

Detailed Description

Example: Grocery puzzle

A kid goes into a grocery store and buys four items. The cashier charges $7.11, the kid pays and is about to leave when the cashier calls the kid back, and says ''Hold on, I multiplied the four items instead of adding them; I'll try again; Hah, with adding them the price still comes to $7.11''. What were the prices of the four items?

The model is taken from: Christian Schulte, Gert Smolka, Finite Domain Constraint Programming in Oz. A Tutorial. 2001. Available from:

Definition at line 60 of file grocery.cpp.

Constructor & Destructor Documentation

Grocery::Grocery ( const Options opt  )  [inline]

The actual model.

Definition at line 70 of file grocery.cpp.

Grocery::Grocery ( bool  share,
Grocery s 
) [inline]

Constructor for cloning s.

Definition at line 87 of file grocery.cpp.

Member Function Documentation

virtual Space* Grocery::copy ( bool  share  )  [inline, virtual]

Copy during cloning.

Definition at line 93 of file grocery.cpp.

virtual void Grocery::print ( std::ostream &  os  )  const [inline, virtual]

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.

Definition at line 99 of file grocery.cpp.

Member Data Documentation

The price of each item.

Definition at line 63 of file grocery.cpp.

const int Grocery::s = 711 [static, protected]

Sum and product of prices.

Definition at line 65 of file grocery.cpp.

const int Grocery::p = 711 * 100 * 100 * 100 [static, protected]

Decimal product of prices.

Definition at line 67 of file grocery.cpp.

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