Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedKamp committed Nov 13, 2015
2 parents cda5d97 + fff2ee5 commit 8597f42
Show file tree
Hide file tree
Showing 49 changed files with 2,183 additions and 1,240 deletions.
2 changes: 1 addition & 1 deletion 3rdParty
Submodule 3rdParty updated 51 files
+2 −0 FMIL/Config.cmake/fmixml.cmake
+0 −98 SuiteSparse/AMD/Doc/AMD_UserGuide.bib
+0 −1,206 SuiteSparse/AMD/Doc/AMD_UserGuide.tex
+34 −0 SuiteSparse/BTF/Doc/ChangeLog
+504 −0 SuiteSparse/BTF/Doc/lesser.txt
+263 −0 SuiteSparse/BTF/Include/btf.h
+64 −0 SuiteSparse/BTF/Include/btf_internal.h
+59 −0 SuiteSparse/BTF/Lib/Makefile
+18 −0 SuiteSparse/BTF/Makefile
+109 −0 SuiteSparse/BTF/README.txt
+387 −0 SuiteSparse/BTF/Source/btf_maxtrans.c
+132 −0 SuiteSparse/BTF/Source/btf_order.c
+593 −0 SuiteSparse/BTF/Source/btf_strongcomp.c
+54 −0 SuiteSparse/CMakeLists.txt
+129 −0 SuiteSparse/COLAMD/Doc/ChangeLog
+504 −0 SuiteSparse/COLAMD/Doc/lesser.txt
+255 −0 SuiteSparse/COLAMD/Include/colamd.h
+32 −0 SuiteSparse/COLAMD/Lib/Makefile
+49 −0 SuiteSparse/COLAMD/Makefile
+127 −0 SuiteSparse/COLAMD/README.txt
+3,611 −0 SuiteSparse/COLAMD/Source/colamd.c
+24 −0 SuiteSparse/COLAMD/Source/colamd_global.c
+47 −0 SuiteSparse/KLU/Doc/ChangeLog
+44 −0 SuiteSparse/KLU/Doc/Makefile
+504 −0 SuiteSparse/KLU/Doc/lesser.txt
+831 −0 SuiteSparse/KLU/Include/klu.h
+243 −0 SuiteSparse/KLU/Include/klu_internal.h
+694 −0 SuiteSparse/KLU/Include/klu_version.h
+248 −0 SuiteSparse/KLU/Lib/Makefile
+24 −0 SuiteSparse/KLU/Makefile
+139 −0 SuiteSparse/KLU/README.txt
+773 −0 SuiteSparse/KLU/Source/klu.c
+488 −0 SuiteSparse/KLU/Source/klu_analyze.c
+369 −0 SuiteSparse/KLU/Source/klu_analyze_given.c
+60 −0 SuiteSparse/KLU/Source/klu_defaults.c
+570 −0 SuiteSparse/KLU/Source/klu_diagnostics.c
+142 −0 SuiteSparse/KLU/Source/klu_dump.c
+290 −0 SuiteSparse/KLU/Source/klu_extract.c
+545 −0 SuiteSparse/KLU/Source/klu_factor.c
+71 −0 SuiteSparse/KLU/Source/klu_free_numeric.c
+34 −0 SuiteSparse/KLU/Source/klu_free_symbolic.c
+1,008 −0 SuiteSparse/KLU/Source/klu_kernel.c
+225 −0 SuiteSparse/KLU/Source/klu_memory.c
+478 −0 SuiteSparse/KLU/Source/klu_refactor.c
+159 −0 SuiteSparse/KLU/Source/klu_scale.c
+396 −0 SuiteSparse/KLU/Source/klu_solve.c
+156 −0 SuiteSparse/KLU/Source/klu_sort.c
+465 −0 SuiteSparse/KLU/Source/klu_tsolve.c
+0 −1,026 SuiteSparse/UMFPACK/Doc/QuickStart.tex
+0 −322 SuiteSparse/UMFPACK/Doc/UserGuide.bib
+6 −6 graphstream/gs-netstream/c++/Makefile
444 changes: 253 additions & 191 deletions Compiler/BackEnd/BackendDAEUtil.mo

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -1065,6 +1065,9 @@ algorithm
DAE.CallAttributes attr;
DAE.Ident ident;
HashTable2.HashTable derConst;
String solverMethod;
Integer resolution;
Real startInterval;

