soley studio tutorial - part 2 · soley studio tutorial - part 2 soley gmbh refers to soley studio...

45
Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12 www.soley.io Version 0.0.9 - Draft June 11, 2018

Upload: others

Post on 15-Jul-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

Soley Studio Tutorial - Part 2Soley GmbH

Refers to Soley Studio Release 2.12

www.soley.io

Version 0.0.9 - DraftJune 11, 2018

Page 2: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

ii

Page 3: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CONTENTS

1 Introduction 11.1 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Tutorial Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Summary of Tutorial Part 1 . . . . . . . . . . . . . . . . . . . . . . 2

2 Write a Rule-Based Analysis 52.1 Setting the Stage: Tutorial Part 2 . . . . . . . . . . . . . . . . . . . . 5

2.1.1 Define Questions (Step 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.2 Extend the Metamodel (Step 3) . . . . . . . . . . . . . . . . . . . . . . . . 6

2.1.2.1 Exercise: Enhance Metamodel . . . . . . . . . . . . . . . . . . . . 62.1.3 Further Information about the Modeling Process . . . . . . . . . . . . . . . 8

2.2 Calculate Properties for Carry-Over Part Analysis . . . . . . . . . . . . . . 92.2.1 Exercise: Perform the Carry-Over Parts (COP) Analysis . . . . . . . . . . . 9

3 Create Different Views 213.1 Exercise: Create Bar Chart from COP-Analysis . . . . . . . . . . . . . . 213.2 Exercise: Create Bubble Chart from COP-Analysis . . . . . . . . . . . . . 263.3 Exercise: Create Dashboard from view templates . . . . . . . . . . . . . . 29

4 Create Single-Click Workflows 314.1 Introduction to Workflows . . . . . . . . . . . . . . . . . . . . . . . 314.2 Create Import & Build Hierarchy Workflow . . . . . . . . . . . . . . . . 32

4.2.1 Exercise: Import Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.3 Create Analysis Workflow . . . . . . . . . . . . . . . . . . . . . . . 38

4.3.1 Exercise: Analysis Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Index 41

iii

Page 4: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

Contents

iv Contents

Page 5: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 1

INTRODUCTION

Welcome to the Soley Studio tutorial part 2! This tutorial provides an insight into more featuresof Soley Studio and serves as an advanced hands-on training. The practical exercises build uponanother, so make sure to go through all exercises sequentially.Tutorial part 2 continues where we left off in part 1. If you have not yet done so we highly recommendto first go through tutorial part 1, which you can find here. Our demo datafile can be downloadedhere.

1.1 Conventions

Individual names and references from examples are emphasized like this.Code examples in our exercises are written in typewriter style.Hyperlinks in the PDF document are marked with black underlines.

We also use numbered boxes to provide tips, notes and examples.

EXAMPLE (1)

This is an Example Box for our exercises.We are going to provide code examples in black frames.

NOTE (1)

This is a note box. It provides additional information or background knowledge.

TIP (1)

This is a tip box that contains tips & tricks or best practices. All code that is shown in this tutorialcan be copied and pasted, but for the sake of learning we recommend typing it.

Exercises are marked with a vertical line on the left side.1. First do this.

2. Then do this.

1

Page 6: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 1. INTRODUCTION

1.2 Tutorial Overview

The main goal of tutorial part 2 is to learn more about the details and possibilities that SoleyStudio offers and to cover features that have not yet been presented. We will do this by divingdeeper into the product portfolio analysis started in tutorial part 1. Once you are done with thistutorial you will have taken another big step in becoming a Soley Studio expert and a real dataanalytics magician.

After a short summary of tutorial part 1 we start our project in chapter 2. We iteratively extend theexisting solution by defining the analysis questions and extending the metamodel we used in tutorialpart 1 (2.1). Then we discuss the approach and create the rules required to answer the definedquestions (2.2). This covers several new and powerful aspects of the used coding language.In chapter 3 we learn how to visualize the resulting data graph as bar chart (3.1) and as bubble chart(3.2) view using the Open View dialog and the View Manager.Finally, Chapter 4 is all about creating workflows. We introduce workflows as a way to executeseveral process steps with a single click of a button (4.1). Then we create one workflow to importour data and build the structural hierarchy (4.2) and another to carry out the analysis (4.3).

1.3 Summary of Tutorial Part 1

Let us quickly wrap up the content of tutorial part 1:

1. Create a Metamodel

2. Import Data from Excel files

3. Visualize Data

4. Writing Rules and Sequences.

5. Manipulating Graphs

6. Analyzing Graphs with Smart Selector and Mapping Tool.

We started modeling the product portfolio of a bicycle manufacturer. Each bike is considered aproduct that contains several parts which again can contain (sub-)parts. Further, the products belongto three different product families. Product families, products and parts have certain properties, suchas costs or id numbers. We start with creating an informal metamodel for the given domain, whichwe then formalize in Soley Studio. Next we import the product and part data from two Excelsheets as node instances into an empty graph file. Then we use graph transformation rules to createedges (= relations) between the nodes, based on their property values. Another graph transformationrule helps us to create product family nodes and their relations to the products. We visualize theresulting graph as hierarchical structure and then use the Smart Selector and Mapping tool to visuallyanalyze the graph, e.g. by highlighting expensive parts or hiding cheap products.The resulting graph is shown in Figure 1.1. It’s the graph08.slg from Tutorial Part 1, without anysize or color mappings. In this Tutorial we call it graph01.slg, and the other graphs are not needed.If you don’t have it, you can build this graph again by running importNodes with an empty graphas input, saving the file and then running analyzeGraph with the previous graph as input. We willcontinue with this example and extend the calculations and visualizations to analyze the productportfolio in more detail.

2 1.2. TUTORIAL OVERVIEW

Page 7: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 1. INTRODUCTION

Figure 1.1: Solution Graph of tutorial part 1 without mapping

1.3. SUMMARY OF TUTORIAL PART 1 3

Page 8: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 1. INTRODUCTION

4 1.3. SUMMARY OF TUTORIAL PART 1

Page 9: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2

WRITE A RULE-BASED ANALYSIS

To analyze the product portfolio in more detail we want to calculate some key performance indicators(KPIs) for our parts and products or product families based on the graph. This will be done usingrules and sequences to transform the graph. As we will see, this requires some iterative changes tothe metamodel and data graph we created in tutorial part 1.

2.1 Setting the Stage: Tutorial Part 2

The process of creating a data graph and running analyses has been presented before and is recalledin Figure 2.1. This time, we do not start from scratch but with an existing model. A good point tostart with an iterative extension is to define the questions that we want to answer with the analysis(2.1.1) and then, if needed, extend the metamodel to cover all changes (2.1.2).

Sketch metamodelInformally define node and edgeclasses

Define questionsCollect questions that themodel/analyses should answer

Formalize metamodelTransfer metamodel to thecomputer

Define visualization(s)Choose view (graph, table, chart, …) and set style (color, labels, …)

Create instancesModel the data by creating nodesand edges with attributes

Modify modelCreate rules to do calculationsand transform the model

Run analysesGroup rules in sequences andvisualize results

Create workflowsBuild single-click analysisprocesses

Figure 2.1: Process of Creating a Data Graph and Running Analyses

2.1.1 Define Questions (Step 2)

Defining analysis questions helps us to identify what we need to model or calculate. Recall that wefirst need to think about the desired output before starting to create our metamodel. To sharpenour product portfolio analysis we are interested in answers to the following questions:

• Are the parts only used in one product (exclusive use) or are they carry-over parts, meaningthat the same part (id) is used in multiple products?

• How many different parts is each product built from?

• How many of these different parts are exclusively used for a product or a product family?

5

Page 10: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

• Based on these numbers, what is the carry-over part ratio (COP-ratio) of each product orproduct family?

• Which of my products or product families are economically efficient and which should beimproved?

We can answer these questions based on our existing data graph. The first few questions requirethe calculation of some numeric values. To store these values we need to add a few propertiesto our existing metamodel. For example, we want to know the COP-ratio for each Product nodeand the number of products a part is installed in for each Part node. Further, we see that severalcalculations should be done on both the Product and the Product Family level, so we might wantto add a common parent class for only these two classes. The last question is a bit more vague.How is economic efficiency defined? We will take a pragmatic data-driven approach to answer thisquestion. Looking at our data, we only have sales and product hierarchy data available. So let usdefine that economically efficient products have a high revenue and should have a high COP-ratio.A high COP-ratio means less exclusive parts which leads to manifold savings in complexity costs,be it in development, storage, service or other steps in the lifecycle. So to quantify the economicefficiency of products or product families we need to set the revenue in relation to the sales volumeand the COP-ratio. All these calculated values must then be presented in a way that allows for easyand fast interpretation. Coming up with a quickly interpretable view type requires some knowledgeand experience about the available views and some creativity. We will get to this later (in chapter 3).For now, let us first extend and change our metamodel as needed and then calculate the values.

2.1.2 Extend the Metamodel (Step 3)

To be able to answer the new analyses questions, we will revise the metamodel we created in thelast tutorial. As already mentioned, some of our classes need additional attributes and show a formalfigure of it.In detail, we add a new class COPart which extends the class Part. We will merge Carry-Over Partsand therefore use the new node class to distinguish merged (=Carry-Over) from not merged nodes.

2.1.2.1 Exercise: Enhance Metamodel

In the following, we go step by step through the process of adapting the metamodel files.

1. We add one new node class for retyping Carry-Over Parts MergedPart, that is used to mergeequivalent Part nodes.

2. Now, several attributes are added for further analyses. We start with new attributes of classPart.

• copMarker (boolean)• nbInstalledInProd (int), one by default

3. The abstract AnalyticNode class gets five new attributes, too:

• salesvolume (int)• nbDifferentParts (int)• nbExclusiveParts (int)• nbCOParts (int)• copRatio (double)

4. The top hierarchy level ProductFamily stays unchanged.

6 2.1. SETTING THE STAGE: TUTORIAL PART 2

Page 11: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

5. The resulting Nodes.gm file should look like Example 2.

EXAMPLE (2)

abstract node class BomNode extends IdentifiableNode{id:int;name:string;cost:double;productid:int;salesvolume:int;

}

//Declaration of the (concrete node) class ’Part’ as a subclass of ’BomNode’node class Part extends BomNode{

parentid:int;quantity:int = 1;copMarker:boolean;nbInstalledInProd:int = 1;

}

