Group Abstract Group Abstract

Message Boards Message Boards

0
|
11.8K Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

Automate routines in SystemModeler?

Posted 9 years ago

Hi everyone,

Is there any way, perhaps through an API, to automate some routines such as test cases generation. For instance, let's define a simple block containing a RealInput interface and an assertion function that is violated when the RealInput is greater than 5. Thus, after having manually defined the assertion block, I would like to automatically :

  • generate a source of type RealExpression whose value is randomly set, and
  • connect the RealExpression source to the RealInput interface of the assertion block.

Do you see any solution to automate such operations? The reason why I want to achieve such a thing is because I have numerous assertion blocks and just want to generate various test scenarios.

Cheers,

Romain

POSTED BY: Romain Pinquié
5 Replies
Posted 9 years ago

Romain,

Yes. What you do is you create the block you need (maybe by using the assert() keyword in Modelica), and then use that block in this type of construct:

Needs["WSMLink`"]
WSMConnectComponents["newmodel",{"c1"\[Element]"RealExpression","c2"\[Element]"RealOutput"},{"c1.y"->"c2"}];
WSMSetValues["newmodel",{"c1.y"->RandomReal[]}]

Now you can change the input to be different random real for each model. You can use WSMConnectComponents with any components, here I'm using the Modelica.Blocks.Sources.RealExpression and Modelica.Blocks.Interfaces.RealOutput, but can be anything you like. You can use all the Wolfram Language symbols to generate a large set of these models, just wrap the two commands here with Table, For or any such construct.

POSTED BY: Johan Rhodin
Attachments:
POSTED BY: Romain Pinquié

Hi Romain,

This on-demand video can help you get started with SystemModeler and the Wolfram Language: http://www.wolfram.com/training/courses/eng022.html.

POSTED BY: Jan Brugard

Thanks Johan, I'll give it a try this week-end. Although the Wolfram language looks very powerful, I am not familiar with it yet, I will have to get my hands dirty ;).

POSTED BY: Romain Pinquié
POSTED BY: Jan Brugard
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard