Skip to content

Commit

Permalink
Stochastic and Graphical Revision (#55)
Browse files Browse the repository at this point in the history
    Animations of the simulation for Dymola Revised
    New symbol of test arrows and stochastic transition
    Transition TS Renamed to TDS
    Error fixed at the time of generating random numbers at TDS
    New Stochhastic Event Transition TES Added
    Added Truncated normal distribution to TDS, TES, and TFDS
    RA removed because not needed

== 0 out of 92 tests failed [Testing/OpenModelica, time: 1492]
  • Loading branch information
tlask committed Aug 9, 2017
1 parent 1b0c2d7 commit 4729fa1
Show file tree
Hide file tree
Showing 45 changed files with 605 additions and 175 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
within PNlib.Examples.ExtTest;
model TSTest
model TDSTest
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PD P1(nOut=1, startTokens=8) annotation(Placement(transformation(extent={{-40, -10}, {-20, 10}})));
PD P2(nIn=1) annotation(Placement(transformation(extent={{20, -10}, {40, 10}})));
TS T1(localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
TDS T1(localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
equation
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(Line(points={{-19.2, 0}, {-4.8, 0}}, color={0, 0, 0}));
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(Line(points={{4.8, 0}, {19.2, 0}}, color={0, 0, 0}));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=10.0, Tolerance = 1e-6));
end TSTest;
end TDSTest;
22 changes: 22 additions & 0 deletions PNlib/Examples/ExtTest/TDSTestinterrupt.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
within PNlib.Examples.ExtTest;
model TDSTestinterrupt
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PNlib.PD P1(nIn = 1, nOut = 2, startTokens= 1) annotation(Placement(visible = true, transformation(extent = {{-48, -20}, {-28, 0}}, rotation = 0)));
PNlib.PD P2(nIn=1) annotation(Placement(visible = true, transformation(extent = {{12, -20}, {32, 0}}, rotation = 0)));
PNlib.TDS T1(a = 0.5, b = 1.5, c = 1,distributionType=PNlib.Types.DistributionType.Triangular, localSeed=1, nIn=1, nOut=1) annotation(Placement(visible = true, transformation(extent = {{-18, -20}, {2, 0}}, rotation = 0)));
PNlib.TE T2(event = {0.4}, nIn = 1) annotation(
Placement(visible = true, transformation(origin = {-8, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
PNlib.TE T3(event = {2, 4}, nOut = 1) annotation(
Placement(visible = true, transformation(origin = {-66, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(
Line(points = {{-3.2, -10}, {11.2, -10}}));
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(
Line(points = {{-27.2, -10}, {-12.8, -10}}));
connect(P1.outTransition[2], T2.inPlaces[1]) annotation(
Line(points = {{-27.2, -10}, {-19.2, -10}, {-19.2, 20}, {-11.2, 20}, {-11.2, 20}}, thickness = 0.5));
connect(T3.outPlaces[1], P1.inTransition[1]) annotation(
Line(points = {{-61.2, -10}, {-49.2, -10}, {-49.2, -10}, {-47.2, -10}}, thickness = 0.5));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-80, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=8.0, Tolerance = 1e-6));
end TDSTestinterrupt;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
within PNlib.Examples.ExtTest;
model TSdiscrete
model TDSdiscrete
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PD P1(nOut=1, startTokens=18) annotation(Placement(transformation(extent={{-40, -10}, {-20, 10}})));
PD P2(nIn=1) annotation(Placement(transformation(extent={{20, -10}, {40, 10}})));
TS T1(distributionType=PNlib.Types.DistributionType.Discrete, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
TDS T1(distributionType=PNlib.Types.DistributionType.Discrete, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
equation
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(Line(points={{-19.2, 0}, {-4.8, 0}}, color={0, 0, 0}));
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(Line(points={{4.8, 0}, {19.2, 0}}, color={0, 0, 0}));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=60.0, Tolerance = 1e-6));
end TSdiscrete;
end TDSdiscrete;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
within PNlib.Examples.ExtTest;
model TStriangular
model TDStriangular
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PD P1(nOut=1, startTokens=8) annotation(Placement(transformation(extent={{-40, -10}, {-20, 10}})));
PD P2(nIn=1) annotation(Placement(transformation(extent={{20, -10}, {40, 10}})));
TS T1(distributionType=PNlib.Types.DistributionType.Triangular, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
TDS T1(distributionType=PNlib.Types.DistributionType.Triangular, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
equation
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(Line(points={{-19.2, 0}, {-4.8, 0}}, color={0, 0, 0}));
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(Line(points={{4.8, 0}, {19.2, 0}}, color={0, 0, 0}));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=10.0, Tolerance = 1e-6));
end TStriangular;
end TDStriangular;
12 changes: 12 additions & 0 deletions PNlib/Examples/ExtTest/TDStruncatednormal.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
within PNlib.Examples.ExtTest;
model TDStruncatednormal
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PD P1(nOut=1, startTokens=8) annotation(Placement(transformation(extent={{-40, -10}, {-20, 10}})));
PD P2(nIn=1) annotation(Placement(transformation(extent={{20, -10}, {40, 10}})));
TDS T1(distributionType = PNlib.Types.DistributionType.TruncatedNormal,localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
equation
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(Line(points={{-19.2, 0}, {-4.8, 0}}, color={0, 0, 0}));
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(Line(points={{4.8, 0}, {19.2, 0}}, color={0, 0, 0}));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=5.0, Tolerance = 1e-6));
end TDStruncatednormal;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
within PNlib.Examples.ExtTest;
model TSuniform
model TDSuniform
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PD P1(nOut=1, startTokens=8) annotation(Placement(transformation(extent={{-40, -10}, {-20, 10}})));
PD P2(nIn=1) annotation(Placement(transformation(extent={{20, -10}, {40, 10}})));
TS T1(a = 2, b = 4,distributionType=PNlib.Types.DistributionType.Uniform, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
TDS T1(a = 2, b = 4,distributionType=PNlib.Types.DistributionType.Uniform, localSeed=1, nIn=1, nOut=1) annotation(Placement(transformation(extent={{-10, -10}, {10, 10}})));
equation
connect(P1.outTransition[1], T1.inPlaces[1]) annotation(Line(points={{-19.2, 0}, {-4.8, 0}}, color={0, 0, 0}));
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(Line(points={{4.8, 0}, {19.2, 0}}, color={0, 0, 0}));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-40, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=20.0, Tolerance = 1e-6));
end TSuniform;
end TDSuniform;
19 changes: 19 additions & 0 deletions PNlib/Examples/ExtTest/TESTest.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
within PNlib.Examples.ExtTest;
model TESTest
extends Modelica.Icons.Example;
inner PNlib.Settings settings annotation(Placement(transformation(extent={{20, 20}, {40, 40}})));
PNlib.PD P1(nIn = 1, nOut = 1, startTokens= 1) annotation(Placement(visible = true, transformation(extent = {{-48, -20}, {-28, 0}}, rotation = 0)));
PNlib.PD P2(nIn=1) annotation(Placement(visible = true, transformation(extent = {{12, -20}, {32, 0}}, rotation = 0)));
PNlib.TE T2(event = {3, 4, 5, 9}, nOut = 1) annotation(
Placement(visible = true, transformation(origin = {-66, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
TES T1(distributionType = PNlib.Types.DistributionType.Triangular, nIn = 1, nOut = 1) annotation(
Placement(visible = true, transformation(origin = {-8, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(T1.outPlaces[1], P2.inTransition[1]) annotation(
Line(points = {{-4, -10}, {10, -10}, {10, -10}, {12, -10}}, thickness = 0.5));
connect(T1.inPlaces[1], P1.outTransition[1]) annotation(
Line(points = {{-12, -10}, {-28, -10}, {-28, -10}, {-28, -10}}, thickness = 0.5));
connect(T2.outPlaces[1], P1.inTransition[1]) annotation(
Line(points = {{-61.2, -10}, {-49.2, -10}, {-49.2, -10}, {-47.2, -10}}, thickness = 0.5));
annotation(Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-80, -40}, {40, 40}})), experiment(StartTime=0.0, StopTime=10.0, Tolerance = 1e-6));
end TESTest;
11 changes: 7 additions & 4 deletions PNlib/Examples/ExtTest/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ TAwithWeaklyActivation
ArcswithPCtoTC
ArcswithPCtoTC2
ArcswithPCtoTC3
TSTest
TStriangular
TSuniform
TSdiscrete
TDSTest
TDSTestinterrupt
TDStriangular
TDSuniform
TDStruncatednormal
TDSdiscrete
TFDStest
TESTest
NoTokens
4 changes: 2 additions & 2 deletions PNlib/Examples/Models/FlushToilet.mo
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ model FlushToilet "Model of a flush toilet"
annotation(Placement(transformation(extent={{-10,-10},{10,10}},
rotation=-90,
origin={-62,88})));
TS entering(
TDS entering(
nOut=1,
nIn=1,
h=1/10) "Visitor enters the toilet" annotation(Placement(transformation(
Expand Down Expand Up @@ -255,7 +255,7 @@ equation
Documentation(info="<html>
<p>
This is a hybrid model of a flush toilet represented by the xHPN formalism.
A visitor enters the toilet; thereby, the time between two visitors is not exactly known so that it is modelled by a stochastic transition with an exponential distributed delay (TS, T1).
A visitor enters the toilet; thereby, the time between two visitors is not exactly known so that it is modelled by a stochastic transition with an exponential distributed delay (TDS, T1).
The visitor (PD, P1) pushes (TD, T2) the lever (PD, P2) which lifts the flush valve flapper (PD, P3). Then the water can flow (TC, T5) from the tank (PC, P4)
to the bowl (PC, P5) and afterwards to the sewer (TC, T6). When the water flows to the bowl, the float (PC, P6) sinks in the toilet tank.
If the float falls below a specific level (IA), the tank fill-valve (PD, P7) is opened (TD, T7) and new water can flow (TC, T9) into the tank.
Expand Down
2 changes: 1 addition & 1 deletion PNlib/Examples/Models/PNproBP/Model.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ model Model "Top Model"
parameter Real time_installation=4 "Time for installation";
parameter Real time_accounting=1 "Time for order accounting";

TS RaiseRequest(nOut=1, h=1/time_between_requests)
TDS RaiseRequest(nOut=1, h=1/time_between_requests)
"a request is raised from a customer"
annotation(Placement(transformation(extent={{-400,90},{-380,110}})));
PD Request(
Expand Down
4 changes: 2 additions & 2 deletions PNlib/Examples/Models/Printing/Maculation.mo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ model Maculation "maculation of the printing process"
nOut=1,
maxTokens=1)
annotation(Placement(transformation(extent={{-128,-64},{-108,-44}})));
TS pressing_button(nOut=1,
TDS pressing_button(nOut=1,
firingCon=start,
nIn=1,
h=1/time_between_macus)
Expand All @@ -38,7 +38,7 @@ model Maculation "maculation of the printing process"
nIn=2,
maxTokens=2)
annotation(Placement(transformation(extent={{4,-28},{24,-8}})));
TS Stop_macu(
TDS Stop_macu(
nIn=1,
nOut=1,
h=h,
Expand Down
2 changes: 1 addition & 1 deletion PNlib/Examples/Models/Senseo/Insert_Pad.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within PNlib.Examples.Models.Senseo;
model Insert_Pad
"Insert pad: coffee pads are inserted to the Senseo machine (step 5)."

TS inserting2(
TDS inserting2(
nIn=1,
nOut=1,
arcWeightOut={1},
Expand Down
2 changes: 1 addition & 1 deletion PNlib/Examples/Models/Senseo/Start.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within PNlib.Examples.Models.Senseo;
model Start
"User action: starting and stopping the machine (step 1, 2, 11), initiating the insertion of coffee pads (step 5) and the refill of water (step 3)."
parameter Real EV_time=600;
TS starting(
TDS starting(
h=1/EV_time,
nIn=1,
nOut=1)
Expand Down
1 change: 0 additions & 1 deletion PNlib/Functions/Random/package.order
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
counter
randomexp
randomtriangular
randomuniform
randomdis
14 changes: 0 additions & 14 deletions PNlib/Functions/Random/randomuniform.mo

This file was deleted.

50 changes: 0 additions & 50 deletions PNlib/RA.mo

This file was deleted.

24 changes: 23 additions & 1 deletion PNlib/TA.mo
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,27 @@ equation
assert((outTransition.disPlace and testValue-testValueInt<=0.0) or not outTransition.disPlace, "Test arcs connected to discrete places must have integer test values.");
assert(testValue>=inPlace.minTokens, "Test values must be greater or equal than minimum values.");
//****ERROR MESSENGES END****//
annotation(defaultComponentName = "TA1", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-98, 4}, {28, 48}}), graphics={Rectangle(extent={{-98, 48}, {28, 4}}, lineColor={0, 0, 0}, fillColor=DynamicSelect({255, 255, 255}, testColor), fillPattern=FillPattern.Solid), Line(points={{-94, 24}, {22, 24}}, color={0, 0, 0}, smooth=Smooth.None, pattern=LinePattern.Dash), Polygon(points={{14, 32}, {14, 16}, {26, 24}, {14, 32}}, lineColor={0, 0, 0}, smooth=Smooth.None, fillColor={0, 0, 0}, fillPattern=FillPattern.Solid), Text(extent={{-38, -4}, {-38, -16}}, lineColor={0, 0, 0}, lineThickness=0.5, textString=DynamicSelect(" ", if animateWeightTIarc then realString(testValue, 1, 1) else " "))}), Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-98, 0}, {28, 48}}), graphics));
annotation(defaultComponentName = "TA1", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-98, 4},
{28, 48}}),
graphics={
Rectangle(
extent={{-98, 48}, {28, 4}},
lineColor={0, 0, 0},
fillColor=DynamicSelect({255, 255, 255}, testColor),
fillPattern=FillPattern.Solid),
Line(
points={{-94, 24}, {22, 24}},
color={0, 0, 0},
smooth=Smooth.None),
Ellipse(
extent={{14, 30}, {26, 18}},
lineColor={0, 0, 0},
fillColor={0, 0, 0},
fillPattern=FillPattern.Solid),
Text(
extent={{-38, -4}, {-38, -16}},
lineColor={0, 0, 0},
lineThickness=0.5,
textString=DynamicSelect(" ", if animateWeightTIarc then realString(testValue, 1, 1) else " "))}), Diagram(coordinateSystem(
preserveAspectRatio=true, extent={{-98, 0}, {28, 48}}), graphics));
end TA;
18 changes: 17 additions & 1 deletion PNlib/TC.mo
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,21 @@ equation
assert(arcWeightOut[i]>=0, "Output arc weights must be positive.");
end for;
//****ERROR MESSENGES END****//
annotation(defaultComponentName = "T1", Icon(graphics={Rectangle(extent={{-40, 100}, {40, -100}}, lineColor={0, 0, 0}, fillColor=DynamicSelect({255, 255, 255}, color), fillPattern=FillPattern.Solid), Text(extent={{-2, -116}, {-2, -144}}, lineColor={0, 0, 0}, textString=DynamicSelect(" ", if animateSpeed1 and fire>0.5 then if instantaneousSpeed>0 then realString(instantaneousSpeed, 1, 2) else "0.0" else " ")), Text(extent={{-4, 139}, {-4, 114}}, lineColor={0, 0, 0}, textString="%name")}));
annotation(defaultComponentName = "T1",
Icon(graphics={Rectangle(extent={{-40, 100}, {40, -100}},
lineColor={0, 0, 0},
fillColor=DynamicSelect({255, 255, 255}, color),
fillPattern=FillPattern.Solid),
Text(
extent={{-2, -116}, {-2, -144}},
lineColor={0, 0, 0},
textString=DynamicSelect("vmax=%maximumSpeed ", if animateSpeed then "vmax=%maximumSpeed " else " ")),
Text(
extent={{-2, -156}, {-2, -184}},
lineColor={0, 0, 0},
textString=DynamicSelect(" ", if animateSpeed and fire then if instantaneousSpeed>0 then "vakt="+realString(instantaneousSpeed, 1, 2) else "vakt=0.0" else " ")),
Text(
extent={{-4, 139}, {-4, 114}},
lineColor={0, 0, 0},
textString="%name")}));
end TC;
2 changes: 1 addition & 1 deletion PNlib/TD.mo
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ equation
fillColor=DynamicSelect({0, 0, 0}, color),
fillPattern=FillPattern.Solid),
Text(
extent={{-2, -116}, {-2, -144}},
extent={{-2, -112}, {-2, -140}},
lineColor={0, 0, 0},
textString=DynamicSelect("d=%delay", if showTime then "d=%delay" else " ")),
Text(
Expand Down
Loading

0 comments on commit 4729fa1

Please sign in to comment.