An operationplan is the key dynamic element of a plan. It represents a certain quantity being planned along a certain operation during a certain date range. More...

#include <model.h>

Inheritance diagram for frepple::OperationPlan:

Classes

class  FlowPlanIterator
 An iterator class to go through all flowplans of an operationplan. More...
 
class  iterator
 This class models an STL-like iterator that allows us to iterate over the operationplans in a simple and safe way. More...
 
class  LoadPlanIterator
 An iterator class to go through all loadplans of an operationplan. More...
 

Public Member Functions

bool activate (bool useMinCounter=true)
 
virtual void addSubOperationPlan (OperationPlan *)
 
void beginElement (XMLInput &, const Attribute &)
 
FlowPlanIterator beginFlowPlans () const
 
LoadPlanIterator beginLoadPlans () const
 
void createFlowLoads ()
 
void deactivate ()
 
void deleteFlowLoads ()
 
void endElement (XMLInput &, const Attribute &, const DataElement &)
 
FlowPlanIterator endFlowPlans () const
 
LoadPlanIterator endLoadPlans () const
 
virtual void eraseSubOperationPlan (OperationPlan *)
 
virtual PyObject * getattro (const Attribute &)
 
const DateRangegetDates () const
 
DemandgetDemand () const
 
PlannablegetEntity () const
 
bool getHidden () const
 
unsigned long getIdentifier () const
 
bool getLocked () const
 
PlannablegetMotive () const
 
OperationgetOperation () const
 
OperationPlangetOwner () const
 
double getPenalty () const
 
double getQuantity () const
 
virtual size_t getSize () const
 
const OperationPlangetTopOwner () const
 
const MetaClassgetType () const
 
TimePeriod getUnavailable () const
 
void insertInOperationplanList ()
 
bool isExcess (bool=false) const
 
 OperationPlan (const OperationPlan &, bool=true)
 
bool operator< (const OperationPlan &a) const
 
void removeFromOperationplanList ()
 
void restore (const OperationPlanState &x)
 
virtual int setattro (const Attribute &, const PythonObject &)
 
virtual void setChanged (bool b=true)
 
void setDemand (Demand *l)
 
virtual void setEnd (Date)
 
virtual void setLocked (bool b=true)
 
void setMotive (Plannable *v)
 
void setOwner (OperationPlan *o)
 
virtual double setQuantity (double f, bool roundDown=false, bool update=true, bool execute=true)
 
virtual void setStart (Date)
 
void setStartAndEnd (Date st, Date nd)
 
int sizeFlowPlans () const
 
int sizeLoadPlans () const
 
PyObject * str () const
 
virtual void updateProblems ()
 
virtual void writeElement (XMLOutput *, const Keyword &, mode=DEFAULT) const
 
virtual ~OperationPlan ()
 
- Public Member Functions inherited from frepple::utils::Object
 Object ()
 
virtual void setHidden (bool b)
 
virtual ~Object ()
 
- Public Member Functions inherited from frepple::utils::PythonExtensionBase
virtual PyObject * call (const PythonObject &args, const PythonObject &kwds)
 
virtual int compare (const PyObject *other) const
 
Py_ssize_t getReferenceCount () const
 
void initType (const MetaClass *t)
 
void initType (PyTypeObject *t)
 
virtual PyObject * iternext ()
 
 PythonExtensionBase ()
 
void resetReferenceCount ()
 
virtual ~PythonExtensionBase ()
 
- Public Member Functions inherited from frepple::HasProblems
 HasProblems ()
 
virtual ~HasProblems ()
 

Static Public Member Functions

static iterator begin ()
 
static PyObject * create (PyTypeObject *, PyObject *, PyObject *)
 
static ObjectcreateOperationPlan (const MetaClass *, const AttributeList &)
 
static void deleteOperationPlans (Operation *o, bool deleteLocked=false)
 
static bool empty ()
 
static iterator end ()
 
static OperationPlanfindId (unsigned long l)
 
static int initialize ()
 
static unsigned long size ()
 
static void writer (const MetaCategory *, XMLOutput *)
 
- Static Public Member Functions inherited from frepple::utils::Object
template<class T >
static PyObject * create (PyTypeObject *pytype, PyObject *args, PyObject *kwds)
 
template<class T >
static ObjectcreateDefault ()
 
template<class T >
static ObjectcreateString (const string &n)
 
