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

Use ZeroCrossingSet instead of searching in list #1962

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAE.mo
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ uniontype EventInfo
record EVENT_INFO
list<TimeEvent> timeEvents "stores all information related to time events";
ZeroCrossingSet zeroCrossings "list of zero crossing conditions";
DoubleEndedList<ZeroCrossing> relations "list of zero crossing function as before";
ZeroCrossingSet relations "list of zero crossing function as before";
ZeroCrossingSet samples "[deprecated] list of sample as before, only used by cpp runtime (TODO: REMOVE ME)";
Integer numberMathEvents "stores the number of math function that trigger events e.g. floor, ceil, integer, ...";
end EVENT_INFO;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ algorithm
eqnarr := BackendEquation.listEquation(eqns);
reqnarr := BackendEquation.listEquation(reqns);
ieqnarr := BackendEquation.listEquation(ieqns);
einfo := BackendDAE.EVENT_INFO(timeEvents, ZeroCrossings.new(), DoubleEndedList.fromList({}), ZeroCrossings.new(), 0);
einfo := BackendDAE.EVENT_INFO(timeEvents, ZeroCrossings.new(), ZeroCrossings.new(), ZeroCrossings.new(), 0);
symjacs := {(NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {}), (NONE(), ({}, {}, ({}, {}), -1), {})};
syst := BackendDAEUtil.createEqSystem(vars_1, eqnarr, {}, BackendDAE.UNKNOWN_PARTITION(), reqnarr);
outBackendDAE := BackendDAE.DAE(syst::{},
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ protected function traverseEventInfoExps<T>
algorithm
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.zeroCrossings.zc, function traverseZeroCrossingExps(func=func), arg);
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.samples.zc, function traverseZeroCrossingExps(func=func), arg);
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.relations, function traverseZeroCrossingExps(func=func), arg);
arg := DoubleEndedList.mapFoldNoCopy(eventInfo.relations.zc, function traverseZeroCrossingExps(func=func), arg);
end traverseEventInfoExps;

protected function traverseZeroCrossingExps<T>
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ protected
algorithm
outNumZeroCrossings := ZeroCrossings.length(eventInfo.zeroCrossings);
outNumTimeEvents := listLength(eventInfo.timeEvents);
outNumRelations := DoubleEndedList.length(eventInfo.relations);
outNumRelations := ZeroCrossings.length(eventInfo.relations);
outNumMathEventFunctions := eventInfo.numberMathEvents;
end numberOfZeroCrossings;

Expand Down Expand Up @@ -8958,7 +8958,7 @@ end collapseRemovedEqs1;
public function emptyEventInfo
output BackendDAE.EventInfo info;
algorithm
info := BackendDAE.EVENT_INFO({}, ZeroCrossings.new(), DoubleEndedList.fromList({}), ZeroCrossings.new(), 0);
info := BackendDAE.EVENT_INFO({}, ZeroCrossings.new(), ZeroCrossings.new(), ZeroCrossings.new(), 0);
end emptyEventInfo;

public function getSubClock
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ algorithm
dumpEquationArray(inShared.removedEqs, "Simple Shared Equations");
dumpEquationArray(inShared.initialEqs, "Initial Equations");
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.zeroCrossings), "Zero Crossings");
dumpZeroCrossingList(DoubleEndedList.toListNoCopyNoClear(inShared.eventInfo.relations), "Relations");
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.relations), "Relations");
if stringEqual(Config.simCodeTarget(), "Cpp") then
dumpZeroCrossingList(ZeroCrossings.toList(inShared.eventInfo.samples), "Samples");
else
Expand Down
5 changes: 2 additions & 3 deletions Compiler/BackEnd/BackendInline.mo
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,11 @@ protected function inlineEventInfo "inlines function calls in event info"
algorithm
_ := matchcontinue inEventInfo
local
BackendDAE.ZeroCrossingSet zclst;
DoubleEndedList<BackendDAE.ZeroCrossing> relations;
BackendDAE.ZeroCrossingSet zclst, relations;

case BackendDAE.EVENT_INFO(zeroCrossings=zclst, relations=relations) equation
inlineZeroCrossings(zclst.zc, fns);
inlineZeroCrossings(relations, fns);
inlineZeroCrossings(relations.zc, fns);
then ();

else
Expand Down
5 changes: 2 additions & 3 deletions Compiler/BackEnd/BackendVarTransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2737,8 +2737,7 @@ public function replaceEventInfo
protected
Integer numberMathEvents;
list<BackendDAE.TimeEvent> timeEvents;
BackendDAE.ZeroCrossingSet zeroCrossingLst, sampleLst;
DoubleEndedList<BackendDAE.ZeroCrossing> relationsLst;
BackendDAE.ZeroCrossingSet zeroCrossingLst, sampleLst, relationsLst;
protected partial function Func
input output BackendDAE.ZeroCrossing zc;
input Option<FuncTypeExp_ExpToBoolean> inFuncTypeExpExpToBooleanOption;
Expand All @@ -2750,7 +2749,7 @@ algorithm
zc := function replaceZeroCrossing(inVariableReplacements=inVariableReplacements);
DoubleEndedList.mapNoCopy_1(zeroCrossingLst.zc, zc, inFuncTypeExpExpToBooleanOption);
DoubleEndedList.mapNoCopy_1(sampleLst.zc, zc, inFuncTypeExpExpToBooleanOption);
DoubleEndedList.mapNoCopy_1(relationsLst, zc, inFuncTypeExpExpToBooleanOption);
DoubleEndedList.mapNoCopy_1(relationsLst.zc, zc, inFuncTypeExpExpToBooleanOption);
eInfoOut := BackendDAE.EVENT_INFO(timeEvents,zeroCrossingLst,relationsLst,sampleLst,numberMathEvents);
end replaceEventInfo;

Expand Down
Loading