Creating the Use Case Diagram
Overview
At this point, the state describing the arrogant behaviors of the hare is complete. At the beginning of the race, the hare has an opportunity to give the tortoise a head start if you provide a nonzero duration for “startingDelay.” Once the hare starts running, the behavior we described will have the hare to proceed to run until half way through the race. At that point the hare will consider resting if the tortoise is further behind in the race, assuming the “hasTakenANap” attribute is still “false.” The hare will continue to nap for a prescribed duration before resuming the race. Like the tortoise the determination of a "Winner” or “Loser” status is based on the status of the other reference part usage to the other racer.
Prerequisites
Prerequisite | Description |
---|---|
Behavior Execution Engine Installation | You must have installed Behavior Execution Engine. |
Tutorial Project | You must start this section with the Behavior Execution Engine simulation project from the previous section. |
Instructions
Creating the use case diagram
Now that we have the behaviors and structure all defined, we can finally construct our use case diagram. The use case diagram serves to create the specific versions of the tortoise and the hare that you wish to utilize for simulation. You need to provide input for how fast they run, how long the race is, etc. To get this process started.
- Create a new General diagram and give it the name
Use Case Diagram
. - Create a use case with the name
infamousRaceCase
Creating the Race part
With the part definitions in place, you can start creating specific parts and attributes that will enable you to execute and visualize the simulation. The first part we will create is a Race.
- Unhide the structure compartment of the
infamousRaceCase
use case. - Create a part with the name
animalRace
and set the definition toRace
. -
Create an attribute outside the case with the name
raceStartTime
and set the definition to Iso8601DateTime.- Expand the
raceStartTime
in the model tree explorer. - Redefine the
^val
attribute and give it a bound value of"2000-01-01T12:10:00.000000Z"
. - Drag the redefined
val
attribute next to theraceStartTime
. This is to see the start time on the same diagram view.
- Expand the
- Redefine
animalRace
’s^startTime
,^distance
, and^checkInRate
inherited attributes. - Unhide
animalRace
’s attribute compartment. - Give the
startTime
abound value ofraceStartTime
. - Give the
distance
abound value of40 [m]
. - Give the
checkInRate
abound value of1 [s]
. - Set the subject of the case to the
animalRace
.
Complete Race Part
Creating the part for the Tortoise
The first part is complete. You have created a Race part and populated it with the necessary information. Now create parts for the racers. The Tortoise part will be straightforward, and the Hare part will follow a similar process to that used to create the Race part.
- Create a part with the name
theTortoise
and set the definition toTortoise
. - Redefine the
^topSpeed
,^race
, and^hare
inherited elements. - Unhide
theTortoise
’stopSpeed
from the attribute compartment. - Drag the redefined
race
andhare
parts into theinfamousRaceCase
. - Give the
topSpeed
abound value of1 [‘m/s’]
. - Give the redefined
race
part a bound value ofanimalRace
. - Add
theTortoise
as an actor in the case.
Creating the part for the Hare
You have not created a part for the Hare yet, so you cannot give the redefined hare reference part a value.
- Create a part with the name
theHare
and set the definition toHare
. - Redefine the
^topSpeed
,^restDuration
,^startingDelay
,^race
, and^tortoise
inherited elements. - Unhide
theHare
’stopSpeed
,restDuration
, andstartingDelay
from the attribute compartment. - Drag the redefined
race
andtortoise
parts into theinfamouseRaceCase
. - Give the
topSpeed
a bound value of3 [‘m/s’]
. - Give the
restDuration
a bound value of30 [s]
. - Give the
startingDelay
a bound value of10 [s]
. - Give the redefined
race
part a bound value ofanimalRace
. - Give the redefined
tortoise
part a bound value oftheTortoise
. - Add
theHare
as an actor in the case.
Populating the missing values
With the Hare now participating as an actor in the use case, you can go back and finish populating the tortoise as an actor with the similarly missing values.
- Give the redefined
hare
part owned bytheTortoise
a bound value oftheHare
.
Complete Use Case Diagram
Creating a model config
You need to create a model config file before you are ready to execute the simulation. The file is written in a JSON format, and more information can be found on the page about executing a model. This sample config is also available in the installation samples (<BEE Install Directory>/samples/sysml2/tutorialTortoiseVsHare/part-1/TortoiseVsHare Part 1.config).
- Create a file on your computer called
TortoiseVsHare Part 1.config
. -
Copy and paste the snippet below into the config file:
{
"configVersion" : "0.1.0",
"delegateModules" : [],
"additionalDelegateModuleSearchDirectories" : [],
"simConfigs" : [
{
"name" : "Part-1 Simple Version",
"startTime" : "2000-01-01T12:00:00.000000Z",
"stopTime" : "2000-01-02T12:00:00.000000Z",
"targetElement" : "TortoiseVsHare Part 1::infamousRaceCase"
}
]
}
The start time corresponds to ten seconds before the race start time. The stop time is set to a day after the start of the race. The target element is the specific case we want to execute. Your model can have multiple cases that can be represented as additional entries in the simConfigs object. If you gave the model a different name, make sure you change the fully qualified name of the target element.
Executing the model
You are now ready to execute the model and simulate the motion of the two racers.
- Open the project page for your model.
- Open the kebab menu and click SysML 2 Launcher. Note – Larger models may cause the application to take longer to open. . This will open the
- Click the button for the Model Config File.
- Navigate and select the file that you created in the previous section.
- Click .
Running the simulation will pop up a log that contains the simulation trace. At the end of the trace, you can see which racer won by looking for the Winner and Loser StateStarted messages. With the default settings, you can see the expected outcome of the tortoise winning because the hare was too busy napping. Play with the settings for racer speeds and time durations to see how the race plays out when you start changing the values. How likely is it for the hare to win given a certain nap duration or a certain running speed?
Sample execution with presets
What if you wanted to scale this up dramatically and run a large study on just what it would take for the hare to win while being as lazy as possible? To tackle those types of problems, you would want to make use of the Behavioral Execution Engine delegate infrastructure to increase the precision of the model and take advantage of the event-based simulation mechanics to speed up the execution. Then you can use ModelCenter to create a trade study that automates all of this. Eventually, you might even want to connect to a tool like Ansys Fluent to model the aerodynamics of the Tortoise or Ansys Mechanical to analyze the mechanical strain on the hare while running to determine its rate of exhaustion. Combining all these tools together would enable you to analyze aspects of these systems together in the same mission scenario to achieve better designs.
Continue onto the next training module that builds on this example with Delegate Modules.
Next Section >