How to draw a "list of" relation between 2 objects? - oop

I am drawing a schema to represent the relation among my objects... For instance, the following schema shows that an object A is a pair of an object B and an object C.
Now I want to represent an object D, which is a list of A, I just don't know how to draw the arrow between A and D...
Could anyone help?

Since it is a 1 to N relation, write a line from D to A with an aggregation or composition symbol (open/closed diamond symbol).
Write at the A side * (meaning 0..n) or 1..n if there needs to be at least one element in the list.
See http://www.ibm.com/developerworks/rational/library/content/RationalEdge/nov03/t_modelinguml_db.pdf for an example, search for the Flight and Plane class diagram about halfway the document.

Actually your model is not correct. If you say that A is a pair of B and C then the aggregation should start at A and finishes at B and C. The drawing you show says that B contains A and C contains A.
As for showing multiplicity, add [0..*] to the end closer to the class that has multiple instances. If D has a list of A, add an aggregation/composition link from D to A and set the multiplicity as said above. But note that this does not specify that D contains a list of A, only that D has many (0 or more) instances of A. If you want to specify that the reference is implemented as a list, you can add a {list} constraint on top of the link or don't use the link and add an attribute to D using alist:A[0..*] {list}.
See this site for more information

Related

In Cypher, nodes are queried if they have edges type A. How to display other edge type they have?

In my graph the edges have two types: A and B. I want to query all the nodes having edges type A. Within those nodes, if they have edges B then they should be displayed as well. So for example, if we have (node1)-[A]-(node2), (node3)-[A]-(node4), and if there are B edges between those 4 nodes, then only them should be displayed, not all other Bs.
I try both:
match (n)-[r:A]-(m)
match (n)-[s:B]-(m)
return n,r,s,m
and
match (n)-[r:A]-(m),
(n)-[s:B]-(m)
return n,r,s,m
But none of them works.
I don't use Neo4j Browser, so the edges need to be explicitly queried. The manual for MATCH doesn't help.
Try this, since you seem to be looking for triangles
MATCH (n)-[r1:A]-(m)-[r2:A]-(k)
OPTIONAL MATCH (k)-[r3:B]-(n)

(GAMS) how to use subsets when loading gdx-file?

I don't think it's a complex problem, but I searched for a long time and didn't find a solution :/
I want to load data from a gdx-file and use set-items and subsets as identifiers (in the example below: different value for d and e and same value for all local modes).
The gdx-file is written correctly, but the parameter includes only the value for set-items. How can I get GAMS to assign the value to all items of the according subset?
I hope, the problem is clear and there is an easy solution. Thanks in advance!
Code (simplified):
sets
mode /a, b, c, d, e/
local_mode(mode) /a, b, c/
;
parameter par_consumption_per_km(year, mode);
$LOAD par_consumption_per_km;

Xcode - Objective C- How to make a dictionary of persons?

I can't get my head around my objective C code. I want to make a dictionary with persons that I save in the app. The dictionary is in first empty and then we need to add it from the textfields I created (see image)textfieldWelkom
For every person that is added, we have to show it in a list (see image) lijstTabblad in the tableviewcontroller. (The list has to be the whole name of the person)
I don't get the idea of how to making a dictionary with multiple persons with every person his own ELEMENTS. And how that I can get the elements again out of de dictionary for making the list etc..
(not like the 1 example but multiple values with that person)
I would be sow thankfull if you could help me!
Greetings,
Kevin
You needs to first create single person dictionary dictionary keys
are like name sirname age and put values for respected keys
add this dictionary in one array or another dictionary(array/dictionary must be mutable array)

Esper - pattern detection

I have a question for the community regarding pattern detection with Esper.
Suppose you want to detect the following pattern among a collection of data : A B C
However, it is possible, that in the actual data, you might have: A,B,D,E,C. My goal is to design a rule that could still detect A B C by keeping A B in memory, and fire the alert as soon as it sees C.
Is it possible to do this? With the standard select * from pattern(a = event -> b= event -> c=event), It only outputs when the three are in sequence in the data, but not when there are other useless data between them
With the standard "select * from pattern [a=A -> b=B]" there can be any events between A and B. Your statement is therefore wrong. I think you are confused about how to remove useless data. Use a filter such as "a=event(...not useless...) -> b=event(...not useless...)". Within the parens place the filter expressions that distinguish between useless and not useless events, i.e. "a=event(amount>10)" or whatever.

Why does fold have the following type in Scala?

I was looking at the way fold is defined for immutable.Set:
def fold [A1 >: A] (z: A1)(op: (A1, A1) ⇒ A1): A1
yet foldLeft is defined as:
def foldLeft [B] (z: B)(op: (B, A) ⇒ B): B
This looks weird for me, at least at first glance, since I was expecting fold to be able to change the type of the collection it returned, much like foldLeft does.
I imagine this is because foldLeft and foldRight guarantee something about the order in which the elements are folded. What is the guarantee given by fold?
When you're applying foldLeft then your start value is combined with the first list element. The result is combined with the second list element. This result with the third and so on. Eventually, the list has collapsed to one element of the same type than your start value. Therefore you just need some type that can be combined by your function with a list element.
For foldRight the same applies but in reverse order.
fold does not guarantee the order in with the combinations are done. And it does not guarantee that it starts off at only one position. The folds might happen in parallel. Because you could have the parallelism it is required that any 2 list elements or return values can be combined – this adds a constraint to the types.
Regarding your comment that you have to see a case were order has an effect: Assume you're using folds to concatenate a list of characters and you want to have a text as result. If your input is A, B, C, you probably would like to preserve the order to receive ABC instead of ACB (for example).
On the other hand if you're, say, just adding up numbers, the order does not matter. Summing up 1, 2, 3 gives 6 independent of the additions' order. In such cases using fold instead of foldLeft or foldRight could lead to faster execution.
It seems that FoldLeft must return B. The method takes a B arg - this is an accumulator. Values of A are used to "add more to" a B. The final accumulated value is returned. I think FoldLeft and FoldRight are the same in this respect.