Example files

Learn how to link P2 Engine with LUA using our example scripts

On this webpage, a download is available with example scripts. This zipped file contains example LUA scripts and wil be updated on a regular basis.

Various downloads of script examples are available as zipped files and are classified in folders as shown below. After your download, unzip the file and put them in a folder on your PC or MAC. Some scripts contain a line as follows:

MY_PATH=string.format('/Users/mariovanhoucke/Documenten van Mario/Lua Scripts/tutorial/') 

You should update the scripts by adding your path between the brackets.

Download the examples here. (zipped, last update: May 04, 2015),

Currently, the zipped file contains the following example scripts:

Examples from the book "Measuring Time".

  • example_chapter1_measuring_time.lua: In this example script, it is shown how the project example of the pages 18-19, figures 1.7 and 1.8 and tables 1.5 and 1.6) can be reproduced using P2 Engine. It constructs a project network, an earliest start schedule and generates a project progress scenario and all EVM metrics.
  • example_chapter2_measuring_time.lua: In this example script, it is shown how the project example of page 34, table 2.2 can be reproduced using P2 Engine. It reads a project network from file and generates traditional and effective EVM metrics (using the p-factor approach).
  • example_chapter4_measuring_time_part1.lua: In this example script, it is shown how the network topology of the project example of page 60 can be calculated using P2 Engine. It calculates the four network topology measures SP, AD, LA and TF.
  • example_chapter4_measuring_time_part2.lua: In this example script, it is shown how the forecast accuracy MAPE as shown in table 4.3 (page 68) of the simulation experiments can be calculated using P2 Engine. It reads 900 project files and simulates project progress under 9 scenarios (see table 4.2) and calculates the forecast accuracy for all scenarios and 9 forecasting methods (to predict the time). The final values can differ due to settings of the projects and random numbers. A similar script can be made for table 4.4 (page 69) by simply replacing "get_time_mape" by "get_time_mpe" in the script.
  • example_chapter5_schedule_risk_analysis.lua: This example shows how to run a schedule risk analysis. It shows how a project file (figure 1.7) can be used to generate fictitious project progress and how the sensitivity measures for time and cost can be generated.

Examples from the book "Dynamic Scheduling".

Unlike the book "Measuring Time", the topics described in the book "Dynamic Scheduling" are much more diverse and hold the middle between tools and techniques well-known and used in practice (such as resource-constrained project scheduling with the time objective, schedule risk analysis and project control using Earned Value Management) and new techniques coming from research that haven't found their way into many companies. Since P2 Engine is based on a commercial software tool ProTrack, much of the topics described in the book cannot be generated by P2 Engine (such as project scheduling with the net present value objective, or critical chain scheduling, ...). Therefore, the P2 Engine experiments of this book are restricted to resource-constrained project scheduling under the time minimization objective (parts of chapter 7). However, P2 Engine is an ideal tool to generate a lot of project management data that can later be used in another software tool (e.g. MS Excel) in order to make changes to the data or to test a novel idea. So P2 Engine is not restricted as long as you want to program a liitle bit in LUA to extend the generated data. The generation of PM data is one of the most important features of P2 Engine if it is used in a research environment.

  • example_chapter7_dynamic_scheduling_part1.lua: In this example script, it is shown how resource-constrained project scheduling using the time minimization objective can be done using P2 Engine. This script is an experiment written on page 117 of the book and can be used to construct figures 7.1, 7.2, 7.3 and 7.4 and table 7.2. 

Examples from the book "Integrated Project Management and Control".

The book "Integrated Project Management and Control" explains in detail all the calculations necessary to schedule a project, to analyse its risk and to control its performance using Earned Value Management. Unlike the two previous books, the focus of this book lies on the calculations behind all the techniques. Therefore, all calculations have been illustrated on three example projects with only 17 activities. These projects are called project_1.rcp, project_2.rcp and project_3.rcp, formatted in the well-known Patterson format and available when downloaded the zipped file. 

  • example_script_IPMC_book: This single script enables the user to recalculate all the calculations done in the various chapters of the book. More information of some of the functions in this script is given in chapter 9 of the book.

Other examples.

As you know, P2 Engine can generate numbers from any distribution, whether it is an existing one, or one that you define yourself. Learn with a simple example how to generate data from a predefined distribution. The example shows the generation of numbers from both a triangular and normal distribution.

  • Triangular and normal distributions: Use the file "test_distributions.lua" in the folder "GeneratingNumbers"
  • People who have coded examples from other distrubution can send their script for upload here.