static PyObject * toXML (PyObject *, PyObject *)
 
- Static Public Member Functions inherited from frepple::HasProblems
static EntityIterator beginEntity ()
 
static EntityIterator endEntity ()
 

Static Public Attributes

static const MetaCategorymetacategory
 
static const MetaClassmetadata
 

Friends

class Demand
 
class FlowPlan
 
class iterator
 
class LoadPlan
 
class Operation
 
class OperationAlternate
 
class OperationRouting
 
class ProblemPrecedence
 

Additional Inherited Members

- Protected Member Functions inherited from frepple::utils::NonCopyable
 NonCopyable ()
 
 ~NonCopyable ()
 
- Static Protected Member Functions inherited from frepple::utils::PythonExtensionBase
static PythonTyperegisterPythonType (int, const type_info *)
 
- Static Protected Attributes inherited from frepple::utils::PythonExtensionBase
static vector< PythonType * > table
 

Detailed Description

An operationplan is the key dynamic element of a plan. It represents a certain quantity being planned along a certain operation during a certain date range.

From a coding perspective:

  • Operationplans are created by the factory method createOperationPlan() on the matching Operation class.
  • The createLoadAndFlowplans() can optionally be called to also create the loadplans and flowplans, to take care of the material and capacity consumption.
  • Once you're sure about creating the operationplan, the activate() method should be called. It will assign the operationplan a unique numeric identifier, register the operationplan in a container owned by the operation instance, and also create loadplans and flowplans if this hasn't been done yet.
  • Operationplans can be organized in hierarchical structure, matching the operation hierarchies they belong to.

Definition at line 1588 of file model.h.

Constructor & Destructor Documentation

frepple::OperationPlan::~OperationPlan ( )
virtual

Destructor.

Definition at line 485 of file operationplan.cpp.

frepple::OperationPlan::OperationPlan ( const OperationPlan src,
bool  init = true 
)

Copy constructor.
If the optional argument is false, the new copy is not initialized and won't have flowplans and loadplans.

Definition at line 708 of file operationplan.cpp.

Member Function Documentation

bool frepple::OperationPlan::activate ( bool  useMinCounter = true)

Initialize the operationplan. The initialization function should be called when the operationplan is ready to be 'officially' added. The initialization performs the following actions:

  1. assign an identifier
  2. create the flow and loadplans if these hadn't been created before
  3. add the operationplan to the global list of operationplans
  4. create a link with a demand object if this is a delivery operationplan

Every operationplan subclass that has sub-operations will normally need to create an override of this function.

The return value indicates whether the initialization was successfull. If the operationplan is invalid, it will be DELETED and the return value is 'false'.

Definition at line 196 of file operationplan.cpp.

void frepple::OperationPlan::addSubOperationPlan ( OperationPlan o)
virtual

Add a sub-operationplan to the list.

Definition at line 364 of file operationplan.cpp.

static iterator frepple::OperationPlan::begin ( )
inlinestatic

Definition at line 1732 of file model.h.

void frepple::OperationPlan::beginElement ( XMLInput ,
const Attribute  
)
virtual

Called while restoring the model from an XML-file.
This is called for each element within the "this" element, for which the "this" element is immediate parent.
It is called when the open element tag is encountered.

Reimplemented from frepple::utils::Object.

Definition at line 961 of file operationplan.cpp.

OperationPlan::FlowPlanIterator frepple::OperationPlan::beginFlowPlans ( ) const
inline

Returns an iterator pointing to the first flowplan.

Definition at line 5881 of file model.h.

OperationPlan::LoadPlanIterator frepple::OperationPlan::beginLoadPlans ( ) const
inline

Returns an iterator pointing to the first loadplan.

Definition at line 5939 of file model.h.

PyObject * frepple::OperationPlan::create ( PyTypeObject *  pytype,
PyObject *  args,
PyObject *  kwds 
)
static

Python factory method.

Definition at line 1037 of file operationplan.cpp.

void frepple::OperationPlan::createFlowLoads ( )

This function is used to create the loadplans, flowplans and setup operationplans.

Definition at line 444 of file operationplan.cpp.

Object * frepple::OperationPlan::createOperationPlan ( const MetaClass cat,
const AttributeList in 
)
static

This is a factory method that creates an operationplan pointer based on the name and id, which are passed as an array of character pointers. This method is intended to be used to create objects when reading XML input data.

