Skip to content

Commit

Permalink
- add AdjacencyMatrixTEnhanced
Browse files Browse the repository at this point in the history
- C-Implementation of Matchingalgorithms from Kamer Kaya, Johannes Langguth and Bora Ucar see: http://bmi.osu.edu/~kamer/index.html
- improve tearingNew
- fix coundOperations -> countOperations
- minor changes to dump functions
- remove getNumberOfEquationArray, is the same like equationSize
- add new dynamic state selection module (not yet finished)
- add source info for division by zero 
- add GraphML.mo (dumps grahml files see http://www.yworks.com, Matching.mo (some Matching Algorithms DFS,BFS,MC21A,PF,PFPlus,HK,HKDW,ABMP,PR_FIFO_FAIR,cheapMatching), IndexReduction (dynamic state selection, Pantelides index reduction)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12006 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jun 8, 2012
1 parent 4e69e96 commit 3e36ec3
Show file tree
Hide file tree
Showing 21 changed files with 14,251 additions and 504 deletions.
35 changes: 32 additions & 3 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -437,6 +437,31 @@ type IncidenceMatrixT = IncidenceMatrix "IncidenceMatrixT : a list of equation i
has a negative index.
- Incidence Matrix T" ;

public
uniontype Solvability
record SOLVABILITY_SOLVED "Equation is already solved for the variable" end SOLVABILITY_SOLVED;
record SOLVABILITY_CONSTONE "Coefficient is equal 1 or -1" end SOLVABILITY_CONSTONE;
record SOLVABILITY_CONST "Coefficient is constant" end SOLVABILITY_CONST;
record SOLVABILITY_PARAMETER "Coefficient contains parameters"
Boolean b "false if the partial derivative is zero";
end SOLVABILITY_PARAMETER;
record SOLVABILITY_TIMEVARYING "Coefficient contains variables, is time varying"
Boolean b "false if the partial derivative is zero";
end SOLVABILITY_TIMEVARYING;
record SOLVABILITY_NONLINEAR "The variable occurse nonlinear in the equation." end SOLVABILITY_NONLINEAR;
record SOLVABILITY_UNSOLVABLE "The variable occurse in the equation, but it is not posible to solve
the equation for it." end SOLVABILITY_UNSOLVABLE;
end Solvability;

public
type AdjacencyMatrixElementEnhanced = list<tuple<Integer,Solvability>>;

public
type AdjacencyMatrixEnhanced = array<AdjacencyMatrixElementEnhanced>;

public
type AdjacencyMatrixTEnhanced = AdjacencyMatrixEnhanced;

public
uniontype JacobianType "- Jacobian Type"
record JAC_CONSTANT "If jacobian has only constant values, for system
Expand Down Expand Up @@ -486,14 +511,18 @@ public
type DAEHandlerArg = tuple<StateOrder,ConstraintEquations>;

public
type ConstraintEquations = list<tuple<Integer,list<tuple<Equation,Boolean>>>>;
type StructurallySingularSystemHandlerArg = tuple<StateOrder,ConstraintEquations,list<tuple<Integer,Integer,Integer>>,list<tuple<Integer,Integer,Integer>>> "StateOrder,ConstraintEqns,DerivedAlgs,DerivesArrayEqns";


public
type ConstraintEquations = list<tuple<Integer,list<Equation>>>;


public
uniontype StateOrder
record STATEORDER
HashTableCG.HashTable hashTable "x -> dx.";
HashTable3.HashTable invHashTable "dx -> x.";
HashTableCG.HashTable hashTable "x -> dx";
HashTable3.HashTable invHashTable "dx -> {x,y,z}";
end STATEORDER;
end StateOrder;

Expand Down
87 changes: 87 additions & 0 deletions Compiler/BackEnd/BackendDAEEXT.mo
Expand Up @@ -195,5 +195,92 @@ public function getF

external "C" outInteger=BackendDAEEXT_getF(inInteger) annotation(Library = "omcruntime");
end getF;

/******************************************
C-Implementation Stuff from
Kamer Kaya, Johannes Langguth and Bora Ucar
see: http://bmi.osu.edu/~kamer/index.html
*****************************************/

public function setIncidenceMatrix
"function: setIncidenceMatrix
author: Frenkel TUD 2012-04
"
input Integer nv;
input Integer ne;
input Integer nz;
input array<list<Integer>> m;

external "C" BackendDAEEXT_setIncidenceMatrix(nv,ne,nz,m) annotation(Library = "omcruntime");
end setIncidenceMatrix;

public function matching
"function: matchingExternal
author: Frenkel TUD 2012-04
calls matching algorithms
matchingID: id of match algo (1-9)
1: DFS based
2: BFS based
3: MC21 (DFS + lookahead)
4: PF (Pothen and Fan' algorithm)
5: PF+ (PF + fairness)
6: HK (Hopcroft and Karp's algorithm)
7: HK-DW (Duff-Wiberg implementation of HK)
8: ABMP (Alt et al.'s algorithm)
9: ABMP-BFS (ABMP + BFS)
10: PR-FIFO-FAIR (DEFAULT)
cheapID: id of cheap algo (1-4)
1: Simple Greedy
2: Karp-Sipser
3: Random Karp-Sipser (DEFAULT)
4: Minimum Degree (two-sided)
relabel_period: used only when matchID = 10. Otherwise it is ignored.
For the PR based algorithm, a global relabeling is started after
every (m+n) x 'relabel_period' pushes where m and
n are the number of rows and columns of the matrix. Default is 1.
-1: for a global relabeling after every m pushes
-2: for a global relabeling after every n pushes
Other than these two, non-positive values are not allowed.
"
input Integer nv;
input Integer ne;
input Integer matchingID;
input Integer cheapID;
input Real relabel_period;
input Integer clear_match;
external "C" BackendDAEEXT_matching(nv,ne,matchingID,cheapID,relabel_period,clear_match) annotation(Library = "omcruntime");
end matching;

public function getEqnsforIndexReduction
"function: getEqnsforIndexReduction
author: Frenkel TUD 2012-04
"
output list<Integer> eqns;
external "C" eqns = BackendDAEEXT_getEqnsforIndexReduction() annotation(Library = "omcruntime");
end getEqnsforIndexReduction;

public function getAssignment
"function: getAssignment
author: Frenkel TUD 2012-04"
input array<Integer> ass1;
input array<Integer> ass2;

external "C" BackendDAEEXT_getAssignment(ass1,ass2) annotation(Library = "omcruntime");
end getAssignment;

public function setAssignment
"function: getAssignment
author: Frenkel TUD 2012-04"
input Integer lenass1;
input Integer lenass2;
input array<Integer> ass1;
input array<Integer> ass2;
output Boolean outBoolean;

external "C" outBoolean=BackendDAEEXT_setAssignment(lenass1,lenass2,ass1,ass2) annotation(Library = "omcruntime");
end setAssignment;

end BackendDAEEXT;

0 comments on commit 3e36ec3

Please sign in to comment.