This page is under construction and the function cannot be used in the current P2 Engine releases. Will appear soon in the next release of P2 Engine!

Read the project and schedule data (required) as well as the resource, simulation and tracking data (optional) from a file in the PSPLIB format.

The P2 Engine file format contains all relevant data information for project activities, precedence relations, renewable and nonrenewable resources, simulation input settings and tracking information and much more. The following data is always saved in the P2 Engine output file:

  • Network Data: Similar to a Patterson and PSPLib format, all relevant network data is saved and includes all details on the precedence relations, activity constraints, time-lags and more
  • Schedule Data: All relevant data on the project schedule, including start times, size of project buffer, slack, and much more is saved

The data below is optional and is only saved in the P2 Engine file when relevant and created by the user. 

  • Resource Data: When resources have been assigned to the project using the P2Resource object, all relevant resource data (demand and availability) is saved in the P2 Engine file format
  • Tracking Data: When tracking periods and Earned Value Management data has been used to create periodic review periods, all relevant data of the P2Tracking object is saved
  • Simulation Data: When advanced simulation profiles have been defined using the P2Simulator:create_monte_carlo_object and P2Simulator:set_advanced_distributions functions of the P2Simulator object, this information is also saved in the file

Note 1. Only relevant input data is saved in the P2 Engine file format. Results of calculations are therefore not saved since they can easily be reproduced by reading the P2 Engine file and running a new script. As an example, the results of a simulation run (e.g. criticality index of an activity) are not saved, but can be re-calculated running the simulation again using the simulation input settings stored in the file. There is, however, a grey zone between input data and calculated data. Therefore, some parts are also saved, such as the activity starting times of a schedule, although they might be the results of calculations (using the P2Schedule:earliest_start_schedule_with_float_factor function) rather than input data. However, the user can have shifted activities (using the P2Schedule:change_starttime function) such that they can no longer be considered as calculated data but rather as input data.

Note 2. The optional data (resources, simulation and tracking data) can only be read when the user creates objects prior to calling the P2Reader:read_p2engine_file function. P2Resource:new, P2Simulator:new and P2Tracking:new. When these objects are not created in advance, the reader will return the following return values:

  • No P2Tracking object created: return value = -1
  • No P2Simulator object created: return value = -2
  • When no P2Resource object is created, the function will not return a special value and resources will be saved. However, the user must create a P2Resource object to have access to the resource data
  • When the name of the p2engine file is incorrect or the file does not exist: return value = 0


I/O Type Name Description
input string filename Name of the p2engine file
input project project a P2Project object
input schedule schedule a P2Schedule object
output integer success 0, -1 or -2 (failure) or 1 (success)


function ()
        -- Create the objects
        -- Read the data from a P2 Engine file
        filename = "p2engine.p2e"
        local return_value=MyReader:read_p2engine_file(filename)
        if return_value == 0 then
                io.write('File does not exist')
                do return end
        if return_value == -1 then
                io.write('No P2Tracking object created')
                do return end
        if return_value == -2 then
                io.write('No P2Simulator object created')
                do return end