5.1.6. The Conditional Work Flow Pattern




The "Conditional Work Flow Pattern" allows to run two or more different external applications according to the value of a mathematical expression.

In this test case a set of Input Files (A.dat and B.dat) is created by the application ApplicationAB. These Input Files are then transferred to two different applications (ApplicationA and ApplicationB) depending on the value of the conditional node Switch .

Both applications must write an Output File named out.dat which must be passed to another application, that do not do anything but collect the file out.dat coming from either ApplicationA or ApplicationB, because an Output File can be linked to only one application.

Note:

the format of this Output File MUST be identical for both application (or similar if we are going to extract the ouput variable using a relative position mining rule) because the Output Variables will be extracted using a unique template Output File

The Work Flow (Figure 5.49, "the Process Flow window") shows the Event Sequence and the Data Flow for this project as well as the files transferred between the applications.

the Process Flow window

Figure 5.49. the Process Flow window

The project for this Work Flow can be found in:

.../modeFRONTIER30x/projects/testcase/switch/testSwitch.prj

or, if we prefer, we can rebuild it following the following steps.

Building the Event Sequence

Since we want to choose ApplicationA or ApplicationB accordingly to the value of the Input Variable x the first thing to do is to define two Input Variables, so put two Input Variables icons in the Work Flow canvas and define them like in Figure 5.50, "The Input Variables definition".

The Input Variables definition

Figure 5.50. The Input Variables definition

Now we start creating the Logic Flow which define the application sequence that evaluate each design.

Select from the tool bar four External Script objects and one Switch Node object and place them on the Work Flow desktop.

To complete the logic Flow for this example, we need to set a starting point and, at least, one ending point. So we need to select from the tool bar a Scheduler object and two Logic End object .

Give each logic nodes a meaningful name renaming them as ApplicationAB, ApplicationA, ApplicationB and Collector.

Double LMB click on one of the Logic End and change the End Status in Failed and click the Ok button to accept the change.

At this point Work Flow will be like in Figure 5.51, "the Logic Flow components".

the Logic Flow components

Figure 5.51. the Logic Flow components

As we can see in the Logic Log panel there a lot of errors that will disappear while the project creation goes on.

Double LMB click on a ApplicationAB icon to bring up the properties editor and do the following:

the ApplicationAB node

Figure 5.52. the ApplicationAB node

Double LMB click on a Switch icon to bring up the properties editor and do the following:

the Switch node properties

Figure 5.53. the Switch node properties

Double LMB click on a ApplicationA icon to bring up the properties editor and do the following:

the applicationA node

Figure 5.54. the applicationA node

Double LMB click on a ApplicationB icon to bring up the properties editor and do the following (more or less the same operation we did for ApplicationA):

the applicationB node

Figure 5.55. the applicationB node

Since an Output File can be linked to only one External Script node we need to define a further External Script node named Collector which is used for receiving the Output File out.dat created by either ApplicationA or ApplicationB.

Double LMB click on the Collector icon to bring up the properties editor and do the following:

the Collector node

Figure 5.56. the Collector node

Now define the DOE and Scheduler nodes as we did in the Simple Process Flow Pattern, see Figure 5.57, "the DOE settings" and Figure 5.58, "the Scheduler settings".

the DOE settings

Figure 5.57. the DOE settings

the Scheduler settings

Figure 5.58. the Scheduler settings

Building the Data Flow

Now we have to build the Data Flow from the definition of the model, inserting the Input Variables into the Input Files to the extraction of the Output Variables from Output Files.

The Input Variables have been already defined because one of them was necessary for the Switch node definition.

Create the Input File selecting the relative object from the palette on the left and place them on the Work Flow desktop.

The Input File object must then be configured.

Double LMB click on the Input File icon to bring up the properties editor (Figure 5.59, "the Input File loading") and do the following:

the Input File loading

Figure 5.59. the Input File loading

The Input File node

Figure 5.60. The Input File node

In the lower part of the Template Input Editor a list of all the linked Input Variables is shown.

To define how an Input Variable is going to be inserted into the template file during the optimisation loop do the follow:

