« Back to Fachhochschule Nordwestschweiz FHNW

Logical Operation Representation Between two or more Relations/Connectors

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dear all

To model a feature tree with logical operators, I'd like to create a meta-model, to represent a tree e.g. like this:
(see attached illustration)

I need to use e.g. a "OR relation/connector" which goes from a parent feature to at least two child features, but also more than two!! Is it possible, to define, maybe in the Notebook, the number of connectors necessary? [ 2; ∞]?

And furthermore, I'd like to create this internal corner which goes always from the first to the last connector (of the chosen type like "OR" or "XOR"). Does anyone knows an approach or a solution to realize this?
It has to be dynamic and it has to stay always stuck to those two external connectors and keep a certain balanced shape.


Thanks a lot for your help.
Sebastian
Attachment

Attachments: ATT00001.png (6.2k)

RE: Logical Operation Representation Between two or more Relations/Connecto
graphrep aval expr
Answer
4/29/14 12:38 PM as a reply to Sebastian J. Baur.
Dear Sebastian,
This is a very interesting question.

We have developed a simple application library that implements the functionality that you described. You can download the application library in the "Attachments" section of this post.
Starting from an ADOxx 1.3 Experimentation Library, we have defined a class "Task" and two relation classes "AND" and "OR", both from "Task" to "Task".
In the class Task, we have defined two attributes of type EXPRESSION that will identify the ID's of the left-most (_get_start_point_) and right-most (_get_end_point_) objects of class "Task" that are connected to the current instance as target objects of a connector "OR". These attributes won't be displayed in the notebook.

In the GraphRep of the class "Task", the values of these two attributes are read with the AVAL statement and a pie arc is drawn having the current object as center and the centers of the left-most and right-most objects as points for defining the first and second semi-straight lines.

The expressions in the attribute "_get_start_point_" uses the function ctobjs() for returning the ID's of all objects that are connected to the current object via "OR" connectors. The first ID is set as left-most object and then the expression loops through the whole list of ID's. If the x-coordinate of an object is lower than the current left-most position, the ID is saved and the new x-position is saved. In the end, the value of the attribute "Position" of the left-most object is returned.
If there's less than two objects connected via a "OR" connector, the string "NONE" is returned.

Below is the definition of the attribute "_get_start_point_":

 1EXPR type:string expr: (
 2
 3set ( sToObjIDs, ctobjs ( "OR" ) ),
 4
 5cond (tokcnt (sToObjIDs, " ") >1 ,
 6(
 7set ( minXid , VAL token ( sToObjIDs , 0 , " " ) ),
 8set ( s1, token ( aval ( minXid , "Position" ) , 1 , " " )),
 9set ( s2, token (s1, 1, ":")),
10set ( minX, CMS (VAL s2) ),
11
12fortok ( sObjID , sToObjIDs , " " , (
13  set ( s1, token ( aval ( VAL (sObjID) , "Position" ) , 1 , " " )),
14  set ( s2, token (s1, 1, ":")),
15  set ( crtX, CMS (VAL s2) ),
16
17  cond ( crtX < minX ,
18         (
19           set (minX, crtX),
20           set (minXid, VAL (sObjID) )
21         ),
22     0
23    )
24  )       
25),
26
27aval ( minXid, "Position" )
28),
29"NONE"
30)
31)
Attachments: graph_expr_ab_02.abl (12.6k)

RE: Logical Operation Representation Between two or more Relations/Connecto
Answer
4/28/14 2:49 PM as a reply to Sabin Popescu.
Dear Sabin

Wow, that looks great, thanks a lot.

While importing the library, there was a small error (see error-message import).
Afterwards I added the the code to the relation class "OR" according to the relation class "AND" instead of the line "@INCLUDE ....", and it worked.
My next step is, to enhance the functionality with a third relation class "XOR" (in blue and the same shape as "OR" just without filling it). Depending my research results, maybe there are even more relation classes coming using the "_get_start_point_" and the "_get_end_point_" of each type. Therefore I'd like to adapte the GraphRep of class "Task".
I tried it with IF/ELSIF/ENDIF to get the ID of the relation class, to identify if it is a "OR" class or a "XOR" class - unfortunately without any success.
How can I access the relation-class-ID from the class "Task"? Do you have a hint how the code IF/ELSIF/ENDIF-code of the class "Task" should look like?

A small example of potential upcoming relation classes and additions like a default-OR are shown in the illustration.

Thanks a lot for your support.



Error-message import:
Dynamic library: Connector Graph Dynamic Library2
Check of the class attributes
Date:     28.04.2014, 18:15
=============================================
=============================================
Error in the attribute "GraphRep" of the class "OR":
[aleo-43]
@INCLUDE: "D:\\temp\\graphrep_OR.leo" could not be opened!
in "GraphRep" (OR)
Attachment

Attachments: MoreOperators.jpg (24.7k)

RE: Logical Operation Representation Between two or more Relations/Connecto
Answer
4/29/14 12:43 PM as a reply to Sebastian J. Baur.
I added that statement to allow me debugging a bit faster and I've forgotten to remove it. I have changed the library in the previous post, too.

If you want to implement the same functionality for several relation classes, I suggest you define a pair of attributes for each of these relation classes (i.e. _get_left_object_XOR_ and _get_right_object_XOR_) and in the GraphRep implement a module for each of the relation class.