Definition at line 71 of file operationplan.cpp.

void frepple::OperationPlan::deactivate ( )

Remove an operationplan from the list of officially registered ones.
The operationplan will keep its loadplans and flowplans after unregistration.

Definition at line 285 of file operationplan.cpp.

void frepple::OperationPlan::deleteFlowLoads ( )

This function is used to delete the loadplans, flowplans and setup operationplans.

Definition at line 467 of file operationplan.cpp.

void frepple::OperationPlan::deleteOperationPlans ( Operation o,
bool  deleteLocked = false 
)
static

Deletes all operationplans of a certain operation. A boolean flag allows to specify whether locked operationplans are to be deleted too.

Definition at line 812 of file operationplan.cpp.

static bool frepple::OperationPlan::empty ( )
inlinestatic

Returns true when not a single operationplan object exists.

Definition at line 1735 of file model.h.

static iterator frepple::OperationPlan::end ( )
inlinestatic

Definition at line 1730 of file model.h.

void frepple::OperationPlan::endElement ( XMLInput ,
const Attribute ,
const DataElement  
)
virtual

Called while restoring the model from an XML-file.
This is called when the corresponding close element tag is encountered, and the Data() member of pElement is valid.

Implements frepple::utils::Object.

Definition at line 972 of file operationplan.cpp.

OperationPlan::FlowPlanIterator frepple::OperationPlan::endFlowPlans ( ) const
inline

Returns an iterator pointing beyond the last flowplan.

Definition at line 5884 of file model.h.

OperationPlan::LoadPlanIterator frepple::OperationPlan::endLoadPlans ( ) const
inline

Returns an iterator pointing beyond the last loadplan.

Definition at line 5943 of file model.h.

void frepple::OperationPlan::eraseSubOperationPlan ( OperationPlan o)
virtual

Remove a sub-operation_plan from the list.

Definition at line 405 of file operationplan.cpp.

OperationPlan * frepple::OperationPlan::findId ( unsigned long  l)
static

Searches for an OperationPlan with a given identifier.
Returns a NULL pointer if no such OperationPlan can be found.
The method is of complexity O(n), i.e. involves a LINEAR search through the existing operationplans, and can thus be quite slow in big models.
The method is O(1), i.e. constant time regardless of the model size, when the parameter passed is bigger than the operationplan counter.

Definition at line 180 of file operationplan.cpp.

PyObject * frepple::OperationPlan::getattro ( const Attribute attr)
virtual

Default getattro method.
Subclasses are expected to implement an override if the type supports gettattro.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 1092 of file operationplan.cpp.

const DateRange& frepple::OperationPlan::getDates ( ) const
inline

Returns the start and end date of this operationplan.

Definition at line 1868 of file model.h.

Demand* frepple::OperationPlan::getDemand ( ) const
inline

Returns a pointer to the demand for which this operationplan is a delivery. If the operationplan isn't a delivery, this is a NULL pointer.

Definition at line 1783 of file model.h.

Plannable* frepple::OperationPlan::getEntity ( ) const
inlinevirtual

Implement the pure virtual function from the HasProblem class.

Implements frepple::HasProblems.

Definition at line 1997 of file model.h.

bool frepple::OperationPlan::getHidden ( ) const
inlinevirtual

Returns whether an entity is real or dummy.

Reimplemented from frepple::utils::Object.

Definition at line 1980 of file model.h.

unsigned long frepple::OperationPlan::getIdentifier ( ) const
inline

Returns a unique identifier of the operationplan.
The identifier can be specified in the data input (in which case we check for the uniqueness during the read operation).
For operationplans created during a solver run, the identifier is assigned in the instantiate() function. The numbering starts with the highest identifier read in from the input and is then incremented for every operationplan that is registered.

Definition at line 1886 of file model.h.

bool frepple::OperationPlan::getLocked ( ) const
inline

Returns whether the operationplan is locked. A locked operationplan is never changed.

Definition at line 1800 of file model.h.

Plannable* frepple::OperationPlan::getMotive ( ) const
inline

Return the plannable object that caused the creation of this operationplan. Usage of this field can vary by solver. The information is normally not relevant for end users.

Definition at line 2034 of file model.h.

Operation* frepple::OperationPlan::getOperation ( ) const
inline

Returns a pointer to the operation being instantiated.

Definition at line 1813 of file model.h.

