-
Notifications
You must be signed in to change notification settings - Fork 46
ST6RI-886 Evaluation of functions from additional model libraries #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Created Java packages under corresponding to Kernel Function Library packages.
- Also added tests to ExpressionEvaluationTest.
Functions are evaluated using modeled return expressions (except for functions that are evaluated as model-level evaluable library functions).
|
@himi @hpdekoning |
- Also implemented DataFunctions::min and DataFunctions::max, used in the implementation of ControlFunctions::minimize and maximize. - Also removed old overrides of getInput and getOutput in ExpressionImpl.
| Type maxFunction = SysMLLibraryUtil.getLibraryType(expr, MIN_FUNCTION); | ||
| InvocationExpression maxInvocation = EvaluationUtil.createInvocationOf(maxFunction, result, exprValue.get(0)); | ||
| EList<Element> newResult = evaluator.evaluateInvocation(maxInvocation, target); | ||
| return newResult == null || newResult.size() != 1? null: newResult.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing you meant naming these minFunction, minInvocation. Looks like a copy/paste typo, does not change behavior & result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you are right. I've fixed it.
- maxFunction -> minFunction, maxInvocation -> minInvocaion
|
|
||
| // ControlFunctions | ||
| put(new DotFunction()); | ||
| put(new ConditionalFunction()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be named ConditionalIfFunction to show correspondence to KerML if function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function corresponds to what is called a "conditional expression" in KerML and is described as a "conditional test" function. So I think ConditionalFunction is an OK name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great. I could only do some rather random spot checks.
You may want to check that the copyright statement is updated for 2026 everywhere, but perhaps that is a global check just before release.
|
Thank you. I want to try these functions tonight. But please go ahead if you want to finish this PR. |
|
I could not find a written specification on these functions in KerML spec. Is the |
|
I could not make an example to check the difference of |
In general, many of the library functions are really not well specified right now. However, many of the sequence functions actually have complete definitions in The definition of So, The definition of So, it selects the values in The definition of And this is exactly how it is implement, by checking inclusion of each sequence in the other. The intent of One could possibly propose changes in how these functions are defined, but that would be a specification issue, not an implementation issue. |
There currently is no difference in the implementation of |
himi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seidewitz thank you for confirming it. To be honest, union() seems confusing to me because it is actually concat(). But I understand it is intended. I think we need a proper documentation on these. Also I think we need unique() for set semantics and we can implement it with collect and reduce but the complexity will be O^2.



This PR implements the (non-model-level) evaluation of all the functions from the following Kernel Function Library packages that had not been previously implemented:
CollectionFunctionsControlFunctionsSequenceFunctionsImplemented Functions
The following Kernel Functions Library functions are implemented in this PR.
CollectionFunctionsThere are no
LibraryFunctionimplementations of these functions, but they all have complete functional specifications in the library model, which evaluate correctly given the other updates in this PR (except for the'#'index functions, which already have model-level evaluation implementations).ControlFunctionsexistsforAllmaximizeminimizereducerejectselectOneDataFunctionsThese functions were implemented to support the implementation of
maximizeandminimize.maxminSequenceFunctionsexcludingAtexcludingheadincludesOnlyincludingAtincludingintersectionlastequalssamesubsequencetailunionRefactoring
The PR also includes some refactoring of the structure of packages related to library function implementations.
LibraryFunctionimplementations in the packageorg.omg.sysml.expressions.functionhave been re-organized into Java subpackages based on the Kernel Function Library package of the function being implemented.org.omg.sysml.expressions.function.baseorg.omg.sysml.expressions.function.boolorg.omg.sysml.expressions.function.controlorg.omg.sysml.expressions.function.dataLibraryFunctionimplementations in the packageorg.omg.sysml.execution.expressions.functionhave been similarly re-organized into subpackages.org.omg.sysml.execution.expressions.function.dataorg.omg.sysml.execution.expressions.function.numericalorg.omg.sysml.execution.expressions.function.sequenceorg.omg.sysml.execution.expressions.function.stringOther Changes
EvaluationUtil::expressionForwhen the argument is a list or a body expression.getInputandgetOutputinExpressionImplthat are no longer necessary.