Using fmus with Mathematica - wolfram-mathematica

Is there a way to import and simulate fmus in Mathematica notebooks?
I have models developed in Modelica and one of the user of the models is proficient in using Mathematica notebooks but new to fmus. I was curious if Mathematica can import fmus similar to Python libraries like fmpy and pyfmi.

As mentioned in the comments, import of FMU is supported in System Modeler, you can get a free trial here,
https://www.wolfram.com/system-modeler/trial/
Once you import the FMU, as indicated here
https://reference.wolfram.com/system-modeler/UserGuide/ModelCenterFMUExportAndImport.html
you can simulate and access the model in Mathematica. When Mathematica and System Modeler with the same version are used in the same session they share a state and models can be modified, simulated, created, etc. in either tool. In Mathematica this is done using the system modeling functionality,
https://reference.wolfram.com/language/tutorial/GettingStartedWithModelSimulationAndAnalysis.html#47330727
More specifically, simulation is done fundamentally through the function SystemModelSimulate
https://reference.wolfram.com/language/ref/SystemModelSimulate.html

Related

Different inference result in AWS versus the Keras-Windows

I trained my model in Keras with Tensorflow 2.5 (from tensorflow import keras) and I converted it to tensorflow model for inference using AWS SageMaker. The inference result is quite different. I reviewed the libraries and all of them are same version, feature extraction is the same one too. What else can I review?.
Thanks a lot.
One option would be to test inference on your local laptop using SageMaker local (runs the SageMaker TF inference container locally using docker). Then you could troubleshoot it very quickly (seconds to launch the container).
Additionally, you could debug the inference code using PyCharm (this example debugs training, but it could be close enough).

dlib cnn python, is there any way or wrapper for python to do cnn based object training

I'm working on object detection using dlib, I was going through python implementation. I tested couple of examples from dlib python examples, specially i worked on train_object_detector.py. this works well. Now I would like to train same data model on CNN based object detector mode But i could not find python implementation for training CNN using python, but there is c++ example. (dnn_mmod_ex.cpp). I think it seems i'm missing something or python implementation is not available?
if python implementation is not available, then should i switch to c++ for CNN based object detector training
Yes, use C++ for CNN training. The dlib DNN tooling is meant to be used from C++ and so uses C++11 features that can't be represented in Python.

Programmatically choose correct backend for Matplotlib on Mac OS X

I have a program which integrates a tkinter GUI as well as a matplotlib plot (using pyplot). I'm running into endless troubles having this program work correctly across a variety of Mac platforms. The main problem seems to be the appropriate selection of the backend.
In some cases, the program runs fine no problem. In other cases, I run into a similar issue documented in this question. Implementing the solution outlined there solves that problem, but then other errors pop up for other systems. The solution to these other errors appears to be to use the Qt4Agg backend.
There has to be some standard way of getting a program using tkinter and matplotlib at the same time to play nice with Macs. How can I programmatically make sure the correct backend is being used such that the program won't crash for a Mac user?
Sorry if this is vague but it is a very broad problem.
See this answer: How to switch backends in matplotlib / Python
In essence, if you do not know which backend is available, the following code should load up the first backend that is available on the current machine. (I have only included 4 backends, there are quite a few others).
import matplotlib
gui_env = ['TKAgg','GTKAgg','Qt4Agg','WXAgg']
for gui in gui_env:
try:
print("testing", gui)
matplotlib.use(gui,warn=False, force=True)
from matplotlib import pyplot as plt
break
except:
continue
print("Using:",matplotlib.get_backend())
Using: GTKAgg
Update: I am lead to believe that there is a backend for OSX called MacOSX which could be added to that list, although I have no way of testing it myself.

Are there any benefits to using Python for GUI development?

I was looking into Tkinter, but I was wondering if there are any other packages that help with GUI. Even though Java is more robust than python, python is faster to write and would be very helpful if I am just trying to create a quick application. I usually use .Swing and .awt in java to make all of my applications.
Also, Is there something similar to JWS for python? I am looking to add a link on a website that will fire up a python coded application
Thanks
(P.S. I'm using Python 3.2.2)
I love using tkinter with python. It is pretty easy to do, there are lots of examples, and numerous questions with answers on here too! Also, 90% of people with python have tkinter already on their system, making distribution pretty straight forward. I also have had success using py2exe to create windows executables.
Here is a gui that I wrote in all of ~10 minutes. Once you understand the syntax it is very easy.
And another more elaborate one that I wrote with vtk and matplotlib embedded into the gui for 3D and 2D graphics! The question I asked with this.
Yes, python and tkinter are excellent for developing GUIs. While this is true of most scripting languages, I think these two make a particularly good combination.
For most GUIs, functionality is more important than form (ie: eye candy is not top priority). Even then, it's possible to make very nice looking GUIs with Tkinter. Tk has been my go-to toolkit for close to twenty years. It is most easily used with Tcl since that is its native language, but there's no denying the advantage python has over Tcl as far as built-in functionality goes.
That being said, all of the toolkits available to a python programmer are good. Tkinter's main advantages are that it is extremely easy to use and you probably already have it installed, so the barrier for entry is very low.

Which programming languages have REPLs that can display graphical data?

I'm starting to feel disappointed with REPLs that force me to do everything with text. I've used several environments that allow the presentation and manipulation of graphical data, and I wish all languages had it. Here's a short list of the graphical REPLs (in the broad sense) I'm aware of:
CAS typically have this: Mathematica, Maple, Axiom, MuPad, Sage*, etc.
The most recent version of IPython (notebook interface)
DrRacket
Factor's REPL
Are there any for other languages out there?
* If it weren't for IPython I'd recommend Sage notebooks to all python users, even non-mathematical ones.
Lisp:
Dynamic Windows of the Symbolics Lisp Machine operating system (Genera)
Common Lisp Interface Manager (CLIM), McCLIM
Julia has together with the IPython team released a Julia backend for the IPython notebook, called IJulia. It has gotten a good reputation in the Julia community and since MIT has began to do many of it's numerical analysis courses in Julia they have also released a nice little document explaining the reasoning behind the decision and a good intro to using Julia with the IPython/IJulia notebook.

Resources