// Note: Most of these functions check if a subexpression did a replacement.
// If it did not, we do not create a new copy of the expression (to save some memory).
Expand Down Expand Up @@ -1157,6 +1160,30 @@ algorithm
(expl_1,true) = replaceExpList(expl, repl, cond, {}, false);
then
(DAE.CALL(path,expl_1,attr),true);
// INTEGER_CLOCK
case (DAE.CLKCONST(DAE.INTEGER_CLOCK(intervalCounter=e, resolution=resolution)), repl, cond)
equation
e = replaceExp(e, repl, cond);
then
(DAE.CLKCONST(DAE.INTEGER_CLOCK(e, resolution)), true);
// REAL_CLOCK
case (DAE.CLKCONST(DAE.REAL_CLOCK(interval=e)), repl, cond)
equation
e = replaceExp(e, repl, cond);
then
(DAE.CLKCONST(DAE.REAL_CLOCK(e)), true);
// BOOLEAN_CLOCK
case (DAE.CLKCONST(DAE.BOOLEAN_CLOCK(condition=e, startInterval=startInterval)), repl, cond)
equation
e = replaceExp(e, repl, cond);
then
(DAE.CLKCONST(DAE.BOOLEAN_CLOCK(e, startInterval)), true);
// SOLVER_CLOCK
case (DAE.CLKCONST(DAE.SOLVER_CLOCK(c=e, solverMethod=solverMethod)), repl, cond)
equation
e = replaceExp(e, repl, cond);
then
(DAE.CLKCONST(DAE.SOLVER_CLOCK(e, solverMethod)), true);
case ((e as DAE.PARTEVALFUNCTION(path,expl,tp,t)),repl,cond)
equation
true = replaceExpCond(cond, e);
Expand Down
18 changes: 10 additions & 8 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -94,7 +94,7 @@ protected
HashSet.HashSet clkHS "contains all clocked variables";
list<BackendDAE.Equation> removedEqns;
list<BackendDAE.Var> dumpVars, dumpVars2;
list<tuple<BackendDAEFunc.optimizationModule, String, Boolean>> initOptModules;
list<tuple<BackendDAEFunc.optimizationModule, String>> initOptModules;
tuple<BackendDAEFunc.StructurallySingularSystemHandlerFunc, String, BackendDAEFunc.stateDeselectionFunc, String> daeHandler;
tuple<BackendDAEFunc.matchingAlgorithmFunc, String> matchingAlgorithm;
algorithm
Expand Down Expand Up @@ -1139,6 +1139,7 @@ algorithm
end for;
dae := BackendDAE.DAE(eqs, inInitDAE.shared);

//SimCodeFunctionUtil.execStat("reset analyzeInitialSystem (initialization)");
(outDAE, (_, outDumpVars, outRemovedEqns)) := BackendDAEUtil.mapEqSystemAndFold(dae, fixInitialSystem, (inInitVars, {}, outRemovedEqns));
end analyzeInitialSystem;

Expand Down Expand Up @@ -1218,13 +1219,13 @@ algorithm
m := fixOverDeterminedSystem(m, initEqsIndices, nVars, nAddVars);

// match the system (nVars+nAddVars == nEqns+nAddEqs)
ass1 := arrayCreate(nVars+nAddVars, -1);
ass2 := arrayCreate(nEqns+nAddEqs, -1);
Matching.matchingExternalsetIncidenceMatrix(nVars+nAddVars, nEqns+nAddEqs, m);
BackendDAEEXT.matching(nVars+nAddVars, nEqns+nAddEqs, 5, 0, 0.0, 1);
BackendDAEEXT.getAssignment(ass2, ass1);
perfectMatching := listEmpty(Matching.getUnassigned(nVars+nAddVars, ass1, {}));
// (ass1, ass2, perfectMatching) := Matching.RegularMatching(m, nVars+nAddVars, nEqns+nAddEqs);
//ass1 := arrayCreate(nVars+nAddVars, -1);
//ass2 := arrayCreate(nEqns+nAddEqs, -1);
//Matching.matchingExternalsetIncidenceMatrix(nVars+nAddVars, nEqns+nAddEqs, m);
//BackendDAEEXT.matching(nVars+nAddVars, nEqns+nAddEqs, 5, 0, 0.0, 1);
//BackendDAEEXT.getAssignment(ass2, ass1);
//perfectMatching := listEmpty(Matching.getUnassigned(nVars+nAddVars, ass1, {}));
(ass1, ass2, perfectMatching) := Matching.RegularMatching(m, nVars+nAddVars, nEqns+nAddEqs);
//BackendDump.dumpMatchingVars(ass1);
//BackendDump.dumpMatchingEqns(ass2);

