Scripting API¶
The following are short summaries of OpenModelica scripting commands. These commands are useful for loading and saving classes, reading and storing data, plotting of results, and various other tasks.
The arguments passed to a scripting function should follow syntactic and typing rules for Modelica and for the scripting function in question. In the following tables we briefly indicate the types or character of the formal parameters to the functions by the following notation:
String typed argument, e.g. "hello", "myfile.mo".
- TypeName – class, package or function name, e.g. MyClass,
Modelica.Math.
VariableName – variable name, e.g.
v1
,v2
,vars1[2].x
, etc.Integer or Real typed argument, e.g. 35, 3.14, xintvariable.
options – optional parameters with named formal parameter passing.
OpenModelica Scripting Commands¶
The following are brief descriptions of the scripting commands available in the OpenModelica environment. All commands are shown in alphabetical order:
interactiveDumpAbsynToJL¶
function interactiveDumpAbsynToJL
output String res;
end interactiveDumpAbsynToJL;
relocateFunctions¶
function relocateFunctions
input String fileName;
input String names[:, 2];
output Boolean success;
end relocateFunctions;
toJulia¶
function toJulia
output String res;
end toJulia;
GC_expand_hp¶
function GC_expand_hp
input Integer size;
output Boolean success;
end GC_expand_hp;
GC_gcollect_and_unmap¶
GC_get_prof_stats¶
function GC_get_prof_stats
output GC_PROFSTATS gcStats;
end GC_get_prof_stats;
GC_set_max_heap_size¶
function GC_set_max_heap_size
input Integer size;
output Boolean success;
end GC_set_max_heap_size;
addClassAnnotation¶
function addClassAnnotation
input TypeName class_;
input ExpressionOrModification annotate;
output Boolean bool;
end addClassAnnotation;
addInitialState¶
function addInitialState
input TypeName cl;
input String state;
input ExpressionOrModification annotate;
output Boolean bool;
end addInitialState;
addTransition¶
function addTransition
input TypeName cl;
input String from;
input String to;
input String condition;
input Boolean immediate = true;
input Boolean reset = true;
input Boolean synchronize = false;
input Integer priority = 1;
input ExpressionOrModification annotate;
output Boolean bool;
end addTransition;
alarm¶
impure function alarm
input Integer seconds;
output Integer previousSeconds;
end alarm;
appendEnvironmentVar¶
function appendEnvironmentVar
input String var;
input String value;
output String result "returns \"error\" if the variable could not be appended";
end appendEnvironmentVar;
basename¶
function basename
input String path;
output String basename;
end basename;
buildEncryptedPackage¶
function buildEncryptedPackage
input TypeName className "the class that should encrypted";
input Boolean encrypt = true;
output Boolean success;
end buildEncryptedPackage;
buildLabel¶
function buildLabel
input TypeName className "the class that should be built";
input Real startTime = 0.0 "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = "dassl" "integration method used for simulation. <default> = dassl";
input String fileNamePrefix = "" "fileNamePrefix. <default> = \"\"";
input String options = "" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "" "cflags. <default> = \"\"";
input String simflags = "" "simflags. <default> = \"\"";
output String[2] buildModelResults;
end buildLabel;
buildModel¶
function buildModel
input TypeName className "the class that should be built";
input Real startTime = "<default>" "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = "<default>" "integration method used for simulation. <default> = dassl";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"\"";
input String options = "<default>" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "<default>" "cflags. <default> = \"\"";
input String simflags = "<default>" "simflags. <default> = \"\"";
output String[2] buildModelResults;
end buildModel;
buildModelFMU¶
function buildModelFMU
input TypeName className "the class that should translated";
input String version = "2.0" "FMU version, 1.0 or 2.0.";
input String fmuType = "me" "FMU type, me (model exchange), cs (co-simulation), me_cs (both model exchange and co-simulation)";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"className\"";
input String platforms[:] = {"static"} "The list of platforms to generate code for. \"dynamic\"=current platform, dynamically link the runtime. \"static\"=current platform, statically link everything. Else, use a host triple, e.g. \"x86_64-linux-gnu\" or \"x86_64-w64-mingw32\"";
input Boolean includeResources = false "include Modelica based resources via loadResource or not";
output String generatedFileName "Returns the full path of the generated FMU.";
end buildModelFMU;
cd¶
function cd
input String newWorkingDirectory = "";
output String workingDirectory;
end cd;
checkAllModelsRecursive¶
function checkAllModelsRecursive
input TypeName className;
input Boolean checkProtected = false "Checks also protected classes if true";
output String result;
end checkAllModelsRecursive;
checkCodeGraph¶
function checkCodeGraph
input String graphfile;
input String codefile;
output String[:] result;
end checkCodeGraph;
checkInterfaceOfPackages¶
function checkInterfaceOfPackages
input TypeName cl;
input String dependencyMatrix[:, :];
output Boolean success;
end checkInterfaceOfPackages;
checkModel¶
function checkModel
input TypeName className;
output String result;
end checkModel;
checkSettings¶
function checkSettings
output CheckSettingsResult result;
end checkSettings;
checkTaskGraph¶
function checkTaskGraph
input String filename;
input String reffilename;
output String[:] result;
end checkTaskGraph;
classAnnotationExists¶
function classAnnotationExists
input TypeName className;
input TypeName annotationName;
output Boolean exists;
end classAnnotationExists;
clear¶
function clear
output Boolean success;
end clear;
clearCommandLineOptions¶
function clearCommandLineOptions
output Boolean success;
end clearCommandLineOptions;
clearDebugFlags¶
function clearDebugFlags
output Boolean success;
end clearDebugFlags;
clearMessages¶
function clearMessages
output Boolean success;
end clearMessages;
clearProgram¶
function clearProgram
output Boolean success;
end clearProgram;
clearVariables¶
function clearVariables
output Boolean success;
end clearVariables;
closeSimulationResultFile¶
function closeSimulationResultFile
output Boolean success;
end closeSimulationResultFile;
codeToString¶
function codeToString
input $Code className;
output String string;
end codeToString;
compareFiles¶
impure function compareFiles
input String file1;
input String file2;
output Boolean isEqual;
end compareFiles;
compareFilesAndMove¶
impure function compareFilesAndMove
input String newFile;
input String oldFile;
output Boolean success;
end compareFilesAndMove;
compareSimulationResults¶
function compareSimulationResults
input String filename;
input String reffilename;
input String logfilename;
input Real relTol = 0.01;
input Real absTol = 0.0001;
input String[:] vars = fill("", 0);
output String[:] result;
end compareSimulationResults;
convertPackageToLibrary¶
function convertPackageToLibrary
input TypeName packageToConvert;
input TypeName library;
input String libraryVersion;
output Boolean success;
end convertPackageToLibrary;
convertUnits¶
function convertUnits
input String s1;
input String s2;
output Boolean unitsCompatible;
output Real scaleFactor;
output Real offset;
end convertUnits;
copy¶
function copy
input String source;
input String destination;
output Boolean success;
end copy;
copyClass¶
function copyClass
input TypeName className "the class that should be copied";
input String newClassName "the name for new class";
input TypeName withIn = $Code(TopLevel) "the with in path for new class";
output Boolean result;
end copyClass;
countMessages¶
function countMessages
output Integer numMessages;
output Integer numErrors;
output Integer numWarnings;
end countMessages;
deleteFile¶
function deleteFile
input String fileName;
output Boolean success;
end deleteFile;
deleteInitialState¶
function deleteInitialState
input TypeName cl;
input String state;
output Boolean bool;
end deleteInitialState;
deleteTransition¶
function deleteTransition
input TypeName cl;
input String from;
input String to;
input String condition;
input Boolean immediate;
input Boolean reset;
input Boolean synchronize;
input Integer priority;
output Boolean bool;
end deleteTransition;
deltaSimulationResults¶
function deltaSimulationResults
input String filename;
input String reffilename;
input String method "method to compute then error. choose 1norm, 2norm, maxerr";
input String[:] vars = fill("", 0);
output Real result;
end deltaSimulationResults;
diffModelicaFileListings¶
function diffModelicaFileListings
input String before, after;
input DiffFormat diffFormat = DiffFormat.color;
input Boolean failOnSemanticsChange = false "Defaults to returning after instead of hard fail";
output String result;
end diffModelicaFileListings;
diffSimulationResults¶
function diffSimulationResults
input String actualFile;
input String expectedFile;
input String diffPrefix;
input Real relTol = 1e-3 "y tolerance";
input Real relTolDiffMinMax = 1e-4 "y tolerance based on the difference between the maximum and minimum of the signal";
input Real rangeDelta = 0.002 "x tolerance";
input String[:] vars = fill("", 0);
input Boolean keepEqualResults = false;
output Boolean success;
output String[:] failVars;
end diffSimulationResults;
diffSimulationResultsHtml¶
function diffSimulationResultsHtml
input String var;
input String actualFile;
input String expectedFile;
input Real relTol = 1e-3 "y tolerance";
input Real relTolDiffMinMax = 1e-4 "y tolerance based on the difference between the maximum and minimum of the signal";
input Real rangeDelta = 0.002 "x tolerance";
output String html;
end diffSimulationResultsHtml;
directoryExists¶
function directoryExists
input String dirName;
output Boolean exists;
end directoryExists;
dirname¶
function dirname
input String path;
output String dirname;
end dirname;
disableNewInstantiation¶
function disableNewInstantiation
output Boolean success;
end disableNewInstantiation;
dumpXMLDAE¶
function dumpXMLDAE
input TypeName className;
input String translationLevel = "flat" "flat, optimiser, backEnd, or stateSpace";
input Boolean addOriginalAdjacencyMatrix = false;
input Boolean addSolvingInfo = false;
input Boolean addMathMLCode = false;
input Boolean dumpResiduals = false;
input String fileNamePrefix = "<default>" "this is the className in string form by default";
input String rewriteRulesFile = "" "the file from where the rewiteRules are read, default is empty which means no rewrite rules";
output Boolean success "if the function succeeded true/false";
output String xmlfileName "the Xml file";
end dumpXMLDAE;
echo¶
function echo
input Boolean setEcho;
output Boolean newEcho;
end echo;
enableNewInstantiation¶
function enableNewInstantiation
output Boolean success;
end enableNewInstantiation;
escapeXML¶
function escapeXML
input String inStr;
output String outStr;
end escapeXML;
exit¶
function exit
input Integer status;
end exit;
exportToFigaro¶
function exportToFigaro
input TypeName path;
input String directory = cd();
input String database;
input String mode;
input String options;
input String processor;
output Boolean success;
end exportToFigaro;
extendsFrom¶
function extendsFrom
input TypeName className;
input TypeName baseClassName;
output Boolean res;
end extendsFrom;
filterSimulationResults¶
function filterSimulationResults
input String inFile;
input String outFile;
input String[:] vars;
input Integer numberOfIntervals = 0 "0=Do not resample";
input Boolean removeDescription = false;
input Boolean hintReadAllVars = true;
output Boolean success;
end filterSimulationResults;
generateCode¶
function generateCode
input TypeName className;
output Boolean success;
end generateCode;
generateEntryPoint¶
function generateEntryPoint
input String fileName;
input TypeName entryPoint;
input String url = "https://trac.openmodelica.org/OpenModelica/newticket";
end generateEntryPoint;
generateHeader¶
function generateHeader
input String fileName;
output Boolean success;
end generateHeader;
generateJuliaHeader¶
function generateJuliaHeader
input String fileName;
output Boolean success;
end generateJuliaHeader;
generateScriptingAPI¶
function generateScriptingAPI
input TypeName cl;
input String name;
output Boolean success;
output String moFile;
output String qtFile;
output String qtHeader;
end generateScriptingAPI;
generateSeparateCode¶
function generateSeparateCode
input TypeName className;
input Boolean cleanCache = false "If true, the cache is reset between each generated package. This conserves memory at the cost of speed.";
output Boolean success;
end generateSeparateCode;
generateSeparateCodeDependencies¶
function generateSeparateCodeDependencies
input String stampSuffix = ".c" "Suffix to add to dependencies (often .c.stamp)";
output String[:] dependencies;
end generateSeparateCodeDependencies;
generateSeparateCodeDependenciesMakefile¶
function generateSeparateCodeDependenciesMakefile
input String filename "The file to write the makefile to";
input String directory = "" "The relative path of the generated files";
input String suffix = ".c" "Often .stamp since we do not update all the files";
output Boolean success;
end generateSeparateCodeDependenciesMakefile;
generateVerificationScenarios¶
function generateVerificationScenarios
input TypeName path;
output Boolean success;
end generateVerificationScenarios;
getAlgorithmCount¶
function getAlgorithmCount
input TypeName class_;
output Integer count;
end getAlgorithmCount;
getAlgorithmItemsCount¶
function getAlgorithmItemsCount
input TypeName class_;
output Integer count;
end getAlgorithmItemsCount;
getAllSubtypeOf¶
function getAllSubtypeOf
input TypeName className;
input TypeName parentClass = $Code(AllLoadedClasses);
input Boolean qualified = false;
input Boolean includePartial = false;
input Boolean sort = false;
output TypeName classNames[:];
end getAllSubtypeOf;
getAnnotationCount¶
function getAnnotationCount
input TypeName class_;
output Integer count;
end getAnnotationCount;
getAnnotationModifierValue¶
function getAnnotationModifierValue
input TypeName name;
input String vendorannotation;
input String modifiername;
output String modifiernamevalue;
end getAnnotationModifierValue;
getAnnotationNamedModifiers¶
function getAnnotationNamedModifiers
input TypeName name;
input String vendorannotation;
output String[:] modifiernamelist;
end getAnnotationNamedModifiers;
getAnnotationVersion¶
function getAnnotationVersion
output String annotationVersion;
end getAnnotationVersion;
getAstAsCorbaString¶
function getAstAsCorbaString
input String fileName = "<interactive>";
output String result "returns the string if fileName is interactive; else it returns ok or error depending on if writing the file succeeded";
end getAstAsCorbaString;
getAvailableIndexReductionMethods¶
function getAvailableIndexReductionMethods
output String[:] allChoices;
output String[:] allComments;
end getAvailableIndexReductionMethods;
getAvailableLibraries¶
function getAvailableLibraries
output String[:] libraries;
end getAvailableLibraries;
getAvailableLibraryVersions¶
function getAvailableLibraryVersions
input TypeName libraryName;
output String[:] librariesAndVersions;
end getAvailableLibraryVersions;
getAvailableMatchingAlgorithms¶
function getAvailableMatchingAlgorithms
output String[:] allChoices;
output String[:] allComments;
end getAvailableMatchingAlgorithms;
getAvailablePackageConversionsFrom¶
function getAvailablePackageConversionsFrom
input TypeName pkg;
input String version;
output String[:] convertsTo;
end getAvailablePackageConversionsFrom;
getAvailablePackageConversionsTo¶
function getAvailablePackageConversionsTo
input TypeName pkg;
input String version;
output String[:] convertsTo;
end getAvailablePackageConversionsTo;
getAvailablePackageVersions¶
function getAvailablePackageVersions
input TypeName pkg;
input String version;
output String[:] withoutConversion;
end getAvailablePackageVersions;
getAvailableTearingMethods¶
function getAvailableTearingMethods
output String[:] allChoices;
output String[:] allComments;
end getAvailableTearingMethods;
getBooleanClassAnnotation¶
function getBooleanClassAnnotation
input TypeName className;
input TypeName annotationName;
output Boolean value;
end getBooleanClassAnnotation;
getBuiltinType¶
function getBuiltinType
input TypeName cl;
output String name;
end getBuiltinType;
getCFlags¶
function getCFlags
output String outString;
end getCFlags;
getCXXCompiler¶
function getCXXCompiler
output String compiler;
end getCXXCompiler;
getClassComment¶
function getClassComment
input TypeName cl;
output String comment;
end getClassComment;
getClassInformation¶
function getClassInformation
input TypeName cl;
output String restriction, comment;
output Boolean partialPrefix, finalPrefix, encapsulatedPrefix;
output String fileName;
output Boolean fileReadOnly;
output Integer lineNumberStart, columnNumberStart, lineNumberEnd, columnNumberEnd;
output String dimensions[:];
output Boolean isProtectedClass;
output Boolean isDocumentationClass;
output String version;
output String preferredView;
output Boolean state;
output String access;
output String versionDate;
output String versionBuild;
output String dateModified;
output String revisionId;
end getClassInformation;
getClassNames¶
function getClassNames
input TypeName class_ = $Code(AllLoadedClasses);
input Boolean recursive = false;
input Boolean qualified = false;
input Boolean sort = false;
input Boolean builtin = false "List also builtin classes if true";
input Boolean showProtected = false "List also protected classes if true";
input Boolean includeConstants = false "List also constants in the class if true";
output TypeName classNames[:];
end getClassNames;
getClassRestriction¶
function getClassRestriction
input TypeName cl;
output String restriction;
end getClassRestriction;
getClassesInModelicaPath¶
function getClassesInModelicaPath
output String classesInModelicaPath;
end getClassesInModelicaPath;
getCommandLineOptions¶
function getCommandLineOptions
output String[:] flags;
end getCommandLineOptions;
getCompileCommand¶
function getCompileCommand
output String compileCommand;
end getCompileCommand;
getCompiler¶
function getCompiler
output String compiler;
end getCompiler;
getComponentModifierNames¶
function getComponentModifierNames
input TypeName class_;
input String componentName;
output String[:] modifiers;
end getComponentModifierNames;
getComponentModifierValue¶
function getComponentModifierValue
input TypeName class_;
input TypeName modifier;
output String value;
end getComponentModifierValue;
getComponentModifierValues¶
function getComponentModifierValues
input TypeName class_;
input TypeName modifier;
output String value;
end getComponentModifierValues;
getComponentsTest¶
function getComponentsTest
input TypeName name;
output Component[:] components;
record Component
String className "the type of the component";
String name "the name of the component";
String comment "the comment of the component";
Boolean isProtected "true if component is protected";
Boolean isFinal "true if component is final";
Boolean isFlow "true if component is flow";
Boolean isStream "true if component is stream";
Boolean isReplaceable "true if component is replaceable";
String variability "'constant', 'parameter', 'discrete', ''";
String innerOuter "'inner', 'outer', ''";
String inputOutput "'input', 'output', ''";
String dimensions[:] "array with the dimensions of the component";
end Component;
end getComponentsTest;
getConfigFlagValidOptions¶
function getConfigFlagValidOptions
input String flag;
output String validOptions[:];
output String mainDescription;
output String descriptions[:];
end getConfigFlagValidOptions;
getConnectionCount¶
function getConnectionCount
input TypeName className;
output Integer count;
end getConnectionCount;
getConnectionList¶
function getConnectionList
input TypeName className;
output String[:, :] result;
end getConnectionList;
getConversionsFromVersions¶
function getConversionsFromVersions
input TypeName pack;
output String[:] withoutConversion;
output String[:] withConversion;
end getConversionsFromVersions;
getDefaultOpenCLDevice¶
function getDefaultOpenCLDevice
output Integer defdevid;
end getDefaultOpenCLDevice;
getDerivedClassModifierNames¶
function getDerivedClassModifierNames
input TypeName className;
output String[:] modifierNames;
end getDerivedClassModifierNames;
getDerivedClassModifierValue¶
function getDerivedClassModifierValue
input TypeName className;
input TypeName modifierName;
output String modifierValue;
end getDerivedClassModifierValue;
getDerivedUnits¶
function getDerivedUnits
input String baseUnit;
output String[:] derivedUnits;
end getDerivedUnits;
getDocumentationAnnotation¶
function getDocumentationAnnotation
input TypeName cl;
output String out[3] "{info,revision,infoHeader} TODO: Should be changed to have 2 outputs instead of an array of 2 Strings...";
end getDocumentationAnnotation;
getElementModifierNames¶
function getElementModifierNames
input TypeName className;
input String elementName;
output String[:] modifiers;
end getElementModifierNames;
getElementModifierValue¶
function getElementModifierValue
input TypeName className;
input TypeName modifier;
output String value;
end getElementModifierValue;
getElementModifierValues¶
function getElementModifierValues
input TypeName className;
input TypeName modifier;
output String value;
end getElementModifierValues;
getEnvironmentVar¶
function getEnvironmentVar
input String var;
output String value "returns empty string on failure";
end getEnvironmentVar;
getEquationCount¶
function getEquationCount
input TypeName class_;
output Integer count;
end getEquationCount;
getEquationItemsCount¶
function getEquationItemsCount
input TypeName class_;
output Integer count;
end getEquationItemsCount;
getErrorString¶
impure function getErrorString
input Boolean warningsAsErrors = false;
output String errorString;
end getErrorString;
getHomeDirectoryPath¶
function getHomeDirectoryPath
output String homeDirectoryPath;
end getHomeDirectoryPath;
getImportCount¶
function getImportCount
input TypeName class_;
output Integer count;
end getImportCount;
getImportedNames¶
function getImportedNames
input TypeName class_;
output String[:] out_public;
output String[:] out_protected;
end getImportedNames;
getIndexReductionMethod¶
function getIndexReductionMethod
output String selected;
end getIndexReductionMethod;
getInheritedClasses¶
function getInheritedClasses
input TypeName name;
output TypeName inheritedClasses[:];
end getInheritedClasses;
getInitialAlgorithmCount¶
function getInitialAlgorithmCount
input TypeName class_;
output Integer count;
end getInitialAlgorithmCount;
getInitialAlgorithmItemsCount¶
function getInitialAlgorithmItemsCount
input TypeName class_;
output Integer count;
end getInitialAlgorithmItemsCount;
getInitialEquationCount¶
function getInitialEquationCount
input TypeName class_;
output Integer count;
end getInitialEquationCount;
getInitialEquationItemsCount¶
function getInitialEquationItemsCount
input TypeName class_;
output Integer count;
end getInitialEquationItemsCount;
getInitialStates¶
function getInitialStates
input TypeName cl;
output String[:, :] initialStates;
end getInitialStates;
getInstallationDirectoryPath¶
function getInstallationDirectoryPath
output String installationDirectoryPath;
end getInstallationDirectoryPath;
getInstantiatedParametersAndValues¶
function getInstantiatedParametersAndValues
input TypeName cls;
output String[:] values;
end getInstantiatedParametersAndValues;
getLanguageStandard¶
function getLanguageStandard
output String outVersion;
end getLanguageStandard;
getLinker¶
function getLinker
output String linker;
end getLinker;
getLinkerFlags¶
function getLinkerFlags
output String linkerFlags;
end getLinkerFlags;
getLoadedLibraries¶
function getLoadedLibraries
output String[:, 2] libraries;
end getLoadedLibraries;
getMMfileTotalDependencies¶
function getMMfileTotalDependencies
input String in_package_name;
input String public_imports_dir;
output String[:] total_pub_imports;
end getMMfileTotalDependencies;
getMatchingAlgorithm¶
function getMatchingAlgorithm
output String selected;
end getMatchingAlgorithm;
getMemorySize¶
function getMemorySize
output Real memory(unit = "MiB");
end getMemorySize;
getMessagesString¶
function getMessagesString
output String messagesString;
end getMessagesString;
getModelInstance¶
function getModelInstance
input TypeName className;
input String modifier = "";
input Boolean prettyPrint = false;
output String result;
end getModelInstance;
getModelInstanceIcon¶
function getModelInstanceIcon
input TypeName className;
input Boolean prettyPrint = false;
output String result;
end getModelInstanceIcon;
getModelicaPath¶
function getModelicaPath
output String modelicaPath;
end getModelicaPath;
getNoSimplify¶
function getNoSimplify
output Boolean noSimplify;
end getNoSimplify;
getNthAlgorithm¶
function getNthAlgorithm
input TypeName class_;
input Integer index;
output String result;
end getNthAlgorithm;
getNthAlgorithmItem¶
function getNthAlgorithmItem
input TypeName class_;
input Integer index;
output String result;
end getNthAlgorithmItem;
getNthAnnotationString¶
function getNthAnnotationString
input TypeName class_;
input Integer index;
output String result;
end getNthAnnotationString;
getNthConnection¶
function getNthConnection
input TypeName className;
input Integer index;
output String[:] result;
end getNthConnection;
getNthEquation¶
function getNthEquation
input TypeName class_;
input Integer index;
output String result;
end getNthEquation;
getNthEquationItem¶
function getNthEquationItem
input TypeName class_;
input Integer index;
output String result;
end getNthEquationItem;
getNthImport¶
function getNthImport
input TypeName class_;
input Integer index;
output String out[3] "{\"Path\",\"Id\",\"Kind\"}";
end getNthImport;
getNthInitialAlgorithm¶
function getNthInitialAlgorithm
input TypeName class_;
input Integer index;
output String result;
end getNthInitialAlgorithm;
getNthInitialAlgorithmItem¶
function getNthInitialAlgorithmItem
input TypeName class_;
input Integer index;
output String result;
end getNthInitialAlgorithmItem;
getNthInitialEquation¶
function getNthInitialEquation
input TypeName class_;
input Integer index;
output String result;
end getNthInitialEquation;
getNthInitialEquationItem¶
function getNthInitialEquationItem
input TypeName class_;
input Integer index;
output String result;
end getNthInitialEquationItem;
getOrderConnections¶
function getOrderConnections
output Boolean orderConnections;
end getOrderConnections;
getPackages¶
function getPackages
input TypeName class_ = $Code(AllLoadedClasses);
output TypeName classNames[:];
end getPackages;
getParameterNames¶
function getParameterNames
input TypeName class_;
output String[:] parameters;
end getParameterNames;
getParameterValue¶
function getParameterValue
input TypeName class_;
input String parameterName;
output String parameterValue;
end getParameterValue;
getSettings¶
function getSettings
output String settings;
end getSettings;
getShowAnnotations¶
function getShowAnnotations
output Boolean show;
end getShowAnnotations;
getSimulationOptions¶
function getSimulationOptions
input TypeName name;
input Real defaultStartTime = 0.0;
input Real defaultStopTime = 1.0;
input Real defaultTolerance = 1e-6;
input Integer defaultNumberOfIntervals = 500 "May be overridden by defining defaultInterval instead";
input Real defaultInterval = 0.0 "If = 0.0, then numberOfIntervals is used to calculate the step size";
output Real startTime;
output Real stopTime;
output Real tolerance;
output Integer numberOfIntervals;
output Real interval;
end getSimulationOptions;
getSourceFile¶
function getSourceFile
input TypeName class_;
output String filename "empty on failure";
end getSourceFile;
getTearingMethod¶
function getTearingMethod
output String selected;
end getTearingMethod;
getTempDirectoryPath¶
function getTempDirectoryPath
output String tempDirectoryPath;
end getTempDirectoryPath;
getTimeStamp¶
function getTimeStamp
input TypeName cl;
output Real timeStamp;
output String timeStampAsString;
end getTimeStamp;
getTransitions¶
function getTransitions
input TypeName cl;
output String[:, :] transitions;
end getTransitions;
getUsedClassNames¶
function getUsedClassNames
input TypeName className;
output TypeName classNames[:];
end getUsedClassNames;
getUses¶
function getUses
input TypeName pack;
output String[:, :] uses;
end getUses;
getVectorizationLimit¶
function getVectorizationLimit
output Integer vectorizationLimit;
end getVectorizationLimit;
getVersion¶
function getVersion
input TypeName cl = $Code(OpenModelica);
output String version;
end getVersion;
help¶
function help
input String topic = "topics";
output String helpText;
end help;
iconv¶
function iconv
input String string;
input String from;
input String to = "UTF-8";
output String result;
end iconv;
importFMU¶
function importFMU
input String filename "the fmu file name";
input String workdir = "<default>" "The output directory for imported FMU files. <default> will put the files to current working directory.";
input Integer loglevel = 3 "loglevel_nothing=0;loglevel_fatal=1;loglevel_error=2;loglevel_warning=3;loglevel_info=4;loglevel_verbose=5;loglevel_debug=6";
input Boolean fullPath = false "When true the full output path is returned otherwise only the file name.";
input Boolean debugLogging = false "When true the FMU's debug output is printed.";
input Boolean generateInputConnectors = true "When true creates the input connector pins.";
input Boolean generateOutputConnectors = true "When true creates the output connector pins.";
input TypeName modelName = $Code(Default) "Name of the generated model. If default then the name is auto generated using FMU information.";
output String generatedFileName "Returns the full path of the generated file.";
end importFMU;
importFMUModelDescription¶
function importFMUModelDescription
input String filename "the fmu file name";
input String workdir = "<default>" "The output directory for imported FMU files. <default> will put the files to current working directory.";
input Integer loglevel = 3 "loglevel_nothing=0;loglevel_fatal=1;loglevel_error=2;loglevel_warning=3;loglevel_info=4;loglevel_verbose=5;loglevel_debug=6";
input Boolean fullPath = false "When true the full output path is returned otherwise only the file name.";
input Boolean debugLogging = false "When true the FMU's debug output is printed.";
input Boolean generateInputConnectors = true "When true creates the input connector pins.";
input Boolean generateOutputConnectors = true "When true creates the output connector pins.";
output String generatedFileName "Returns the full path of the generated file.";
end importFMUModelDescription;
inferBindings¶
function inferBindings
input TypeName path;
output Boolean success;
end inferBindings;
installPackage¶
function installPackage
input TypeName pkg;
input String version = "";
input Boolean exactMatch = false;
output Boolean result;
end installPackage;
instantiateModel¶
function instantiateModel
input TypeName className;
output String result;
end instantiateModel;
isBlock¶
function isBlock
input TypeName cl;
output Boolean b;
end isBlock;
isClass¶
function isClass
input TypeName cl;
output Boolean b;
end isClass;
isConnector¶
function isConnector
input TypeName cl;
output Boolean b;
end isConnector;
isEnumeration¶
function isEnumeration
input TypeName cl;
output Boolean b;
end isEnumeration;
isExperiment¶
function isExperiment
input TypeName name;
output Boolean res;
end isExperiment;
isFunction¶
function isFunction
input TypeName cl;
output Boolean b;
end isFunction;
isModel¶
function isModel
input TypeName cl;
output Boolean b;
end isModel;
isOperator¶
function isOperator
input TypeName cl;
output Boolean b;
end isOperator;
isOperatorFunction¶
function isOperatorFunction
input TypeName cl;
output Boolean b;
end isOperatorFunction;
isOperatorRecord¶
function isOperatorRecord
input TypeName cl;
output Boolean b;
end isOperatorRecord;
isOptimization¶
function isOptimization
input TypeName cl;
output Boolean b;
end isOptimization;
isPackage¶
function isPackage
input TypeName cl;
output Boolean b;
end isPackage;
isPartial¶
function isPartial
input TypeName cl;
output Boolean b;
end isPartial;
isProtectedClass¶
function isProtectedClass
input TypeName cl;
input String c2;
output Boolean b;
end isProtectedClass;
isRecord¶
function isRecord
input TypeName cl;
output Boolean b;
end isRecord;
isShortDefinition¶
function isShortDefinition
input TypeName class_;
output Boolean isShortCls;
end isShortDefinition;
isType¶
function isType
input TypeName cl;
output Boolean b;
end isType;
linearize¶
function linearize
input TypeName className "the class that should simulated";
input Real startTime = "<default>" "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real stepSize = 0.002 "step size that is used for the result file. <default> = 0.002";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = "<default>" "integration method used for simulation. <default> = dassl";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"\"";
input Boolean storeInTemp = false "storeInTemp. <default> = false";
input Boolean noClean = false "noClean. <default> = false";
input String options = "<default>" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "<default>" "cflags. <default> = \"\"";
input String simflags = "<default>" "simflags. <default> = \"\"";
output String linearizationResult;
end linearize;
list¶
function list
input TypeName class_ = $Code(AllLoadedClasses);
input Boolean interfaceOnly = false;
input Boolean shortOnly = false "only short class definitions";
input ExportKind exportKind = ExportKind.Absyn;
output String contents;
end list;
listFile¶
function listFile
input TypeName class_;
input Boolean nestedClasses = true;
output String contents;
end listFile;
listVariables¶
function listVariables
output TypeName variables[:];
end listVariables;
loadEncryptedPackage¶
function loadEncryptedPackage
input String fileName;
input String workdir = "<default>" "The output directory for imported encrypted files. <default> will put the files to current working directory.";
input Boolean skipUnzip = false "Skips the unzip of .mol if true. In that case we expect the files are already extracted e.g., because of parseEncryptedPackage() call.";
input Boolean uses = true;
input Boolean notify = true "Give a notification of the libraries and versions that were loaded";
input Boolean requireExactVersion = false "If the version is required to be exact, if there is a uses Modelica(version=\"3.2\"), Modelica 3.2.1 will not match it.";
output Boolean success;
end loadEncryptedPackage;
loadFile¶
function loadFile
input String fileName;
input String encoding = "UTF-8";
input Boolean uses = true;
input Boolean notify = true "Give a notification of the libraries and versions that were loaded";
input Boolean requireExactVersion = false "If the version is required to be exact, if there is a uses Modelica(version=\"3.2\"), Modelica 3.2.1 will not match it.";
output Boolean success;
end loadFile;
loadFileInteractive¶
function loadFileInteractive
input String filename;
input String encoding = "UTF-8";
input Boolean uses = true;
input Boolean notify = true "Give a notification of the libraries and versions that were loaded";
input Boolean requireExactVersion = false "If the version is required to be exact, if there is a uses Modelica(version=\"3.2\"), Modelica 3.2.1 will not match it.";
output TypeName names[:];
end loadFileInteractive;
loadFileInteractiveQualified¶
function loadFileInteractiveQualified
input String filename;
input String encoding = "UTF-8";
output TypeName names[:];
end loadFileInteractiveQualified;
loadFiles¶
function loadFiles
input String[:] fileNames;
input String encoding = "UTF-8";
input Integer numThreads = OpenModelica.Scripting.numProcessors();
input Boolean uses = true;
input Boolean notify = true "Give a notification of the libraries and versions that were loaded";
input Boolean requireExactVersion = false "If the version is required to be exact, if there is a uses Modelica(version=\"3.2\"), Modelica 3.2.1 will not match it.";
output Boolean success;
end loadFiles;
loadModel¶
function loadModel
input TypeName className;
input String[:] priorityVersion = {"default"};
input Boolean notify = false "Give a notification of the libraries and versions that were loaded";
input String languageStandard = "" "Override the set language standard. Parse with the given setting, but do not change it permanently.";
input Boolean requireExactVersion = false "If the version is required to be exact, if there is a uses Modelica(version=\"3.2\"), Modelica 3.2.1 will not match it.";
output Boolean success;
end loadModel;
loadModelica3D¶
function loadModelica3D
input String version = "3.2.1";
output Boolean status;
end loadModelica3D;
loadOMSimulator¶
function loadOMSimulator
output Integer status;
end loadOMSimulator;
loadString¶
function loadString
input String data;
input String filename = "<interactive>";
input String encoding = "UTF-8";
input Boolean merge = false "if merge is true the parsed AST is merged with the existing AST, default to false which means that is replaced, not merged";
output Boolean success;
end loadString;
mkdir¶
function mkdir
input String newDirectory;
output Boolean success;
end mkdir;
modifierToJSON¶
function modifierToJSON
input String modifier;
input Boolean prettyPrint = false;
output String json;
end modifierToJSON;
moveClass¶
function moveClass
input TypeName className "the class that should be moved";
input Integer offset "Offset in the class list.";
output Boolean result;
end moveClass;
moveClassToBottom¶
function moveClassToBottom
input TypeName className;
output Boolean result;
end moveClassToBottom;
moveClassToTop¶
function moveClassToTop
input TypeName className;
output Boolean result;
end moveClassToTop;
ngspicetoModelica¶
function ngspicetoModelica
input String netlistfileName;
output Boolean success = false;
end ngspicetoModelica;
numProcessors¶
function numProcessors
output Integer result;
end numProcessors;
oms_RunFile¶
function oms_RunFile
input String filename;
output Integer status;
end oms_RunFile;
oms_addBus¶
function oms_addBus
input String cref;
output Integer status;
end oms_addBus;
oms_addConnection¶
function oms_addConnection
input String crefA;
input String crefB;
output Integer status;
end oms_addConnection;
oms_addConnector¶
function oms_addConnector
input String cref;
input oms_causality causality;
input oms_signal_type type_;
output Integer status;
end oms_addConnector;
oms_addConnectorToBus¶
function oms_addConnectorToBus
input String busCref;
input String connectorCref;
output Integer status;
end oms_addConnectorToBus;
oms_addConnectorToTLMBus¶
function oms_addConnectorToTLMBus
input String busCref;
input String connectorCref;
input String type_;
output Integer status;
end oms_addConnectorToTLMBus;
oms_addDynamicValueIndicator¶
function oms_addDynamicValueIndicator
input String signal;
input String lower;
input String upper;
input Real stepSize;
output Integer status;
end oms_addDynamicValueIndicator;
oms_addEventIndicator¶
function oms_addEventIndicator
input String signal;
output Integer status;
end oms_addEventIndicator;
oms_addExternalModel¶
function oms_addExternalModel
input String cref;
input String path;
input String startscript;
output Integer status;
end oms_addExternalModel;
oms_addSignalsToResults¶
function oms_addSignalsToResults
input String cref;
input String regex;
output Integer status;
end oms_addSignalsToResults;
oms_addStaticValueIndicator¶
function oms_addStaticValueIndicator
input String signal;
input Real lower;
input Real upper;
input Real stepSize;
output Integer status;
end oms_addStaticValueIndicator;
oms_addSubModel¶
function oms_addSubModel
input String cref;
input String fmuPath;
output Integer status;
end oms_addSubModel;
oms_addSystem¶
function oms_addSystem
input String cref;
input oms_system type_;
output Integer status;
end oms_addSystem;
oms_addTLMBus¶
function oms_addTLMBus
input String cref;
input oms_tlm_domain domain;
input Integer dimensions;
input oms_tlm_interpolation interpolation;
output Integer status;
end oms_addTLMBus;
oms_addTLMConnection¶
function oms_addTLMConnection
input String crefA;
input String crefB;
input Real delay;
input Real alpha;
input Real linearimpedance;
input Real angularimpedance;
output Integer status;
end oms_addTLMConnection;
oms_addTimeIndicator¶
function oms_addTimeIndicator
input String signal;
output Integer status;
end oms_addTimeIndicator;
oms_compareSimulationResults¶
function oms_compareSimulationResults
input String filenameA;
input String filenameB;
input String var;
input Real relTol;
input Real absTol;
output Integer status;
end oms_compareSimulationResults;
oms_copySystem¶
function oms_copySystem
input String source;
input String target;
output Integer status;
end oms_copySystem;
oms_delete¶
function oms_delete
input String cref;
output Integer status;
end oms_delete;
oms_deleteConnection¶
function oms_deleteConnection
input String crefA;
input String crefB;
output Integer status;
end oms_deleteConnection;
oms_deleteConnectorFromBus¶
function oms_deleteConnectorFromBus
input String busCref;
input String connectorCref;
output Integer status;
end oms_deleteConnectorFromBus;
oms_deleteConnectorFromTLMBus¶
function oms_deleteConnectorFromTLMBus
input String busCref;
input String connectorCref;
output Integer status;
end oms_deleteConnectorFromTLMBus;
oms_export¶
function oms_export
input String cref;
input String filename;
output Integer status;
end oms_export;
oms_exportDependencyGraphs¶
function oms_exportDependencyGraphs
input String cref;
input String initialization;
input String event;
input String simulation;
output Integer status;
end oms_exportDependencyGraphs;
oms_exportSnapshot¶
function oms_exportSnapshot
input String cref;
output String contents;
output Integer status;
end oms_exportSnapshot;
oms_extractFMIKind¶
function oms_extractFMIKind
input String filename;
output Integer kind;
output Integer status;
end oms_extractFMIKind;
oms_faultInjection¶
function oms_faultInjection
input String signal;
input oms_fault_type faultType;
input Real faultValue;
output Integer status;
end oms_faultInjection;
oms_getBoolean¶
function oms_getBoolean
input String cref;
output Boolean value;
output Integer status;
end oms_getBoolean;
oms_getFixedStepSize¶
function oms_getFixedStepSize
input String cref;
output Real stepSize;
output Integer status;
end oms_getFixedStepSize;
oms_getInteger¶
function oms_getInteger
input String cref;
input Integer value;
output Integer status;
end oms_getInteger;
oms_getModelState¶
function oms_getModelState
input String cref;
output Integer modelState;
output Integer status;
end oms_getModelState;
oms_getReal¶
function oms_getReal
input String cref;
output Real value;
output Integer status;
end oms_getReal;
oms_getSolver¶
function oms_getSolver
input String cref;
output Integer solver;
output Integer status;
end oms_getSolver;
oms_getStartTime¶
function oms_getStartTime
input String cref;
output Real startTime;
output Integer status;
end oms_getStartTime;
oms_getStopTime¶
function oms_getStopTime
input String cref;
output Real stopTime;
output Integer status;
end oms_getStopTime;
oms_getSubModelPath¶
function oms_getSubModelPath
input String cref;
output String path;
output Integer status;
end oms_getSubModelPath;
oms_getSystemType¶
function oms_getSystemType
input String cref;
output Integer type_;
output Integer status;
end oms_getSystemType;
oms_getTolerance¶
function oms_getTolerance
input String cref;
output Real absoluteTolerance;
output Real relativeTolerance;
output Integer status;
end oms_getTolerance;
oms_getVariableStepSize¶
function oms_getVariableStepSize
input String cref;
output Real initialStepSize;
output Real minimumStepSize;
output Real maximumStepSize;
output Integer status;
end oms_getVariableStepSize;
oms_getVersion¶
function oms_getVersion
output String version;
end oms_getVersion;
oms_importFile¶
function oms_importFile
input String filename;
output String cref;
output Integer status;
end oms_importFile;
oms_importSnapshot¶
function oms_importSnapshot
input String cref;
input String snapshot;
output Integer status;
end oms_importSnapshot;
oms_initialize¶
function oms_initialize
input String cref;
output Integer status;
end oms_initialize;
oms_instantiate¶
function oms_instantiate
input String cref;
output Integer status;
end oms_instantiate;
oms_list¶
function oms_list
input String cref;
output String contents;
output Integer status;
end oms_list;
oms_listUnconnectedConnectors¶
function oms_listUnconnectedConnectors
input String cref;
output String contents;
output Integer status;
end oms_listUnconnectedConnectors;
oms_loadSnapshot¶
function oms_loadSnapshot
input String cref;
input String snapshot;
output String newCref;
output Integer status;
end oms_loadSnapshot;
oms_newModel¶
function oms_newModel
input String cref;
output Integer status;
end oms_newModel;
oms_removeSignalsFromResults¶
function oms_removeSignalsFromResults
input String cref;
input String regex;
output Integer status;
end oms_removeSignalsFromResults;
oms_rename¶
function oms_rename
input String cref;
input String newCref;
output Integer status;
end oms_rename;
oms_reset¶
function oms_reset
input String cref;
output Integer status;
end oms_reset;
oms_setBoolean¶
function oms_setBoolean
input String cref;
input Boolean value;
output Integer status;
end oms_setBoolean;
oms_setCommandLineOption¶
function oms_setCommandLineOption
input String cmd;
output Integer status;
end oms_setCommandLineOption;
oms_setFixedStepSize¶
function oms_setFixedStepSize
input String cref;
input Real stepSize;
output Integer status;
end oms_setFixedStepSize;
oms_setInteger¶
function oms_setInteger
input String cref;
input Integer value;
output Integer status;
end oms_setInteger;
oms_setLogFile¶
function oms_setLogFile
input String filename;
output Integer status;
end oms_setLogFile;
oms_setLoggingInterval¶
function oms_setLoggingInterval
input String cref;
input Real loggingInterval;
output Integer status;
end oms_setLoggingInterval;
oms_setLoggingLevel¶
function oms_setLoggingLevel
input Integer logLevel;
output Integer status;
end oms_setLoggingLevel;
oms_setReal¶
function oms_setReal
input String cref;
input Real value;
output Integer status;
end oms_setReal;
oms_setRealInputDerivative¶
function oms_setRealInputDerivative
input String cref;
input Real value;
output Integer status;
end oms_setRealInputDerivative;
oms_setResultFile¶
function oms_setResultFile
input String cref;
input String filename;
input Integer bufferSize;
output Integer status;
end oms_setResultFile;
oms_setSignalFilter¶
function oms_setSignalFilter
input String cref;
input String regex;
output Integer status;
end oms_setSignalFilter;
oms_setSolver¶
function oms_setSolver
input String cref;
input oms_solver solver;
output Integer status;
end oms_setSolver;
oms_setStartTime¶
function oms_setStartTime
input String cref;
input Real startTime;
output Integer status;
end oms_setStartTime;
oms_setStopTime¶
function oms_setStopTime
input String cref;
input Real stopTime;
output Integer status;
end oms_setStopTime;
oms_setTLMPositionAndOrientation¶
function oms_setTLMPositionAndOrientation
input String cref;
input Real x1;
input Real x2;
input Real x3;
input Real A11;
input Real A12;
input Real A13;
input Real A21;
input Real A22;
input Real A23;
input Real A31;
input Real A32;
input Real A33;
output Integer status;
end oms_setTLMPositionAndOrientation;
oms_setTLMSocketData¶
function oms_setTLMSocketData
input String cref;
input String address;
input Integer managerPort;
input Integer monitorPort;
output Integer status;
end oms_setTLMSocketData;
oms_setTempDirectory¶
function oms_setTempDirectory
input String newTempDir;
output Integer status;
end oms_setTempDirectory;
oms_setTolerance¶
function oms_setTolerance
input String cref;
input Real absoluteTolerance;
input Real relativeTolerance;
output Integer status;
end oms_setTolerance;
oms_setVariableStepSize¶
function oms_setVariableStepSize
input String cref;
input Real initialStepSize;
input Real minimumStepSize;
input Real maximumStepSize;
output Integer status;
end oms_setVariableStepSize;
oms_setWorkingDirectory¶
function oms_setWorkingDirectory
input String newWorkingDir;
output Integer status;
end oms_setWorkingDirectory;
oms_simulate¶
function oms_simulate
input String cref;
output Integer status;
end oms_simulate;
oms_stepUntil¶
function oms_stepUntil
input String cref;
input Real stopTime;
output Integer status;
end oms_stepUntil;
oms_terminate¶
function oms_terminate
input String cref;
output Integer status;
end oms_terminate;
optimize¶
function optimize
input TypeName className "the class that should simulated";
input Real startTime = "<default>" "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real stepSize = 0.002 "step size that is used for the result file. <default> = 0.002";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = DAE.SCONST("optimization") "optimize a modelica/optimica model.";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"\"";
input Boolean storeInTemp = false "storeInTemp. <default> = false";
input Boolean noClean = false "noClean. <default> = false";
input String options = "<default>" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "<default>" "cflags. <default> = \"\"";
input String simflags = "<default>" "simflags. <default> = \"\"";
output String optimizationResults;
end optimize;
parseEncryptedPackage¶
function parseEncryptedPackage
input String fileName;
input String workdir = "<default>" "The output directory for imported encrypted files. <default> will put the files to current working directory.";
output TypeName names[:];
end parseEncryptedPackage;
parseFile¶
function parseFile
input String filename;
input String encoding = "UTF-8";
output TypeName names[:];
end parseFile;
parseString¶
function parseString
input String data;
input String filename = "<interactive>";
output TypeName names[:];
end parseString;
plot¶
function plot
input VariableNames vars "The variables you want to plot";
input Boolean externalWindow = false "Opens the plot in a new plot window";
input String fileName = "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String title = "" "This text will be used as the diagram title.";
input String grid = "simple" "Sets the grid for the plot i.e simple, detailed, none.";
input Boolean logX = false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY = false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel = "time" "This text will be used as the horizontal label in the diagram.";
input String yLabel = "" "This text will be used as the vertical label in the diagram.";
input Real xRange[2] = {0.0, 0.0} "Determines the horizontal interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real yRange[2] = {0.0, 0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth = 1.0 "Sets the width of the curve.";
input Integer curveStyle = 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
end plot;
plotAll¶
function plotAll
input Boolean externalWindow = false "Opens the plot in a new plot window";
input String fileName = "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String title = "" "This text will be used as the diagram title.";
input String grid = "simple" "Sets the grid for the plot i.e simple, detailed, none.";
input Boolean logX = false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY = false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel = "time" "This text will be used as the horizontal label in the diagram.";
input String yLabel = "" "This text will be used as the vertical label in the diagram.";
input Real xRange[2] = {0.0, 0.0} "Determines the horizontal interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real yRange[2] = {0.0, 0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth = 1.0 "Sets the width of the curve.";
input Integer curveStyle = 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
end plotAll;
plotParametric¶
function plotParametric
input VariableName xVariable;
input VariableName yVariable;
input Boolean externalWindow = false "Opens the plot in a new plot window";
input String fileName = "<default>" "The filename containing the variables. <default> will read the last simulation result";
input String title = "" "This text will be used as the diagram title.";
input String grid = "simple" "Sets the grid for the plot i.e simple, detailed, none.";
input Boolean logX = false "Determines whether or not the horizontal axis is logarithmically scaled.";
input Boolean logY = false "Determines whether or not the vertical axis is logarithmically scaled.";
input String xLabel = "" "This text will be used as the horizontal label in the diagram.";
input String yLabel = "" "This text will be used as the vertical label in the diagram.";
input Real xRange[2] = {0.0, 0.0} "Determines the horizontal interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real yRange[2] = {0.0, 0.0} "Determines the vertical interval that is visible in the diagram. {0,0} will select a suitable range.";
input Real curveWidth = 1.0 "Sets the width of the curve.";
input Integer curveStyle = 1 "Sets the style of the curve. SolidLine=1, DashLine=2, DotLine=3, DashDotLine=4, DashDotDotLine=5, Sticks=6, Steps=7.";
input String legendPosition = "top" "Sets the POSITION of the legend i.e left, right, top, bottom, none.";
input String footer = "" "This text will be used as the diagram footer.";
input Boolean autoScale = true "Use auto scale while plotting.";
input Boolean forceOMPlot = false "if true launches OMPlot and doesn't call callback function even if it is defined.";
output Boolean success "Returns true on success";
end plotParametric;
readFile¶
impure function readFile
input String fileName;
output String contents;
end readFile;
readFileNoNumeric¶
function readFileNoNumeric
input String fileName;
output String contents;
end readFileNoNumeric;
readSimulationResult¶
function readSimulationResult
input String filename;
input VariableNames variables;
input Integer size = 0 "0=read any size... If the size is not the same as the result-file, this function fails";
output Real result[:, :];
end readSimulationResult;
readSimulationResultSize¶
function readSimulationResultSize
input String fileName;
output Integer sz;
end readSimulationResultSize;
readSimulationResultVars¶
function readSimulationResultVars
input String fileName;
input Boolean readParameters = true;
input Boolean openmodelicaStyle = false;
output String[:] vars;
end readSimulationResultVars;
realpath¶
function realpath
input String name "Absolute or relative file or directory name";
output String fullName "Full path of 'name'";
end realpath;
reduceTerms¶
function reduceTerms
input TypeName className "the class that should be built";
input Real startTime = 0.0 "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = "dassl" "integration method used for simulation. <default> = dassl";
input String fileNamePrefix = "" "fileNamePrefix. <default> = \"\"";
input String options = "" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "" "cflags. <default> = \"\"";
input String simflags = "" "simflags. <default> = \"\"";
input String labelstoCancel = "";
output String[2] buildModelResults;
end reduceTerms;
regex¶
function regex
input String str;
input String re;
input Integer maxMatches = 1 "The maximum number of matches that will be returned";
input Boolean extended = true "Use POSIX extended or regular syntax";
input Boolean caseInsensitive = false;
output Integer numMatches "-1 is an error, 0 means no match, else returns a number 1..maxMatches";
output String matchedSubstrings[maxMatches] "unmatched strings are returned as empty";
end regex;
regexBool¶
function regexBool
input String str;
input String re;
input Boolean extended = true "Use POSIX extended or regular syntax";
input Boolean caseInsensitive = false;
output Boolean matches;
end regexBool;
regularFileExists¶
function regularFileExists
input String fileName;
output Boolean exists;
end regularFileExists;
reloadClass¶
function reloadClass
input TypeName name;
input String encoding = "UTF-8";
output Boolean success;
end reloadClass;
remove¶
function remove
input String path;
output Boolean success "Returns true on success.";
end remove;
removeComponentModifiers¶
function removeComponentModifiers
input TypeName class_;
input String componentName;
input Boolean keepRedeclares = false;
output Boolean success;
end removeComponentModifiers;
removeElementModifiers¶
function removeElementModifiers
input TypeName className;
input String componentName;
input Boolean keepRedeclares = false;
output Boolean success;
end removeElementModifiers;
removeExtendsModifiers¶
function removeExtendsModifiers
input TypeName className;
input TypeName baseClassName;
input Boolean keepRedeclares = false;
output Boolean success;
end removeExtendsModifiers;
reopenStandardStream¶
function reopenStandardStream
input StandardStream _stream;
input String filename;
output Boolean success;
end reopenStandardStream;
restoreAST¶
function restoreAST
input Integer id;
output Boolean success;
end restoreAST;
rewriteBlockCall¶
function rewriteBlockCall
input TypeName className;
input TypeName inDefs;
output Boolean success;
end rewriteBlockCall;
runConversionScript¶
function runConversionScript
input TypeName packageToConvert;
input String scriptFile;
output Boolean success;
end runConversionScript;
runScript¶
impure function runScript
input String fileName "*.mos";
output String result;
end runScript;
runScriptParallel¶
function runScriptParallel
input String scripts[:];
input Integer numThreads = numProcessors();
input Boolean useThreads = false;
output Boolean results[:];
end runScriptParallel;
save¶
function save
input TypeName className;
output Boolean success;
end save;
saveAll¶
function saveAll
input String fileName;
output Boolean success;
end saveAll;
saveModel¶
function saveModel
input String fileName;
input TypeName className;
output Boolean success;
end saveModel;
saveTotalModel¶
function saveTotalModel
input String fileName;
input TypeName className;
input Boolean stripAnnotations = false;
input Boolean stripComments = false;
input Boolean obfuscate = false;
output Boolean success;
end saveTotalModel;
saveTotalModelDebug¶
function saveTotalModelDebug
input String filename;
input TypeName className;
output Boolean success;
end saveTotalModelDebug;
saveTotalSCode¶
searchClassNames¶
function searchClassNames
input String searchText;
input Boolean findInText = false;
output TypeName classNames[:];
end searchClassNames;
setAnnotationVersion¶
function setAnnotationVersion
input String annotationVersion;
output Boolean success;
end setAnnotationVersion;
setCFlags¶
function setCFlags
input String inString;
output Boolean success;
end setCFlags;
setCXXCompiler¶
function setCXXCompiler
input String compiler;
output Boolean success;
end setCXXCompiler;
setCheapMatchingAlgorithm¶
function setCheapMatchingAlgorithm
input Integer matchingAlgorithm;
output Boolean success;
end setCheapMatchingAlgorithm;
setClassComment¶
function setClassComment
input TypeName class_;
input String filename;
output Boolean success;
end setClassComment;
setCommandLineOptions¶
function setCommandLineOptions
input String option;
output Boolean success;
end setCommandLineOptions;
setCompileCommand¶
function setCompileCommand
input String compileCommand;
output Boolean success;
end setCompileCommand;
setCompiler¶
function setCompiler
input String compiler;
output Boolean success;
end setCompiler;
setCompilerFlags¶
function setCompilerFlags
input String compilerFlags;
output Boolean success;
end setCompilerFlags;
setCompilerPath¶
function setCompilerPath
input String compilerPath;
output Boolean success;
end setCompilerPath;
setDebugFlags¶
function setDebugFlags
input String debugFlags;
output Boolean success;
end setDebugFlags;
setDefaultOpenCLDevice¶
function setDefaultOpenCLDevice
input Integer defdevid;
output Boolean success;
end setDefaultOpenCLDevice;
setDocumentationAnnotation¶
function setDocumentationAnnotation
input TypeName class_;
input String info = "";
input String revisions = "";
output Boolean bool;
end setDocumentationAnnotation;
setEnvironmentVar¶
function setEnvironmentVar
input String var;
input String value;
output Boolean success;
end setEnvironmentVar;
setIndexReductionMethod¶
function setIndexReductionMethod
input String method;
output Boolean success;
end setIndexReductionMethod;
setInitXmlStartValue¶
function setInitXmlStartValue
input String fileName;
input String variableName;
input String startValue;
input String outputFile;
output Boolean success = false;
end setInitXmlStartValue;
setInstallationDirectoryPath¶
function setInstallationDirectoryPath
input String installationDirectoryPath;
output Boolean success;
end setInstallationDirectoryPath;
setLanguageStandard¶
function setLanguageStandard
input String inVersion;
output Boolean success;
end setLanguageStandard;
setLinker¶
function setLinker
input String linker;
output Boolean success;
end setLinker;
setLinkerFlags¶
function setLinkerFlags
input String linkerFlags;
output Boolean success;
end setLinkerFlags;
setMatchingAlgorithm¶
function setMatchingAlgorithm
input String matchingAlgorithm;
output Boolean success;
end setMatchingAlgorithm;
setModelicaPath¶
function setModelicaPath
input String modelicaPath;
output Boolean success;
end setModelicaPath;
setNoSimplify¶
function setNoSimplify
input Boolean noSimplify;
output Boolean success;
end setNoSimplify;
setOrderConnections¶
function setOrderConnections
input Boolean orderConnections;
output Boolean success;
end setOrderConnections;
setPlotCommand¶
function setPlotCommand
input String plotCommand;
output Boolean success;
end setPlotCommand;
setPostOptModules¶
function setPostOptModules
input String modules;
output Boolean success;
end setPostOptModules;
setPreOptModules¶
function setPreOptModules
input String modules;
output Boolean success;
end setPreOptModules;
setShowAnnotations¶
function setShowAnnotations
input Boolean show;
output Boolean success;
end setShowAnnotations;
setSourceFile¶
function setSourceFile
input TypeName class_;
input String filename;
output Boolean success;
end setSourceFile;
setTearingMethod¶
function setTearingMethod
input String tearingMethod;
output Boolean success;
end setTearingMethod;
setTempDirectoryPath¶
function setTempDirectoryPath
input String tempDirectoryPath;
output Boolean success;
end setTempDirectoryPath;
setVectorizationLimit¶
function setVectorizationLimit
input Integer vectorizationLimit;
output Boolean success;
end setVectorizationLimit;
simulate¶
function simulate
input TypeName className "the class that should simulated";
input Real startTime = "<default>" "the start time of the simulation. <default> = 0.0";
input Real stopTime = 1.0 "the stop time of the simulation. <default> = 1.0";
input Integer numberOfIntervals = 500 "number of intervals in the result file. <default> = 500";
input Real tolerance = 1e-6 "tolerance used by the integration method. <default> = 1e-6";
input String method = "<default>" "integration method used for simulation. <default> = dassl";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"\"";
input String options = "<default>" "options. <default> = \"\"";
input String outputFormat = "mat" "Format for the result file. <default> = \"mat\"";
input String variableFilter = ".*" "Only variables fully matching the regexp are stored in the result file. <default> = \".*\"";
input String cflags = "<default>" "cflags. <default> = \"\"";
input String simflags = "<default>" "simflags. <default> = \"\"";
output SimulationResult simulationResults;
record SimulationResult
String resultFile;
String simulationOptions;
String messages;
Real timeFrontend;
Real timeBackend;
Real timeSimCode;
Real timeTemplates;
Real timeCompile;
Real timeSimulation;
Real timeTotal;
end SimulationResult;
end simulate;
solveLinearSystem¶
function solveLinearSystem
input Real[size(B, 1), size(B, 1)] A;
input Real[:] B;
output Real[size(B, 1)] X;
output Integer info;
end solveLinearSystem;
sortStrings¶
function sortStrings
input String arr[:];
output String sorted[:];
end sortStrings;
stat¶
impure function stat
input String fileName;
output Boolean success;
output Real fileSize;
output Real mtime;
end stat;
storeAST¶
function storeAST
output Integer id;
end storeAST;
stringReplace¶
function stringReplace
input String str;
input String source;
input String target;
output String res;
end stringReplace;
stringSplit¶
function stringSplit
input String string;
input String token "single character only";
output String[:] strings;
end stringSplit;
stringTypeName¶
function stringTypeName
input String str;
output TypeName cl;
end stringTypeName;
stringVariableName¶
function stringVariableName
input String str;
output VariableName cl;
end stringVariableName;
strtok¶
function strtok
input String string;
input String token;
output String[:] strings;
end strtok;
system¶
impure function system
input String callStr "String to call: sh -c $callStr";
input String outputFile = "" "The output is redirected to this file (unless already done by callStr)";
output Integer retval "Return value of the system call; usually 0 on success";
end system;
system_parallel¶
impure function system_parallel
input String callStr[:] "String to call: sh -c $callStr";
input Integer numThreads = numProcessors();
output Integer retval[:] "Return value of the system call; usually 0 on success";
end system_parallel;
testsuiteFriendlyName¶
function testsuiteFriendlyName
input String path;
output String fixed;
end testsuiteFriendlyName;
threadWorkFailed¶
translateGraphics¶
function translateGraphics
input TypeName className;
output String result;
end translateGraphics;
translateModelFMU¶
function translateModelFMU
input TypeName className "the class that should translated";
input String version = "2.0" "FMU version, 1.0 or 2.0.";
input String fmuType = "me" "FMU type, me (model exchange), cs (co-simulation), me_cs (both model exchange and co-simulation)";
input String fileNamePrefix = "<default>" "fileNamePrefix. <default> = \"className\"";
input Boolean includeResources = false "include Modelica based resources via loadResource or not";
output String generatedFileName "Returns the full path of the generated FMU.";
end translateModelFMU;
typeNameString¶
function typeNameString
input TypeName cl;
output String out;
end typeNameString;
typeNameStrings¶
function typeNameStrings
input TypeName cl;
output String out[:];
end typeNameStrings;
typeOf¶
function typeOf
input VariableName variableName;
output String result;
end typeOf;
unloadOMSimulator¶
function unloadOMSimulator
output Integer status;
end unloadOMSimulator;
updateConnection¶
function updateConnection
input TypeName className;
input String from;
input String to;
input ExpressionOrModification annotate;
output Boolean result;
end updateConnection;
updateConnectionAnnotation¶
function updateConnectionAnnotation
input TypeName className;
input String from;
input String to;
input String annotate;
output Boolean result;
end updateConnectionAnnotation;
updateConnectionNames¶
function updateConnectionNames
input TypeName className;
input String from;
input String to;
input String fromNew;
input String toNew;
output Boolean result;
end updateConnectionNames;
updateInitialState¶
function updateInitialState
input TypeName cl;
input String state;
input ExpressionOrModification annotate;
output Boolean bool;
end updateInitialState;
updatePackageIndex¶
function updatePackageIndex
output Boolean result;
end updatePackageIndex;
updateTransition¶
function updateTransition
input TypeName cl;
input String from;
input String to;
input String oldCondition;
input Boolean oldImmediate;
input Boolean oldReset;
input Boolean oldSynchronize;
input Integer oldPriority;
input String newCondition;
input Boolean newImmediate;
input Boolean newReset;
input Boolean newSynchronize;
input Integer newPriority;
input ExpressionOrModification annotate;
output Boolean bool;
end updateTransition;
upgradeInstalledPackages¶
function upgradeInstalledPackages
input Boolean installNewestVersions = true;
output Boolean result;
end upgradeInstalledPackages;
uriToFilename¶
function uriToFilename
input String uri;
output String filename = "";
end uriToFilename;
val¶
function val
input VariableName var;
input Real timePoint = 0.0;
input String fileName = "<default>" "The contents of the currentSimulationResult variable";
output Real valAtTime;
end val;
verifyCompiler¶
function verifyCompiler
output Boolean compilerWorks;
end verifyCompiler;
writeFile¶
impure function writeFile
input String fileName;
input String data;
input Boolean append = false;
output Boolean success;
end writeFile;
Simulation Parameter Sweep¶
Following example shows how to update the parameters and re-run the simulation without compiling the model.
loadFile("BouncingBall.mo");
getErrorString();
// build the model once
buildModel(BouncingBall);
getErrorString();
for i in 1:3 loop
// We update the parameter e start value from 0.7 to "0.7 + i".
value := 0.7 + i;
// call the generated simulation code to produce a result file BouncingBall%i%_res.mat
system("./BouncingBall -override=e="+String(value)+" -r=BouncingBall" + String(i) + "_res.mat");
getErrorString();
end for;
We used the BouncingBall.mo in the example above. The above example produces three result files each containing different start value for e i.e., 1.7, 2.7, 3.7.
Examples¶
The following is an interactive session with the OpenModelica environment including some of the abovementioned commands and examples. First we start the system, and use the command line interface from OMShell, OMNotebook, or command window of some of the other tools.
We type in a very small model:
model Test "Testing OpenModelica Scripts"
Real x, y;
equation
x = 5.0+time; y = 6.0;
end Test;
We give the command to flatten a model:
>>> instantiateModel(Test)
class Test "Testing OpenModelica Scripts"
Real x;
Real y;
equation
x = 5.0 + time;
y = 6.0;
end Test;
A range expression is typed in:
>>> a:=1:10
{1,2,3,4,5,6,7,8,9,10}
It is multiplied by 2:
>>> a*2
{2,4,6,8,10,12,14,16,18,20}
The variables are cleared:
>>> clearVariables()
true
We print the loaded class test from its internal representation:
>>> list(Test)
model Test "Testing OpenModelica Scripts"
Real x, y;
equation
x = 5.0 + time;
y = 6.0;
end Test;
We get the name and other properties of a class:
>>> getClassNames()
{Test,ProfilingTest}
>>> getClassComment(Test)
"Testing OpenModelica Scripts"
>>> isPartial(Test)
false
>>> isPackage(Test)
false
>>> isModel(Test)
true
>>> checkModel(Test)
"Check of Test completed successfully.
Class Test has 2 equation(s) and 2 variable(s).
2 of these are trivial equation(s)."
The common combination of a simulation followed by getting a value and doing a plot:
>>> simulate(Test, stopTime=3.0)
record SimulationResult
resultFile = "«DOCHOME»/Test_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 3.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
stdout | info | Time measurements are stored in Test_prof.html (human-readable) and Test_prof.xml (for XSL transforms or more details)
",
timeFrontend = 0.002377549,
timeBackend = 0.002397005,
timeSimCode = 0.000958438,
timeTemplates = 0.00334907,
timeCompile = 0.538506408,
timeSimulation = 0.037385957,
timeTotal = 0.585127955
end SimulationResult;
>>> val(x , 2.0)
7.0
>>> plotall()
Interactive Function Calls, Reading, and Writing¶
We enter an assignment of a vector expression, created by the range construction expression 1:12, to be stored in the variable x. The type and the value of the expression is returned.
>>> x := 1:12
{1,2,3,4,5,6,7,8,9,10,11,12}
The function bubblesort is called to sort this vector in descending order. The sorted result is returned together with its type. Note that the result vector is of type Real[:], instantiated as Real[12], since this is the declared type of the function result. The input Integer vector was automatically converted to a Real vector according to the Modelica type coercion rules.
>>> loadFile(getInstallationDirectoryPath() + "/share/doc/omc/testmodels/bubblesort.mo")
true
>>> bubblesort(x)
{12.0,11.0,10.0,9.0,8.0,7.0,6.0,5.0,4.0,3.0,2.0,1.0}
Now we want to try another small application, a simplex algorithm for optimization. First read in a small matrix containing coefficients that define a simplex problem to be solved:
>>> a := {
{-1,-1,-1, 0, 0, 0, 0, 0, 0},
{-1, 1, 0, 1, 0, 0, 0, 0, 5},
{ 1, 4, 0, 0, 1, 0, 0, 0, 45},
{ 2, 1, 0, 0, 0, 1, 0, 0, 27},
{ 3,-4, 0, 0, 0, 0, 1, 0, 24},
{ 0, 0, 1, 0, 0, 0, 0, 1, 4}
}
{{-1,-1,-1,0,0,0,0,0,0},{-1,1,0,1,0,0,0,0,5},{1,4,0,0,1,0,0,0,45},{2,1,0,0,0,1,0,0,27},{3,-4,0,0,0,0,1,0,24},{0,0,1,0,0,0,0,1,4}}
function pivot1
input Real b[:,:];
input Integer p;
input Integer q;
output Real a[size(b,1),size(b,2)];
protected
Integer M;
Integer N;
algorithm
a := b;
N := size(a,1)-1;
M := size(a,2)-1;
for j in 1:N loop
for k in 1:M loop
if j<>p and k<>q then
a[j,k] := a[j,k]-0.3*j;
end if;
end for;
end for;
a[p,q] := 0.05;
end pivot1;
function misc_simplex1
input Real matr[:,:];
output Real x[size(matr,2)-1];
output Real z;
output Integer q;
output Integer p;
protected
Real a[size(matr,1),size(matr,2)];
Integer M;
Integer N;
algorithm
N := size(a,1)-1;
M := size(a,2)-1;
a := matr;
p:=0;q:=0;
a := pivot1(a,p+1,q+1);
while not (q==(M) or p==(N)) loop
q := 0;
while not (q == (M) or a[0+1,q+1]>1) loop
q:=q+1;
end while;
p := 0;
while not (p == (N) or a[p+1,q+1]>0.1) loop
p:=p+1;
end while;
if (q < M) and (p < N) and(p>0) and (q>0) then
a := pivot1(a,p,q);
end if;
if(p<=0) and (q<=0) then
a := pivot1(a,p+1,q+1);
end if;
if(p<=0) and (q>0) then
a := pivot1(a,p+1,q);
end if;
if(p>0) and (q<=0) then
a := pivot1(a,p,q+1);
end if;
end while;
z := a[1,M];
x := {a[1,i] for i in 1:size(x,1)};
for i in 1:10 loop
for j in 1:M loop
x[j] := x[j]+x[j]*0.01;
end for;
end for;
end misc_simplex1;
Then call the simplex algorithm implemented as the Modelica function simplex1. This function returns four results, which are represented as a tuple of four return values:
>>> misc_simplex1(a)
({0.05523110627056022,-1.104622125411205,-1.104622125411205,0.0,0.0,0.0,0.0,0.0},0.0,8,1)