node class MergedPart extends Part{}

//Declaration of the abstract class ’AnalyticNode’ as subclass of BomNodeabstract node class AnalyticNode extends BomNode{

profit:double;nbExclusiveParts:int;nbDifferentParts:int;nbCOParts:int;copRatio:double;

}

//Declaration of the class ’Product’ as a subclass of ’AnalyticNode’node class Product extends AnalyticNode {

salesprice:double;family:string;

}

//Declaration of the (concrete node) class ’ProductFamily’ as subclass of ’AnalysisNode’node class ProductFamily extends AnalyticNode {}

6. For the sake of completeness, the Edges.gm file is given in Example 3, although it is un-changed.

2.1. SETTING THE STAGE: TUTORIAL PART 2 7

Page 12: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (3)

//Declaration of ’Contains’ as subclass of the generic edge superclass’IdentifiableDirectedEdge’

directed edge class Contains extends IdentifiableDirectedEdge{}

//Declaration of ’IsFamilyOf’ as subclass of ’IdentifiableDirectedEdge’directed edge class IsFamilyOf extends MyDirectedEdge{}

As we did not present a formalized metamodel after the last hierarchical change, we show the updatedmetamodel in Figure 2.2.

CityMoveMan

Drive Assembly

Speed Sensor

Pedal Assembly

Contains

Contains Contains

id:10000…

id:8572647…

quantity:1

quantity:1

quantity:1

IsFamilyOf

id:200050…

id:200060…

StreetBikes

id:0profit: 569600 €…

quantity:1

City Move

Woman

Id:10001…

Figure 2.2: Enhanced Metamodel: The product family PE is a new hierarchical superclass

2.1.3 Further Information about the Modeling Process

These are the changes to the metamodel for a quick start of part 2 of the Soley Studio Tutorial. If youfeel like you lack information on Step 5 of the modelling process (How to create/define visualizations)or any other step, have a look at the tutorial part 1 or our Help Center.

8 2.1. SETTING THE STAGE: TUTORIAL PART 2

Page 13: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

2.2 Calculate Properties for Carry-Over Part Analysis

Let’s get right into answering the questions formulated above. In this chapter a rule based analysis forcalculating the carry-over part ratio (COP-ratio) of a Product is explained. The COP-ratio describeshow many parts of one product are not unique, thus used several times in the product portfolio. Suchanalysis can be used to identify potentials for standardization within the product portfolio. To get abetter understanding of the complex task we sketched the process in three formal steps as describedin figure 2.3.

www.soley-technology.com © 2015

Merge equalNodes

Mark Carry Over Parts

Count COP and calculate

COP Ratio

Figure 2.3: Process of the COP Analysis

In the first step we will merge equal part nodes within the product portfolio, hence only unique nodesremain in the resulting graph. The Carry Over Parts will have more than one edge of type Containsconnecting them with another part of higher hierarchy or a product. With this information we cansubsequently identify the CO-Parts, count them, and calculate the COP-ratio.

www.soley-technology.com © 2015

LHS RHS

Part 5Part 5

Product 1

contains

Part 5

Product 2

contains

Product 1 Product 2

containscontains

Figure 2.4: Merging of nodes

2.2.1 Exercise: Perform the Carry-Over Parts (COP) Analysis

