Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 14eabaa

Browse files
sjoelundhkiel
authored andcommitted
Use ZeroCrossingSet instead of searching in list
This fixed the main issue reported in ticket:4584.
1 parent 5ef43cc commit 14eabaa

File tree

9 files changed

+72
-94
lines changed

9 files changed

+72
-94
lines changed

Compiler/BackEnd/BackendDAE.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ uniontype EventInfo
633633
record EVENT_INFO
634634
list<TimeEvent> timeEvents "stores all information related to time events";
635635
ZeroCrossingSet zeroCrossings "list of zero crossing conditions";
636-
DoubleEndedList<ZeroCrossing> relations "list of zero crossing function as before";
636+
ZeroCrossingSet relations "list of zero crossing function as before";
637637
ZeroCrossingSet samples "[deprecated] list of sample as before, only used by cpp runtime (TODO: REMOVE ME)";
638638
Integer numberMathEvents "stores the number of math function that trigger events e.g. floor, ceil, integer, ...";
639639
end EVENT_INFO;

Compiler/BackEnd/BackendDAECreate.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ algorithm
147147
eqnarr := BackendEquation.listEquation(eqns);
148148
reqnarr := BackendEquation.listEquation(reqns);
149149
ieqnarr := BackendEquation.listEquation(ieqns);
150-
einfo := BackendDAE.EVENT_INFO(timeEvents, ZeroCrossings.new(), DoubleEndedList.fromList({}), ZeroCrossings.new(), 0);
150+
einfo := BackendDAE.EVENT_INFO(timeEvents, ZeroCrossings.new(), ZeroCrossings.new(), ZeroCrossings.new(), 0);
151151
symjacs := {(NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {})};
152152
syst := BackendDAEUtil.createEqSystem(vars_1, eqnarr, {}, BackendDAE.UNKNOWN_PARTITION(), reqnarr);
153153
outBackendDAE := BackendDAE.DAE(syst::{},

Compiler/BackEnd/BackendDAEOptimize.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ protected function traverseEventInfoExps<T>
426426
algorithm
427427
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.zeroCrossings.zc, function traverseZeroCrossingExps(func=func), arg);
428428
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.samples.zc, function traverseZeroCrossingExps(func=func), arg);
429-
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.relations, function traverseZeroCrossingExps(func=func), arg);
429+
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.relations.zc, function traverseZeroCrossingExps(func=func), arg);
430430
end traverseEventInfoExps;
431431

432432
protected function traverseZeroCrossingExps<T>

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ protected
603603
algorithm
604604
outNumZeroCrossings := ZeroCrossings.length(eventInfo.zeroCrossings);
605605
outNumTimeEvents := listLength(eventInfo.timeEvents);
606-
outNumRelations := DoubleEndedList.length(eventInfo.relations);
606+
outNumRelations := ZeroCrossings.length(eventInfo.relations);
607607
outNumMathEventFunctions := eventInfo.numberMathEvents;
608608
end numberOfZeroCrossings;
609609

@@ -8958,7 +8958,7 @@ end collapseRemovedEqs1;
89588958
public function emptyEventInfo
89598959
output BackendDAE.EventInfo info;
89608960
algorithm
8961-
info := BackendDAE.EVENT_INFO({}, ZeroCrossings.new(), DoubleEndedList.fromList({}), ZeroCrossings.new(), 0);
8961+
info := BackendDAE.EVENT_INFO({}, ZeroCrossings.new(), ZeroCrossings.new(), ZeroCrossings.new(), 0);
89628962
end emptyEventInfo;
89638963

89648964
public function getSubClock

Compiler/BackEnd/BackendDump.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ algorithm
269269
dumpEquationArray(inShared.removedEqs, "Simple Shared Equations");
270270
dumpEquationArray(inShared.initialEqs, "Initial Equations");
271271
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.zeroCrossings), "Zero Crossings");
272-
dumpZeroCrossingList(DoubleEndedList.toListNoCopyNoClear(inShared.eventInfo.relations), "Relations");
272+
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.relations), "Relations");
273273
if stringEqual(Config.simCodeTarget(), "Cpp") then
274274
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.samples), "Samples");
275275
else

Compiler/BackEnd/BackendInline.mo

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,11 @@ protected function inlineEventInfo "inlines function calls in event info"
523523
algorithm
524524
_ := matchcontinue inEventInfo
525525
local
526-
BackendDAE.ZeroCrossingSet zclst;
527-
DoubleEndedList<BackendDAE.ZeroCrossing> relations;
526+
BackendDAE.ZeroCrossingSet zclst, relations;
528527

529528
case BackendDAE.EVENT_INFO(zeroCrossings=zclst, relations=relations) equation
530529
inlineZeroCrossings(zclst.zc, fns);
531-
inlineZeroCrossings(relations, fns);
530+
inlineZeroCrossings(relations.zc, fns);
532531
then ();
533532

534533
else

Compiler/BackEnd/BackendVarTransform.mo

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,8 +2737,7 @@ public function replaceEventInfo
27372737
protected
27382738
Integer numberMathEvents;
27392739
list<BackendDAE.TimeEvent> timeEvents;
2740-
BackendDAE.ZeroCrossingSet zeroCrossingLst, sampleLst;
2741-
DoubleEndedList<BackendDAE.ZeroCrossing> relationsLst;
2740+
BackendDAE.ZeroCrossingSet zeroCrossingLst, sampleLst, relationsLst;
27422741
protected partial function Func
27432742
input output BackendDAE.ZeroCrossing zc;
27442743
input Option<FuncTypeExp_ExpToBoolean> inFuncTypeExpExpToBooleanOption;
@@ -2750,7 +2749,7 @@ algorithm
27502749
zc := function replaceZeroCrossing(inVariableReplacements=inVariableReplacements);
27512750
DoubleEndedList.mapNoCopy_1(zeroCrossingLst.zc, zc, inFuncTypeExpExpToBooleanOption);
27522751
DoubleEndedList.mapNoCopy_1(sampleLst.zc, zc, inFuncTypeExpExpToBooleanOption);
2753-
DoubleEndedList.mapNoCopy_1(relationsLst, zc, inFuncTypeExpExpToBooleanOption);
2752+
DoubleEndedList.mapNoCopy_1(relationsLst.zc, zc, inFuncTypeExpExpToBooleanOption);
27542753
eInfoOut := BackendDAE.EVENT_INFO(timeEvents,zeroCrossingLst,relationsLst,sampleLst,numberMathEvents);
27552754
end replaceEventInfo;
27562755

0 commit comments

Comments
 (0)