OperationPlan* frepple::OperationPlan::getOwner ( ) const
inline

Returns a pointer to the operationplan for which this operationplan a sub-operationplan.
The method returns NULL if there is no owner defined.
E.g. Sub-operationplans of a routing refer to the overall routing operationplan.
E.g. An alternate sub-operationplan refers to its parent.

See Also
getTopOwner

Definition at line 1846 of file model.h.

double frepple::OperationPlan::getPenalty ( ) const

Calculate the penalty of an operationplan.
It is the sum of all setup penalties of the resources it loads.

Definition at line 825 of file operationplan.cpp.

double frepple::OperationPlan::getQuantity ( ) const
inline

Returns the quantity.

Definition at line 1761 of file model.h.

virtual size_t frepple::OperationPlan::getSize ( ) const
inlinevirtual

Return the memory size of the object in bytes.

Implements frepple::utils::Object.

Definition at line 2008 of file model.h.

const OperationPlan* frepple::OperationPlan::getTopOwner ( ) const
inline

Returns a pointer to the operationplan owning a set of sub-operationplans. There can be multiple levels of suboperations.
If no owner exists the method returns the current operationplan.

See Also
getOwner

Definition at line 1853 of file model.h.

const MetaClass& frepple::OperationPlan::getType ( ) const
inlinevirtual

Return the metadata. We return the metadata of the operation class, not the one of the operationplan class!

Implements frepple::utils::Object.

Definition at line 2002 of file model.h.

TimePeriod frepple::OperationPlan::getUnavailable ( ) const

Calculate the unavailable time during the operationplan. The regular duration is extended with this amount.

Definition at line 898 of file operationplan.cpp.

int frepple::OperationPlan::initialize ( )
static

Definition at line 37 of file operationplan.cpp.

void frepple::OperationPlan::insertInOperationplanList ( )

This method links the operationplan in the list of all operationplans maintained on the operation.
In most cases calling this method is not required since it included in the activate method. In exceptional cases the solver already needs to see uncommitted operationplans in the list - eg for the procurement buffer.

See Also
activate

Definition at line 303 of file operationplan.cpp.

bool frepple::OperationPlan::isExcess ( bool  strict = false) const

Return true if the operationplan is redundant, ie all material it produces is not used at all.
If the optional argument is false (which is the default value), we check with the minimum stock level of the buffers. If the argument is true, we check with 0.

Definition at line 840 of file operationplan.cpp.

bool frepple::OperationPlan::operator< ( const OperationPlan a) const

Comparison of 2 OperationPlans. To garantuee that the problems are sorted in a consistent and stable way, the following sorting criteria are used (in order of priority):

  1. Operation
  2. Start date (earliest dates first)
  3. Quantity (biggest quantities first)

Multiple operationplans for the same values of the above keys can exist.

Definition at line 429 of file operationplan.cpp.

void frepple::OperationPlan::removeFromOperationplanList ( )

This method remove the operationplan from the list of all operationplans maintained on the operation.

See Also
deactivate

Definition at line 347 of file operationplan.cpp.

void frepple::OperationPlan::restore ( const OperationPlanState x)
inline

A method to restore a previous state of an operationplan.
NO validity checks are done on the parameters.

Definition at line 2438 of file model.h.

int frepple::OperationPlan::setattro ( const Attribute attr,
const PythonObject field 
)
virtual

Default setattro method.
Subclasses are expected to implement an override if the type supports settattro.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 1149 of file operationplan.cpp.

void frepple::OperationPlan::setChanged ( bool  b = true)
virtual

Definition at line 58 of file operationplan.cpp.

void frepple::OperationPlan::setDemand ( Demand l)

Updates the demand to which this operationplan is a solution.

Definition at line 1019 of file operationplan.cpp.

void frepple::OperationPlan::setEnd ( Date  d)
virtual

Updates the end date of the operationplan and compute the start date.
Locked operationplans are not updated by this function.
Slack can be introduced between sub operationaplans by this method, i.e. the sub operationplans are only moved if required to meet the end date.

Definition at line 561 of file operationplan.cpp.

void frepple::OperationPlan::setLocked ( bool  b = true)
virtual

Locks/unlocks an operationplan. A locked operationplan is never changed.

Definition at line 1007 of file operationplan.cpp.

void frepple::OperationPlan::setMotive ( Plannable v)
inline