Translating the process of the COP-Analysis to Soley Studio code results in (1) a rule to merge nodesand afterwards deleting duplicate edges (2) as a clean up. Next, we (3) mark the carry-over parts and(4) count the number of unique and Carry-Over Parts with a sequence and embedded procedure.Finally calculate the COP ratio in a rule (5) with the KPIs generated in the sequence before. Butlet’s move forward step by step. First create a new Ruleset, and add it to the MainRuleset. You canthen write all rules on the same ruleset.

1. Merge identical nodes: As we want to merge identical part nodes we have to set up arule, which selects two part nodes n1:Part and n2:Part and compares their id attribute. Ifthis comparison succeeds, we merge them into a new node of type MergedPart on the RHSwhich substitutes the old nodes and initialize the new node with the name mergedNode. Themerging is described by the <.,.> sign and the whole expression <n1,n2> describes, whichnodes we want to merge (n1 and n2).

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 9

Page 14: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (4)

rule mergeEqualNodes{

n1:Part;n2:Part;if{n1.id == n2.id;}

modify{mergedNode:MergedPart<n1,n2>;

}}

Since at a certain step the LHS pattern won’t be found anymore, this rule can be executedwith an asterisk in the super sequence, which we will use to automate the COP-analysis.

NOTE (2)

• Make sure that when you merge nodes they have exactly the same attribute values. If valuesdiffer, one value will randomly be selected from the merged sourceNodes as value for thetargetNode. Take this into account for structuring your analysis! Thus, using <n1,n2> iscomfortable if you have no need for distinguishing. Otherwise it may be beneficial to typea custom merging rule.

• The merging of graph elements is called an Inbuilt function. These functions execute acomplex task automatically. They are either provided as library elements from the librariespad or you can add them manually. Therefore, we provide a big section in our Help Centerwhich covers the explanation and syntax of all available functions.

2. Delete parallel edges: It might occur, that the same part is connected several times tothe same parent part/product. This indicates that a combination of parts was used multipletimes, basically a COP assembly/structural combination. To clean up your graph and henceincrease performance, it is recommended to delete those edges. But it will not only improveperformance but as well prevent erroneous pattern search - an edge connecting two nodes isfound once, not depending on the number of its duplicates. Therefore, we have to look fora parent part or product, which is connected to a child of type MergedNode, and examinewhether at least two edges exist between these nodes. If this is the case, the rule deletes oneof the edges.

10 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 15: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (5)

rule deleteParallelContainsEdges{

n1:BomNode -edge1:Contains-> n2:MergedPart; /*matching pattern: if one BoMNode n1 has a Contains edge to another mergedNode n2*/

n1 -edge2:Contains-> n2; /*matching pattern: and n1 has anotherContains edge to n2 (meaning the edges are parallel)*/

modify{delete(edge2); //then delete the second edge

}}

As in the mergeEqualNodes rule, the LHS pattern works as a termination criterion, whichallows the use of the asterisk in the super sequence.

NOTE (3)

If your Contains edges contain attributes you don’t want to lose, you can sum up theseattributes before deleting the parallel edges.

TIP (2)

The graph behavior as described above shows one of the obstacles, that have to be managedfor more complex analysis. To become aware of such obstacles it’s best practice to test thelogic of your rules on small data sets which cover all possible behavior options.

3. Mark Carry Over Parts: In this rule we will realize several tasks at once, and also learnmany new coding options. To ensure that you don’t get lost in the process, we sketched theprocess of this rule in figure 2.5, which splits the rule’s content into five steps.

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 11

Page 16: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

www.soley-technology.com © 2015

Merged

Part

Product 1 Product 2

contains containsProduct 1

Product 2

Set of

Nodes

I.Collect reachable

elements

II. Fill set

with elementsIII. Extract

elements with

for loop

counter

IV. Increment

counter for

products for

each extracted

element

CO-Part

V. Identify CO-

Parts

Figure 2.5: Marking CO-Parts Process

• I and II: By merging the part nodes we created a new pattern which can now be usedto identify Carry-Over Parts. Carry-Over Parts are used in more than one product,subsequently they have incoming Contains edges to more than one product. To workwith this pattern in Soley Studio Syntax, we create a rule, which looks for a node oftype MergedPart. In the eval part of this rule we create a set of nodes. A set is acontainer type, which only allows storing unique content, in this case only uniquenodes. This set is then filled with all nodes which can be reached from the selectednode with only incoming edges of type "Contains". This can be expressed by the inbuiltfunction reachableIncoming. The rule up to this point looks like in example 6.

NOTE (4)

Containers can store multiple elements of the same type (e.g. strings, nodes) in a twodimensional structure. They can be filled either with the .add statement or with anInbuilt function. The most common type is the array, which stores all elements at adefined position within the array, and allows calling elements by their position index.On the opposite sets only store unique content without index. Luckily it’s possible tocast a set into an array and the other way around.

www.soley-technology.com © 2015

Set of Nodes

String 1

String 2

String 3

String 3

Array of Nodes

String 1

String 2

String 3

String 4

String 1

String 2

String 3

String 4

String 1

String 2

String 3

1

2

3

4

Figure 2.6: Difference between sets and arrays

12 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 17: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (6)

rule markCarryOverParts {n:MergedPart;

modify{eval{

def ref uniqueNodeSet:set<Node> = set<Node>{};uniqueNodeSet = reachableIncoming(n,Contains);

}}

}

NOTE (5)

• In this code example, we create a variable for the first time. Variables (such asstrings, int, double) are defined with a def and a var statement. Since we define acontainer type (arrays, sets, maps) in this case, we have to use the ref statementinstead. The different initialization methods are depicted below in example 7.Regarding the container definition the string before the : is the reference name,the text within the <...> defines the type of the container and the different kindof brackets end the statement.

EXAMPLE (7)

def var integer:int = 0;def ref array1:array<Node> = array<Node>[];def ref set1:set<Node> = set<Node>{};

• A set only stores unique content. Thus, using this container type avoids storingduplicate values or instances.

• To create a set, you have to divide creation and initialization into two steps toavoid errors when compiling. For the right syntax for each code element (rule,sequence, procedure, function), take a look at our Cheat Sheet in the Help Center.

• III and IV: Now we have to define a variable to count the number of products themergedNode is installed in. Afterwards we can loop through the set elements (allreachable nodes from the considered merged part) with a for loop, in which we, withthe help of an if statement, check for each element whether it is a product, and thenthe counter is incremented by one if this is true.

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 13

Page 18: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (8)

rule markCarryOverParts {n:MergedPart;

modify{eval{

def ref uniqueNodeSet:set<Node> = set<Node>{};uniqueNodeSet = reachableIncoming(n,Contains);def var counter:int = 0;for(n1:Node in uniqueNodeSet){

if(typeof(n1) == Product) {counter = counter+1;

}}

}}

}

NOTE (6)

– In this code example we use the Inbuilt function typeof, which returns the typeof an edge or a node.

– In code example 8 we now define a variable with the def and var statement asmentioned above. Unlike a container, we can initialize this variable with the value"0" simultaneously in the same step.

TIP (3)

In most cases in Soley Studio, for loops are used to iterate over container type objects.Keep this in mind, when sketching your analysis code structure. For other options,please check the GrGen Manual.

