I use Sequence Diagrams to show how flows of Use Case are implemented.
I would like lean on the Sequence diagram to map the possible scenarios to an Excel sheet.
I mean: according to the conditions in the sequence diagram flow I will have an ordered list of possible scenarios and output. Such as:
if condition 1, 2 and 4 are met -> then the output is A
if only 2 and 4 are met -> then the output is B
if only condition 1 is met -> then the output is C
and so on...
Is there a built-in feature that performs this or something similar?
Thoughts?
Related
My professor is having us create a series of functions relating to approximating pi and e based on continuing fractions. In order to set this up, he is having us create a function that takes an integer and maps that many odd numbers squared, starting from 1. For instance, here is the desired behavior:
oddSquares 6;;
val it : int list = [1.0; 9.0; 25.0; 49.0; 81.0; 121.0]
I can see that one mapping will likely be used to square all the values in the list, but I can't figure out a way to map the number to a list of numbers. I don't want to ask anybody to write code for me, but methodically, what am I trying to do when I'm assembling the base list?
It feels like the best method is to work backwards, starting from the base number of 6 terms. We then evaluate the 6th odd term (11, or 2x-1 practically), but then require some method of recursion to continue to evaluate smaller values of oddSquares. I also think this is against the spirit of trying to map the number into these values. Can someone give me some guidance as to the first translation from the number into the list form?
F# offers special neat syntax for creating lists of successive numbers:
let oneToSix = [1..6]
This is a special case of something called "list comprehension". They can be more complex than just successive numbers - they can include multiple generators, filters, projections, Cartesian products, etc. In particular, your whole task of generating first N odd numbers can be expressed as one list comprehension. However, since you explicitly asked not to write the code for you, I won't.
I have a problem trying to "decypher" a logical tree with Neo4js Cypher.
I have a logical tree of Operation to Leaves. I want to collect valid sets of Leaves.
I am currently trying to collect valid Sets of Leaves on a Valid Configuration Node. So I can later quickly path through that Configuration node.
Example
(1 AND 2) AND (3 AND 4)
Is easy to match (rule)-[AND*]->(leaf) return collect(leaf)
However
(1 XOR 2) AND (3 XOR 4)
Is a problem because whenever I collect 1,2,3,4 in a single variable, I cannot later properly get the cartesian product of the AND Operation. (13,14,23,24) would be valid.
In general I have a tree of variable depth (upto max about 3-4)
Operations are XOR, AND, Not AND, Not XOR
Is there a simple way in Cypher I am missing for navigating such trees?
Is trying to merge Valid Sets in a ValidConfiguration Node a good idea for fast Queries?
Later it should support a query of the form
(:Model)->(:ValidConf)->(:Leaf:Option)->(:Feature)
then return all models that have a certain Feature in a valid configuration.
Or multiple Features at a certain configuration price.
Do I need UDFs or ObjectGraphMapper to get this problem solved?
Are there any UDFs that work with such decision trees which I can use?
Any help would be highly appreciated.
Create Example
CREATE (r:Rule{id:123})-[:COMPOSITION]->
startOp:AndOperation:Operation:Operand)
CREATE (startOp)-[:AND]->(intermediateOp1:OrOperation:Operation:Operand)
CREATE (startOp)-[:AND]->(intermediateOp2:OrOperation:Operation:Operand)
CREATE (intermediateOp1)-[:XOR]->(o1:Option:Operand{id:321})
CREATE (intermediateOp1)-[:XOR]->(o2:Option:Operand{id:564})
CREATE (intermediateOp2)-[:XOR]->(o3:Option:Operand{id:876})
CREATE (intermediateOp2)-[:XOR]->(o4:Option:Operand{id:227})
CREATE (o1)-[:CONSISTS_OF]->(f1:Feature{text:"magicwand"})
....
This tree is symmetric but they usually aren't. I need to make o1 + o4 be valid and o1 + o2 to not be valid. The OR are to be understood as XOR.
I don't think Cypher is going to work for evaluating a boolean binary expression tree. To quote cybersam's answer to a related question:
This is because Cypher has no looping statements powerful enough to
iteratively calculate subresults (in the correct order) for trees of
arbitrary depth.
You're going to have to look for some additional system to do the evaluation.
If you can code Java, you should be able to do this by implementing your own custom procedure to evaluate a boolean expression tree in the correct order.
I'm parsing a stream with record fragments that are always sequential, but not always consecutive, e.g., in the example below line 1 and 3 are part of the same record and while line 1 will always come before line 3 it is possible to get an entirely unrelated line between them, in this case line 2, which parenthetically needs to be matched up with line 4.
1: [[aaaa
2: [[bbbb
3: aaaa]]
4: bbbb]]
If there is deterministic way to match the record fragments, could ANTLR handle this kind of fragmentation? If so, what would the grammar look like?
No, this is not possible (and I wonder if that is even desirable, given that you cannot match start and stop parts of intermingled input in an arbitrarily deep source nesting). Input is always processed as it comes from the input stream. You could of course fake the input by feeding in different parts of the source on certain conditions. But that would require to preprocess the input to a level that is almost the same as the following parsing stage.
Is there any difference between the following ways of expressing multiple necessary conditions in ontology (via Protege)
Each necessary condition expressed one by one inside the SubclassOf Section (for class A):
instrument some B
object some C
All of those stated at once (via the class expression editor)
instrument some B and object some C
Are 1 and 2 semantically the same?
Yes they are equivalent. The choice of which way to go is yours: which approach do you find more readable? That is the best choice.
Let's say in the example lower case is constant and upper case is variable.
I'd like to have programs that can "intelligently" do specified tasks like algebra, but teaching the program new methods should be easy using symbols understood by humans. For example if the program told these facts:
aX+bX=(a+b)X
if a=bX then X=a/b
Then it should be able to perform these operations:
2a+3a=5a
3x+3x=6x
3x=1 therefore x=1/3
4x+2x=1 -> 6x=1 therefore x= 1/6
I was trying to do similar things with Prolog as it can easily "understand" variables, but then I had too many complications, mainly because two describing a relationship both ways results in a crash. (not easy to sort out)
To summarise: I want to know if a program which can be taught algebra by using mathematic symbols only. I'd like to know if other people have tried this and how complicated it is expected to be. The purpose of this is to make programming easier (runtime is not so important)
It depends on what do you want machine to do and how intelligent it should be.
Your question is mostly about AI but not ML. AI deals with formalization of "human" tasks while ML (though being a subset of AI) is about building models from data.
Described program may be implemented like this:
Each fact form a pattern. Program given with an expression and some patterns can try to apply some of them to expression and see what happens. If you want your program to be able to, for example, solve quadratic equations given rule like ax² + bx + c = 0 → x = (-b ± sqrt(b²-4ac))/(2a) then it'd be designed as follows:
Somebody gives a set of rules. Rule consists of a pattern and an outcome (solution or equivalent form). Think about the pattern as kind of a regular expression.
Then the program is asked to show some intelligence and prove its knowledge via doing something with a given expression. Here comes the major part:
you build a graph of expressions by applying possible rules (if a pattern is applicable to an expression you add new vertex with the corresponding outcome).
Then you run some path-search algorithm (A*, for example) to find sequence of transformations leading to the form like x = ...
I think this is an interesting question, although it off topic in SO (tool recommendation)
But nevertheless, because it captured my imagination, I wrote couple of function using R that can solve stuff like that quite easily
First, you'll have to install R, after words you'll need to download package called stringr
So in R console run
install.packages("stringr")
library(stringr)
And then you can define the following functions that I wrote
FirstFunc <- function(temp){
paste0(eval(parse(text = gsub("[A-Z]", "", temp))), unique(str_extract_all(temp, "[A-Z]")[[1]]))
}
SecondFunc <- function(temp){
eval(parse(text = strsplit(temp, "=")[[1]][2])) / eval(parse(text = gsub("[[:alpha:]]", "", strsplit(temp, "=")[[1]][1])))
}
Now, the first function will solve equations like
aX+bX=(a+b)X
While the second will solve equations like
4x+2x=1
For example
FirstFunc("3X+6X-2X-3X")
will return
"4X"
Now this functions is pretty primitive (mostly for the propose of illustration) and will solve equation that contain only one variable type, something like FirstFunc("3X-2X-2Y") won't give the correct result (but the function could be easily modified)
The second function will solve stuff like
SecondFunc("4x-2x=1")
will return
0.5
or
SecondFunc("4x+2x*3x=1")
will return
0.1
Note that this function also works only for one unknown variable (x) but could be easily modified too