Expand Down Expand Up @@ -1270,6 +1271,7 @@ algorithm
outEqSystem := BackendDAEUtil.setEqSystEqs(inEqSystem, eqns2);
//print("index-" + intString(index) + " ende\n");
outTpl := ((initVars, dumpVars, removedEqns));
//SimCodeFunctionUtil.execStat("fixInitialSystem (initialization) [nEqns: " + intString(nEqns) + ", nAddEqs: " + intString(nAddEqs) + ", nAddVars: " + intString(nAddVars) + "]");
return;
end if;
//print("index-" + intString(index) + " ende\n");
Expand Down
14 changes: 7 additions & 7 deletions Compiler/BackEnd/ResolveLoops.mo
Expand Up @@ -1311,14 +1311,14 @@ protected
list<list<Integer>> partitions;
algorithm
numEqs := arrayLength(m);
numVars := arrayLength(mT);
numVars := arrayLength(mT);
if intEq(numEqs,0) or intEq(numVars,0) then
partitionsOut := arrayCreate(1,{});
else
markEqs := arrayCreate(numEqs,-1);
markVars := arrayCreate(numVars,-1);
(_,partitions) := colorNodePartitions(m,mT,{1},markEqs,markVars,1,{});
partitionsOut := listArray(partitions);
markEqs := arrayCreate(numEqs,-1);
markVars := arrayCreate(numVars,-1);
(_,partitions) := colorNodePartitions(m,mT,{1},markEqs,markVars,1,{});
partitionsOut := listArray(partitions);
end if;
end partitionBipartiteGraph;

Expand All @@ -1341,7 +1341,7 @@ protected
list<Integer> rest, vars, addEqs, eqs, part;
list<list<Integer>> restPart, partitions;
algorithm
(currNumberOut,partitionsOut) := matchcontinue(m,mT,checkNextIn,markEqs,markVars,currNumberIn,partitionsIn)
(currNumberOut,partitionsOut) := match (m,mT,checkNextIn,markEqs,markVars,currNumberIn,partitionsIn)
local
case(_,_,{0},_,_,_,_)
equation
Expand Down Expand Up @@ -1393,7 +1393,7 @@ algorithm
(currNumber,partitions) = colorNodePartitions(m,mT,{eq},markEqs,markVars,currNumberIn+1,{}::partitionsIn);
then
(currNumber,partitions);
end matchcontinue;
end match;
end colorNodePartitions;

protected function arrayGetIsNotPositive" outputs true if the indexed entry is not zero."
Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -1830,20 +1830,20 @@ algorithm
end if;

backendDAE2 = BackendDAEUtil.getSolvedSystemforJacobians(backendDAE,
SOME({"simplifyAllExpressions",
SOME({"removeEqualFunctionCalls",
"removeSimpleEquations",
"evalFunc",
"removeEqualFunctionCalls",
"removeSimpleEquations"}),
"simplifyAllExpressions"}),
NONE(),
NONE(),
SOME({"inlineArrayEqn",
"constantLinearSystem",
"removeSimpleEquations",
"removeConstants",
"tearingSystem",
"calculateStrongComponentJacobians",
"removeConstants",
"solveSimpleEquations",
"simplifyTimeIndepFuncCalls",
"calculateStrongComponentJacobians",
"simplifyAllExpressions"}));
_ = Flags.set(Flags.EXEC_STAT, b);
if Flags.isSet(Flags.JAC_DUMP) then
Expand Down
6 changes: 5 additions & 1 deletion Compiler/BackEnd/Uncertainties.mo
Expand Up @@ -130,6 +130,8 @@ algorithm
String outStringA,outStringB,outString,description;
list<Option<DAE.Distribution>> distributions;

Boolean forceOrdering = Flags.getConfigBool(Flags.FORCE_RECOMMENDED_ORDERING);