• V: After iterating over all reachable nodes, we jump out of the for loop and check thevalue of the counter variable. If it is bigger than one, we have to mark the merged partas a CO-Part by setting the attribute "copMarker" true. Additionally, we calculate thenumber of "Products Installed In" with the value of the counter variable. The wholerule is depicted in example 9.

14 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 19: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (9)

rule markCarryOverParts {n:MergedPart;

modify{eval{

def ref uniqueNodeSet:set<Node> = set<Node>{};uniqueNodeSet = reachableIncoming(n,Contains);def var counter:int = 0;for(n1:Node in uniqueNodeSet){

if(typeof(n1) == Product) {counter = counter+1;

}}if(counter >= 2){

n.nbInstalledInProd = counter;n.copMarker = true;

}}

}}

As we want to mark all CO-Parts, this rule has to be applied in square brackets in the supersequence.

4. Calculate Unique Parts, CO-Parts and Exclusive Parts: As before, we will first reducethe complexity of the upcoming task, which is using the marked CO-Parts to count theirnumber within each product/the whole portfolio. Hence, we divided the rule into four stepsand sketched them in figure 2.7.

www.soley-technology.com © 2015

Product

1

Product

2

Product

3 Set of Nodes Set of Nodes

Product 1

Product 2

Product 3

Part 2

Prod. 1

Part 1

Prod. 2

Part 1

Part 2

Set of Nodes

Part 1

Part 2

Counter 1 =

#Different

Parts

Counter 2

=

#CO-Parts

+1

I. Create set for

all products

II. Create set for

all reachable

elements

III. Extract set

with all reachable

parts

IV. Count set

elements and

calculate

attributes

Procedure

Figure 2.7: Process of counting CO- and unique parts

• I and II: We create a sequence which iterates with a for loop over all products/ portfo-lios,which have the super node class AnalyticNode (I). The for-loop picks one productand creates a set with all nodes that can be reached by outgoing edges from the con-

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 15

Page 20: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

sidered node (II). We also create two counter variables, which will be used in step IVto evaluate the number of unique and CO-Parts. This is implemented with the code inexample 10.

NOTE (7)

When using sequences, there are some things you should be aware of:

• The conditions of if-statements have to be in double curly brackets:if{ {{condition}} ...

}

• Functions, evaluations and other code which has to be executed have to be in singlecurly brackets.

• More information about sequence flow operations can be found here

EXAMPLE (10)

sequence calculateNbUniqueDiffPartsAndCOParts{for{n:AnalyticNode in nodes(AnalyticNode);

uniqueNodeSet:set<Node> = set<Node>{} &{uniqueNodeSet = reachableOutgoing(n)} &counter1:int = 0 &counter2:int = 0

}}

NOTE (8)

• The for loop in example 10 iterates over a set, which is created by the Inbuilt functionnodes(...). This function stores all nodes of the in brackets defined type of yourgraph.

• Up to now we used sequences only to summarize the execution of rules or to apply themseveral times. As we see now, sequences can also be used in a similar way as rules ascan be procedures and functions, which we will learn about in a minute. Performanceand code architecture are the main factors influencing the decision on which syntax touse.

• However the syntax in a sequence varies from the one used in a rule, for instance thesyntax of the for loop. Our Cheat Sheet gives an overview of the differences.

5. III: To calculate the value of the counter variable we have to avoid counting set elementsin the "uniqueNodeSet", which are not parts. Thus, we extract all parts from the set andstore them in a new set. Beforehand we have to define this set as uniquePartSet. Fillingthis new set is executed in an additional procedure getPartsOutOfNodeset, which workssimilar to an Inbuilt function. A procedure can have multiple input values and no, one ormultiple output values. In this case the procedure has two input elements (uniqueNodeSetand uniquePartSet) and no return value. Our sequence now looks like example 11.

16 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 21: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

EXAMPLE (11)

sequence calculateNbUniqueDiffPartsAndCOParts{for{n:AnalyticNode in nodes(AnalyticNode);

uniqueNodeSet:set<Node> = set<Node>{} & // Within a sequence you can use &// as a logical AND. s & t means, you execute s, then t.// Success if s or t succeeded.{uniqueNodeSet = reachableOutgoing(n)} &counter1:int = 0 &counter2:int = 0 &uniquePartSet:set<Part> = set<Part>{} &{getPartsOutOfNodeset(uniqueNodeSet,uniquePartSet)} //This is the procedure

}}

NOTE (9)

With input and output elements you can transfer information from one code segment toanother. Input and Output elements are available for all code segments (rules, sequences,procedures, functions). This can be helpful to structure your analysis problem in several subproblems which can be solved each in one code segment. Inputs can be transferred betweenrules with the exec statement. Outputs can be used to calculate values. Furthermore, outputscan be stored in variables in sequences and then be used as input for other rules again. Havea look at the Cheat Sheet for the syntax of creating input or output elements.

Now let’s have a closer look at the procedure. A procedure is a code element like a ruleor sequence and very similar in its syntax to a function. Functions and procedures offera good possibility to structure your code and extract difficult calculations to an additionalcode block, for instance. As we can see in example 11 the procedure obtains the two nodesets uniqueNodeSet and uniquePartSet, the filled one and the empty one, as an input.The procedure then iterates over the elements of the filled "uniqueNodeSet", and adds theelement to the empty "uniquePartSet" if the considered element is of type "Part". In SoleyStudio the code of the procedure looks like this:

NOTE (10)

With typeof(n) >= something, the program searches for all classes and child classes ofsomething, just as it looks for classes and superclasses of something if you usetypeof(n) <= something.More information on the expression typeof(n) can be found here

EXAMPLE (12)

procedure getPartsOutOfNodeset(ref nodesSet:set<Node>, ref partsSet:set<Part>) {for(n:Node in nodesSet){

if(typeof(n) >= Part){partsSet.add((Part)n);

}}return ();

}

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 17

Page 22: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

NOTE (11)

• Even when your procedure does not have a return value as in this example, everyprocedure (and also function) has to end with the return(); statement.

• To add elements to a set, the .add method is used. There are several other options tomanipulate a set all further explained in our Help Center.

6. IV: After understanding the structure of the procedure we can now think of the actual purposeof the sequence, the calculation of the different parts. We already defined the counters andfilled a set with all part nodes reachable from the AnalyticNode. Now we just have to iterateover this uniqueNodeSet and increment the counter for the unique parts by one for eachelement and if the element’s, meaning the considered part, attribute copMarker is true, wealso increment the counter for the CO-Parts by one. After looping over all parts we just copythe counters’ values to the considered AnalysisNode’s attributes and by subtracting the CO-Parts from the unique parts we also obtain the number of exclusive parts. The whole codestructure containing both the sequence and the procedure is displayed beneath in example 13.

EXAMPLE (13)