Update the plannable object that created this operationplan.

Definition at line 2037 of file model.h.

void frepple::OperationPlan::setOwner ( OperationPlan o)

Updates the operationplan owning this operationplan. In case of a OperationRouting steps this will be the operationplan representing the complete routing.

Definition at line 520 of file operationplan.cpp.

double frepple::OperationPlan::setQuantity ( double  f,
bool  roundDown = false,
bool  update = true,
bool  execute = true 
)
virtual

Updates the quantity.
The operationplan quantity is subject to the following rules:

  • The quantity must be greater than or equal to the minimum size.
    The value is rounded up to the smallest multiple above the minimum size if required, or rounded down to 0.
  • The quantity must be a multiple of the multiple_size field.
    The value is rounded up or down to meet this constraint.
  • The quantity must be smaller than or equal to the maximum size.
    The value is limited to the smallest multiple below this limit.
  • Setting the quantity of an operationplan to 0 is always possible, regardless of the minimum, multiple and maximum values. This method can only be called on top operationplans. Sub operation plans should pass on a call to the parent operationplan.

Definition at line 591 of file operationplan.cpp.

void frepple::OperationPlan::setStart ( Date  d)
virtual

Updates the start date of the operationplan and compute the end date.
Locked operation_plans are not updated by this function.
Slack can be introduced between sub operationaplans by this method, i.e. the sub operationplans are only moved if required to meet the start date.

Definition at line 531 of file operationplan.cpp.

void frepple::OperationPlan::setStartAndEnd ( Date  st,
Date  nd 
)
inline

Fixes the start and end date of an operationplan. Note that this overrules the standard duration given on the operation, i.e. no logic kicks in to verify the data makes sense. This is up to the user to take care of.
The methods setStart(Date) and setEnd(Date) are therefore preferred since they properly apply all appropriate logic.

Definition at line 1822 of file model.h.

static unsigned long frepple::OperationPlan::size ( )
inlinestatic

Returns the number of operationplans in the system. This method is linear with the number of operationplans in the model, and should therefore be used only with care.

Definition at line 1741 of file model.h.

int frepple::OperationPlan::sizeFlowPlans ( ) const
inline

Returns how many flowplans are created on an operationplan.

Definition at line 5887 of file model.h.

int frepple::OperationPlan::sizeLoadPlans ( ) const
inline

Returns how many loadplans are created on an operationplan.

Definition at line 5947 of file model.h.

PyObject* frepple::OperationPlan::str ( ) const
inlinevirtual

Default str method.
Subclasses are expected to implement an override if the type supports conversion to a string.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 1913 of file model.h.

void frepple::OperationPlan::updateProblems ( )
virtual

Problem detection is actually done by the Operation class. That class actually "delegates" the responsability to this class, for efficiency.

Implements frepple::HasProblems.

Definition at line 40 of file problems_operationplan.cpp.

void frepple::OperationPlan::writeElement ( XMLOutput ,
const Keyword ,
mode  = DEFAULT 
) const
virtual

Called while writing the model into an XML-file. The user class should write itself out, using the IOutStream members for its "simple" members and calling writeElement recursively for any contained objects. Not all classes are expected to implement this method. In instances of such a class can be created but can't be persisted. E.g. Command

Reimplemented from frepple::utils::Object.

Definition at line 918 of file operationplan.cpp.

void frepple::OperationPlan::writer ( const MetaCategory c,
XMLOutput o 
)
static

Handles the persistence of operationplan objects.

Definition at line 906 of file operationplan.cpp.

Friends And Related Function Documentation

friend class Demand
friend

Definition at line 1593 of file model.h.

friend class FlowPlan
friend

Definition at line 1591 of file model.h.

friend class iterator
friend

Definition at line 1728 of file model.h.

friend class LoadPlan
friend

Definition at line 1592 of file model.h.

friend class Operation
friend

Definition at line 1594 of file model.h.

friend class OperationAlternate
friend

Definition at line 1595 of file model.h.

friend class OperationRouting
friend

Definition at line 1596 of file model.h.

friend class ProblemPrecedence
friend

Definition at line 1597 of file model.h.

Member Data Documentation

const MetaCategory * frepple::OperationPlan::metacategory
static

Definition at line 2006 of file model.h.

const MetaClass * frepple::OperationPlan::metadata
static

Definition at line 2004 of file model.h.


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