case (cache,graph,_,(st as GlobalScript.SYMBOLTABLE(ast = p)),outputFile,_)
equation
//print("Initiating\n");
Expand All @@ -140,7 +142,9 @@ algorithm
//print("- Flatten ok\n");
dlow = BackendDAECreate.lower(dae,cache,graph,BackendDAE.EXTRA_INFO(description,outputFile));
//(dlow_1,funcs1) = BackendDAEUtil.getSolvedSystem(dlow, funcs,SOME({"removeSimpleEquations","removeFinalParameters", "removeEqualFunctionCalls", "expandDerOperator"}), NONE(), NONE(),NONE());
(dlow_1) = BackendDAEUtil.getSolvedSystem(dlow,"", SOME({"removeSimpleEquations","removeUnusedVariables","removeEqualFunctionCalls","expandDerOperator"}), NONE(), NONE(), SOME({}));
Flags.setConfigBool(Flags.FORCE_RECOMMENDED_ORDERING, false);
(dlow_1) = BackendDAEUtil.getSolvedSystem(dlow, "", SOME({"removeSimpleEquations","removeUnusedVariables","removeEqualFunctionCalls","expandDerOperator"}), NONE(), NONE(), SOME({}));
Flags.setConfigBool(Flags.FORCE_RECOMMENDED_ORDERING, forceOrdering);
//print("* Lowered Ok \n");

dlow_1 = removeSimpleEquationsUC(dlow_1);
Expand Down
9 changes: 3 additions & 6 deletions Compiler/BackEnd/UnitCheck.mo
Expand Up @@ -87,20 +87,17 @@ public function unitChecking "author: jhagemann"
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
protected
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
BackendDAE.Variables orderedVars, knownVars, aliasVars;
BackendDAE.EqSystem syst;

list<BackendDAE.Var> varList, paraList, aliasList;
list<BackendDAE.Equation> eqList;

HashTableCrToUnit.HashTable HtCr2U1, HtCr2U2;
HashTableStringToUnit.HashTable HtS2U;
HashTableUnitToString.HashTable HtU2S;
list<BackendDAE.Equation> eqList;
list<BackendDAE.Var> varList, paraList, aliasList;
algorithm
try
BackendDAE.DAE({syst}, shared) := inDAE;
true := Flags.getConfigBool(Flags.NEW_UNIT_CHECKING);

varList := BackendVariable.varList(syst.orderedVars);
paraList := BackendVariable.varList(shared.knownVars);
Expand Down
25 changes: 4 additions & 21 deletions Compiler/FrontEnd/Inline.mo
Expand Up @@ -825,16 +825,13 @@ algorithm
(newExp1,(_,_,assrtLst)) = Expression.Expression.traverseExpBottomUp(newExp,inlineCall,(fns,true,assrtLstIn));
else // normal Modelica
// get inputs, body and output
//print(ExpressionDump.printExpStr(e1) + "--In\n");
(crefs,lst_cr,stmts,repl) = getFunctionInputsOutputBody(fn,{},{},{},VarTransform.emptyReplacements());

// merge statements to one line
(repl,assrtStmts) = mergeFunctionBody(stmts,repl,{});
// depend on detection of assert or not
if (listEmpty(assrtStmts))
then // no assert detected
newExp = Expression.makeTuple(list( getReplacementCheckComplex(repl,cr,ty) for cr in lst_cr));
//print(ExpressionDump.printExpStr(newExp) + "--newExp\n");
argmap = List.threadTuple(crefs,args);
(argmap,checkcr) = extendCrefRecords(argmap,HashTableCG.emptyHashTable());
// compare types
Expand Down Expand Up @@ -1081,8 +1078,9 @@ algorithm
then
(oInputs,oOutput,oBody,repl);
case (DAE.VAR(componentRef=cr,protection=DAE.PROTECTED(),ty=tp,binding=binding)::rest,_,_,_,_)
guard not Expression.isRecordType(tp)
equation
false = Expression.isArrayType(tp);
false = Expression.isRecordType(tp);
repl = addOptBindingReplacements(cr,binding,iRepl);
(oInputs,oOutput,oBody,repl) = getFunctionInputsOutputBody(rest,iInputs,iOutput,iBody,repl);
then
Expand Down Expand Up @@ -1119,26 +1117,11 @@ algorithm
oRepl := match(iCr,iExp,iRepl)
local
DAE.Type tp;
VarTransform.VariableReplacements repl;
list<DAE.ComponentRef> crefs;
list<DAE.Exp> arrExp;
DAE.Exp e;