sequence calculateNbUniqueDiffPartsAndCOParts{for{n:AnalyticNode in nodes(AnalyticNode);

uniqueNodeSet:set<Node> = set<Node>{} &{uniqueNodeSet = reachableOutgoing(n)} &counter1:int = 0 &counter2:int = 0 &uniquePartSet:set<Part> = set<Part>{} &{getPartsOutOfNodeset(uniqueNodeSet,uniquePartSet)} &for{n1:Part in uniquePartSet;

{counter1 = counter1+1} &if{ {{n1.copMarker}};

{counter2 = counter2+1}}

} &{n.nbDifferentParts = counter1} &{n.nbCOParts = counter2} &{n.nbExclusiveParts = n.nbDifferentParts - n.nbCOParts}

}}

//Find Part nodes in a set of Node nodes and add them to another set, both sets areinput arguments

procedure getPartsOutOfNodeset(ref nodesSet:set<Node>, ref partsSet:set<Part>) {for(n:Node in nodesSet){

if(typeof(n) >= Part){partsSet.add((Part)n);

}}return ();

}

This process is then repeated for every Analysis Node we stored in step I. Since we are

18 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 23: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

already using a sequence with a for loop, we just have to execute it once to apply it to allAnalysisNodes.

NOTE (12)

In contrast to rules, sequences can not be called with square brackets or asterisk. A for loophas to be used to apply it to several matches.

7. Calculate COP-Ratio: Finally, we can calculate the COP-ratio by dividing the numberof Carry-Over Parts (nbCOParts) of an AnalyticNode through the number of Unique Parts(nbDifferentParts). Therefore, we have to cast the nbDifferentParts to a double variable,since the COP-ratio is a decimal figure and also stored as double. As a last step we roundthe result on one decimal digit by first multiplying the COP-Ratio by 10, then applying theround function, which rounds a figure on its last integer place, and afterwards dividing it by10 again. In Soley Studio it’s realized like this:

EXAMPLE (14)

rule calculateCopRatio{

n:AnalyticNode;

modify{eval{

n.copRatio = 100.0*(n.nbCOParts/(double)n.nbDifferentParts);n.copRatio = Math::round(n.copRatio*10.0)/10.0;

}}

}

NOTE (13)

• In example 14 the integer attribute nbDifferentParts is casted to a double vari-able with the Inbuilt (double) function. Unfortunately casting types is strongly typedependent. Hence, we wrote a Help Center article about this topic.

• The Math::round() function is one of the math functions, which can be used in SoleyStudio. The figure 2.8 describes again how to provide a certain number of decimalfigures.

www.soley-technology.com © 2015

10,1234 1012,34 1012 10,12

*100 ::round /100

Figure 2.8: Rounding of doubles

This rule will be executed for all AnalysisNodes and thus will be called with square brackets.

2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS 19

Page 24: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 2. WRITE A RULE-BASED ANALYSIS

8. Automation: To execute the whole process at once, we have to embed all the rules andthe sequence in one super sequence analyzeGraph. According to the process displayed infigure 2.3 the sequence has to be structured as below.

EXAMPLE (15)

sequence analyzeGraph {mergeEqualNodes*& deleteParallelContainsEdges*& [markCarryOverParts]& calculateNbUniqueDiffPartsAndCOParts& [calculateCopRatio]

}

Now we created all the code needed to execute the COP-Analysis. In the next chapter we willvisualize the outcome of this and other analyses.

20 2.2. CALCULATE PROPERTIES FOR CARRY-OVER PART ANALYSIS

Page 25: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3

CREATE DIFFERENT VIEWS

The most genius analyses are worthless when the visualization of the results can not present theoutcome of the analysis properly. Creating such visualizations will be part of this chapter. We willcreate a bar chart to understand the product architecture of the different products and afterwardscompare them regarding their profit, COP-ratios and sales volume in a bubble chart created withthe same process used for the bar chart. With this process several different kinds of charts can becreated. Have a look at our Help Center. We will achieve this by using the Open View Dialog andView Manager as already mentioned in the Soley Tutorial Part 1.

3.1 Exercise: Create Bar Chart from COP-Analysis

This exercise explains how to set up a Bar Chart as in figure 3.1 from a saved graph file and adaptthe visualized data to your needs by using the View Manager. Therefore we first open the graphwith the Open View Dialog, choose the data to plot, adapt the visualization with the View Managerand extract the settings for later use. Let’s start now with the Open View Dialog.

Figure 3.1: Adjusted and sorted bar chart.

1. After setting up the COP-analysis we have to execute the analyzeGraph sequence withthe Build and Run pad from the existing graph01.slg file (graph08.slg from Tutorial Part 1,the last one). The output data graph has to be saved afterwards. By double clicking onthe graph02.slg file in the Solution Explorer , we open the Open View Dialog. In the leftcolumn of this dialog we select Bar. The Open View Dialog then shows the information as

21

Page 26: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

in figure 3.2.

Figure 3.2: Open View Dialog to create a Bar Chart.

2. Selecting settings in the Open View Dialog: Now we have to decide which values to setfor the different dropdowns. In the first view we want to plot all products, thus we choose"Product" as the Data set to plot. With the Category dropdown we define by which attributethe products should be grouped. We decide to group them by the attribute "family", whichrepresents the product family of the product. Lastly we set the Value to "nbCOParts" tovisualize the number of common parts as the height of the bars. Afterwards, we open theview by clicking on OK.

3. Adjusting the Bar Chart’s visualization with the View Manager: By opening the ViewManager we can start customizing the graph. Within the View Manager window node series’color can be adapted, they can be hid or deleted from the view and other node/ edge seriescan be added as different plots to the view. We want to change the color to green by selectingthe color from the color dropdown next to the node series.

4. Further customizations within the properties pad : When we click on a node series in theView Manager the Properties Pad on the bottom left side shows the properties of the ViewSeries. Since we want to plot the COP ratio below each bar we have to use a Converter .Therefore click on the "..." next to the property category in the Properties Pad, which willopen the Edit Property Window. In this window select the tick box Converter and from thedropdown the "String Format Converter". Now we have to combine the name string withthe COP ratio. Select from the Property Dropdown "name", insert it and repeat this forthe "copRatio". Finally add a "-" between the two values and a "%" behind the copRatioexpression in the Expression field. Your Edit Property Window should now look like infigure 3.3.

22 3.1. EXERCISE: CREATE BAR CHART FROM COP-ANALYSIS

Page 27: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

NOTE (14)

For a whole list of converter functionality please see the relevant article in Soley Help Center.

Figure 3.3: Edit Properties Window to adapt the grouping of the products.

5. Furthermore, let’s define the Legend title, which appears on the upper right corner by over-writing "Product # carry-over parts" to the corresponding property in the Properties Pad.Below we also can define how the bars are sorted. To create a bar chart as in figure 3.1choose "copRatio" for the Sort by attribute and "descending" for the sort direction. Afterthese adjustments your properties pad should look like figure 3.4.

Figure 3.4: Properties Pad with view properties of the product node series.

