Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/lochel/PNlib into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Apr 27, 2015
2 parents 057d45e + ce796ec commit e943703
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions PNlib/Blocks/enablingInCon.mo
Expand Up @@ -31,14 +31,14 @@ algorithm
if nIn>0 then
disTAin:=TAein and disTransition;
arcWeightSum:=Functions.OddsAndEnds.conditionalSum(arcWeight,disTAin); //arc weight sum of all active input transitions which are already enabled by their input places
if t + arcWeightSum <= maxMarks or arcWeightSum==0 then //Place has no actual conflict; all active input transitions are enabled
if t + arcWeightSum <= maxMarks or Functions.OddsAndEnds.isEqual(arcWeightSum, 0.0) then //Place has no actual conflict; all active input transitions are enabled
TEin:=TAein;
else //Place has an actual conflict
TEin:=TAein and not disTransition;
if enablingType==1 then //deterministic enabling according to priorities
arcWeightSum:=0;
for i in 1:nIn loop
if disTAin[i] and ((t+(arcWeightSum+arcWeight[i])<=maxMarks) or arcWeight[i]==0) then
if disTAin[i] and ((t+(arcWeightSum+arcWeight[i])<=maxMarks) or Functions.OddsAndEnds.isEqual(arcWeight[i], 0.0)) then
TEin[i]:=true;
arcWeightSum:=arcWeightSum + arcWeight[i];
end if;
Expand Down Expand Up @@ -75,7 +75,7 @@ algorithm
k:=k + 1;
end if;
end while;
if t+arcWeightSum + arcWeight[posTE] <= maxMarks or arcWeight[i]==0 then
if t+arcWeightSum + arcWeight[posTE] <= maxMarks or Functions.OddsAndEnds.isEqual(arcWeight[i], 0.0) then
arcWeightSum:=arcWeightSum + arcWeight[posTE];
TEin[posTE]:=true;
end if;
Expand Down
6 changes: 3 additions & 3 deletions PNlib/Blocks/enablingOutCon.mo
Expand Up @@ -34,14 +34,14 @@ algorithm
disTAout:=TAout and disTransition;
arcWeightSum := Functions.OddsAndEnds.conditionalSum(arcWeight, disTAout);
//arc weight sum of all active output transitions
if t - arcWeightSum >= minMarks or arcWeightSum==0 then //Place has no actual conflict; all active output transitions are enabled
if t - arcWeightSum >= minMarks or Functions.OddsAndEnds.isEqual(arcWeightSum, 0.0) then //Place has no actual conflict; all active output transitions are enabled
TEout:=TAout;
else //Place has an actual conflict;
TEout:=TAout and not disTransition;
if enablingType==1 then //deterministic enabling according to priorities
arcWeightSum:=0;
for i in 1: nOut loop
if disTAout[i] and ((t-(arcWeightSum+arcWeight[i])>=minMarks) or arcWeight[i]==0) then
if disTAout[i] and ((t-(arcWeightSum+arcWeight[i])>=minMarks) or Functions.OddsAndEnds.isEqual(arcWeight[i], 0.0)) then
TEout[i]:=true;
arcWeightSum:=arcWeightSum + arcWeight[i];
end if;
Expand Down Expand Up @@ -78,7 +78,7 @@ algorithm
k:=k + 1;
end if;
end while;
if (t-(arcWeightSum + arcWeight[posTE]) >= minMarks) or arcWeight[i]==0 then
if (t-(arcWeightSum + arcWeight[posTE]) >= minMarks) or Functions.OddsAndEnds.isEqual(arcWeight[i], 0.0) then
arcWeightSum:=arcWeightSum + arcWeight[posTE];
TEout[posTE]:=true;
end if;
Expand Down
2 changes: 1 addition & 1 deletion PNlib/Functions/OddsAndEnds/isEqual.mo
Expand Up @@ -3,7 +3,7 @@ function isEqual "Determine if two Real scalars are numerically identical"
extends Modelica.Icons.Function;
input Real s1 "First scalar";
input Real s2 "Second scalar";
input Real eps(min=0) = 0
input Real eps(min=0) = 1e-8
"The two scalars are identical if abs(s1-s2) <= eps";
output Boolean result "= true, if scalars are identical";
algorithm
Expand Down
4 changes: 2 additions & 2 deletions PNlib/PC.mo
Expand Up @@ -146,8 +146,8 @@ equation
color=if settings1.animatePlace==1 then if tokenscale<100 then {255,255-2.55*tokenscale,255-2.55*tokenscale} else {255,0,0} else {255,255,255};
//****ANIMATION END****//
//****ERROR MESSENGES BEGIN****//
assert(abs(sum(enablingProbIn)-1)<1e-6 or nIn==0 or enablingType==1,"The sum of input enabling probabilities has to be equal to 1");
assert(abs(sum(enablingProbOut)-1)<1e-6 or nOut==0 or enablingType==1,"The sum of output enabling probabilities has to be equal to 1");
assert(Functions.OddsAndEnds.isEqual(sum(enablingProbIn), 1.0, 1e-6) or nIn==0 or enablingType==1,"The sum of input enabling probabilities has to be equal to 1");
assert(Functions.OddsAndEnds.isEqual(sum(enablingProbOut), 1.0, 1e-6) or nOut==0 or enablingType==1,"The sum of output enabling probabilities has to be equal to 1");
assert(startMarks>=minMarks and startMarks<=maxMarks,"minMarks<=startMarks<=maxMarks");
//****ERROR MESSENGES END****//
annotation (defaultComponentName = "P1",Icon(graphics={
Expand Down
4 changes: 2 additions & 2 deletions PNlib/PD.mo
Expand Up @@ -116,8 +116,8 @@ equation
color=if settings1.animatePlace==1 then if tokenscale<100 then {255,255-2.55*tokenscale,255-2.55*tokenscale} else {255,0,0} else {255,255,255};
//****ANIMATION END****//
//****ERROR MESSENGES BEGIN****//
assert(abs(sum(enablingProbIn)-1)<1e-6 or nIn==0 or enablingType==1,"The sum of input enabling probabilities has to be equal to 1");
assert(abs(sum(enablingProbOut)-1)<1e-6 or nOut==0 or enablingType==1,"The sum of output enabling probabilities has to be equal to 1");
assert(Functions.OddsAndEnds.isEqual(sum(enablingProbIn), 1.0, 1e-6) or nIn==0 or enablingType==1,"The sum of input enabling probabilities has to be equal to 1");
assert(Functions.OddsAndEnds.isEqual(sum(enablingProbOut), 1.0, 1e-6) or nOut==0 or enablingType==1,"The sum of output enabling probabilities has to be equal to 1");
assert(startTokens>=minTokens and startTokens<=maxTokens,"minTokens<=startTokens<=maxTokens");
//****ERROR MESSENGES END****//
annotation (defaultComponentName = "P1",Icon(graphics={Ellipse(
Expand Down

0 comments on commit e943703

Please sign in to comment.