Main Content

PhaseLogic

RoadRunner scenario phase logic

Since R2025a

    Description

    The PhaseLogic object represents the scenario logic in RoadRunner Scenario. The scenario logic contains all logic components, such as phases, actions, and conditions, for a scenario. You can use the PhaseLogic object to programmatically add and modify scenario logic components.

    Creation

    By default, all scenarios contain a PhaseLogic object. To retrieve the PhaseLogic object that represents the RoadRunner scenario logic, extract the PhaseLogic property of your Scenario object and assign it to a variable. For example, rrLogic = scnro.PhaseLogic extracts the PhaseLogic property from the scenario scnro and assigns it to the variable rrLogic.

    Properties

    expand all

    This property is read-only.

    Top-most phase in the scenario logic phase hierarchy, represented as a ParallelPhase object. By default, RoadRunner Scenario creates a root phase when you open a new scenario. The root phase contains all other phases for your scenario.

    Object Functions

    initialPhaseForActorExtract object for actor initial phase
    addPhaseInSerialCreate logic phase that executes sequentially during simulation
    addPhaseInParallelCreate logic phase that executes concurrently during simulation

    Examples

    collapse all

    To programmatically add and modify logic components, such as phases, actions, and conditions, in your RoadRunner scenario, you must first extract the PhaseLogic object to represent the RoadRunner scenario logic.

    Create a roadrunner object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject". This code assumes that RoadRunner is installed in the default location, and returns an object, rrApp, that provides functions for performing basic tasks such as opening, closing, and saving scenes and projects.

    rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");

    Note

    If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup function to specify new default project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB sessions option from the corresponding drop down.

    Open an existing scene in RoadRunner by using the openScene function, specifying the roadrunner object rrApp and the filename of the specific scene that you want to open. Then, use the newScenario function to create a new scenario.

    openScene(rrApp,"ScenarioBasic.rrscene")
    newScenario(rrApp)

    Create an object for the RoadRunner authoring API, rrApi, that references the object for the current RoadRunner instance rrApp. The rrApi object enables you to programmatically author scenarios, such as by adding and modifying actors and logic components, using MATLAB.

    rrApi = roadrunnerAPI(rrApp);
    
    Extract the object for your scenario from the Scenario property of the authoring API object rrApi. The extracted Scenario object enables you to specify the scenario in which to add scenario components such as actors and logic.
    scnro = rrApi.Scenario;
    Extract the object for your RoadRunner project from the Project property of the authoring API object rrApi. The extracted Project object enables you to specify the project folder for the current RoadRunner session from which to retrieve asset objects. You can use the asset objects to assign assets to actors in your scenario.
    prj = rrApi.Project;

    Extract the PhaseLogic property of the scenario object scnro to get a PhaseLogic object, rrLogic, that represents the RoadRunner scenario logic.

    rrLogic = scnro.PhaseLogic;
    

    Version History

    Introduced in R2025a