I'm currently working on a program that generates a PMML file. I'm starting with decision tree model.
In the PMML website, in a example of tree model, I see this:
<Internal closure="closedClosed" leftMargin="4.3" rightMargin="4.4"/>
What is this this Internal node ? What does closure, or Margin refers to ?
Related
We are working with a tool that generates C-code. For example, the C-code could be for the logic: "if a sensor is activated, turn on the LED bulb". The code can be saved into a function that can be called from outside. What is the best way to embed this kind of external C-code into the rest of the Modelica model? How can we compile this code along with the rest of the .mo files preferably using OM Shell script and omc?
You can directly put C code in external functions or link with a library.
See:
https://specification.modelica.org/v3.4/Ch12.html#external-function-interface
https://specification.modelica.org/v3.4/Ch12.html#external-objects
As examples see some of our tests from the testsuite:
https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/simulation/modelica/
Simple example:
https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/simulation/modelica/external_functions/ExternalLibraries.mo
https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/simulation/modelica/external_functions/ExternalLibraries.mos
https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/simulation/modelica/external_functions/ExternalFunc1.c
https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/simulation/modelica/external_functions/ExternalFunc2.c
Some advanced libraries:
https://github.com/modelica-3rdparty/Modelica_DeviceDrivers
https://github.com/modelica-3rdparty/ExternData
I want to do Monte Carlo simulation with a model. This model has some external functions linked to a library that reads its inputs from a file. I have been recently experimenting with ".mos" files to run the same model over and over. With external files it is easy to change them and re-simulate the model using the mos file (even in parallel). Yet I was unable to change the internal parameters of the model in the mos script. I have done many experiments and been looking for the answer for some time now. I wonder what is the correct syntax for changing the parameters of the model inside a simple .mos file like the one below.
cd(<working directory>);
loadFile(<address of the package that also loads the OpenModelica>);
simulate(<model>, stopTime=<...>, numberOfIntervals=<...>);
quit();
For instance, lets say the model has a parameter param and a submodel sub with the parameter sub_param. How can I change param and sub_param inside the mos file.
I am using AnyLogic University edition (cannot export AnyLogic model). I need my Java application to call an AnyLogic model (passing a few parameters), execute the model and receive the experiment results (from AnyLogic to my application). How can this be achieved?
Another question is, can the same be done from other programming languages (say, VB or Python)? What I mean is, calling an AnyLogic model from Python.
One approach would be to use a ProcessBuilder in Java to execute a shell command, that runs your anylogic model like so (assuming the model is in /c directory on windows):
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("cmd.exe", "/c","anylogic 'absolute path to the model .alp file'");
There are several ways to then pass back results. The easiest may be to import an Excel file into Anylogic which stores your results, and then read it with a CSVReadWrite object in your Java application.
Not sure what is your objective behind calling the simulation dynamically using a java application. But one way to do it might be inside Anylogic itself. You can use the 'Custom Experiment' to write any reasonably small java source code and run the model (in iteration if needed) to collect results and possibly even saving the results to a csv file after each run. See the link below for examples and details
https://help.anylogic.com/nav/0_11
I have created a simple Simulink library because I am learning about masks. The library is saved into Documents folder, which is in path of MATLAB. To test my library, I've created a model and I've inserted my block from my library. When I want to change the value of a parameter in the mask I receive this error screenshot of message
Is there any configuration to do?
Thank you so much
I'm working on a project where I have to build a graphical process modeler for a proprietary BPM (business process management) system made in java. I'm mentioning that the software is proprietary because it does not follow ANY international standards like BPEL, BPMN, XPDL, and this is a vital information for any answers I may get.
My intended approach is to use the eclipse GMF to create a standalone RCP application, similar to Bonita Studio, where business analysts will graphically model the business processes and deploy the process model into the web application.
This application has an internal wizard-like process modeler, very rudimentary. But this modeler has a functionality to import and export models in a custom, well defined XML format, which is also proprietary and has no international standards.
What I need is to persist the graphical model created with the eclipse gmf rcp application I'm developing into this custom XML format. This way I can simply invoque the import function in the web application and the process will be deployed. I also need to be able to do the reverse: open a custom process in this XML format into my eclipse RCP and show it in a graphical manner.
So, what I need is:
I need to save a graphical diagram in a custom XML format and open a custom XML file in this format and show it as graphical diagrams
Thank you very much for any help!
GMF is using EMF models to store its diagrams. As EMF Models are already able to map to XML, a XSL stylesheet transformation might be enough in most cases to map your model to your custom XML format and vice versa.
Daniel, I had this requirement for exporting diagram as XML and vice versa. I'll give you the procedure that I have followed below.
GUI to XML : - Use your model file in the below code to return the root element as java object.
Note : - Assuming GMF editor generates 2 files, one for model and one for the diagram, you have to choose the model file as input to the below code.
File model_file = new File(Path_to_your_model_file);
ResourceSet rs = new ResourceSetImpl();
URI fileUri = URI.createFileURI(model_file.getAbsolutePath());
Resource res = rs.getResource(fileUri, true);
Model model = res.getContents().get(0);
In the above line Model represent your root object of your ecore model. Now as you got the root object you can use it to get the all the values, references, etc
Using these you can manually write a java code to write a XML file.
XML to GUI : - This is pretty straight forward too
Create a new object for the root element for your model by using the below code.
ModelImpl model = (ModelImpl)ModelFactoryImpl.eINSTANCE.createModel(); // Replace Model with your model element name
You have to first parse the XML file using JAVA and read all the values step by step and assing the attributes to the model object step by step (for example : model.setName(doc.getDocumentElement().getAttribute("name")); and ChildObjImpl childObject = (ChildObj)ModelFactoryImpl.eINSTANCE.createChildObj();)
You can create all the different required objects that are supported by your code and then add them to the parent object (for example : model.getChildObject().add(childObject)); )
Once you have finished adding all the info from XML into these objects, you can use the root model object to create the model file as shown below
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",new XMIResourceFactoryImpl());
Resource resource = resourceSet.createResource(URI.createFileURI(path_where_u_want_to_save_the_model_with_filename));
resource.getContents().add(dd);
resource.save(null);
Above code will generate the model fine, you can right click that file and generate the diagram file.
I don't know if there is a better way to do this, but this one worked for me well. Try it and let me know if you need further help.