Calling Matlab functions from SysML activities

732 views
Skip to first unread message

Adrian

unread,
May 26, 2015, 10:53:21 AM5/26/15
to sysml...@googlegroups.com
Hello everyone,

I have the following problem: For my model, I want to call a Matlab function from a behaviour action. I want to do this because I am modelling a waste treatment plant, and there are modules that have been very well described already in Matlab. So, ideally in my SysML model I want to have my input parameters; the call behaviour then calls a Matlab function with those parameters, which executes and gives back the result. That is then outputted.

I thought that that should not be too much of a problem, but I did not manage to do that yet. Do I really need additional plugins like Matclipse or Massif? (If so, which one do you prefer?) In an activity, does defining the language anything more than give additional information to the viewer of the diagram?

Thanks a lot!
Adrian

Eran Peleg - Mobile Phone

unread,
May 26, 2015, 1:58:49 PM5/26/15
to sysml...@googlegroups.com
Hi Adrian
Rhapsody ha an interface to MATLAB from its SysML Parametriv Dgm.
You may try it with relation to Action oe CBA in AD.
Good luck
Eran
===================
Eran Peleg, CEO
Metaphor Vision Ltd.
+972545346060
epe...@metaphor.co.il
===================

Adrian <adrian...@gmail.com> כתב:
--
--
You received this message because you are subscribed to the Google
Groups "SysML Forum" group.
Public website: http://www.SysMLforum.com
To post to this group, send email to sysml...@googlegroups.com
To unsubscribe from this group, send email to
sysmlforum+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sysmlforum?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "SysML Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sysmlforum+...@googlegroups.com.
To post to this group, send email to sysml...@googlegroups.com.
Visit this group at http://groups.google.com/group/sysmlforum.
To view this discussion on the web visit https://groups.google.com/d/msgid/sysmlforum/7746d53c-7081-47b0-a6c6-4a745d2c9e76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gupta Stueti

unread,
May 26, 2015, 1:58:49 PM5/26/15
to sysml...@googlegroups.com

Adrian,

 

As far as I have used the Matlab function, it’s been in the parametric diagram and not the activity diagram. I am unsure if you can do such a thing in activity diagram.

You can use the following syntax in a constraint equation in parametric diagram,

Output = xfwExternal(matlab,function,input1,…,inputN,output1,…,outputM)

 

I use MagicDraw and needed to install the ParaMagic plugin for this capability. Also chose Matlab as the core solver in the Environment settings. For more information, you can refer this tutorial,

http://www.isr.umd.edu/~austin/enes489p/lab-resources/ENES489P-MagicDraw-Tutorial2010-09-02.pdf, Page 70

 

Hope this is helpful.

 

Best,

Stueti

--

Nerijus Jankevicius

unread,
May 26, 2015, 1:58:53 PM5/26/15
to <sysmlforum@googlegroups.com>
Adrian,

You did not mention what Modeling tool you use.
In MagicDraw (Cameo Systems Modeler) you can simply drop any m-file into Activity diagram to automatically represent it as CallBehaviorAction with pins representing function parameters. Use Cameo Simulation Toolkit to call that funtion and flow result to the output pin. Other actions can call Mathematica, Maple or have javascript, python, ruby or groovy scripts as body of OpaqueBehaviors. 

Regards,
Nerijus
--

FAUDOU raphael

unread,
May 26, 2015, 5:09:17 PM5/26/15
to sysml...@googlegroups.com, raphael FAUDOU
Hello Adrian,

A callBehavior action is used to call a UML/SysML activity, interaction or state machine.
In order to reference a behavior outside of UML, there is the Opaque Action for that. There is a language (in your case « matlab ») and a body where you can put the code/model/data from external language (matlab function in your case).
You will use the pins of the opaque action to match matlab function parameters and that ’s it.
Best regards
raphaël


Adrian

unread,
May 27, 2015, 10:12:02 AM5/27/15
to sysml...@googlegroups.com
Thanks everyone for all the help!

True, forgot to mention that I am using Eclipse Papyrus. So I am guessing the alternative for MagaicDraw's "Paramagic" (mentioned by Stueti) for me would be Massif or Matclipse? (https://github.com/FTSRG/massif and http://undocumentedmatlab.com/blog/matclipse-eclipse-matlab-interface)

The way I hoped to do it is basically exactly the way described by Raphael Faudou - but I don't have the option to tick "Matlab" as a language in which the Opage (or any other) action is written, only C, C++, Java, Natural language and OCL. Is that what above mentioned plugins are for? Will try those out later and come back here with results.

