sysmlpy 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. sysmlpy/__init__.py +226 -0
  2. sysmlpy/__main__.py +75 -0
  3. sysmlpy/antlr/README.md +146 -0
  4. sysmlpy/antlr/SysMLv2Lexer.interp +695 -0
  5. sysmlpy/antlr/SysMLv2Lexer.py +1123 -0
  6. sysmlpy/antlr/SysMLv2Lexer.tokens +444 -0
  7. sysmlpy/antlr/SysMLv2Parser.interp +960 -0
  8. sysmlpy/antlr/SysMLv2Parser.py +40750 -0
  9. sysmlpy/antlr/SysMLv2Parser.tokens +444 -0
  10. sysmlpy/antlr/SysMLv2ParserListener.py +4485 -0
  11. sysmlpy/antlr/SysMLv2ParserVisitor.py +2498 -0
  12. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  13. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  14. sysmlpy/antlr/src/sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  15. sysmlpy/antlr_parser.py +185 -0
  16. sysmlpy/antlr_visitor.py +10864 -0
  17. sysmlpy/definition.py +1115 -0
  18. sysmlpy/examples/attribute_values.py +161 -0
  19. sysmlpy/examples/part_attributes.py +139 -0
  20. sysmlpy/examples/tuples_sequences.py +231 -0
  21. sysmlpy/formatting.py +47 -0
  22. sysmlpy/grammar/antlr4/README.md +30 -0
  23. sysmlpy/grammar/antlr4/SysMLv2Lexer.g4 +931 -0
  24. sysmlpy/grammar/antlr4/SysMLv2Lexer.interp +695 -0
  25. sysmlpy/grammar/antlr4/SysMLv2Lexer.py +1123 -0
  26. sysmlpy/grammar/antlr4/SysMLv2Lexer.tokens +444 -0
  27. sysmlpy/grammar/antlr4/SysMLv2Parser.g4 +2432 -0
  28. sysmlpy/grammar/antlr4/SysMLv2Parser.interp +960 -0
  29. sysmlpy/grammar/antlr4/SysMLv2Parser.py +40750 -0
  30. sysmlpy/grammar/antlr4/SysMLv2Parser.tokens +444 -0
  31. sysmlpy/grammar/antlr4/SysMLv2ParserListener.py +4485 -0
  32. sysmlpy/grammar/antlr4/SysMLv2ParserVisitor.py +2498 -0
  33. sysmlpy/grammar/antlr4/desc.xml +7 -0
  34. sysmlpy/grammar/antlr4/examples/camera.sysml +14 -0
  35. sysmlpy/grammar/antlr4/examples/toaster-system.sysml +193 -0
  36. sysmlpy/grammar/antlr4/examples/vehicle-model.sysml +118 -0
  37. sysmlpy/grammar/antlr4/pom.xml +59 -0
  38. sysmlpy/grammar/classes.py +8610 -0
  39. sysmlpy/library/LICENSE +165 -0
  40. sysmlpy/library/README.md +52 -0
  41. sysmlpy/library/__init__.py +0 -0
  42. sysmlpy/library/domain/Analysis/AnalysisTooling.sysml +34 -0
  43. sysmlpy/library/domain/Analysis/SampledFunctions.sysml +119 -0
  44. sysmlpy/library/domain/Analysis/StateSpaceRepresentation.sysml +143 -0
  45. sysmlpy/library/domain/Analysis/TradeStudies.sysml +171 -0
  46. sysmlpy/library/domain/Cause and Effect/CausationConnections.sysml +83 -0
  47. sysmlpy/library/domain/Cause and Effect/CauseAndEffect.sysml +81 -0
  48. sysmlpy/library/domain/Geometry/ShapeItems.sysml +899 -0
  49. sysmlpy/library/domain/Geometry/SpatialItems.sysml +168 -0
  50. sysmlpy/library/domain/Metadata/ImageMetadata.sysml +78 -0
  51. sysmlpy/library/domain/Metadata/ModelingMetadata.sysml +143 -0
  52. sysmlpy/library/domain/Metadata/ParametersOfInterestMetadata.sysml +39 -0
  53. sysmlpy/library/domain/Metadata/RiskMetadata.sysml +100 -0
  54. sysmlpy/library/domain/Quantities and Units/ISQ.sysml +42 -0
  55. sysmlpy/library/domain/Quantities and Units/ISQAcoustics.sysml +439 -0
  56. sysmlpy/library/domain/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
  57. sysmlpy/library/domain/Quantities and Units/ISQBase.sysml +206 -0
  58. sysmlpy/library/domain/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
  59. sysmlpy/library/domain/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
  60. sysmlpy/library/domain/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
  61. sysmlpy/library/domain/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
  62. sysmlpy/library/domain/Quantities and Units/ISQInformation.sysml +958 -0
  63. sysmlpy/library/domain/Quantities and Units/ISQLight.sysml +1537 -0
  64. sysmlpy/library/domain/Quantities and Units/ISQMechanics.sysml +1564 -0
  65. sysmlpy/library/domain/Quantities and Units/ISQSpaceTime.sysml +1169 -0
  66. sysmlpy/library/domain/Quantities and Units/ISQThermodynamics.sysml +1256 -0
  67. sysmlpy/library/domain/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
  68. sysmlpy/library/domain/Quantities and Units/MeasurementReferences.sysml +526 -0
  69. sysmlpy/library/domain/Quantities and Units/Quantities.sysml +107 -0
  70. sysmlpy/library/domain/Quantities and Units/QuantityCalculations.sysml +70 -0
  71. sysmlpy/library/domain/Quantities and Units/SI.sysml +378 -0
  72. sysmlpy/library/domain/Quantities and Units/SIPrefixes.sysml +48 -0
  73. sysmlpy/library/domain/Quantities and Units/TensorCalculations.sysml +50 -0
  74. sysmlpy/library/domain/Quantities and Units/Time.sysml +274 -0
  75. sysmlpy/library/domain/Quantities and Units/USCustomaryUnits.sysml +260 -0
  76. sysmlpy/library/domain/Quantities and Units/VectorCalculations.sysml +62 -0
  77. sysmlpy/library/domain/Requirement Derivation/DerivationConnections.sysml +63 -0
  78. sysmlpy/library/domain/Requirement Derivation/RequirementDerivation.sysml +39 -0
  79. sysmlpy/library/kernel/Base.kerml +95 -0
  80. sysmlpy/library/kernel/BaseFunctions.kerml +80 -0
  81. sysmlpy/library/kernel/BooleanFunctions.kerml +22 -0
  82. sysmlpy/library/kernel/Clocks.kerml +156 -0
  83. sysmlpy/library/kernel/CollectionFunctions.kerml +68 -0
  84. sysmlpy/library/kernel/Collections.kerml +147 -0
  85. sysmlpy/library/kernel/ComplexFunctions.kerml +47 -0
  86. sysmlpy/library/kernel/ControlFunctions.kerml +117 -0
  87. sysmlpy/library/kernel/ControlPerformances.kerml +135 -0
  88. sysmlpy/library/kernel/DataFunctions.kerml +43 -0
  89. sysmlpy/library/kernel/FeatureReferencingPerformances.kerml +190 -0
  90. sysmlpy/library/kernel/IntegerFunctions.kerml +43 -0
  91. sysmlpy/library/kernel/KerML.kerml +483 -0
  92. sysmlpy/library/kernel/Links.kerml +67 -0
  93. sysmlpy/library/kernel/Metaobjects.kerml +58 -0
  94. sysmlpy/library/kernel/NaturalFunctions.kerml +27 -0
  95. sysmlpy/library/kernel/NumericalFunctions.kerml +43 -0
  96. sysmlpy/library/kernel/Objects.kerml +212 -0
  97. sysmlpy/library/kernel/Observation.kerml +161 -0
  98. sysmlpy/library/kernel/OccurrenceFunctions.kerml +154 -0
  99. sysmlpy/library/kernel/Occurrences.kerml +992 -0
  100. sysmlpy/library/kernel/Performances.kerml +293 -0
  101. sysmlpy/library/kernel/RationalFunctions.kerml +49 -0
  102. sysmlpy/library/kernel/RealFunctions.kerml +56 -0
  103. sysmlpy/library/kernel/ScalarFunctions.kerml +33 -0
  104. sysmlpy/library/kernel/ScalarValues.kerml +23 -0
  105. sysmlpy/library/kernel/SequenceFunctions.kerml +111 -0
  106. sysmlpy/library/kernel/SpatialFrames.kerml +197 -0
  107. sysmlpy/library/kernel/StatePerformances.kerml +145 -0
  108. sysmlpy/library/kernel/StringFunctions.kerml +25 -0
  109. sysmlpy/library/kernel/Transfers.kerml +281 -0
  110. sysmlpy/library/kernel/TransitionPerformances.kerml +66 -0
  111. sysmlpy/library/kernel/TrigFunctions.kerml +35 -0
  112. sysmlpy/library/kernel/Triggers.kerml +188 -0
  113. sysmlpy/library/kernel/VectorFunctions.kerml +273 -0
  114. sysmlpy/library/kernel/VectorValues.kerml +64 -0
  115. sysmlpy/library/systems/Actions.sysml +552 -0
  116. sysmlpy/library/systems/Allocations.sysml +29 -0
  117. sysmlpy/library/systems/AnalysisCases.sysml +38 -0
  118. sysmlpy/library/systems/Attributes.sysml +25 -0
  119. sysmlpy/library/systems/Calculations.sysml +37 -0
  120. sysmlpy/library/systems/Cases.sysml +71 -0
  121. sysmlpy/library/systems/Connections.sysml +60 -0
  122. sysmlpy/library/systems/Constraints.sysml +44 -0
  123. sysmlpy/library/systems/Flows.sysml +126 -0
  124. sysmlpy/library/systems/Interfaces.sysml +89 -0
  125. sysmlpy/library/systems/Items.sysml +153 -0
  126. sysmlpy/library/systems/Metadata.sysml +32 -0
  127. sysmlpy/library/systems/Parts.sysml +81 -0
  128. sysmlpy/library/systems/Ports.sysml +54 -0
  129. sysmlpy/library/systems/Requirements.sysml +194 -0
  130. sysmlpy/library/systems/StandardViewDefinitions.sysml +123 -0
  131. sysmlpy/library/systems/States.sysml +103 -0
  132. sysmlpy/library/systems/SysML.sysml +539 -0
  133. sysmlpy/library/systems/UseCases.sysml +57 -0
  134. sysmlpy/library/systems/VerificationCases.sysml +103 -0
  135. sysmlpy/library/systems/Views.sysml +164 -0
  136. sysmlpy/navigate.py +272 -0
  137. sysmlpy/store.py +547 -0
  138. sysmlpy/usage.py +2978 -0
  139. sysmlpy-0.1.0.dist-info/METADATA +230 -0
  140. sysmlpy-0.1.0.dist-info/RECORD +143 -0
  141. sysmlpy-0.1.0.dist-info/WHEEL +4 -0
  142. sysmlpy-0.1.0.dist-info/entry_points.txt +3 -0
  143. sysmlpy-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,52 @@