6. Now we want to compare the number of common parts with the number of unique parts perproduct. Therefore, we have to add a new product node series in the View Manager. Clickon the dropdown next to the Product Series and add a "Bar Series". By clicking on the eyenext to the newly created series it will be displayed.

3.1. EXERCISE: CREATE BAR CHART FROM COP-ANALYSIS 23

Page 28: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

7. Finally adapt the properties of this node series as in figure 3.5. The Category value corre-sponds to the one for the first series (figure 3.3).

Figure 3.5: Properties Pad of the second node series to visualize the unique parts.

8. To reuse these settings for further plots click on the Extract View Template Button (3.6)in the View Manager and save it in the View Templates folder. We choose the nameBarChart-Prod-CopRatio.slvt.

www.soley-technology.com © 2015

Extract View as View Template

Figure 3.6: Extract View Button in the View Manager

9. The bar chart can be created on ProductFamily level as well. The required changes are quitesmall: Instead of selecting the Data Set "Product", choose "ProductFamily". For Category,you can just chose name. Please change the title of the graph legend respectively, and savethe extracted view template with the name BarChart-ProdFam-CopRatio.slvt.

24 3.1. EXERCISE: CREATE BAR CHART FROM COP-ANALYSIS

Page 29: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

Figure 3.7: Properties Pads for the Bar Chart - Product Family (COParts / Exclusive Parts)

3.1. EXERCISE: CREATE BAR CHART FROM COP-ANALYSIS 25

Page 30: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

3.2 Exercise: Create Bubble Chart from COP-Analysis

An even more expressive kind of chart that we want to set up now is the bubble chart. It will arrangethe products depending on their profit, COP-Ratio and their sales volume. Furthermore, we willstructure our chart in four quadrants to ease decision making.

1. Choosing the graph: Open the graph created in exercise 3.1 from the solution explorer.

2. Selecting seetings in the Open View Dialog: Now select in the Open View Dialog Scatterin the left column and select "ScatterBubble Chart" from the View Type dropdown. Select"Product" as Data set. With the properties X value and Y value the attributes displayed oneach axis are defined. Select "profit" for the X value and "copRatio" for the Y value. To mapthe size of the bubbles to an attribute select "salesvolume" in the last dropdown. Finally, tickthe box "Show data point labels". Your selections should fit those pictured in figure 3.8.

Figure 3.8: Open View Dialog for the Bubble Chart of the COP Analysis.

3. Creating quadrants: In the next step, we want to create the chart annotations. Thereforeclick on the annotation symbol on the bottom left edge of your graph window as in figure 3.9.

26 3.2. EXERCISE: CREATE BUBBLE CHART FROM COP-ANALYSIS

Page 31: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

www.soley-technology.com © 2015

Create Chart Annotation

Figure 3.9: Create Chart Annotation

4. In the Chart Annotations window click on Add GridLine to add a line. The Axis Propertydefines to which axis the line will be perpendicular. The value defines the position on theselected axis. Select first Horizontal and the value 350. Additionally, we will create the label"limit profit".

5. Repeat this procedure for Vertical choosing the value 50 and the label "limit cop ratio" asshown in figure 3.10

Figure 3.10: Chart Annotation Window

6. Finally, we have to adapt the properties pad of the Node series to create a graph as infigure 3.11. Change the Legend title property to "Products (size sales volume)" and chose thereference name as the Label Text attribute for the nodes, as already described in exercise 3.1.

3.2. EXERCISE: CREATE BUBBLE CHART FROM COP-ANALYSIS 27

Page 32: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

Figure 3.11: Adjusted Bubble Chart.

7. To reuse these settings for further plots click on the Extract View Template Button (3.6) inthe View Manager and save it in the View Templates folder. We name the view templateBubbleChart-Prod-CopRatio-Profit-Salesvolume.slvt. As in the bar chart section,we will also directly prepare a ProductFamily view template for the workflow chapter.Select the "ProductFamily" for Data set in 3.8 and follow the steps 1 to 6. Extract it as a ViewTemplate under the name BubbleChart-ProdFamily-CopRatio-Profit-Salesvolume.slvt.

28 3.2. EXERCISE: CREATE BUBBLE CHART FROM COP-ANALYSIS

Page 33: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

3.3 Exercise: Create Dashboard from view templates

In order to take important decisions, seeing more than one chart at a time is very helpful. The toolthat makes it happen is called a Dashboard. A combination of different charts can be easily plottedin it.

1. Choosing the graph: Open the graph created in exercise 3.1 from the solution explorer bydouble clicking on it.

2. Selecting seetings in the Open View Dialog: Now select in the Open View Dialog Dash-board in the left column and tick the box "Graph View" if not ticket automatically. Yourselections should fit those pictured in figure 3.12.

Figure 3.12: Open View Dialog for the Dashboard.

NOTE (15)

It is also possible that figure 3.12 does not match exactly the picture showed in your OpenView Dialog. There may appear other suggestions such as the View Templates Bar Chartsand the Bubble Charts previously created in exercises 3.1 and 3.2. Do not worry, we willadd them manually in the following steps of the present exercise.

3. Adding visualizations on the Dashboard: In the next step, we want to add two more chartson the Dashboard, since it only appears one Graph View on the central window. To do so,we click on the "+" symbol just on top of the Dashboard window as shown in figure 3.13.

Figure 3.13: Add View to Dashboard.

3.3. EXERCISE: CREATE DASHBOARD FROM VIEW TEMPLATES 29

Page 34: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 3. CREATE DIFFERENT VIEWS

4. In the Open View window select from View Templates the one called BarChart-Prod-CopRatioand accept by clicking on OK or just double-clicking on it. Repeat this procedure but thistime adding the view BubbleChart-Prod-CopRatio-Profit-Salesvolume. The Dash-board will now look as figure 3.14 shows.

Figure 3.14: Finished Dashboard’s look.

5. Finally, we can arrange and enlarge the three views by dragging and dropping. Use the iconsappearing on the top of the canvas to position the individual view tiles. You can then dragthe borders to resize each tile in the dashboard as shown in figure 3.15.

Figure 3.15: Arranging of windows in the Dashboard View.

6. To reuse these settings for further plots click on the Extract View Template Button (3.6) inthe View Manager and save it in the View Templates folder. We name the view templateDashboard-Product.slvt. As in the bar chart section, we will also directly prepare aProductFamily view template done the same way.Select the "ProductFamily" for Add View in 3.13 and follow the steps 1 to 6. Extract it asa View Template under the name Dashboard-ProdFamily.slvt.

Now that we set up all parts of our analysis, the metamodel, the import, the analysis and theirvisualizations, we can proceed to the next chapter. This will explain how to create workflows, anautomatized way to run and visualize your analysis with only one click.

30 3.3. EXERCISE: CREATE DASHBOARD FROM VIEW TEMPLATES

Page 35: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4

CREATE SINGLE-CL ICK WORKFLOWS

The first chapter is implemented and you got the answers to the questions we asked in the beginning.You could stop at that point and be satisfied. But on our mission to make you a data magician,we’ll introduce workflows to you and provide two short exercises.