Best,
Adrian.

FAUDOU raphael

unread,
May 27, 2015, 3:17:47 PM5/27/15
to sysml...@googlegroups.com, raphael FAUDOU
Hello Adrian,

In fact you can add your own language for Opaque Actions in Papyrus. There is a predefined list but you can use the « + » button to add yours.
Come back to me if you still encounter issues with that. I can help
best 
Raphaël


Le 27 mai 2015 à 09:53, Adrian <adrian...@gmail.com> a écrit :

Thanks everyone for all the help!

True, forgot to mention that I am using Eclipse Papyrus. So I am guessing the alternative for MagaicDraw's "Paramagic" (mentioned by Stueti) for me would be Massif or Matclipse? (https://github.com/FTSRG/massif andhttp://undocumentedmatlab.com/blog/matclipse-eclipse-matlab-interface)


The way I hoped to do it is basically exactly the way described by Raphael Faudou - but I don't have the option to tick "Matlab" as a language in which the Opage (or any other) action is written, only C, C++, Java, Natural language and OCL. Is that what above mentioned plugins are for? Will try those out later and come back here with results.

Best,
Adrian.



Am Dienstag, 26. Mai 2015 16:53:21 UTC+2 schrieb Adrian:
Hello everyone,

I have the following problem: For my model, I want to call a Matlab function from a behaviour action. I want to do this because I am modelling a waste treatment plant, and there are modules that have been very well described already in Matlab. So, ideally in my SysML model I want to have my input parameters; the call behaviour then calls a Matlab function with those parameters, which executes and gives back the result. That is then outputted. 

I thought that that should not be too much of a problem, but I did not manage to do that yet. Do I really need additional plugins like Matclipse or Massif? (If so, which one do you prefer?) In an activity, does defining the language anything more than give additional information to the viewer of the diagram?

Thanks a lot!
Adrian
-- 
-- 
You received this message because you are subscribed to the Google
Groups "SysML Forum" group.
Public website: http://www.SysMLforum.com
To post to this group, send email to sysml...@googlegroups.com
To unsubscribe from this group, send email to
sysmlforum+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sysmlforum?hl=en_US?hl=en
--- 
You received this message because you are subscribed to the Google Groups "SysML Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sysmlforum+...@googlegroups.com.
To post to this group, send email to sysml...@googlegroups.com.
Visit this group at http://groups.google.com/group/sysmlforum.

Adrian

unread,
May 28, 2015, 11:09:06 AM5/28/15
to sysml...@googlegroups.com
Hello Raphael,

I hope I am not very much missing something here, but: Doing so, this will not give any more information to the SysML environment than any Action written in "Natural Language" would, right? As an "arbitrarily" named language obviously does not execute Matlab to run the specified action.
As an example maybe: Let's assume I want to change the value of a flow. As far as I get it, I can do that via an action directly writing that value or via a constraint. The above-mentioned methods either need a commercial SysML program (with possibly the appropriate plugins), or (Raphaels answer) will "only" convey this information to a human looking at the diagram, intepreting the action himself.

Am I right so far? Will take a look at the Matlab-plugins for Eclipse Papyrus I found so far, be back with updates!

Thanks again so far, Adrian.

FAUDOU raphael

unread,
May 28, 2015, 8:29:30 PM5/28/15
to sysml...@googlegroups.com, raphael FAUDOU
Le 28 mai 2015 à 10:10, Adrian <adrian...@gmail.com> a écrit :

Hello Raphael,

I hope I am not very much missing something here, but: Doing so, this will not give any more information to the SysML environment than any Action written in "Natural Language" would, right? As an "arbitrarily" named language obviously does not execute Matlab to run the specified action.
You are right and I realize my sentence was confusing. what I wanted to highlight is that with Papyrus you can mention « Matlab » in the « language » property of an opaqueAction even the predefined combo box does not contain this language by default.
If you do that, you can probably integrate matlab plugins for Eclipse and then « tell » simulation engine to call those matlab plugins when engine steps into an opaque action with language=« matlab ».

As an example maybe: Let's assume I want to change the value of a flow. As far as I get it, I can do that via an action directly writing that value or via a constraint. The above-mentioned methods either need a commercial SysML program (with possibly the appropriate plugins), or (Raphaels answer) will "only" convey this information to a human looking at the diagram, intepreting the action himself.


Am I right so far? Will take a look at the Matlab-plugins for Eclipse Papyrus I found so far, be back with updates!
Good. Eager to hear from you after your updates ;-)
Raphaël
Reply all
Reply to author
Forward
0 new messages