frePPLev2.0
open source Production PLanning
  • Home
  • Documentation
    • Getting started
    • Modeling guide
    • User guide
    • Installation guide
    • Developer guide
    • FAQ
  • C++ API

Calendar

A calendar represents a numeric value that is varying over time.
Calendars can be linked to multiple entities: a maximum capacity limit of a resource, a minimum capacity usage of a resource, a minimum or maximum inventory limit of a buffer, etc…

A calendar has multiple buckets to define the values over time. To determine the calendar value at a certain date the calendar will evaluate each of the buckets and combine the results in the following way:

  • A bucket is only valid from its “start” date (inclusive) till its “end” date (exclusive).
    Outside of this date range a bucket is never selected.
  • If multiple bucket are effective on a date, the one with the lowest “priority” value is taken.
    In case buckets have the same priority, the value of the bucket with the latest start date is selected.
  • In case no bucket is effective on a certain date, the calendar will return the “default” value.

Calendar Fields

Field Type Description
name non-empty string Name of the calendar.
This is the key field and a required attribute.
default double The default value of the calendar when no bucket is effective.
action A
C
AC (default)
R
Type of action to be executed:

  • A: Add an new entity, and report an error if the entity already exists.
  • C: Change an existing entity, and report an error if the entity doesn’t exist yet.
  • AC: Change an entity or create a new one if it doesn’t exist yet.
  • R: Remove an entity, and report an error if the entity doesn’t exist.
Method Description
setValue([start date],[end date],[value]) Creates or updates calendar buckets to reflect the specified value in the given date range.
buckets() Returns an iterator over the calendar buckets.
events([start date],[direction]) Returns an iterator over the calendar events starting from the (optional) start date, either backward or forward in time. These are the dates at which the calendar value is changing.
Each event is a tuple with 2 fields:

  • date: date of the event.
  • value: value that becomes effective at the time of the event.

Bucket Fields

Field Type Description
id integer Unique identifier within the calendar of the bucket.
When left unspecified in the input data it is automatically created.
start dateTime Start date of the validity of this bucket.
When left unspecified, the entry is effective from the infinite past.
end dateTime End date of the validity of this bucket.
When left unspecified, the entry is effective indefinitely in the future.
priority integer Priority of this bucket when multiple buckets are effective for the same date.
Lower values indicate higher priority.
days integer
between 0 and 127
Bit pattern representing the days on which the calendar bucket is valid:

  • Bit 0 = 1 = Sunday
  • Bit 1 = 2 = Monday
  • Bit 2 = 4 = Tuesday
  • Bit 3 = 8 = Wednesday
  • Bit 4 = 16 = Thursday
  • Bit 5 = 32 = Friday
  • Bit 6 = 64 = Saturday

The default value is 127, ie valid on every day of the week.

starttime duration Time when this entry becomes effective on valid days in the valid date horizon.
The default value is PT0S, ie midnight
endtime duration Time when this entry becomes ineffective on valid days in the valid date horizon.
The default value is PT23H59M59S, ie right before midnight of the next day.
value Varies with the calendar type The actual time-varying value.
action A
C
AC (default)
R
Type of action to be executed:

  • A: Add an new entity, and report an error if the entity already exists.
  • C: Change an existing entity, and report an error if the entity doesn’t exist yet.
  • AC: Change an entity or create a new one if it doesn’t exist yet.
  • R: Remove an entity, and report an error if the entity doesn’t exist.

Example XML structures

  • Adding or changing a calendar and its buckets
 <plan>
   <calendars>
     <calendar name="cal">
       <default>5</default>
       <buckets>
         <bucket start="2007-01-01T00:00:00" value="10"
            priority="1"/>
         <!-- This entry overrides the first one during February. -->
         <bucket start="2007-02-01T00:00:00" end="2007-03-01T00:00:00
            value="20" priority="0"/>
       </buckets>
     </calendar >
   </calendars>
 </plan>
  • Removing a calendar
 <plan>
    <calendars>
       <calendar name="cal" action="R"/>
    </calendars>
 </plan>