4.1 Introduction to Workflows

In a lot of cases, you do an analysis not only once but multiple times. For example, if you getthe sales figures of the new quarter and you want to check the progress of your actions, or if yourboss liked your work and asks you to analyze another product segment of your company’s productportfolio. Another scenario that comes to mind is if you want to share the solution you createdwith your colleagues in different departments so that they apply analysis based on your solutionsindependently.

A workflow is perfect for those scenarios. You wrap up your solution and no more changes inthe programming editor are required. Data analysis becomes how it should be: repeatable, and themachine does the job.

NOTE (16)

Another reference for workflows is the respective article within the Soley Help Center. We alsopresent typical workflows there, in case you finish this chapter and you are still looking for more.

This chapter will include a broad introduction to build your first workflow in 4.2. By one click,this workflow will perform all calculations/manipulations that were done in Tutorial Part 1! Thesecond workflow in 4.3 will perform the Carry-Over Part analyses.

31

Page 36: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

4.2 Create Import & Build Hierarchy Workflow

The first workflow we are going to build will:

1. Import data from excel files.

2. Execute rules to create ProductFamily instances.

3. Build a hierarchy.

4.2.1 Exercise: Import Workflow

1. For simplification we will summarize (1)-(3) in one sequence 16. Add this sequence to aruleset.

EXAMPLE (16)

sequence createHierarchy{importNodes& [createBOMHierarchy]& createProductFamilyNodes*& [calculateProfit]& [calculateFamilyValues]

}

2. We have to create a new file in the workflow directory . Therefore, click right on the Workflowfolder and select Add - New File. In the new file menu, choose the Workflows templateStart With Empty Graph. We name the file 01_ImportData.slwf. This will create two newfiles in your workflow folder. They will have the same name, the only difference will be thefile type. The file ending with .slwf is the workflow file, and the other file, ending with .slmdis an XML file, which we will get back to later on.

3. When you open the workflow file, you will see a new editor. The heart of that editor isthe Activity builder in the middle, where activity blocks are connected in order to build aworkflow. The left bar provides a collection of activity blocks, which are added to the Activitybuilder by dragging them with your mouse to the place where you want them to be. Onthe right, a detailed properties window for activities is given, which we will use later as well.Finally, a bar at the bottom contains the tabs Variables, Arguments and Imports. These tabsare used for defining variables and arguments, and for listing the namespaces which are inuse. Fig. 4.1 shows the workflow editor.

32 4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW

Page 37: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

Figure 4.1: Workflow editor

4. Variables and arguments are used in workflows in order to store certain results, in the case ofvariables, and to provide the user with the option to choose which documents or data will bethe operands in a workflow, in case of the arguments. Both variables and arguments can bedefined either locally or globally. By clicking on the Sequence block in the Activity builder ,and then clicking on the Variables tab, we can see which variables are in use in our workflow.In this case, we are using the dataView variable of the type IDataViewContent, and thegraph variable of the type IGraph.

Figure 4.2: Variables and properties of an activity block

4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW 33

Page 38: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

NOTE (17)

A namespace is a reference. By importing a namespace, the functionality that is stored inthe reference container is added to the workflow. The linked functionality can be generalsystem classes or Soley specific ones. Knowing which additional namespaces are required isvery advanced.

5. When an activity block is clicked on, its attributes will appear in the properties tab onthe right. Let’s select the sequence block. As we can see, the only property listed is theDisplayName. We can change the value of the DisplayName attribute in the properties tabby simply clicking into the field and changing the value into "Sequence Import Workflow".By doing so, the name of the block in the activity builder is changed.

6. The first activity block in our sequence is the If statement. In the condition field of the if blockwe can see Soley.Framework.SDK.Services.AppService.IsItDesk, which provides informationon whether the user is running the workflow in Soley Desk or Soley Studio. The Conditionfield is followed by the Then and Else blocks. If the user is working with Soley Desk, thecurrent view he is using will be treated in the further steps. Otherwise, if Soley Studio isbeing used, a new view is created based on a user view template.

7. We now need to set up the CreateViewFromStartupProject. By clicking on the block withinthe Else field, we will see the attributes to the right. The result field is predefined todataView, which is the default variable which was mentioned earlier. This means that theview created in the CreateViewFromStartupProject block will be stored into the dataViewvariable for further use.

8. The next thing to be done is to choose the template based on which the view will be created.In the ViewFile field, type "name.slvt", replacing name by the name of the template youpicked.In our case, the view we want is the one from graph01.slg (graph08.slg of the Tutorial Part1). Just open graph01.slg, give it the hierarchical layout, extract it from the View Manageras done in exercise 3.1 and save it as "Graph.slvt". Now you can type "Graph.slvt" into theViewFile field. Don’t forget the quotation marks !

NOTE (18)

The general file extension of viewtemplates is .slvt, but as we do not want to create a templatebut a view, we could also use the extension .slv.

Finally, we can name the output view by changing the default setting of ViewName to"1_BasicBoMData". This step should create properties as in Fig. 4.3 depicted.

34 4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW

Page 39: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

Figure 4.3: Properties of Activity CreateViewFromStartupProject

NOTE (19)

The expressions that refer to strings need to be written in quotes, e.g. "string expression",while references to objects are entered without quotes.

9. Next, we continue with the second step of a workflow: the transformation. The trans-formation takes place in the Transformation Context block. Within it we have the RunTransformation and the GetGraph objects.

10. The RunTransformation block is the one that does the modifications to the view which isentering the transformation. In the properties tab of the block, the sequence field should befilled in with the name of the sequence we would like to run. It is good practice to use oneRunTransformation block per workflow by just grouping all the wanted transformations intoone sequence, the way it is done in this example. It is, however, possible to have as many ofthem as you like. So, now we proceed to enter "createHierarchy" into the sequence field.

11. The resulting graph of the transformation is obtained with the GetGraph activity where graphis by default entered as the result property. Just like with the dataView variable in one of theprevious steps, this variable is also predefined when the Start With Empty Graph is chosen.

12. The transformation is now done, and we are once again outside of the TransformationContext.We now encounter another If statement. Again, it is checked whether Soley Desk or SoleyStudio is being used.

13. The first block is the ShowView, which you have to fill in to ensure the Workflow will workon Soley Desk. Its cause is to adapt the inserted graph to a chosen view template. As earlier,we choose "Graph.slvt" as the ViewFile. The Graph and TemplateContent are by default setto graph and dataView, respectively, and the Result field is by default set to a local variablenewView.

14. The view is now available but we also want to display it with a nice layout. Therefore we usethe activity block ApplyLayout and apply "Hierarchical " Layout to the dataView variablewhich will be shown.

4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW 35

Page 40: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

NOTE (20)

In programming we always face the challenge to make our code comprehensible for othersthat did not write that specific code. In the workflow editor, you can add annotations toactivities to describe your workflow. You add an annotation by selecting an activity, rightmouse button Annotations and Add Annotation.