Repeat until all Input Variables are properly linked to the Input File, the result of those actions are a set of new tags inserted in the original inAB.dat file (Figure 5.61, "the Input Variables inserted"): Check out the format to make sure number format is like the following:

  <VAR name="x" format="0.000000" />
  <VAR name="y" format="0.000000" />
  

During the optimisation loop the tags will be substituted with the Input Variables numerical values using the specified format.

the Input Variables inserted

Figure 5.61. the Input Variables inserted

Two more Input Files (A.dat and B.dat) has to be defined because they are necessary to the ApplicationAB.

Create two more Input File selecting the relative object from the palette on the left and place them on the Work Flow desktop.

Configure them as in (Figure 5.62, "two more files needed by the ApplicationAB") and load the files A.dat and B.dat which we can find in:

.../modeFRONTIER30x/projects/testcase/switch/B.dat

.../modeFRONTIER30x/projects/testcase/switch/A.dat

see Figure 5.63, "the Input Variables inserted".

two more files needed by the ApplicationAB

Figure 5.62. two more files needed by the ApplicationAB

the Input Variables inserted

Figure 5.63. the Input Variables inserted

Now the ApplicationAB has all files necessary to run. The ApplicationAB creates two input files (inA.dat and inB.dat) for the following applications (ApplicationA and ApplicationB) so we have to pass the files to the respective application (inA.dat to ApplicationA and inB.dat to ApplicationB). Furthermore, both ApplicationA and ApplicationB write the results into a file named out.dat that must be passed to the Collector application for the Output Variables extraction. The simplest way to copy files from an application to another one is to insert a Transfer File(s) between the two application .

Put four nodes into the Work Flow desktop. Define the Transfer Files from ApplicationAB to ApplicationA and ApplicationB as in Figure 5.64, "The File Transfer from ApplicationAB to ApplicationA and ApplicationB". Define the Transfer Files from ApplicationA and ApplicationB to Collector as in Figure 5.65, "The File Transfer from ApplicationA and ApplicationB to Collector".

The File Transfer from ApplicationAB to ApplicationA and ApplicationB

Figure 5.64. The File Transfer from ApplicationAB to ApplicationA and ApplicationB

The File Transfer from ApplicationA and ApplicationB to Collector

Figure 5.65. The File Transfer from ApplicationA and ApplicationB to Collector

The last thing to do is to define the extration of the Output Variables from the Output File. As we said before, the Output File is passed to the application Collector so we have to define an Output File named out.dat and link it to the Collector application. After that we store results in two Output Variables named o1 and o2.

Create two Output Variables selecting the objects from the palette on the left and place them on the Work Flow desktop and define them as in Figure 5.66, "the Output Variables".

the Output Variables

Figure 5.66. the Output Variables

Create now an Output File selecting the relative object from the palette on the left and place them on the Work Flow desktop.

The Output File object must then be configured.

Double LMB click on the Output File icon to bring up the properties editor (Figure 5.67, "the Output File Properties") and do the following:

the Output File Properties

Figure 5.67. the Output File Properties

the Mining Rule definition

Figure 5.68. the Mining Rule definition

Defining the Goals

The user has to define a set of goals to be achieved during the optimisation loop.

In our example some Objectives are defined for this problem:

To implement these "Goals" in the Work Flow, we link two Objectives objects to our Output Variables:

Every Objective can be edited, as we have done for the other components using its Properties Dialog. Double LMB click on a Objective icon to bring up the properties editor (Figure 5.69, "Objective Properties window") and do the following:

Then double LMB click on the other Objective icon to bring up the properties editor (Figure 5.69, "Objective Properties window") and do the following:

Objective Properties window

Figure 5.69. Objective Properties window

The completed logic flow looks like in Figure 5.49, "the Process Flow window". No error or warning messages appears in the Logic Log panel, and no objects on the Work Flow desktop have a yellow border.

Before exiting modeFRONTIERTM we can save the project as testSwitch.prj.

If we are not sure to have correctly built this project a tested copy is already available in:

.../modeFRONTIER30x/projects/testcase/switch/testSwitch.prj


Return to modeFRONTIER Index