Example Python code

  • Adding or changing a calendar and its buckets
   cal = frepple.calendar_double(name="cal", default=5)
  • Removing a calendar
   frepple.calendar(name="cal", action="R")
  • Iterating over all buckets of a calendar
   for b in frepple.calendar(name="cal").buckets():
     print b.name, b.value
  • Iterating over all events of a calendar, going forward in time from a certain date
   start = datetime.datetime(2009,1,1)
   for date, value in frepple.calendar(name="cal").events(start, True):
     print date, value
    • Getting started
    • Modeling guide
      • Simplified domain model
      • Detailed domain model
      • Environment variables
      • Python interpreter
      • Global parameters
      • Buffer
      • Calendar
      • Customer
      • Demand
      • Flow
      • Item
      • Load
      • Location
      • Operation
      • Suboperation
      • Operationplan
      • Problem
      • Resource
      • SetupMatrix
      • Skill
      • Resource skill
      • Solver
      • Extension modules
        • Forecast module
        • REST web service module
        • Linear programming solver module
        • OpenERP connector module
    • User guide
      • Main features
      • Supported browsers
      • Getting around
        • Logging in
        • Logging out
        • Changing password
        • Navigation
          • Menu bar
          • Jump search
          • Context menus
          • Browser bookmarks
        • Filtering data
        • Sorting data
        • Selecting time buckets
        • Exporting data
        • Importing data
        • User preferences
        • User permissions and roles
      • Screens
        • Data input
        • Supply Path / Where Used
        • Comments
        • History – Audit trail
        • Plan analysis
          • Problem report
          • Constraint report
          • Inventory report
          • Inventory detail report
          • Resource report
          • Resource Gantt report
          • Resource detail report
          • Operation report
          • Operation detail report
          • Demand report
          • Demand detail report
          • Demand Gantt report
          • Forecast report
          • Performance indicator report
        • Execute
      • Batch commands
        • manage.py (manage.exe on Windows)
        • frepple (frepple.exe on Windows)
        • freppleservice.exe (Windows only)
    • Installation guide
      • Windows installer
      • Compiling on Windows
      • Linux binary packages
      • Compiling on Linux
      • Compiling on debian-based linux
      • Compiling on Red Hat based Linux
      • Compiling from the subversion source code repository
      • Running the VMWare virtual machine
      • Other platforms
      • Configuring the user interface
      • Configuring multiple models in the user interface
      • Configuring as a Python extension module
    • FAQ
    • Developer guide
      • Code structure
      • Class diagram
      • Solver
        • Solver features
        • Planning algorithm
          • Top level loop
          • Demand solver
          • Buffer solver
          • Flow solver
          • Load solver
          • Operation solver
          • Resource solver
        • Cluster and level algorithm
      • Extension modules
      • Version control
      • Style guide
      • Portability
      • Security
      • Internationalization
      • Translating the user interface
      • Adding or customizing a report
      • Unit tests
        • buffer_procure_1
        • calendar
        • callback
        • cluster
        • constraints_combined_1
        • constraints_combined_2
        • constraints_leadtime_1
        • constraints_material_1
        • constraints_material_2
        • constraints_material_3
        • constraints_material_4
        • constraints_resource_1
        • constraints_resource_2
        • constraints_resource_3
        • constraints_resource_4
        • constraints_resource_5
        • datetime
        • deletion
        • demand_policy
        • flow_alternate_1
        • flow_alternate_2
        • flow_effective
        • forecast_1
        • forecast_2
        • forecast_3
        • forecast_4
        • forecast_5
        • forecast_6
        • jobshop
        • load_alternate
        • load_effective
        • lpsolver_1
        • multithreading
        • name
        • operation_alternate
        • operation_available
        • operation_effective
        • operation_pre_post
        • operation_routing
        • pegging
        • problems
        • python_1
        • python_2
        • python_3
        • safety_stock
        • sample_module
        • scalability_1
        • scalability_2
        • scalability_3
        • setup_1
        • setup_2
        • skill
        • xml
        • xml_remote
    • License
      • GNU Affero General Public License
      • GNU Free Documentation License
    • Third party add-ons
  • Copyright © 2010-2013 frePPLe bvba