15. Although the workflow is generated, we should edit the XML file that was created at thebeginning in order to better explain the workflow. We also can create a category in whichthe workflow is listed. The description part of the XML file should contain information onhow the workflow functions, and it might be helpful to mention an example of use. Towrite the description you can either use common XML syntax or markdown syntax . We usedmarkdown syntax which leads to Fig. 4.4.

NOTE (21)

Categories are nice because sometimes we use hierarchies in workflow sequences. For exampleyou can build a workflow that requires a graph that was already created as baseline of theworkflow.

NOTE (22)

The part of the file written in markdown does not allow spaces prior to the syntax!

The description is your task: describe what the workflow does.

Figure 4.4: .slmd File of Import Workflow

We did it! The first workflow is created. We add the Workflow Launcher via the Tools bar andsee the available workflows in Fig. 4.5 with the description we wrote inside the .slmd file. When wecompile and run the workflow, we get a familiar result as depicted in Fig. 4.6.

36 4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW

Page 41: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

Figure 4.5: Workflow Launcher with selected Import Workflow

Figure 4.6: Resulting Graph of Import Workflow

4.2. CREATE IMPORT & BUILD HIERARCHY WORKFLOW 37

Page 42: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

4.3 Create Analysis Workflow

Before we show you how to assemble an app from the analysis of Tutorial Part 2, let us applyour newly gained knowledge about the art of Workflows by automating the COP-Analysis. Themain difference to the workflows we created beforehand is that the user can choose from differentvisualizations: Bar Chart and Bubble Chart created in exercise 3.1 and 3.2 for the different productstructure levels product or product family.

4.3.1 Exercise: Analysis Workflow1. Let’s create a new workflow, but this time, pick Start With Current Graph and name the file

02_Analysis_CreateChart.slwf.

2. First, we create the arguments of the workflow (click on the button Arguments at thebottom of the workflow editor). Create two boolean arguments by clicking on Create Ar-gument, set their default value to "False" and name them For_Product_Families andFor_Bubble_Chart. The booleans will be visualized as tick boxes in the Workflow Launcherwindow. With these tick boxes you can choose which combination you want to show. Theywill be available in the Soley Desk app. You can change their display name in the pad on theright.

Figure 4.7: Arguments in the workflow launcher pad once the display names have been changed.

3. In the TransformationContext activity box, adapt the RunTransformation activity’s propertiesby setting the sequence to "analyzeGraph". It will execute the COP-Analysis on the graphthat is currently open.

4. Now we have to implement the logic which chooses the correct view templates according tothe selected tick boxes. The logic can be described by figure 4.8.

www.soley-technology.com © 2015

Product

Level

Product

Family Level

Bar ChartBubble

ChartBar Chart

Bubble

Chart

Figure 4.8: Logic of the View Template choice

38 4.3. CREATE ANALYSIS WORKFLOW

Page 43: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

In order to set up this logic, insert an If activity under the ShowView box and add as anargument in the Condition field For_Product_Families = false. This will check the valueof the For_Product_Families argument. Drag and drop two more If activities in the fieldsThen and Else below and add For_Bubble_Chart = false into the Condition fields. Thiswill check the value of the For_Bubble_Chart variable. Under the first then - then, dragand drop the ShowView activity from above. You can copy - paste this ShowView under thethree other fields.

NOTE (23)

You can also delete the present ShowView activity box, and drag the new ones from theactivity list on the left (under the category ViewHandling). In this case, make sure that youadjust the properties of the four then / else boxes: the Graph property should be set ongraph, and the TemplateContent property should be set on dataView. This is set by defaulton the ShowView box that is already here, which is why you can also copy and paste it.

5. Now continue with filling the properties of the ShowView activities. If both For_Bubble_Chartand For_Product_Families are false, we want to create the Bar Chart for products, souse the ViewFile "BarChart-Prod-CopRatio.slv". Otherwise, for the case if only theFor_Bubble_Chart variable is true, use the ViewFile "BubbleChart-Prod-CopRatio-Profit-Salesvolume.slv". Proceed with the corresponding View Templates for the ViewFile prop-erties if the product family argument is true. Change the name of the four "ShowView"boxes by clicking on them or using the pad on the right.

6. There is no need here to change the layout, as our views are charts and not graphs. You maydelete the ApplyLayout activity box or leave it, it will not affect your workflow.The whole workflow should now be structured as figure 4.9 (the box Check if we have a viewis closed, you can open or close boxes by clicking on the arrow on top of each box ).

4.3. CREATE ANALYSIS WORKFLOW 39

Page 44: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

CHAPTER 4. CREATE SINGLE-CLICK WORKFLOWS

Figure 4.9: Appearance of the Analysis Workflow file

7. The only thing missing is the explanation of your workflow which is explained in step 15 inexercise 4.2.1. Don’t forget to explain the selection of the different visualization methods.

8. Now, let’s check for errors and try to run our workflows on Soley Studio. First, let’s run01_ImportData.slwf, using the WorkflwLauncher pad. The graph 1_BasicBoMData.slgshould appear, with the familiar result of Fig. 4.6. Now let’s run 2_Analysis_CreateBarChart.slwf, with the graph open.Depending on the boxes that are ticked in the Arguments pad, we find our four results fromexercise 3.1 and exercise 3.2.

Well done, you finished tutorial part 2. By now you have decent skills with our software. Weknow that creating workflows is not that simple yet and we continue our efforts in providing you abetter environment. Till the day we made building workflows as easy that your nana can build one.

40 4.3. CREATE ANALYSIS WORKFLOW

Page 45: Soley Studio Tutorial - Part 2 · Soley Studio Tutorial - Part 2 Soley GmbH Refers to Soley Studio Release 2.12  Version0.0.9-Draft June11,2018

INDEX

GrGen keyword(double), 19container type, 12def, 13, 14for loop, 13Math::, 19merged nodes, 6nodes(...), 16procedure, 9reachableIncoming, 12set, 12typeof, 14var, 13, 14

TerminologyAnnotations, 36bar chart, 2, 21bubble chart, 2, 26Converter, 22for loop, 15improve performance, 10Inbuilt function, 10, 14inbuilt function, 12KPI, 9LHS, 10, 11library, 10markdown syntax, 36Merge identical nodes, 9metamodel, 6product portfolio, 9reachable, 18reachable nodes, 14RHS, 9standardization, 9string expression, 35String Format Converter, 22termination criterion, 11transformation, 35variable, 13workflow, 31workflows, 2

User interface

Activity builder, 32, 33Add - New File, 32Add Annotation, 36annotation symbol, 26ApplyLayout, 35Arguments, 38Build and Run, 21Create Argument, 38Edit Property Window, 22Extract View Template, 24, 28, 30Graph View, 29Hierarchical, 35Legend title, 23libraries pad, 10Open View Dialog, 21properties pad, 22Solution Explorer, 21tick boxes, 38View Manager, 21workflow directory, 32Workflow Launcher, 38

41