Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Leveraging Alf for SysML, Part 2: More Effective Trade Study Modeling

93 views

Published on

Alf is the OMG-standard textual language specifically designed for specifying executable behavior in the context of graphical, executable UML and SysML models. It is the best alternative to using complicated activity diagrams or scripting languages not designed for use in models. Part 2 of this tutorial focuses on leveraging Alf in SysML models for studying trade-offs between design variants.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Leveraging Alf for SysML, Part 2: More Effective Trade Study Modeling

  1. 1. Leveraging Alf for SysML Part 2: More Effective Trade Study Modeling Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Ed Seidewitz Model Driven Solutions, Inc. ● http://www.modeldriven.com ed-s@modeldriven.com ● @Seidewitz http://slideshare.net/seidewitz
  2. 2. Page 2 Goals Part 1 –Simulation Modeling (Sunday) • Learn the basics of the Alf action language for executable modeling. • Learn how to use Alf as an action language in SysML models. • Practice executing simulations of models that use Alf. Part 2 – Trade Study Modeling (Today) • Learn how to use the Trade Study Pattern. • Use Alf together with parametric constraints in SysML models. • Use simulation models in trade studies. Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  3. 3. Page 3 Prerequisites • Participant – Knowledge of SysML modeling using MagicDraw or Cameo System Modeler – Some experience with model execution using Cameo Simulation Toolkit – Introductory understanding of using Alf with SysML (e.g., from Part 1 of this tutorial) • System (for hands-on exercises) – Cameo System Modeler 19.0 SP2 (or MagicDraw and SysML) – Cameo Simulation Toolkit 19.0 SP2 (included in CSM Enterprise Edition) – Alf Plugin 19.0 SP2 • Slides: Available at https://www.slideshare.net/seidewitz Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  4. 4. Page 4 4 Installing the Alf Plugin Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Plugin documentation is available at: https://docs.nomagic.com/display/ALFP190SP2/Alf+plugin Under Plugins (commercial), download / install the Alf plugin v19.0 SP2. Select Help ► Resource/Plugin Manager to open the Resource/ Plugin Manager window.
  5. 5. Page 5 Parametrics Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  6. 6. Page 6 Parametric Constraints Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. A constraint block is a generic form of parametrized constraint that can be used in multiple contexts. A constraint property is a property whose type is a constraint block. Constraints are defined using mathematical equations. Constraints are defined in terms of parameters that can be bound to the physical properties modeled for systems. ⚠️ Do not specify constraints using Alf expressions.
  7. 7. Page 7 Parametric Diagrams Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. A constraint property is a usage of a constraint block. A binding connector asserts that the values of the connected properties must be equal.
  8. 8. Page 8 Airplane Mass Roll Up: Definition Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The top-level assembly and each part are all kinds of components. The specific compositions subset the general composition.
  9. 9. Page 9 Airplane Mass Rollup: Execution Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Executing this instance with the given composition. By default, solving is done on initialization. As a result, the total mass is computed.
  10. 10. Page 10 Hands On Airplane Mass Roll Up Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  11. 11. Page 11 Create a Mass Roll Up project Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  12. 12. Page 12 Load the Alf Library and open the Alf Editor window Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  13. 13. Page 13 Create a Component block and totalMass operation Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The total mass is computed using an operation This is a conditional expression, which choses one of two operand expressions to evaluate based on a condition. This is equivalent to this.sub->collect s (s.totalMass()) that is, it collects all the total masses of all the subcomponents. This reduces a sequence using the given function (in this case, it sums). Right click on the operation and select Create Method ► Behavior to open the Behavior selection window.
  14. 14. Page 14 Create the Airplane mass roll up definition Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Drag the subsetted property onto the subsetting property in order to create a subsets relationship.
  15. 15. Page 15 Create a Simulation driver block Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Create an activity under the Simulation block. Enter Alf code to test the roll up operation.
  16. 16. Page 16 Create an Simulation instance model Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Create composition links between the instances. Select the specific association, not the general one. Set all the component masses. Execute the Simulation instance
  17. 17. Page 17 Trade Studies Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  18. 18. Page 18 Trade study pattern Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The trade study pattern is a modelling pattern for choosing the best of a set of alternatives. A parametric constraint is used to test the “value” of each alternative and select the best one.
  19. 19. Page 19 Trade study driver activity Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The current alternative is responsible for setting the current value, which triggers the compare constraint.  To be safe, there should be a control flow to make sure the expansion region does not execute prematurely.
  20. 20. Page 20 Area trade study Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The alternatives for this trade study are Rectangles of different areas. The Area trade study specializes the general Trade Study Pattern and redefines the current alternative to be a Rectangle. A parametric constraint is used to compute the currentValue as the area of the current alternative.
  21. 21. Page 21 Area trade study configuration Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The alternatives to be configured are configured using instance specifications.
  22. 22. Page 22 Area trade study results Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. The “winner” is alternative r3 with the highest area.
  23. 23. Page 23 Hands On Trade Study Pattern Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  24. 24. Page 24 Open the sample TradeStudyPattern project Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. … Click on the Samples button. Select TradeStudyPattern under Simulation.  Be sure to save the project locally before modifying it!  After saving a local copy, load the Alf Library and open the Alf Editor window.
  25. 25. Page 25 Set the animation speed Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Open the Specification for each SimulationConfig and set the Animation Speed to 100.
  26. 26. Page 26 Delete the old method bodies Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Delete the old methods for computeWithBest and evaluateAlternative.
  27. 27. Page 27 Create the evaluateAlternative method Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Add an alternative parameter to the evaluateAlternative operation. Right click on the operation and select Create Method ► Behavior to open the Behavior selection window. Choose either Activity or Opaque Behavior. Enter the Alf code in the Alf Editor window.
  28. 28. Page 28 Create the evaluateAlternative method Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Also create a method for the compareWithBest operation, and add Alf code.
  29. 29. Page 29 Replace the doTradeStudy activity Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Delete the content of the doTradeStudy activity… …and replace it with Alf code.
  30. 30. Page 30 Run the simulations Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Run the simulations, to see if they still work.
  31. 31. Page 31 Revise the compareWithBest operation Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Add a value operation to the Alternative block. Delete the compare constraint property. Update the Alf code for the compareWithBest operation.  Be sure to delete using ctrl-D, not the delete key.
  32. 32. Page 32 Add area operation to Rectangle block Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Add an area operation, and open its specification. Choose Properties: All. Search for the “redefined operation” property. Click here to select a redefined operation. Select value as the redefined operation. Search for the “value” operation.
  33. 33. Page 33 Create the area method Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Correct the spelling of “hight” to “height”. Delete the rArea constraint property. Create a method for the area operation. ⓘ To show the “redefines” annotation, open the Rectangle Symbol Properties and set Show Operation Properties to true.
  34. 34. Page 34 Add hp operation to Engine block Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Delete this connector. Add an hp operation, redefining the value operation. Create a method for the hp operation
  35. 35. Page 35 Redefine hp operation for HybridEngine block Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Add an hp operation, redefining the Engine::hp operation. Delete the Sum constraint property.  The component hp properties need to be made public! Create a method for the hp operation. A super invocation calls the original operation method from the ”superclass” block.
  36. 36. Page 36 Run the simulations Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Run the simulations, to see if they still work.
  37. 37. Page 37 Hands On Heating Simulation Trade Study Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  38. 38. Page 38 Share packages from the Trade Study Pattern project Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Share the three packages from the (modified) TradeStudyPattern project.
  39. 39. Page 39 Use the TradeStudyPattern project in Heating Simulation Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Open the Heating Simulation project and select File ▶︎ Use Project ▶︎ Local Project to attach the TradeStudyPattern.. Create a Trade Study package.
  40. 40. Page 40 Add a block definition diagram for Trade Study Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Create a Heating Simulation Trade Study block as a specialization of the Trade Study Pattern. Redefine the alternatives reference property. Add a generalization from Heating Simulation to Alternative. Redefine the value operation from Alternative.
  41. 41. Page 41 Add signals to provide an asynchronous protocol Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  42. 42. Page 42 Create the Heating Simulation Trade Study state machine Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  43. 43. Page 43 Create Start and Stop signals and receptions Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Make this association end navigable. Make this association end navigable.
  44. 44. Page 44 Update the Environment state machine Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  45. 45. Page 45 Update the heat operation on the Climate block Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  46. 46. Page 46 Update the Climate state machine Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  47. 47. Page 47 Update the Heater state machine Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.
  48. 48. Page 48 Create a Heating Simulation state machine Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Also add a referential attribute to Heating Simulation Trade Study.
  49. 49. Page 49 Create a simulation configuration Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc. Note different values for temperature attributes. Set the animation speed to 100. Set the evaluation target to the study.  The SimulationConfig needs to be created on a Simulation Configuration Diagram.
  50. 50. Page 50 Run the simulation Copyright © 2019 Ed Seidewitz / Model Driven Solutions, Inc.

×