1
+ # SysML v2 Standard Library
2
+
3
+ This directory contains the normative SysML v2 and KerML standard library files,
4
+ copied verbatim from the **SysML-v2-Pilot-Implementation-2026-03** release.
5
+
6
+ ## Layout
7
+
8
+ | Directory | Contents |
9
+ |-----------|----------|
10
+ | `kernel/` | 36 KerML kernel library files (`.kerml`), flattened from `Kernel Libraries/*/` |
11
+ | `systems/` | 21 SysML systems library files (`.sysml`), from `Systems Library/` |
12
+ | `domain/` | 37 SysML domain library files (`.sysml`), organized by subdirectory |
13
+
14
+ The `kernel/` and `systems/` directories are intentionally flat (no subdirectory
15
+ nesting), matching the layout used by the `org.omg.sysml.xpect.tests` project in
16
+ the Pilot Implementation.
17
+
18
+ ## Domain Library Subdirectories
19
+
20
+ ```
21
+ domain/
22
+ Analysis/ AnalysisTooling, SampledFunctions, StateSpaceRepresentation, TradeStudies
23
+ Cause and Effect/ CausationConnections, CauseAndEffect
24
+ Geometry/ ShapeItems, SpatialItems
25
+ Metadata/ ImageMetadata, ModelingMetadata, ParametersOfInterestMetadata, RiskMetadata
26
+ Quantities and Units/ ISQ, ISQBase, SI, SIPrefixes, ... (22 files)
27
+ Requirement Derivation/ DerivationConnections, RequirementDerivation
28
+ ```
29
+
30
+ ## Purpose
31
+
32
+ These files are bundled with sysmlpy for two reasons:
33
+
34
+ 1. **Conformance tests** — the test suite under `tests/sysmlv2/` parses files that
35
+ import from this library (e.g., `private import SI::kg;`). Having the library
36
+ co-located with the package makes the test suite self-contained.
37
+
38
+ 2. **Future import resolution** — once sysmlpy implements `import` / `AliasMember`
39
+ support, it can locate these files via:
40
+ ```python
41
+ import importlib.resources
42
+ lib = importlib.resources.files("sysmlpy") / "library"
43
+ ```
44
+
45
+ ## Source and License
46
+
47
+ **Source:** [SysML-v2-Pilot-Implementation](https://github.com/Systems-Modeling/SysML-v2-Pilot-Implementation),
48
+ tag `2026-03`.
49
+
50
+ **License:** GNU Lesser General Public License v3.0 (see `LICENSE`). The library
51
+ files are copyright © Object Management Group (OMG). sysmlpy itself is MIT-licensed;
52
+ this bundled library content is separately covered by LGPL-3.0.
File without changes
@@ -0,0 +1,34 @@
1
+ standard library package AnalysisTooling {
2
+ doc
3
+ /*
4
+ * This package contains definitions for metadata annotations related
5
+ * to analysis tool integration.
6
+ */
7
+
8
+ private import ScalarValues::*;
9
+
10
+ metadata def ToolExecution {
11
+ doc
12
+ /*
13
+ * ToolExecution metadata identifies an external analysis tool to be
14
+ * used to implement the annotated action.
15
+ */
16
+
17
+ attribute toolName : String;
18
+ attribute uri : String;
19
+ }
20
+
21
+ metadata def ToolVariable {
22
+ doc
23
+ /*
24
+ * ToolVariable metadata is used in the context of an action that has
25
+ * been annotated with ToolExecution metadata. It is used to annotate
26
+ * a parameter or other feature of the action with the name of the
27
+ * variable in the tool that is to correspond to the annotated
28
+ * feature.
29
+ */
30
+
31
+ attribute name : String;
32
+ }
33
+
34
+ }
@@ -0,0 +1,119 @@
1
+ standard library package SampledFunctions {
2
+ doc
3
+ /*
4
+ * This package provides a library model of discretely sampled mathematical functions.
5
+ */
6
+
7
+ private import Base::Anything;
8
+ private import ScalarValues::Positive;
9
+ private import Collections::KeyValuePair;
10
+ private import Collections::OrderedMap;
11
+ private import SequenceFunctions::size;
12
+ private import ControlFunctions::forAll;
13
+ private import ControlFunctions::collect;
14
+ private import ControlFunctions::select;
15
+
16
+ attribute def SamplePair :> KeyValuePair {
17
+ doc
18
+ /*
19
+ * SamplePair is a key-value pair of a domain-value and a range-value, used as a sample element in SampledFunction.
20
+ */
21
+
22
+ attribute domainValue :>> key;
23
+ attribute rangeValue :>> val;
24
+ }
25
+
26
+ attribute def SampledFunction :> OrderedMap {
27
+ doc
28
+ /*
29
+ * SampledFunction is a variable-size, ordered collection of 'SamplePair' elements that represents a generic, discretely sampled,
30
+ * uni-variate or multi-variate mathematical function. The function must be montonic, either strictly increasing or strictly
31
+ * decreasing.
32
+ *
33
+ * It maps discrete domain values to discrete range values.
34
+ * The domain of the function is represented by the sequence of 'domainValue' of each 'SamplePair' in 'samples', and
35
+ * the range of the function is represented by the sequence of 'rangeValue' of each 'SamplePair' in 'samples'.
36
+ */
37
+
38
+ attribute samples: SamplePair[0..*] ordered :>> elements;
39
+
40
+ assert constraint {
41
+ // Note: Assumes the functions '<' and '>' are defined for the domain type.
42
+ (1..size(samples)-1)->forAll { in i; (samples.domainValue#(i) < samples.domainValue#(i+1)) } or // Strictly increasing
43
+ (1..size(samples)-1)->forAll { in i; (samples.domainValue#(i) > samples.domainValue#(i+1)) } // Strictly decreasing
44
+ }
45
+ }
46
+
47
+ calc def Domain {
48
+ doc
49
+ /*
50
+ * Domain returns the sequence of the domainValues of all samples in a SampledFunction.
51
+ */
52
+
53
+ in fn : SampledFunction;
54
+ return : Anything[0..*] = fn.samples.domainValue;
55
+ }
56
+
57
+ calc def Range {
58
+ doc
59
+ /*
60
+ * Range returns the sequence of the rangeValues of all samples in a SampledFunction.
61
+ */
62
+
63
+ in fn : SampledFunction;
64
+ return : Anything[0..*] = fn.samples.rangeValue;
65
+ }
66
+
67
+ calc def Sample {
68
+ doc
69
+ /*
70
+ * Sample returns a SampledFunction that samples a given calculation over a sequence of domainValues.
71
+ */
72
+
73
+ in calc calculation { in x; }
74
+ in attribute domainValues [0..*];
75
+ return sampling = new SampledFunction (
76
+ samples = domainValues->collect { in x; new SamplePair(x, calculation(x)) }
77
+ );
78
+ }
79
+
80
+ calc def Interpolate {
81
+ doc
82
+ /*
83
+ * An Interpolate calculation returns an interpolated range value from a given SampledFunction for a given domain value.
84
+ * If the input domain value is outside the bounds of the domainValues of the SampleFunction, null is returned.
85
+ */
86
+
87
+ in attribute fn : SampledFunction;
88
+ in attribute value;
89
+ return attribute result;
90
+ }
91
+
92
+ calc interpolateLinear : Interpolate {
93
+ doc
94
+ /*
95
+ * interpolateLinear is an Interpolate calculation assuming a linear functional form between SamplePairs.
96
+ */
97
+
98
+ in attribute fn : SampledFunction;
99
+ in attribute value;
100
+
101
+ private attribute domainValues = Domain(fn);
102
+ private attribute index : Positive[0..1] =
103
+ (1..size(domainValues))->select { in i : Positive; domainValues#(i) <= value }#(1);
104
+
105
+ private calc def Linear {
106
+ in attribute lowerSample : SamplePair;
107
+ in attribute upperSample : SamplePair;
108
+ in attribute value;
109
+ private attribute f = (value - lowerSample.domainValue) / (lowerSample.domainValue - upperSample.domainValue);
110
+ return result = upperSample.rangeValue + f * (lowerSample.rangeValue - upperSample.rangeValue);
111
+ }
112
+
113
+ return result [0..1] =
114
+ if index == null or index == size(domainValues)? null
115
+ else if domainValues#(index) < domainValues#(index+1)? Linear(fn.samples#(index), fn.samples#(index+1), value)
116
+ else Linear(fn.samples#(index+1), fn.samples#(index), value);
117
+ }
118
+
119
+ }
@@ -0,0 +1,143 @@
1
+ standard library package StateSpaceRepresentation {
2
+ doc
3
+ /*
4
+ * This package provides a model of the foundational state-space system representation,
5
+ * commonly used in control systems.
6
+ */
7
+
8
+ private import ISQ::DurationValue;
9
+ private import Quantities::VectorQuantityValue;
10
+ private import VectorCalculations::*;
11
+
12
+ abstract attribute def StateSpace :> VectorQuantityValue;
13
+ abstract attribute def Input :> VectorQuantityValue;
14
+ abstract attribute def Output :> VectorQuantityValue;
15
+
16
+ abstract calc def GetNextState {
17
+ in input: Input;
18
+ in stateSpace: StateSpace;
19
+ in timeStep: DurationValue;
20
+ return : StateSpace;
21
+ }
22
+ abstract calc def GetOutput {
23
+ in input: Input;
24
+ in stateSpace: StateSpace;
25
+ return : Output;
26
+ }
27
+
28
+ abstract action def StateSpaceEventDef {
29
+ doc
30
+ /*
31
+ * Events to be received.
32
+ */
33
+ }
34
+ action def ZeroCrossingEventDef :> StateSpaceEventDef;
35
+
36
+ item def StateSpaceItem {
37
+ doc
38
+ /*
39
+ * Item for SSR connection
40
+ */
41
+ }
42
+
43
+ abstract action def StateSpaceDynamics {
44
+ doc
45
+ /*
46
+ * StateSpaceDynamics is the simplest form of State Space Representation,
47
+ * and nextState directly computes the stateSpace of the next timestep.
48
+ */
49
+
50
+ in attribute input: Input;
51
+
52
+ abstract calc getNextState: GetNextState;
53
+ abstract calc getOutput: GetOutput;
54
+ attribute stateSpace: StateSpace;
55
+
56
+ out attribute output: Output = getOutput(input, stateSpace);
57
+ }
58
+
59
+ abstract attribute def StateDerivative :> VectorQuantityValue {
60
+ doc
61
+ /*
62
+ * The definition of the time derivative of StateSpace, which means dx/dt, where x is StateSpace
63
+ */
64
+
65
+ ref stateSpace: StateSpace;
66
+ constraint { stateSpace.order == order }
67
+ }
68
+
69
+ abstract calc def GetDerivative {
70
+ doc
71
+ /*
72
+ * Computes the time derivative of stateSpace, which corresponds dx/dt = f(u, x), where u is input and x is stateSpace.
73
+ */
74
+
75
+ in input: Input;
76
+ in stateSpace: StateSpace;
77
+ return : StateDerivative;
78
+ }
79
+
80
+ abstract calc def Integrate {
81
+ doc
82
+ /*
83
+ * Integrates stateSpace to compute the next stateSpace, which corresponds to x + int dx/dt dt.
84
+ * Its actual implementation should be given by a solver.
85
+ */
86
+
87
+ in getDerivative: GetDerivative;
88
+ in input: Input;
89
+ in initialState: StateSpace;
90
+ in timeInterval: DurationValue;
91
+ return result: StateSpace;
92
+ }
93
+
94
+ abstract action def ContinuousStateSpaceDynamics :> StateSpaceDynamics {
95
+ doc
96
+ /*
97
+ * ContinuousStateSpaceDynamics represents continuous behavior.
98
+ * derivative needs to return a time derivative of stateSpace, i.e. dx/dt.
99
+ */
100
+
101
+ abstract calc getDerivative: GetDerivative;
102
+ calc :>> getNextState: GetNextState {
103
+ /* We compute nextState by Integrate defined above by giving derivative calc. */
104
+ calc integrate: Integrate {
105
+ in getDerivative = ContinuousStateSpaceDynamics::getDerivative;
106
+ in input = GetNextState::input;
107
+ in initialState = GetNextState::stateSpace;
108
+ in timeInterval = GetNextState::timeStep;
109
+ }
110
+ return result = integrate.result;
111
+ }
112
+
113
+ event occurrence zeroCrossingEvents[0..*] : ZeroCrossingEventDef {
114
+ /* ContinuousStateSpaceDynamics may cause zero crossings anomaly. */
115
+ }
116
+ }
117
+
118
+ abstract calc def GetDifference {
119
+ doc
120
+ /*
121
+ * Computes difference of stateSpace by one timestep, that is x(k+1) - x(k),
122
+ * where k is the timestep number.
123
+ */
124
+
125
+ in input: Input;
126
+ in stateSpace: StateSpace;
127
+ return : StateSpace;
128
+ }
129
+
130
+ abstract action def DiscreteStateSpaceDynamics :> StateSpaceDynamics {
131
+ doc
132
+ /*
133
+ * DiscreteStateSpaceDynamics represents discrete behavior.
134
+ * differences needs to return difference of the stateSpace for each timestep.
135
+ */
136
+
137
+ abstract calc getDifference: GetDifference;
138
+ calc :>> getNextState: GetNextState {
139
+ attribute diff: StateSpace = getDifference(input, stateSpace);
140
+ return result = stateSpace + diff;
141
+ }
142
+ }
143
+ }
@@ -0,0 +1,171 @@
1
+ standard library package TradeStudies {
2
+ doc
3
+ /*
4
+ * This package provides a simple framework for defining trade-off study analysis cases.
5
+ */
6
+
7
+ private import Base::Anything;
8
+ private import ScalarValues::*;
9
+ private import ScalarFunctions::*;
10
+ private import ControlFunctions::*;
11
+
12
+ abstract calc def EvaluationFunction {
13
+ doc
14
+ /*
15
+ * An EvaluationFunction is a calculation that evaluates a TradeStudy alternative,
16
+ * producing a ScalarValue that can be comparted with the evaluation of other
17
+ * alternatives.
18
+ */
19
+
20
+ in ref alternative : Anything {
21
+ doc
22
+ /*
23
+ * The alternative to be evaluated.
24
+ */
25
+ }
26
+
27
+ return attribute result : ScalarValue[1] {
28
+ doc
29
+ /*
30
+ * A ScalarValue representing the evaluation of the given alternative.
31
+ */
32
+ }
33
+ }
34
+
35
+ abstract requirement def TradeStudyObjective {
36
+ doc
37
+ /*
38
+ * A TradeStudyObjective is the base definition for the objective of a TradeStudy.
39
+ * The requirement is to choose from a given set of alternatives the selectedAlternative
40
+ * for that has the best evaluation according to a given EvaluationFunction. What
41
+ * value is considered "best" is not defined in the abstract base definition but must be
42
+ * computed in any concrete specialization.
43
+ */
44
+
45
+ subject selectedAlternative : Anything {
46
+ doc
47
+ /*
48
+ * The alternative that should be selected, as evaluated using the given
49
+ * ObjectiveFunction.
50
+ */
51
+ }
52
+
53
+ in ref alternatives : Anything[1..*] {
54
+ doc
55
+ /*
56
+ * The alternatives being considered in the TradeStudy for which this TradeStudyObjective
57
+ * is the objective.
58
+ */
59
+ }
60
+
61
+ in calc eval : EvaluationFunction {
62
+ doc
63
+ /*
64
+ * The EvaluationFunction to be used in evaluating the given alternatives.
65
+ */
66
+ }
67
+
68
+ attribute best : ScalarValue {
69
+ doc
70
+ /*
71
+ * Out of the evaluation results of all the given alternatives, the one that is considered
72
+ * "best", in the sense that it is the value the selectedAlternative should have. This
73
+ * value must be computed in any concrete specialization of TradeStudyObjective.
74
+ */
75
+ }
76
+
77
+ require constraint { eval(selectedAlternative) == best }
78
+ }
79
+
80
+ requirement def MinimizeObjective :> TradeStudyObjective {
81
+ doc
82
+ /*
83
+ * A MinimizeObjective is a TradeStudyObjective that requires that the
84
+ * selectedAlternative have the minimum ObjectiveFunction value of all the
85
+ * given alternatives.
86
+ */
87
+
88
+ attribute :>> best = alternatives->minimize {
89
+ doc
90
+ /*
91
+ * For a MinimizeObjective, the best value is the minimum one.
92
+ */
93
+
94
+ in x; eval(x)
95
+ };
96
+ }
97
+
98
+ requirement def MaximizeObjective :> TradeStudyObjective {
99
+ doc
100
+ /*
101
+ * A MaximizeObjective is a TradeStudyObjective that requires that the
102
+ * selectedAlternative have the maximum ObjectiveFunction value of all the
103
+ * given alternatives.
104
+ */
105
+
106
+ attribute :>> best = alternatives->maximize {
107
+ doc
108
+ /*
109
+ * For a MinimizeObjective, the best value is the maximum one.
110
+ */
111
+
112
+ in x; eval(x)
113
+ };
114
+ }
115
+
116
+ abstract analysis def TradeStudy {
117
+ doc
118
+ /*
119
+ * A TradeStudy is an analysis case whose subject is a set of alternatives
120
+ * (at least one) and whose result is a selection of one of those alternatives.
121
+ * The alternatives are evaluated based on a given ObjectiveFunction and the
122
+ * selection is made such that it satisfies the objective of the TradeStudy
123
+ * (which must be a TradeStudyObjective).
124
+ */
125
+
126
+ subject studyAlternatives : Anything[1..*] {
127
+ doc
128
+ /*
129
+ * The set of alternatives being considered in this TradeStudy.
130
+ *
131
+ * In a TradeStudy usage, bind this feature to the actual collection of
132
+ * alternatives to be considered.
133
+ */
134
+ }
135
+
136
+ abstract calc evaluationFunction : EvaluationFunction {
137
+ doc
138
+ /*
139
+ * The EvaluationFunction to be used to evaluate the alternatives.
140
+ *
141
+ * In a TradeStudy usage, redefine this feature to provide the desired
142
+ * calculation (or bind it to a calculation usage that does so).
143
+ */
144
+ }
145
+
146
+ objective tradeStudyObjective : TradeStudyObjective {
147
+ doc
148
+ /*
149
+ * The objective of this TradeStudy.
150
+ *
151
+ * Redefine this feature to give it a definition that is a concrete
152
+ * specialization of TradeStudyObjective. That can either be one of the
153
+ * specializations provided in this package, or a more specific user-
154
+ * defined one.
155
+ */
156
+
157
+ subject :>> selectedAlternative;
158
+ in ref :>> alternatives = studyAlternatives;
159
+ in calc :>> eval = evaluationFunction;
160
+ }
161
+
162
+ return selectedAlternative : Anything = studyAlternatives->selectOne {in ref a {
163
+ doc
164
+ /*
165
+ * The alternative selected by this TradeStudy, which is the one that meets the
166
+ * requirement of the tradeStudyObjective.
167
+ */
168
+ } tradeStudyObjective(selectedAlternative = a)};
169
+ }
170
+
171
+ }