case (DAE.CREF_IDENT(identType=tp),_,_)
guard not Expression.isRecordType(tp) and not Expression.isArrayType(tp)
equation
false = Expression.isArrayType(tp);
false = Expression.isRecordType(tp);
then VarTransform.addReplacement(iRepl, iCr, iExp);
case (DAE.CREF_IDENT(identType=tp),_,_)
guard not Expression.isRecordType(tp)
algorithm
crefs := ComponentReference.expandCref(iCr, false);
repl := iRepl;
arrExp := Expression.getArrayOrRangeContents(iExp);
for c in crefs loop
e :: arrExp := arrExp;
repl := VarTransform.addReplacement(repl, c, e);
end for;
then repl;
end match;
end addReplacement;

Expand Down
17 changes: 16 additions & 1 deletion Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2333,14 +2333,29 @@ The only required argument is the className, while all others have some default
Example command:
translateModelFMU(className, version=\"2.0\");"
input TypeName className "the class that should translated";
input String version = "1.0" "FMU version, 1.0 or 2.0.";
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\"";
output String generatedFileName "Returns the full path of the generated FMU.";
external "builtin";
annotation(preferredView="text");
end translateModelFMU;

function buildModelFMU
"translates a modelica model into a Functional Mockup Unit.
The only required argument is the className, while all others have some default values.
Example command:
buildModelFMU(className, version=\"2.0\");"
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[:] = {"dynamic"} "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\"";
output String generatedFileName "Returns the full path of the generated FMU.";
external "builtin";
annotation(preferredView="text");
end buildModelFMU;

function simulate "simulates a modelica model by generating c code, build it and run the simulation executable.
The only required argument is the className, while all others have some default values.
simulate(className, [startTime], [stopTime], [numberOfIntervals], [tolerance], [method], [fileNamePrefix], [options], [outputFormat], [variableFilter], [cflags], [simflags])
Expand Down
59 changes: 59 additions & 0 deletions Compiler/Lexers/LexerModelicaDiff.mo
Expand Up @@ -1446,6 +1446,11 @@ algorithm
// Do not delete whitespace in-between two tokens
case (e1 as (Diff.Equal,_))::(Diff.Delete,t1 as TOKEN(id=TokenId.NEWLINE))::(Diff.Delete,t2 as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t1)::(Diff.Equal,t2)::e2::rest,tmp);
case (e1 as (Diff.Equal,_))::(Diff.Delete,t as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t)::e2::rest,tmp);
case (e1 as (Diff.Equal,TOKEN(id=t3)))::rest
guard t3<>TokenId.WHITESPACE and t3<>TokenId.NEWLINE and deleteWhitespaceFollowedByEqualNonWhitespace(rest)
algorithm
(_,rest) := deleteWhitespaceFollowedByEqualNonWhitespace(rest);
then (false,e1::rest,tmp);

// Do not delete+add the same token just because there is whitespace added
case (d1,t1)::(Diff.Add,TOKEN(id=t3))::(Diff.Add,TOKEN(id=t4))::(Diff.Add,TOKEN(id=t5))::(d2,t2)::rest
Expand Down Expand Up @@ -1573,6 +1578,60 @@ algorithm
lines := list(System.trim(s) for s in System.strtok(tokenContent(t),"\n"));
end blockCommentCanonical;

function deleteWhitespaceFollowedByEqualNonWhitespace
import LexerModelicaDiff.{Token,TokenId,TOKEN,tokenContent};
import DiffAlgorithm.Diff;
input list<tuple<Diff, Token>> inRest;
output Boolean b;
output list<tuple<Diff, Token>> result;
protected
tuple<Diff, Token> head;
Diff diff;
Token t;
TokenId id;
list<tuple<Diff, Token>> rest;
Boolean foundWS=false, foundNL=false;
algorithm
rest := inRest;
result := {};
while not listEmpty(rest) loop
(head as (diff,t as TOKEN(id=id))) := listHead(rest);
if diff <> Diff.Delete then
break;
end if;
rest := listRest(rest);
if id==TokenId.WHITESPACE and not foundWS then
foundWS := true;
result := (Diff.Equal,t)::result;
elseif id==TokenId.NEWLINE then
foundNL := true;
break;
else
result := head :: result;
end if;
end while;
if (not foundWS) or foundNL then
// If we find a newline, we probably went too far.
b := false;
result := {};
return;
end if;
_ := match rest
case (Diff.Equal,t)::_ then ();
else
algorithm
b := false;
result := {};
return;
then fail();
end match;
b := true;
for i in result loop
rest := i::rest;
end for;
result := rest;
end deleteWhitespaceFollowedByEqualNonWhitespace;

annotation(__OpenModelica_Interface="backend");


Expand Down

0 comments on commit 8597f42

Please sign in to comment.